SA-MP Forums Archive
How To: check if its the player's first spawn - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How To: check if its the player's first spawn (/showthread.php?tid=137430)



How To: check if its the player's first spawn - laser50 - 28.03.2010

How do i do it?


Re: How To: check if its the player's first spawn - anumaz - 28.03.2010

Could you give us more detail about what you really want?


Re: How To: check if its the player's first spawn - Correlli - 28.03.2010

pawn Код:
new
    playerSpawn[MAX_PLAYERS];

public OnPlayerSpawn(playerid)
{
  if(playerSpawn[playerid] == 0)
  {
    // first spawn.
    playerSpawn[playerid] = 1; // player was spawned for the first time, now we'll set the variable to true.
  }
  else
  {
    // it's not his first spawn.
  }
  return true;
}

public OnPlayerDisconnect(playerid, reason)
{
  playerSpawn[playerid] = 0; // reset the variable when player disconnects.
  return true;
}
I've used the normal arrays here, you can easily change it to P-vars (new functions) if you want to.


Re: How To: check if its the player's first spawn - laser50 - 28.03.2010

hm... cant i just do new FirstTimeLoggedIn[MAX_PLAYERS];?


Re: How To: check if its the player's first spawn - Correlli - 28.03.2010

The name of the array is not important at all (as long its name length isn't bigger than PAWNs limit length for function/variable).


Re: How To: check if its the player's first spawn - laser50 - 28.03.2010

would this work?:

Код:
new FirstSpawn[MAX_PLAYERS];
then:

Код:
stock FirstTimeSpawning(playerid, type)
{
	if (type == 0) //not the first time
	{
	  FirstSpawn[playerid] = 0;
	  
	}
	if (type == 1) //First time
	{
		FirstSpawn[playerid] = 1;
	}
	return 1;
}



Re: How To: check if its the player's first spawn - Correlli - 28.03.2010

I already gave you a working example.


Re: How To: check if its the player's first spawn - laser50 - 28.03.2010

yeah but, would mine work aswell?

edit:
I got a small error

Код:
C:\Documents and Settings\Wouter\Bureaublad\Sa-MP Scripting\pawno\NG-RP.pwn(123) : warning 211: possibly unintended assignment
Код:
	if(FirstSpawn[playerid] = 1)



Re: How To: check if its the player's first spawn - Correlli - 28.03.2010

It's ==, not =


Re: How To: check if its the player's first spawn - RyDeR` - 28.03.2010

'=' is assigning a variable. Use double '='

Код:
if(FirstSpawn[playerid] == 1)
Edit: Damn, Don was faster