Check if player is spawned
#1

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

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!
Reply
#3

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

Reply
#4

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

Thanks guys, will do. Thanks for the help.

Ill rep you guys tmr. Thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)