SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 18/01/2018, 06:34 PM   #1
Sting.
Gangsta
 
Sting.'s Avatar
 
Join Date: May 2011
Location: Malaysia
Posts: 816
Reputation: 122
Default Check if player is spawned

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....
Sting. is offline   Reply With Quote
Old 18/01/2018, 06:47 PM   #2
Pravin
Huge Clucker
 
Pravin's Avatar
 
Join Date: Aug 2011
Location: Scotland, UK
Posts: 265
Reputation: 100
Default Re: Check if player is spawned

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!
__________________

Los Santos Gang Wars - 5.135.24.181:6666
lsgw.forumotion.com
Pravin is offline   Reply With Quote
Old 18/01/2018, 06:59 PM   #3
aoky
Huge Clucker
 
aoky's Avatar
 
Join Date: Oct 2016
Location: Ireland
Posts: 488
Reputation: 136
Default Re: Check if player is spawned

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

__________________
owner/developer @ koky's deathmatch
aoky is offline   Reply With Quote
Old 18/01/2018, 07:03 PM   #4
Ritzy2K
High-roller
 
Ritzy2K's Avatar
 
Join Date: Jun 2014
Location: India
Posts: 1,548
Reputation: 170
Default Re: Check if player is spawned

Heres a perfect solution to your issue!
http://forum.sa-mp.com/showthread.php?t=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;
}
__________________
Ritzy2K is offline   Reply With Quote
Old 18/01/2018, 07:16 PM   #5
Sting.
Gangsta
 
Sting.'s Avatar
 
Join Date: May 2011
Location: Malaysia
Posts: 816
Reputation: 122
Default Re: Check if player is spawned

Thanks guys, will do. Thanks for the help.

Ill rep you guys tmr. Thanks
Sting. is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[HELP] welcome message when player spawned Luca12 Scripting Help 6 27/03/2014 04:01 PM
How to check if player is spawned FireWarrior101 Scripting Help 5 19/08/2013 10:41 AM
Is Player Spawned. thefatshizms Scripting Help 6 12/12/2012 08:27 PM
Check if the player spawned in the position 0ne Help Archive 12 19/11/2010 02:04 PM
how can i put player in vehicle they just spawned iggy1 Help Archive 2 03/05/2010 12:22 PM


All times are GMT. The time now is 08:23 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.