CLEO Help How to get ID?

CLEO related
Status
Not open for further replies.

Husnain

Well-known member
Joined
May 20, 2016
Messages
228
Reaction score
9
Location
Mars
There's an opcode which takes any player's id by its handle:
Code:
0B2B: samp 2@ = get_player_id_by_actor_handle 1@
I want to know... Is there any method to take any actor's ID by their name? Please do not tell me that you have to loop 0@ = 0 to 1000 and keep taking their names until the name and name matches so you can take the id of it. I don't need that method... any snippet?
 

Krc

Active member
Joined
Mar 30, 2018
Messages
193
Reaction score
25
Location
Lithuania
U mean like this or what?
Code:
{$CLEO .cs}
0000: NOP
REPEAT
Wait 0
Until 0AFA: is_samp_structures_available
0B34: "cleo" @CLEO

While True
Wait 0
END

:CLEO
0B35: samp 0@ = get_last_command_params
If
0AD4: $NOT_USED = scan_string 0@ format "%d" 1@
Then
If
0B23: samp is_player_connected 1@
Then
0B36: samp 2@ = get_player_nickname 1@
0B2B: samp 3@ = get_player_id_by_actor_handle 1@
chatmsg "Player nickname: %s | Player ID: %d" -1 2@ 3@
end
end
CmdRet
 

Husnain

Well-known member
Joined
May 20, 2016
Messages
228
Reaction score
9
Location
Mars
No, not this. For example: If I type /cleo Shawn_Mendez

then it will show me the ID of shawn_mendez if he is online
 

ItsRobinson

Active member
Joined
Nov 16, 2017
Messages
105
Reaction score
20
PHP:
FOR 0@ = 0 TO 9999
If
0B23: samp is_player_connected 0@
Then
Alloc 1@ 25
0B36: samp 1@ = get_player_nickname 0@
If
0C29: $NOT_USED = stristr string1 1@ string2 “shawn_mendez”
then
Chatmsg “Player ID: %d” -1 0@
Free 1@
BREAK
end
Free 1@
END
 

Husnain

Well-known member
Joined
May 20, 2016
Messages
228
Reaction score
9
Location
Mars
PHP:
FOR 0@ = 0 TO 9999
If
0B23: samp is_player_connected 0@
Then
Alloc 1@ 25
0B36: samp 1@ = get_player_nickname 0@
If
0C29: $NOT_USED = stristr string1 1@ string2 “shawn_mendez”
then
Chatmsg “Player ID: %d” -1 0@
Free 1@
BREAK
end
Free 1@
END
Please do not tell me that you have to loop 0@ = 0 to 1000 and keep taking their names until the name and name matches so you can take the id of it. I don't need that method... any snippet?
I already know your method but it is too slow. Like if I add any more options then the countdown from 0 to 9999 will become slow like seconds. I need a snippet which will take the id instantly without this loopy thing
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,724
Solutions
2
Reaction score
113
I already know your method but it is too slow. Like if I add any more options then the countdown from 0 to 9999 will become slow like seconds. I need a snippet which will take the id instantly without this loopy thing
It's not slow though, if you put "WAIT 0" in a loop that slows it down (loops like once per frame or something) otherwise the loop will be basically instantaneous. This does have it's limits however with certain opcodes so you can't do like 1000 read memories at once or the game will just crash so we put "WAIT 0" for most loops as that's a supposedly infinite ammount of loops whereas a "FOR" loop is finite.
 

ItsRobinson

Active member
Joined
Nov 16, 2017
Messages
105
Reaction score
20
I already know your method but it is too slow. Like if I add any more options then the countdown from 0 to 9999 will become slow like seconds. I need a snippet which will take the id instantly without this loopy thing

If you're making the CLEO for a specific server, change the 9999 to the max players on the server, or the highest you've ever seen it go (with some leeway). For example, if a server has max slots of 500 but it rarely goes to 350, set it to max 400.
 

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
270
Location
Pluto
I already know your method but it is too slow. Like if I add any more options then the countdown from 0 to 9999 will become slow like seconds. I need a snippet which will take the id instantly without this loopy thing

I think it is impossible to instantly get the ID without Looping, since at the "PLAYER POOL memory", the Player ID is the offset Index of the information about the Player itself... You need to use a Loop to it in order to fetch it, the method is the same as searching an actor from the "Ped Pool Memory"(using loop) but this time, it is the player.

If you're making the CLEO for a specific server, change the 9999 to the max players on the server, or the highest you've ever seen it go (with some leeway). For example, if a server has max slots of 500 but it rarely goes to 350, set it to max 400.

Or you can use Opcode 0C8A since you might have sampfuncs with you:
Code:
0C8A: samp 1@ = get_max_player_id streamed_only false

Opcode 0C8A will get the Max ID that is currently Connected... If the max ID of an online user is 230 out of 1000, 0C8A will return 230 thus saving you from next useless iterations...
 
Status
Not open for further replies.
Top