CLEO Help Loop crash

CLEO related
Status
Not open for further replies.

veysileth

Active member
Joined
Mar 23, 2017
Messages
85
Reaction score
6
Code:
:2
0001: wait 100 ms
0AF8: samp add_message_to_chat "2 STARTED" color -12027976
00D6: if
0039: 1@ == 1
004D: jump_if_false @RET4
0AF8: samp add_message_to_chat "SHIT HAPPENED" color -12027976
00A0: store_actor 14@ position_to 20@ 21@ 22@
02A8: 25@ = create_marker 41 at 20@ 21@ 22@
0001: wait 2000 ms
0002: jump @2

Why it's crashing?
When i put [font=Monaco, Consolas, Courier, monospace]0002: jump @somewhereelso where :somewhereelso is just 0B43: samp cmd_ret then it's working fine but even  [/font]

[font=Monaco, Consolas, Courier, monospace][size=small][font=Monaco, Consolas, Courier, monospace]0002: jump @there[/font][/font][/size]
[font=Monaco, Consolas, Courier, monospace][size=small][font=Monaco, Consolas, Courier, monospace]:there[/font][/font][/size]
[font=Monaco, Consolas, Courier, monospace][size=small][font=Monaco, Consolas, Courier, monospace][size=small][font=Monaco, Consolas, Courier, monospace]0002: jump @2[/font][/font][/size][/font][/size]

[font=Monaco, Consolas, Courier, monospace][size=small][font=Monaco, Consolas, Courier, monospace][size=small][font=Monaco, Consolas, Courier, monospace]is crashing again. I did see some scripts and they don't have this problem.[/font][/font][/size][/font][/size]


[font=Monaco, Consolas, Courier, monospace][size=small][font=Monaco, Consolas, Courier, monospace][size=small][font=Monaco, Consolas, Courier, monospace]Whole script. Yea i know it will spam markers all over the map. I will add disable_marker later.[/font][/font][/size][/font][/size]
[font=Monaco, Consolas, Courier, monospace][size=small][font=Monaco, Consolas, Courier, monospace][size=small][font=Monaco, Consolas, Courier, monospace]
[/font]
[/font][/size][/font][/size]

Code:
// This file was decompiled using SASCM.ini published by GTAG (http://gtag.gtagaming.com/opcode-database) on 14.6.2013
{$CLEO .cs}

//-------------MAIN---------------
0000: NOP 
0006: 1@ = 0 


:HELLO
0001: wait 0 ms
8AFA:   not is_samp_available 
004D: jump_if_false @OK
0001: wait 400 ms 
0002: jump @HELLO 


:OK
0001: wait 0 ms
0AF8: samp add_message_to_chat "OK STARTED" color -12027976 
0001: wait 1000 ms
0006: 1@ = 0 
0B34: samp register_client_command "fd" to_label @1
0B34: samp register_client_command "ufd" to_label @UN_1
0002: jump @MIGHTY_LOOP

:MIGHTY_LOOP
0001: wait 10000 ms
0002: jump @MIGHTY_LOOP


:1
0001: wait 0 ms
0AF8: samp add_message_to_chat "1 STARTED" color -12027976
0B35: samp 10@ = get_last_command_params 
00D6: if 
0AD4: 11@ = scan_string 10@ format "%D" 12@  
004D: jump_if_false @RET1 
0B20: samp 14@ = actor_handle_by_samp_player_id 12@  
00D6: if
056D: actor 14@ defined 
004D: jump_if_false @RET2
0006: 1@ = 1
00D6: if
0039: 1@ == 1
004D: jump_if_false @RET3
0002: jump @2

:2
0001: wait 100 ms
0AF8: samp add_message_to_chat "2 STARTED" color -12027976
00D6: if
0039: 1@ == 1
004D: jump_if_false @RET4
0AF8: samp add_message_to_chat "SHIT HAPPENED" color -12027976
00A0: store_actor 14@ position_to 20@ 21@ 22@
02A8: 25@ = create_marker 41 at 20@ 21@ 22@
0001: wait 2000 ms
0002: jump @2


:UN_1
0001: wait 0 ms
0AF8: samp add_message_to_chat "UN1 STARTED" color -12027976
0006: 1@ = 0
0B43: samp cmd_ret

:RET1
0001: wait 0 ms
0AF8: samp add_message_to_chat "RET1 STARTED" color -12027976
0006: 1@ = 0
0B43: samp cmd_ret

