Jump to content
  • 0

OnPCLogoutEvent


tofubeng

Question


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  05/13/16
  • Last Seen:  

Hi all,

 

Currently working on Novice vs Zombie script, and I can't get the onPCLogoutEvent to work.

Script as below:

 

OnPCLogoutEvent:

if ( .@mapnvz$ == "quiz_01" && getmapusers("quiz_01") == 1 ) {

killmonsterall "quiz_01";

mapannounce "quiz_01","You have won, please approach to Prize NPC.",0;

enablenpc "Prize";

set $@NvZCounter,0;

stopnpctimer;

end;

}
 
Encountered the same issue when I am working with Devil Square, but i ignored it as it won't cause the event to be stucked.
Is there anything wrong with the keyword?
Players will be stuck now if someone logs out and number of players left is 1.
 
Thank you in advance.
Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0

  • Group:  Developer
  • Topic Count:  36
  • Topics Per Day:  0.01
  • Content Count:  587
  • Reputation:   431
  • Joined:  01/26/16
  • Last Seen:  

but why is it returning 2 players ?!

Because the label is being ran before the player is actually removed from the map.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  135
  • Reputation:   13
  • Joined:  06/20/12
  • Last Seen:  

I think your .@mapnvz$ isn't being setted, as it is as temporary variable, show the whole code.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  05/13/16
  • Last Seen:  

Hi Moriarty,

 

I switched the code up a little but it still doesn't work.

 

http://upaste.me/aae2268811d0aac81

 

This is my whole script.

Thanks for your advice.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  505
  • Reputation:   126
  • Joined:  04/04/16
  • Last Seen:  

Maybe when the player logged out the script "getmapusers("quiz_01") == 1" is read first before the character is logged out.

 

Maybe try to add sleep?

OnPCLogoutEvent:
if ( strcharinfo(3) != "quiz_01" )end;
sleep2 1000;
if( getmapusers("quiz_01") == 1 ) {
killmonsterall "quiz_01";
mapannounce "quiz_01","You have won, please approach to Prize NPC.",0;
enablenpc "Prize";
set $@NvZCounter,0;
stopnpctimer;
end;
}

I didn't test the script.

Edited by Technoken
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  05/13/16
  • Last Seen:  

Hi Technoken,

 

Unfortunately it is not working after I add sleep in.

 

Thank you.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  505
  • Reputation:   126
  • Joined:  04/04/16
  • Last Seen:  

Are you sure there's only one player left inside the map? Maybe the gm account is still there.

Try to do some checking and see if there's only 1 player left.

OnPCLogoutEvent:
if ( strcharinfo(3) != "quiz_01" )end;
mapannounce "quiz_01",getmapusers("quiz_01")+" player left.",0;
end;
}
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  05/13/16
  • Last Seen:  

Hi Technoken,

 

Yes I am very sure.

I am suspecting there is something wrong with my onPCLogoutEvent function itself.

Is there any updates where I can patch to solve this problem?

 

Thank you.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  135
  • Reputation:   13
  • Joined:  06/20/12
  • Last Seen:  

Add this:

 

announce "There are "+getmapusers("quiz_01")+" players on the map",8;

 

after the OnPcLogoutEvent ( before the if ).

Log double account and see what number appears on the announce after loggin out.

If it's 1, then it's weird.

 

As an alternative you can create a timer, that checks every 1 minute if there is only one player in the map, then you don't have to use OnLougoutEvent. ( Event start would initnpctimer, and OnTimer60000: would reset the timer if the event is still going on ).
 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  05/13/16
  • Last Seen:  

Hi Moriarty,

 

Thanks for the suggestion.

I did as you said, I added it before the if, and also when the event started, using 2 accounts, 1 gm account and 1 normal account.

 

When the event starts, it gives me 2 players.

When I logout, it gives me 2 players as well.

 

Well at least now i know it is not function problem, but why is it returning 2 players ?!

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  13
  • Reputation:   0
  • Joined:  05/13/16
  • Last Seen:  

Hi Secrets,

 

Thank you for the heads up.

Added a sleep before the checking and it works fine now.

 

Thanks for all your assistance.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...