CLEO Help Scan players in front of my car in a range of 100-200 meters

CLEO related
Status
Not open for further replies.

Rough

Active member
Joined
Mar 7, 2015
Messages
42
Reaction score
4
if and
0AB0: 0@
8B21: samp is_chat_opened
8BAB: dialog -1 is_exists
then
FOR 12@ = 0 to 999
IF
SAMP.IsPlayerConnected(12@)
THEN

26@ = SAMP.GetActorHandleByPlayerID(12@)
IF AND
056D: actor 26@ defined
00DF: actor 26@ driving
0101: actor 26@ in_sphere 10@ 11@ 12@ radius 5.0 5.0 3.0 sphere 0 stopped


THEN
00A0: store_actor $PLAYER_ACTOR position_to 13@ 14@ 15@
00A0: store_actor 26@ position_to 16@ 17@ 18@
050A: 19@ = distance_between_XYZ 13@ 14@ 15@ and_XYZ 16@ 17@ 18@
SAY "/find %d" 12@
chatmsg "finding %d" -1 12@
WAIT 250
END
else
chatmsg " error" -1
END
end
end
0AB2: ret 0


I made it, when I press a button e.g (left click) it would scan all streamed player from 0 to 999 and find all fo them, but I need it to find only in front of my car for a faster find, I tried to work with sphere but I have no Idea how to use it, any help please?

Thank you!
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
Hi, there's this opcode:
0C8A: samp 1@ = get_max_player_id streamed_only 0@

Where 0@ is input parameter, if you supply "true" in there (or 1), it will return max id of steamed player, if you put false (or 0) it will return max id of all players.
This way you can avoid looping over 999 players and loop until the loop reaches max id (of streamed player in your case).
 

Rough

Active member
Joined
Mar 7, 2015
Messages
42
Reaction score
4
Hi, there's this opcode:
0C8A: samp 1@ = get_max_player_id streamed_only 0@

Where 0@ is input parameter, if you supply "true" in there (or 1), it will return max id of steamed player, if you put false (or 0) it will return max id of all players.
This way you can avoid looping over 999 players and loop until the loop reaches max id (of streamed player in your case).

And what about, getting the player's ID in front of me(or at least the closest one)? I wanted to use sphere but Idk how,

Thank you!
 

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
Ok so i have made a code b4 getting the closest players name/id. Ill send you both and you can decide which one you want and how you gonna use it. You can think of it as a snippet and use it in the way you want. You need sampfuncs for it!
 

Rough

Active member
Joined
Mar 7, 2015
Messages
42
Reaction score
4
Ok so i have made a code b4 getting the closest players name/id. Ill send you both and you can decide which one you want and how you gonna use it. You can think of it as a snippet and use it in the way you want. You need sampfuncs for it!

Thank you! I ll wait for PM
 

Rough

Active member
Joined
Mar 7, 2015
Messages
42
Reaction score
4
I modified the script, thank you very much! I'll post it here just in case somebody else needs it.

while true
wait 0
0AB1: call_scm_func @autofind 1 5
end


:autofind
if and
0AB0: 0@
8B21: samp is_chat_opened
8BAB: dialog -1 is_exists
THEN
20@ = 9999.0 // max distance on map
FOR 0@ = 0 TO 999 // ID's on server
IF
SAMP.IsPlayerConnected(0@)
THEN
IF
0B20: samp 2@ = actor_handle_by_samp_player_id 0@
THEN
04C4: store_coords_to 4@ 5@ 6@ from_actor 2@ with_offset 0.0 0.0 0.0 // distance of player
04C4: store_coords_to 7@ 8@ 9@ from_actor $PLAYER_ACTOR with_offset 0.0 0.0 0.0 // distance of me
0509: 10@ = distance_between_XY 4@ 5@ and_XY 7@ 8@ // distance between me : player
IF and
0025: 20@ > 10@ // Distance between me : player < than max distance (gets closest player)
00DF: actor 2@ driving
THEN
0087: 20@ = 10@ // new distance is the max distance
say "/find %d" 0@ // command you want
end
END
END
END
wait 250
END
0AB2: ret 0

Credits: KamikazeSripterul
 

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
Instead of testing for chat open, dialog open, just put IsCursorActive. Im not sure what opcode it is but im quite sure there is such an opcode.
 
Status
Not open for further replies.
Top