Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-02-2008, 11:01 PM
Vulgar Vulgar is offline
()
Vulgar's Avatar
Join Date: May 2008
Location: Chesapeake, Virginia
Posts: 59
Vulgar is an unknown quantity at this point
Send a message via AIM to Vulgar
Checking playercount in another level

How would I check playercount in a level that the player isnt in.I'm having another brainfart and cannot figure this out.
NPC Code:

if (playercount = NULL in this.stageinstance){
deletelevel (this.stageinstance);
}

__________________
.
Reply With Quote
  #2  
Old 09-02-2008, 11:13 PM
Dan Dan is offline
Daniel
Join Date: Oct 2007
Posts: 383
Dan is an unknown quantity at this point
Send a message via MSN to Dan
PHP Code:
if (findlevel("levelname.nw").players.size() == 0)
  
deletelevel("path/levelname.nw"); 
(if deletelevel is actually a command, I'm not sure)
__________________
Reply With Quote
  #3  
Old 09-02-2008, 11:16 PM
Vulgar Vulgar is offline
()
Vulgar's Avatar
Join Date: May 2008
Location: Chesapeake, Virginia
Posts: 59
Vulgar is an unknown quantity at this point
Send a message via AIM to Vulgar
I figured it out like 2 minutes ago but thank you.

Quote:
Originally Posted by Wiki
deletefile(str) - returns boolean
deletelevel(str) - returns boolean
__________________
.
Reply With Quote
  #4  
Old 09-03-2008, 12:01 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Perhaps try to reuse levels rather than copying and deleting them often?
__________________
Reply With Quote
  #5  
Old 09-03-2008, 12:07 AM
Vulgar Vulgar is offline
()
Vulgar's Avatar
Join Date: May 2008
Location: Chesapeake, Virginia
Posts: 59
Vulgar is an unknown quantity at this point
Send a message via AIM to Vulgar
Does that reduce lag or something?
__________________
.
Reply With Quote
  #6  
Old 09-03-2008, 12:16 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Vulgar View Post
Does that reduce lag or something?
Overall I doubt you'll see a performance difference unless you're copying and deleting lots of levels. Though I don't know what happens behind the scenes when you use copylevel() or deletelevel().

But I just think reusing copied levels is a better way to do it. And only create more copies if you go over the amount already existing, and then delete extra copies down to the default amount.
__________________
Reply With Quote
  #7  
Old 09-03-2008, 12:33 AM
Vulgar Vulgar is offline
()
Vulgar's Avatar
Join Date: May 2008
Location: Chesapeake, Virginia
Posts: 59
Vulgar is an unknown quantity at this point
Send a message via AIM to Vulgar
I was setting it up so the players name is in the levelname. I don't exactly know how to do what you are talking about though. If you could give me an example or the Commands to look up that would be great.
__________________
.
Reply With Quote
  #8  
Old 09-03-2008, 12:45 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Vulgar View Post
I was setting it up so the players name is in the levelname.
I assume you mean account name? Nicknames might have characters that won't do so well in filenames.
Quote:
Originally Posted by Vulgar View Post
I don't exactly know how to do what you are talking about though. If you could give me an example or the Commands to look up that would be great.
If you don't know how to do it then don't worry about it.

Basically I would just have some system track what accounts are using what levels and create new levels if there aren't enough already and delete extras when they're not used anymore.
__________________
Reply With Quote
  #9  
Old 09-03-2008, 12:50 AM
Vulgar Vulgar is offline
()
Vulgar's Avatar
Join Date: May 2008
Location: Chesapeake, Virginia
Posts: 59
Vulgar is an unknown quantity at this point
Send a message via AIM to Vulgar
Oh ok, and yes i'm using account names.

edit: I ran into a problem, when someone logs off and then the level is deleted they get stuck 'loading'. Is there any way to check if the player's level has been deleted. Like would FindFile() or would player.level = NULL work?
__________________
.

Last edited by Vulgar; 09-03-2008 at 01:23 AM.. Reason: combining post
Reply With Quote
  #10  
Old 09-03-2008, 02:53 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Normally people are put back to the start level when they login to a level that doesn't exist.
Reply With Quote
  #11  
Old 09-03-2008, 04:25 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Stefan View Post
Normally people are put back to the start level when they login to a level that doesn't exist.
That's broken for about 2-3 years then. It happens all the time, you can experience that on u/c playerworlds quite often.
Reply With Quote
  #12  
Old 09-08-2008, 03:00 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Quote:
Originally Posted by Crow View Post
That's broken for about 2-3 years then. It happens all the time, you can experience that on u/c playerworlds quite often.
It's working fine for me when testing. When a player logs in and the level is not existing then he/she is put in the start level (server option startlevel, startx, starty).
Reply With Quote
  #13  
Old 09-08-2008, 03:18 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Stefan View Post
It's working fine for me when testing. When a player logs in and the level is not existing then he/she is put in the start level (server option startlevel, startx, starty).
Might happen because the server options entries of those are empty then, might want to add an additional check for that.
Reply With Quote
  #14  
Old 09-03-2008, 02:56 AM
Vulgar Vulgar is offline
()
Vulgar's Avatar
Join Date: May 2008
Location: Chesapeake, Virginia
Posts: 59
Vulgar is an unknown quantity at this point
Send a message via AIM to Vulgar
I was testing on a Trial so I don't know if that makes any difference, it came out of observer and it kept 'loading.'
__________________
.
Reply With Quote
  #15  
Old 09-03-2008, 06:51 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Vulgar View Post
I was testing on a Trial so I don't know if that makes any difference, it came out of observer and it kept 'loading.'
findlevel(levelname) returns the TServerLevel object.
PHP Code:
if (findlevel("levelname.nw") == null) {
  
// level does not exist

When a person logs off the PlayerLogout event is called everywhere on the server with the player's object being the first parameter. You should be able to use this to check their level but I don't know if you can actually change it since they've basically logged out. Try changing the level from there, and if it doesn't work then you need some kind of script to track whos logged out in a level that could be deleted.
PHP Code:
function onPlayerLogout(p) {
  if (
p.level.name == "levelname.nw") {
    
// they shouldn't be there
    
p.setlevel2("newlevelname.nw"3030);
    
// if this doesn't work, use a system to track them.
  
}

__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:53 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.