GetPlayerID
From SA-MP Wiki
GetPlayerID
Description:
This function returns the ID of a player by giving a name. If you set partofname=1 you will get the ID of the first player whose name includes that string.
Important | This is a custom function, which can be found in Useful_Functions. |
(const playername[], partofname=0)
const playername[] | The string you want to hash |
partofname=0 | 0 for checking exactly that name, 1 if this is only part of the playername (optional) |
Return Values:
The ID of the player OR -1 if there's no player fulfilling the conditions
// Players: // 0 - Peter // 1 - Paul // 2 - Simon // 3 - Monika GetPlayerID("Peter"); // returns 0 GetPlayerID("Pe", 1); // returns 0 GetPlayerID("on"); // returns 2 (although 3 also contains "on") GetPlayerID("aul"); // returns -1 because there's no player named "aul" GetPlayerID("aul", 1); // returns 1 because that playername contains "aul"
Related Functions
The following functions may be useful, as they are related to this function in one way or another.
- GetPlayerName: Get a player's name.