SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 15/02/2011, 08:18 PM   #11
Calgon
Banned
 
Join Date: Jan 2009
Posts: 6,136
Reputation: 1127
Default Re: How does INVALID_PLAYER_ID work?

sscanf checks if you use "u" and if it searches for a name or player ID with the "u" parameter and doesn't find anyone online with the information you provide, then it returns INVALID_PLAYER_ID instead of the players actual ID, you can compare the ID variable you assign with sscanf to INVALID_PLAYER_ID if the player isn't connected.

pawn Code:
new id; // Variable. The user ID from sscanf needs to be stored in this. If the player isn't connected, INVALID_PLAYER_ID is put as the variable value.
if(sscanf(params, "u", id)) {
// They didn't even provide anything after the command name.
}
else {
// They provided something after the command name, our name. Are they connected?
if(id == INVALID_PLAYER_ID) {
// If this gets called, then the player isn't connected.
return 1;
}
}
Calgon is offline   Reply With Quote
Old 15/02/2011, 08:21 PM   #12
!Phoenix!
Big Clucker
 
Join Date: Feb 2011
Location: 127.0.0.1 - Germany
Posts: 81
Reputation: 0
Default AW: How does INVALID_PLAYER_ID work?

So INVALID_PLAYER_ID simply stands for "The playerid is overall not valid"?
Wouldn't that mean that if it's valid you still have to check if the player is connected?

//-------------
Calgon answered my question while I was writing this reply.
!Phoenix! is offline   Reply With Quote
Old 15/02/2011, 08:23 PM   #13
Calgon
Banned
 
Join Date: Jan 2009
Posts: 6,136
Reputation: 1127
Default Re: How does INVALID_PLAYER_ID work?

INVALID_PLAYER_ID does mean that an invalid player ID was specified, well that's what sscanf sets as the playerid if it can't find valid search criteria.

If INVALID_PLAYER_ID is returned then you don't need any more checks if you use sscanf to parse the userid/name - they aren't connected at all.
Calgon is offline   Reply With Quote
Old 15/02/2011, 08:24 PM   #14
!Phoenix!
Big Clucker
 
Join Date: Feb 2011
Location: 127.0.0.1 - Germany
Posts: 81
Reputation: 0
Default AW: How does INVALID_PLAYER_ID work?

That makes sense; thank you!
(see my last post)
!Phoenix! is offline   Reply With Quote
Old 15/02/2011, 08:41 PM   #15
Mean
High-roller
 
Join Date: Jul 2010
Location: 14th annual lemon party
Posts: 2,727
Reputation: 229
Default Re: How does INVALID_PLAYER_ID work?

Also, you can use !IsPlayerConnected:
pawn Code:
if( !IsPlayerConnected( playerid ) )
 // If this gets called, player is not on the server
Mean is offline   Reply With Quote
Old 06/01/2012, 02:53 PM   #16
vldmrtal
Little Clucker
 
Join Date: Dec 2011
Posts: 2
Reputation: 0
Default Re: How does INVALID_PLAYER_ID work?

How can i use INVALID_PLAYER_ID ?
TO ALL ID at the TAB BAR?
sry I ONLY SCRIPT LITTLE.
vldmrtal 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
Why doesn't "SendDeathMessage(playerid,INVALID_PLAYER_ID,200);" work on some.. _Vortex Help Archive 7 11/10/2010 01:58 PM
should FS/GM that work with windows work on linux iggy1 Help Archive 4 01/06/2010 10:53 AM
NEED HELP ( AGAIN ) : DOES INVALID_PLAYER_ID WORK? [SLOVED 100%] Micko9 Help Archive 9 18/03/2010 11:48 AM
Problem with INVALID_PLAYER_ID Gappy Help Archive 2 11/09/2009 05:01 AM
INVALID_PLAYER_ID russiany Help Archive 13 24/05/2009 10:32 AM


All times are GMT. The time now is 12:35 AM.


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