Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   player log offline (https://forums.graalonline.com/forums/showthread.php?t=83553)

[email protected] 01-07-2009 06:41 PM

player log offline
 
so, i have found
function onPlayerLeaves()
but thats if the player leaves a level


whats the function if the player logs offline?

also, if someone has a full list of the functions can you post them? thank you.:D

Chompy 01-07-2009 06:58 PM

PHP Code:

function onPlayerLogout(account) {
  
temp.pl findplayer(account);



xXziroXx 01-07-2009 07:55 PM

Quote:

Originally Posted by Chompy (Post 1455287)
PHP Code:

function onPlayerLogout(account) {
  
temp.pl findplayer(account);



The first parameter is already the object of the player/RC/IRC that leaves.

cbk1994 01-07-2009 11:52 PM

PlayerLogout is called for more than just players and RCs, so you may want to do something like this to make sure you're only getting players and RCs:

PHP Code:

function onPlayerLogout(pl) {
  if (! 
pl.account.length() > 0) {
    return;
  }



Chompy 01-08-2009 12:22 AM

Quote:

Originally Posted by xXziroXx (Post 1455307)
The first parameter is already the object of the player/RC/IRC that leaves.

Ah.

I think it's weird that findplayer allows objects as input D: Graal Script is way too.. 'soft' if you ask me :o

Skyld 01-08-2009 02:28 AM

Quote:

Originally Posted by Chompy (Post 1455394)
Ah.

I think it's weird that findplayer allows objects as input D: Graal Script is way too.. 'soft' if you ask me :o

It's not so much "allowing objects as input", it's just a consequence of variant typing. When you pass an object to something where there should be a string, it is just taking the name of the object and passing that instead. In this case, the account name is the name of the object.

xXziroXx 01-08-2009 05:03 PM

Quote:

Originally Posted by cbk1994 (Post 1455383)
PlayerLogout is called for more than just players and RCs, so you may want to do something like this to make sure you're only getting players and RCs:

PHP Code:

function onPlayerLogout(pl) {
  if (
pl.objecttype() != "TServerPlayer") {
    return;
  }



Fixed. ^^

Admins 01-08-2009 09:12 PM

onPlayerLogout is only called for players, it's called on the actual logout and when a player is switched to observer mode

xXziroXx 01-08-2009 09:23 PM

Quote:

Originally Posted by Stefan (Post 1455607)
onPlayerLogout is only called for players, it's called on the actual logout and when a player is switched to observer mode

Are you 100% sure of that? I'm pretty confident in having had non-TServerPlayer objects trigger that function.

Chompy 01-08-2009 11:02 PM

Quote:

Originally Posted by Skyld (Post 1455452)
It's not so much "allowing objects as input", it's just a consequence of variant typing. When you pass an object to something where there should be a string, it is just taking the name of the object and passing that instead. In this case, the account name is the name of the object.

That's the same as doing findplayer(findplayer("Chompy").account); :o?

But yeah, I guess it's kinda neat to have, for example when comparing: if (player.level == "osl.nw")

Crow 01-08-2009 11:06 PM

Quote:

Originally Posted by Chompy (Post 1455635)
But yeah, I guess it's kinda neat to have, for example when comparing: if (player.level == "osl.nw")

Which can go horribly wrong. I have experienced quite some bugs with that.

cbk1994 01-09-2009 03:48 AM

I have too. I think it would be best to always use .name (or .account in this case). Even if it doesn't improve the script, it makes it easier to understand, especially to new scripters.


All times are GMT +2. The time now is 08:30 AM.

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