Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-12-2013, 09:46 PM
baseman101 baseman101 is offline
Scripter
baseman101's Avatar
Join Date: Nov 2012
Location: Purcellville, VA
Posts: 76
baseman101 will become famous soon enough
Setting Offline Player's Level

I want to make a handy script that warps a player out of an event if they log off. The only problem is that I cannot manipulate the player's level offline.
PHP Code:
function onPlayerLogout() {
  if(
player.level.name == "s64club_pacman_event.nw") {
    
player.setLevel2("shangri_sky.gmap",30,30); //This will not work because it's an offline player
  
}

Reply With Quote
  #2  
Old 05-12-2013, 09:53 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
I don't think it's possible to change a player's level without them being online (besides editing the accounts file, which you can't do via script). I could be wrong, though.

edit: yes, it's possible, see Jer's post below

The typical solution is to have a list of levels where players aren't allowed to log off in, and then warp any players who log in in this levels to OSL.

PHP Code:
// just an example, put this wherever your server handles log-on stuff
function onActionPlayerOnline() {
  
temp.unstickLevels = {
    
"era_event-",
    
"era_spar-"
  
};
  
  for (
temp.unstickLevel temp.unstickLevels) {
    if (
player.level.name.starts(temp.unstickLevel)) {
      
player.setLevel2(...); // send player to OSL
      
break;
    }
  }

__________________

Last edited by cbk1994; 05-13-2013 at 12:49 AM..
Reply With Quote
  #3  
Old 05-12-2013, 09:54 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
How about doing it when they log back on instead? Changing a players level when they leave the game seems silly.

PHP Code:
function onPlayerLogin(pl) { // player object that logged on
  
if(pl.level.name == "s64club_pacman_event.nw") { 
    
pl.setLevel2("fakewnabezone.gmap",30,30);
  } 
e; lol ckb beat me to it aminute (probably seconds) apart
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you

Last edited by Deas_Voice; 05-12-2013 at 09:57 PM.. Reason: o.o
Reply With Quote
  #4  
Old 05-12-2013, 09:57 PM
baseman101 baseman101 is offline
Scripter
baseman101's Avatar
Join Date: Nov 2012
Location: Purcellville, VA
Posts: 76
baseman101 will become famous soon enough
Sounds good. I thought of this too, but it would be quite useful to manipulate offline player's levels easier.
Reply With Quote
  #5  
Old 05-12-2013, 10:09 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
You can:

PHP Code:
function unstickOfflinePlayer(acc) {
  
temp.pl      findplayer(acc);
  
temp.offline temp.pl == NULL;
  
temp.pl      temp.offline ? new TServerPlayer(@acc) : temp.pl;
  if (
temp.offline) {
    
temp.pl.levelname "onlinestartlocal.nw";
    
temp.pl.30;
    
temp.pl.30;
    
temp.pl.saveaccount();
    
temp.pl.destroy();
  } else {
    
temp.pl.setlevel2("onlinestartlocal.nw"3030);
  }

Just way easier and more reliable to do it when they login though.
__________________
Quote:
Reply With Quote
  #6  
Old 05-12-2013, 11:31 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by fowlplay4 View Post
You can:

PHP Code:
function unstickOfflinePlayer(acc) {
  
temp.pl      findplayer(acc);
  
temp.offline temp.pl == NULL;
  
temp.pl      temp.offline ? new TServerPlayer(@acc) : temp.pl;
  if (
temp.offline) {
    
temp.pl.levelname "onlinestartlocal.nw";
    
temp.pl.30;
    
temp.pl.30;
    
temp.pl.saveaccount();
    
temp.pl.destroy();
  } else {
    
temp.pl.setlevel2("onlinestartlocal.nw"3030);
  }

Just way easier and more reliable to do it when they login though.
Hmm doesn't that crash the server? (warping them if they're offline)
__________________
Reply With Quote
  #7  
Old 05-13-2013, 12:44 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by xAndrewx View Post
Hmm doesn't that crash the server? (warping them if they're offline)
No, I've used similar code without any consequence.
__________________
Quote:
Reply With Quote
  #8  
Old 05-13-2013, 01:36 AM
BlueMelon BlueMelon is offline
asdfg
BlueMelon's Avatar
Join Date: Sep 2008
Posts: 1,481
BlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to behold
Quote:
Originally Posted by xAndrewx View Post
Hmm doesn't that crash the server? (warping them if they're offline)
only on graal would we be asking this question
__________________
http://i.imgur.com/OOJbW.jpg
Reply With Quote
  #9  
Old 05-13-2013, 08:34 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
hmmm weird

I did it on Era iOS about 8 months back and it ended up crashing it haha
__________________
Reply With Quote
  #10  
Old 05-15-2013, 04:04 AM
baseman101 baseman101 is offline
Scripter
baseman101's Avatar
Join Date: Nov 2012
Location: Purcellville, VA
Posts: 76
baseman101 will become famous soon enough
Quote:
Originally Posted by xAndrewx View Post
hmmm weird

I did it on Era iOS about 8 months back and it ended up crashing it haha
Guess that's a sign I shouldn't do it on Zone iPhone :P
Reply With Quote
  #11  
Old 05-15-2013, 05:58 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
It was bugged before but it's fine now. May be the setlevel2 function could be changed to also set those variables when the player is offline.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 02:47 AM.


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