How does INVALID_PLAYER_ID work? -
!Phoenix! - 15.02.2011
Hey,
If you use "sscanf" you may use "INVALID_PLAYER_ID" to check if the player-id exists and someone is using it.
But how does it work? Any idea?
Re: How does INVALID_PLAYER_ID work? -
Ash. - 15.02.2011
Erm, i know Y_Less is an amazing scripter, but i dont think the words INVALID_PLAYER_ID would mean he would want his script to check for if a player(id) EXISTS?
Then again, i havent read the documentation (which i probably should do) and there probably is an algorithm somewhere that causes it to do so.
Can i just ask, where did you read that INVALID_PLAYER_ID does what you said it does?
Re: How does INVALID_PLAYER_ID work? -
The_Moddler - 15.02.2011
sscanf returns INVALID_PLAYER_ID if the player is invalid.
Re: How does INVALID_PLAYER_ID work? -
Ash. - 15.02.2011
Quote:
Originally Posted by The_Moddler
sscanf returns INVALID_PLAYER_ID if the player is invalid.
|
I thought so. I cant quite see why it wouldnt, the word INVALID_PLAYER_ID are pretty self explantatory. Sorry if i caused confusion !Phoenix!
AW: How does INVALID_PLAYER_ID work? -
!Phoenix! - 15.02.2011
Wiki:
pawn Code:
if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/heal <playerid>\"");
else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
So if the id in sscanf(params, "u", id) is invalid " INVALID_PLAYER_ID" will be 0?
-> You can only use it with this special id?
Or does the retrieval of the " INVALID_PLAYER_ID" content runs something like a function?
Re: How does INVALID_PLAYER_ID work? -
Ash. - 15.02.2011
INVALID_PLAYER_ID is equal to (0xFFFF)
(Source, a_samp.inc)
pawn Code:
#define INVALID_PLAYER_ID (0xFFFF)
AW: How does INVALID_PLAYER_ID work? -
!Phoenix! - 15.02.2011
Re: How does INVALID_PLAYER_ID work? -
Ash. - 15.02.2011
Sorry i should of explained better, i meant that INVALID_PLAYER_ID does not run a function or anything, it merely is (0xFFFF) and nothing more.
AW: How does INVALID_PLAYER_ID work? -
!Phoenix! - 15.02.2011
I realized that but I don't understand how this can be used for an if-statement.
(You see I really want to understand how this unimposing comparison works)
Maybe the answer is unbelievable simple, but I don't get it...
(thanks funky)
Re: How does INVALID_PLAYER_ID work? -
Mean - 15.02.2011
So.
Using it under OnPlayerDeath:
pawn Code:
if( killerid == INVALID_PLAYER_ID )
{
SendClientMessage( playerid, 0xAAAAAA, "You have suicided, thefore you have no killer, no one killed you" );
}
Just an example.
Re: How does INVALID_PLAYER_ID work? -
Calgon - 15.02.2011
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;
}
}
AW: How does INVALID_PLAYER_ID work? -
!Phoenix! - 15.02.2011
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.
Re: How does INVALID_PLAYER_ID work? -
Calgon - 15.02.2011
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.
AW: How does INVALID_PLAYER_ID work? -
!Phoenix! - 15.02.2011
That makes sense; thank you!

(see my last post)
Re: How does INVALID_PLAYER_ID work? -
Mean - 15.02.2011
Also, you can use !IsPlayerConnected:
pawn Code:
if( !IsPlayerConnected( playerid ) )
// If this gets called, player is not on the server
Re: How does INVALID_PLAYER_ID work? -
vldmrtal - 06.01.2012
How can i use INVALID_PLAYER_ID ?
TO ALL ID at the TAB BAR?
sry I ONLY SCRIPT LITTLE.