SA-MP Forums Archive
Check if player is spawned - 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: Check if player is spawned (/showthread.php?tid=648260)



Check if player is spawned - Sting. - 18.01.2018

Hmm, I need something to check if the player is spawned, actually this is pretty straight forward but I kinda got confused and decided to ask for assistance.

I have a problem where if a player is Requesting a class, an automated paycheck is sent, which I only want it to be received only if the player is spawned....

Something like:
Code:
if(IsPlayerSpawned)
Any help is appreciated....


Re: Check if player is spawned - Pravin - 18.01.2018

Create a variable and set it to 1 if spawned and 0 if not.
Quote:

new spawn[MAX_PLAYERS];

spawn[playerid] = 1/0;

Use the same to check whether if the player is spawned or not!


Re: Check if player is spawned - aoky - 18.01.2018

On the top of your script add:

PHP Code:
new Spawned[MAX_PLAYERS]; 
OnPlayerConnect add:
PHP Code:
Spawned[playerid] = 0
OnPlayerSpawn add:
PHP Code:
Spawned[playerid] = 1
And if you don't mind post your paycheck code, if you understand above just add this:
PHP Code:
if(Spawned[playerid] == 1)
{
 
//PAYCHECK CODE




Re: Check if player is spawned - Ritzy2K - 18.01.2018

Heres a perfect solution to your issue!
https://sampforum.blast.hk/showthread.php?tid=647031

You can copy the IsPlayerSpawned in your code.

Edit: You can just have it here.
Code:
IsPlayerSpawned(playerid)
{
	new pState = GetPlayerState(playerid);
	
	return 0 <= playerid <= MAX_PLAYERS && pState != PLAYER_STATE_NONE && pState != PLAYER_STATE_WASTED && pState != PLAYER_STATE_SPECTATING;
}



Re: Check if player is spawned - Sting. - 18.01.2018

Thanks guys, will do. Thanks for the help.

Ill rep you guys tmr. Thanks