SA-MP Forums Archive
OnPlayerSpawn callback - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerSpawn callback (/showthread.php?tid=648718)



OnPlayerSpawn callback - wallen - 27.01.2018

How do i make a message on player spawn only for 1 time and not spamming everytime he spawns?


Re: OnPlayerSpawn callback - RogueDrifter - 27.01.2018

._. do a variable check that checks true onplayerspawn and false onplayerdisconnect? ex:
PHP код:
new bool:OneMessage[MAX_PLAYERS];
public 
OnPlayerSpawn(playerid)
{
    if(!
OneMessage[playerid])//checking if it was never set before
    
{
        
SendClientMessage(playerid, -1"Hi one message here");//sending the message
        
OneMessage[playerid] = true;//checking true to make it get called once
        
}
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    
OneMessage[playerid] = false;// resetting it for the next player connecting with that id.
    
return 1;




Re: OnPlayerSpawn callback - Inn0cent - 27.01.2018

Use some variable to store player first spawn and set it to 0 when player connects and under OnPlayerSpawn check if that variable is 0 then Send the spawn message and set the variable to 1.

EDIT: Nevermind, i didn't saw the 2nd post.