SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 15/02/2011, 05:55 PM   #1
!Phoenix!
Big Clucker
 
Join Date: Feb 2011
Location: 127.0.0.1 - Germany
Posts: 81
Reputation: 0
Default How does INVALID_PLAYER_ID work?

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?
!Phoenix! is offline   Reply With Quote
Old 15/02/2011, 06:09 PM   #2
Ash.
High-roller
 
Ash.'s Avatar
 
Join Date: Jan 2010
Location: England
Posts: 2,084
Reputation: 163
Default Re: How does INVALID_PLAYER_ID work?

Erm, i know ****** 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?
__________________
TruckingWorld
Work, Play, Make Friends
Written from scratch, and originally released in 2011, play today!
Visit the forum | Play the game
Ash. is offline   Reply With Quote
Old 15/02/2011, 06:17 PM   #3
The_Moddler
High-roller
 
The_Moddler's Avatar
 
Join Date: Jan 2010
Location: In my house.
Posts: 1,130
Reputation: 3
Default Re: How does INVALID_PLAYER_ID work?

sscanf returns INVALID_PLAYER_ID if the player is invalid.
__________________
The_Moddler is offline   Reply With Quote
Old 15/02/2011, 06:19 PM   #4
Ash.
High-roller
 
Ash.'s Avatar
 
Join Date: Jan 2010
Location: England
Posts: 2,084
Reputation: 163
Default Re: How does INVALID_PLAYER_ID work?

Quote:
Originally Posted by The_Moddler View Post
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!
__________________
TruckingWorld
Work, Play, Make Friends
Written from scratch, and originally released in 2011, play today!
Visit the forum | Play the game
Ash. is offline   Reply With Quote
Old 15/02/2011, 06:27 PM   #5
!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?

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?
!Phoenix! is offline   Reply With Quote
Old 15/02/2011, 07:02 PM   #6
Ash.
High-roller
 
Ash.'s Avatar
 
Join Date: Jan 2010
Location: England
Posts: 2,084
Reputation: 163
Default Re: How does INVALID_PLAYER_ID work?

INVALID_PLAYER_ID is equal to (0xFFFF)

(Source, a_samp.inc)
pawn Code:
#define INVALID_PLAYER_ID                       (0xFFFF)
__________________
TruckingWorld
Work, Play, Make Friends
Written from scratch, and originally released in 2011, play today!
Visit the forum | Play the game
Ash. is offline   Reply With Quote
Old 15/02/2011, 07:16 PM   #7
!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?

!Phoenix! is offline   Reply With Quote
Old 15/02/2011, 07:23 PM   #8
Ash.
High-roller
 
Ash.'s Avatar
 
Join Date: Jan 2010
Location: England
Posts: 2,084
Reputation: 163
Default Re: How does INVALID_PLAYER_ID work?

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.
__________________
TruckingWorld
Work, Play, Make Friends
Written from scratch, and originally released in 2011, play today!
Visit the forum | Play the game
Ash. is offline   Reply With Quote
Old 15/02/2011, 08:13 PM   #9
!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?

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)
!Phoenix! is offline   Reply With Quote
Old 15/02/2011, 08:15 PM   #10
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?

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.
Mean 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 06:46 PM.


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