Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Setting Offline Player's Level (https://forums.graalonline.com/forums/showthread.php?t=134268204)

baseman101 05-12-2013 09:46 PM

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
  
}



cbk1994 05-12-2013 09:53 PM

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;
    }
  }



Deas_Voice 05-12-2013 09:54 PM

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

baseman101 05-12-2013 09:57 PM

Sounds good. I thought of this too, but it would be quite useful to manipulate offline player's levels easier.

fowlplay4 05-12-2013 10:09 PM

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.

xAndrewx 05-12-2013 11:31 PM

Quote:

Originally Posted by fowlplay4 (Post 1717850)
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)

fowlplay4 05-13-2013 12:44 AM

Quote:

Originally Posted by xAndrewx (Post 1717857)
Hmm doesn't that crash the server? (warping them if they're offline)

No, I've used similar code without any consequence.

BlueMelon 05-13-2013 01:36 AM

Quote:

Originally Posted by xAndrewx (Post 1717857)
Hmm doesn't that crash the server? (warping them if they're offline)

only on graal would we be asking this question

xAndrewx 05-13-2013 08:34 AM

hmmm weird

I did it on Era iOS about 8 months back and it ended up crashing it haha

baseman101 05-15-2013 04:04 AM

Quote:

Originally Posted by xAndrewx (Post 1717878)
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

Admins 05-15-2013 05:58 PM

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.


All times are GMT +2. The time now is 09:37 AM.

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