CLEO Help Question

CLEO related
Status
Not open for further replies.

Edvincik

Well-known member
Joined
Mar 15, 2016
Messages
399
Reaction score
27
How to get only nearest player cords and distance between me and him? (only nearest, not all)
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
you could use this:
0AB5: store_actor $PLAYER_ACTOR closest_vehicle_to 0@ closest_ped_to 1@

but I think it causes problems if there's no one near, you could also check this:
http://ugbase.eu/Thread-Taze-nearby-player-is-not-working?pid=91577#pid91577
 

Edvincik

Well-known member
Joined
Mar 15, 2016
Messages
399
Reaction score
27
monday said:
you could use this:
0AB5: store_actor $PLAYER_ACTOR closest_vehicle_to 0@ closest_ped_to 1@

but I think it causes problems if there's no one near, you could also check this:
http://ugbase.eu/Thread-Taze-nearby-player-is-not-working?pid=91577#pid91577

Thanks man very much!!! That line didnt help me xDD but i checked that theme about taz and it helped me a lot
 

Edvincik

Well-known member
Joined
Mar 15, 2016
Messages
399
Reaction score
27
monday said:
you could use this:
0AB5: store_actor $PLAYER_ACTOR closest_vehicle_to 0@ closest_ped_to 1@

but I think it causes problems if there's no one near, you could also check this:
http://ugbase.eu/Thread-Taze-nearby-player-is-not-working?pid=91577#pid91577

Why its crashing when i want to turn off the script?
Code:
{$CLEO .cs}
0000:
13@ = 1
15@ = TRUE
0B34: samp register_client_command "anti" to_label @GModeActivate

:Main
wait 0
if
056D: actor $PLAYER_ACTOR defined 
jf @MAIN 
00A0: store_actor $PLAYER_ACTOR position_to 3@ 4@ 5@
10@ = 100.0 //minimal distance
12@ = false //to check if there are any players around at all

0A8D: 29@ = read_memory 0xB74490 size 4 virtual_protect 0
000A: 29@ += 0x4
0A8D: 29@ = read_memory 29@ size 4 virtual_protect 0
   for 30@ = 0 to 35584 step 0x100
   0A8D: 31@ = read_memory 29@ size 1 virtual_protect 0
   000A: 29@ += 0x1
       if and
       0029:  31@ >= 0x00 
       001B:  0x80 > 31@
       then 
       005A: 31@ += 30@
       00A0: store_actor 31@ position_to 6@ 7@ 8@
       050A: 9@ = distance_between_XYZ 3@ 4@ 5@ and_XYZ 6@ 7@ 8@
           if and
           0025:   10@ > 9@ 
           0021:   9@ > 0.2 //idk if it's neccessary but I remember having some weird problems without it while making other mod so 
           //if
           //0025:   10@ > 9@ 
           then
           0087: 10@ = 9@ // (float) to save the new closest distance found
           0085: 11@ = 31@ // (int) to save the new closest player found
           12@ = true
           end
       end
   end
   
if 12@ == true
jf @Main
IF
15@ == TRUE
       IF AND 
       10@ <= 3.0
       13@ == 1
       THEN
       0C8F: samp process_chat_input "/gmode"
       13@ = 0
       END    
       IF AND
       10@ >= 3.0
       13@ == 0
       THEN
       0C8F: samp process_chat_input "/gmode"
       13@ = 1          
       END                                                     
jump @Main

:GModeActivate
if
15@ == true
then
15@ = false
0ACD: show_text_highpriority "Gmode: ~r~OFF~w~" time 1500
wait 200
0C8F: samp process_chat_input "/gmode"
0B43: samp cmd_ret
end
if
15@ == false
then
15@ = true
0ACD: show_text_highpriority "Gmode: ~g~ON~w~" time 1500
end
0B43: samp cmd_ret  
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
0ACD: show_text_highpriority "Gmode: ~r~OFF~w~" time 1500
wait 200
0C8F: samp process_chat_input "/gmode"


0C8F crashes it, idk why but I guess it's because it tries to process a command while 1 command is already being executed and have not returned yet. Also it seems that "if 15@ == true" is not followed by "then" and "end" so maybe if 15@ turns false it will crash the code... Or it recognises identation which I didn't know and that's why "then/end" is not needed?

Anyway, I'd try running this:
Code:
{$CLEO .cs}
0000:
13@ = 1
15@ = TRUE
0B34: samp register_client_command "anti" to_label @GModeActivate

:Main
wait 0
if
056D: actor $PLAYER_ACTOR defined
jf @MAIN
00A0: store_actor $PLAYER_ACTOR position_to 3@ 4@ 5@
10@ = 100.0 //minimal distance
12@ = false //to check if there are any players around at all

0A8D: 29@ = read_memory 0xB74490 size 4 virtual_protect 0
000A: 29@ += 0x4
0A8D: 29@ = read_memory 29@ size 4 virtual_protect 0
  for 30@ = 0 to 35584 step 0x100
  0A8D: 31@ = read_memory 29@ size 1 virtual_protect 0
  000A: 29@ += 0x1
      if and
      0029:  31@ >= 0x00
      001B:  0x80 > 31@
      then
      005A: 31@ += 30@
      00A0: store_actor 31@ position_to 6@ 7@ 8@
      050A: 9@ = distance_between_XYZ 3@ 4@ 5@ and_XYZ 6@ 7@ 8@
          if and
          0025:   10@ > 9@
          0021:   9@ > 0.2 //idk if it's neccessary but I remember having some weird problems without it while making other mod so
          //if
          //0025:   10@ > 9@
          then
          0087: 10@ = 9@ // (float) to save the new closest distance found
          0085: 11@ = 31@ // (int) to save the new closest player found
          12@ = true
          end
      end
  end
 
if 12@ == true
jf @Main

if
15@ == true
then    
    if and
    10@ <= 3.0
    13@ == 1
    then
    0C8F: samp process_chat_input "/gmode"
    
        chatmsg "1" -1
        wait 5000
    
    end
     
    if and
    10@ >= 3.0
    13@ == 0
    then
    0C8F: samp process_chat_input "/gmode" 
    
        chatmsg "2" -1
        wait 5000        
    
    end
    
    0B12: 13@ = 13@ XOR 1
end                                                   
jump @Main

:GModeActivate
0B12: 15@ = 15@ XOR true
if
15@ == true
then
    0ACD: show_text_highpriority "Gmode: ~g~ON" time 1500   
else
    0ACD: show_text_highpriority "Gmode: ~r~OFF" time 1500
    //0C8F: samp process_chat_input "/gmode"
end
0B43: samp cmd_ret  
(I added 2x chatmsg and wait 5000 just for my "debugging")

If it's really necessary to have "0C8F" executed after deactivation then I'd replace it with something like:


Code:
else
    0ACD: show_text_highpriority "Gmode: ~r~OFF" time 1500
    16@ = true
end

and then at the begining of the main function add:

Code:
if 16@ == true 
then 
    16@ = false
    0C8F: samp process_chat_input "/gmode"
end
 
Status
Not open for further replies.
Top