Jump to content

Question

Posted

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.

10 answers to this question

Recommended Posts

  • 0
Posted (edited)

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
  • 0
Posted

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;
}
  • 0
Posted

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.

  • 0
Posted

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 ).
 

  • 0
Posted

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 ?!

  • 0
Posted

Hi Secrets,

 

Thank you for the heads up.

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

 

Thanks for all your assistance.

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...