SA-MP Forums Archive
How do I detect when the player has spawn first time? - 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: How do I detect when the player has spawn first time? (/showthread.php?tid=606032)



How do I detect when the player has spawn first time? - Ritzy2K - 28.04.2016

Hello, I wana show rules when a player spawns for first time after connecting, not everytime he spawns. If I add it under OnPlayerSpawn, it will show rules each time player spawns, any idea how do I do that? Only once, the first spawn after the player connects.


Re: How do I detect when the player has spawn first time? - TorresxD - 28.04.2016

I think
If(PlayerInfo[playerid][Registered] == 1) {
Ur rules
Return 1;
}


Re: How do I detect when the player has spawn first time? - Ritzy2K - 28.04.2016

What? lol.


Re: How do I detect when the player has spawn first time? - TorresxD - 28.04.2016

I meant
if(PlayerInfo[Playerid][Registered] == 0 ) {
\\ Ur rules
Return 1; // so if player isn't registered the rules dialog will appear


Re: How do I detect when the player has spawn first time? - Ritzy2K - 28.04.2016

This is not at all associated with registration system, what are you trying to prove / say?


Re: How do I detect when the player has spawn first time? - Vince - 28.04.2016

OnPlayerConnect set a global variable to 0. OnPlayerSpawn, if variable is 0 it's first time spawn. Then increment variable. Not that hard.


Re: How do I detect when the player has spawn first time? - Ritzy2K - 28.04.2016

Hi, I thought of this, isn't there any other way? Rather than declaring a variable?


Respuesta: Re: How do I detect when the player has spawn first time? - DragonZafiro - 28.04.2016

Quote:
Originally Posted by [ND]xXZeusXx.
Посмотреть сообщение
Hi, I thought of this, isn't there any other way? Rather than declaring a variable?
No, just
PHP код:
new First[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
  
First[playerid] = 0;
  return 
1;
}
Public 
OnPlayerSpawn(playerid)
{
  if(
First[playerid] == 0// If Player will spawn for first time
 
{
  ........... 
// Do something
  
}
  
First[playerid] = 1;
  return 
1;




Re: How do I detect when the player has spawn first time? - Ritzy2K - 28.04.2016

You've done the same thing, lol. But thanks.