:RET2
0001: wait 0 ms
0AF8: samp add_message_to_chat "RET2 STARTED" color -12027976
0006: 1@ = 0
0B43: samp cmd_ret 

:RET3
0001: wait 0 ms
0AF8: samp add_message_to_chat "RET3 STARTED" color -12027976
0006: 1@ = 0
0B43: samp cmd_ret 

:RET4
0001: wait 0 ms
0AF8: samp add_message_to_chat "RET4 STARTED" color -12027976
0006: 1@ = 0
0B43: samp cmd_ret

:RET5
0001: wait 0 ms
0AF8: samp add_message_to_chat "RET5 STARTED" color -12027976
0006: 1@ = 0
0B43: samp cmd_ret

:RET6
0001: wait 0 ms
0AF8: samp add_message_to_chat "RET5 STARTED" color -12027976
0006: 1@ = 0
0B43: samp cmd_ret   


[font=Monaco, Consolas, Courier, monospace][size=small][font=Monaco, Consolas, Courier, monospace][size=small][font=Monaco, Consolas, Courier, monospace]
[/font][/font][/size][/font][/size]
 

noob213

Active member
Joined
Sep 15, 2017
Messages
88
Reaction score
6
Code:
while not samp.Available()
wait 0
end
0@ = 0
0B34: samp register_client_command "fd" to_label @find
0B34: samp register_client_command "ufd" to_label @unfind

:Noname
wait 0
if
0@ == 1
then
if
0B23:  samp is_player_connected 2@
then
0B2F: samp get_streamed_out_player_pos 2@ to 11@ 12@ 13@
02A7: 22@ = create_icon_marker_and_sphere 41 at 11@ 12@ 13@ 
jump @Noname_2
end
end
jump @noname


:Noname_2
wait 750
0164: disable_marker 22@
jump @noname



:find
0B35: samp 1@ = get_last_command_params
if
0AD4: 10@ = scan_string 1@ format "%d" 2@
then
if
0B23:  samp is_player_connected 2@ 
then
0@ = 1
0B36: samp 4@ = get_player_nickname 2@
0AF8: samp add_message_to_chat "Marker set on the player %s" -1 4@
end
end
0B43: samp cmd_ret

:unfind
if 0@ == 1
then
0@ = 0
chatmsg "Find player disable" -1
end
0B43: samp cmd_ret
 

veysileth

Active member
Joined
Mar 23, 2017
Messages
85
Reaction score
6
Yea, thank you. I will study your script.

But i still wonder why my script is not working. But yea fk it.
As i understand there's no way of adding normal gps marker? I mean same as RMB on map.
 

noob213

Active member
Joined
Sep 15, 2017
Messages
88
Reaction score
6
veysileth said:
Yea, thank you. I will study your script.

But i still wonder why my script is not working. But yea fk it.
As i understand there's no way of adding normal gps marker? I mean same as RMB on map.

in sanny builder press F12> SCM Documentation> GTA SA> Radar icons

like this:
http://wiki.sa-mp.com/wiki/MapIcons
https://gtagmodding.com/opcode-database/opcode/02A7/

02A7: 22@ = create_icon_marker_and_sphere (RadarID) at 11@ 12@ 13@
 

veysileth

Active member
Joined
Mar 23, 2017
Messages
85
Reaction score
6
Icon from opcode is not same as RMB clicked on map :/
I can't use like... autopilot with this marker and i have to put it manually.
 

noob213

Active member
Joined
Sep 15, 2017
Messages
88
Reaction score
6
veysileth said:
Icon from opcode is not same as RMB clicked on map :/
I can't use like... autopilot with this marker and i have to put it manually.

what RMB icon? refers to the red dot when you are on a mission
 

veysileth

Active member
Joined
Mar 23, 2017
Messages
85
Reaction score
6
When you open map from main menu and press RMB on it - id 41. Waypoint.

Manually - autopilot will work. Like auto-Driver.cs or autopilot.cs.
With opcode - It's just visual waypoint without connection to manually placed waypoint.
 
Joined
Dec 31, 2015
Messages
712
Reaction score
27
0AD4: 11@ = scan_string 10@ format "%D" 12@ - the only wrong this i've noticed so far in this code, set case converting as is and make D lowercase
Can you try explain your problem again but more competently?
 

veysileth

Active member
Joined
Mar 23, 2017
Messages
85
Reaction score
6
I wanted to understand why


