How To: check if its the player's first spawn
#1

How do i do it?
Reply
#2

Could you give us more detail about what you really want?
Reply
#3

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.
Reply
#4

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

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).
Reply
#6

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;
}
Reply
#7

I already gave you a working example.
Reply
#8

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)
Reply
#9

It's ==, not =
Reply
#10

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

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


Forum Jump:


Users browsing this thread: 6 Guest(s)