Posts: 81
Threads: 2
Joined: Feb 2011
Reputation:
0
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?
Posts: 2,082
Threads: 118
Joined: Jan 2010
Reputation:
0
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?
Posts: 1,130
Threads: 77
Joined: Jan 2010
Reputation:
0
sscanf returns INVALID_PLAYER_ID if the player is invalid.
Posts: 2,082
Threads: 118
Joined: Jan 2010
Reputation:
0
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.
Posts: 81
Threads: 2
Joined: Feb 2011
Reputation:
0
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)
Posts: 6,129
Threads: 36
Joined: Jan 2009
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;
}
}
Posts: 81
Threads: 2
Joined: Feb 2011
Reputation:
0
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.
Posts: 6,129
Threads: 36
Joined: Jan 2009
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.
Posts: 2
Threads: 0
Joined: Dec 2011
Reputation:
0
How can i use INVALID_PLAYER_ID ?
TO ALL ID at the TAB BAR?
sry I ONLY SCRIPT LITTLE.