Code:
:2
0001: wait 100 ms
0AF8: samp add_message_to_chat "2 STARTED" color -12027976
00D6: if
0039: 1@ == 1
004D: jump_if_false @RET4
0AF8: samp add_message_to_chat "SHIT HAPPENED" color -12027976
00A0: store_actor 14@ position_to 20@ 21@ 22@
02A8: 25@ = create_marker 41 at 20@ 21@ 22@
0001: wait 2000 ms
0002: jump @2

[font=Monaco, Consolas, Courier, monospace]0002: ju[/font][font=Monaco, Consolas, Courier, monospace]mp [/font][font=Monaco, Consolas, Courier, monospace]@[/font][font=Monaco, Consolas, Courier, monospace]2 freezes my game.[/font]


///And then we started talking about markers.

The game freezes, I can't do anything with my PC!
This is a very frequent bug: you forgot a wait somewhere in your code. Any loop in your code should at least 1 wait opcode. [...]
Some FAQ said this. I have this problem with some self-made scripts. What's i don't know what i should? :<
 
Joined
Dec 31, 2015
Messages
712
Reaction score
27
veysileth said:
Any loop in your code should at least 1 wait opcode. [...]

Yea but you usually set it to wait 0, so it wont freeze your game in case your piece of code is being executed in the main game loop
 

noob213

Active member
Joined
Sep 15, 2017
Messages
88
Reaction score
6
In your code I see things that can cause you to crash

here a little explanation
Code:
{$CLEO .cs}
0000:
0B34: samp register_client_command "mycmd" to_label @cmd_mycmd
// 0BDE: pause_thread 0

:idle_loop // You can put the inactive loop in this way if you do not need to use it or use the operation code 0BDE:
wait 0 // here it is important to add wait 0 to avoid crashing
jump @idle loop

:cmd_mycmd  // here it is not necessary to use 0001: wait 0 // If you add it this will not work

0B43: samp cmd_ret // It is important to add an operation code to exit the command procedure. 0B43: samp cmd_ret
 

Deddosouru

Active member
Joined
May 4, 2016
Messages
27
Reaction score
1
Location
Russia
veysileth said:
Yea, thank you. I will study your script.

But i still wonder why my script is not working. But yea fk it.
As i understand there's no way of adding normal gps marker? I mean same as RMB on map.

actually, there is a way
Code:
{
    call @getTargetMarkerHandle 0 returnTo: 0@
}
:getTargetMarkerHandle
0A8D: 0@ = read_memory 0xBA6774 size 4 virtual_protect 0
ret 1 0@

{
    call @setStateTargetMarker 1 state 0
}
:setStateTargetMarker
call @getTargetMarkerHandle 0 return: 1@
if 1@ > 0
then
    if 0@ == 0
    then
        0AA5: call_function 0x587CE0 num_params 1 pop 1 1@ // CRadar::removeBlip         
        0A8C: write_memory 0xBA6774 size 4 value 0 virtual_protect 0 // CMenuManager::m_targetMarker
    end
else
    if 0@ == 1
    then
        0AA7: call_function 0x583820 num_params 6 pop 6 2 0 0 0 0 4 1@ // CRadar::createBlip
        0AA5: call_function 0x583D70 num_params 2 pop 2 41 1@ // CRadar::setBlipSprite
        0A8C: write_memory 0xBA6774 size 4 value 1@ virtual_protect 0 // CMenuManager::m_targetMarker 
    end
end
ret 0

{
    call @setTargetMarkerPosition 3 x 1@ y 2@ z 3@
}
:setTargetMarkerPosition
call @getTargetMarkerHandle 0 return: 3@
if 075C: marker 3@ enabled
then
    0B10: 4@ = 3@ AND 0xFFFF
    0012: 4@ *= 40
    0A8E: 5@ = 0xBA86F8 + 4@
    0A8C: write_memory 5@ size 4 value 1@ virtual_protect 0
    5@ += 4
    0A8C: write_memory 5@ size 4 value 2@ virtual_protect 0
    5@ += 4
    0A8C: write_memory 5@ size 4 value 3@ virtual_protect 0
end     
0AB2: ret 0
made by MISTER_GONWIK, copied from blast.hk
 

noob213

Active member
Joined
Sep 15, 2017
Messages
88
Reaction score
6
Deddosouru Wrote:


actually, there is a way
Code:
{
   call @getTargetMarkerHandle 0 returnTo: 0@
}
:getTargetMarkerHandle
0A8D: 0@ = read_memory 0xBA6774 size 4 virtual_protect 0
ret 1 0@

{
   call @setStateTargetMarker 1 state 0
}
:setStateTargetMarker
call @getTargetMarkerHandle 0 return: 1@
if 1@ > 0
then
   if 0@ == 0
   then
       0AA5: call_function 0x587CE0 num_params 1 pop 1 1@ // CRadar::removeBlip         
       0A8C: write_memory 0xBA6774 size 4 value 0 virtual_protect 0 // CMenuManager::m_targetMarker
   end
else
   if 0@ == 1
   then
       0AA7: call_function 0x583820 num_params 6 pop 6 2 0 0 0 0 4 1@ // CRadar::createBlip
       0AA5: call_function 0x583D70 num_params 2 pop 2 41 1@ // CRadar::setBlipSprite
       0A8C: write_memory 0xBA6774 size 4 value 1@ virtual_protect 0 // CMenuManager::m_targetMarker 
   end
end
ret 0

{
   call @setTargetMarkerPosition 3 x 1@ y 2@ z 3@
}
:setTargetMarkerPosition
call @getTargetMarkerHandle 0 return: 3@
if 075C: marker 3@ enabled
then
   0B10: 4@ = 3@ AND 0xFFFF
   0012: 4@ *= 40
   0A8E: 5@ = 0xBA86F8 + 4@
   0A8C: write_memory 5@ size 4 value 1@ virtual_protect 0
   5@ += 4
   0A8C: write_memory 5@ size 4 value 2@ virtual_protect 0
   5@ += 4
   0A8C: write_memory 5@ size 4 value 3@ virtual_protect 0
end     
0AB2: ret 0

well with this if it will be possible
 

veysileth

Active member
Joined
Mar 23, 2017
Messages
85
Reaction score
6
noob213 said:
In your code I see things that can cause you to crash

here a little explanation
Code:
{$CLEO .cs}
0000:
0B34: samp register_client_command "mycmd" to_label @cmd_mycmd
// 0BDE: pause_thread 0

:idle_loop // You can put the inactive loop in this way if you do not need to use it or use the operation code 0BDE:
wait 0 // here it is important to add wait 0 to avoid crashing
jump @idle loop

:cmd_mycmd  // here it is not necessary to use 0001: wait 0 // If you add it this will not work

0B43: samp cmd_ret // It is important to add an operation code to exit the command procedure. 0B43: samp cmd_ret

Man that's nice.
Im writing few easy scripts that don't need no loops. That's very helpful.


Deddosouru said:
actually, there is a way
Code:
{
    call @getTargetMarkerHandle 0 returnTo: 0@
}
:getTargetMarkerHandle
0A8D: 0@ = read_memory 0xBA6774 size 4 virtual_protect 0
ret 1 0@

{
    call @setStateTargetMarker 1 state 0
}
:setStateTargetMarker
call @getTargetMarkerHandle 0 return: 1@
if 1@ > 0
then
    if 0@ == 0
    then
        0AA5: call_function 0x587CE0 num_params 1 pop 1 1@ // CRadar::removeBlip         
        0A8C: write_memory 0xBA6774 size 4 value 0 virtual_protect 0 // CMenuManager::m_targetMarker
    end
else
    if 0@ == 1
    then
        0AA7: call_function 0x583820 num_params 6 pop 6 2 0 0 0 0 4 1@ // CRadar::createBlip
        0AA5: call_function 0x583D70 num_params 2 pop 2 41 1@ // CRadar::setBlipSprite
        0A8C: write_memory 0xBA6774 size 4 value 1@ virtual_protect 0 // CMenuManager::m_targetMarker 
    end
end
ret 0

{
    call @setTargetMarkerPosition 3 x 1@ y 2@ z 3@
}
:setTargetMarkerPosition
call @getTargetMarkerHandle 0 return: 3@
if 075C: marker 3@ enabled
then
    0B10: 4@ = 3@ AND 0xFFFF
    0012: 4@ *= 40
    0A8E: 5@ = 0xBA86F8 + 4@
    0A8C: write_memory 5@ size 4 value 1@ virtual_protect 0
    5@ += 4
    0A8C: write_memory 5@ size 4 value 2@ virtual_protect 0
    5@ += 4
    0A8C: write_memory 5@ size 4 value 3@ virtual_protect 0
end     
0AB2: ret 0
made by MISTER_GONWIK, copied from blast.hk

Oh god im too naaby for this script, but i will study it.
I thought that writing memory will do.
 
Status
Not open for further replies.
Top