CLEO Help Globals

CLEO related
Status
Not open for further replies.

renko

Active member
Joined
Jul 8, 2014
Messages
58
Reaction score
0
I know global variables are bugged but...i want to make an activation command for my mod with sampfuncs.
Ex:
Code:
0B34: samp register_client_command "arepair" to @accept
And :accept is:
Code:
:accept
wait 0
if 3@ == 0
then
3@ = 1
0ACD: show_text_highpriority "Repair & Refill MOD ~g~enabled" time 3000
else
       3@ = 0
        0ACD: show_text_highpriority "Repair & Refill MOD ~r~disabled~w~" time 3000
end
samp.CmdRet()
goto @OFF
If I use like this, the 3@ local variable it will always be 0...i don't know why it get reset.
P.S: If I use globals it work but if i use globals in more than one mod it get bugged.
 

renko

Active member
Joined
Jul 8, 2014
Messages
58
Reaction score
0
Full script:
Code:
{$CLEO .cs}

0000: NOP
thread 'AcceptR'
var
 3@ : Int
end
3@ = 0
0B34: samp register_client_command "arepair" to @accept

:ON
wait 0
if
3@ == 1  
jf @ON
goto @MAIN

:MAIN
wait 0

0AC8: 0@ = allocate_memory_size 260
0AB1: call @getChatEntryText 1 id 99 to 0@
if 
0AD4: 30@ = scan_string 0@ format "{B8FFDB}* Mechanic %s wants to repair your car for 1$. Use (/accept repair %d)." 5@v 6@ 
jf @check_2

wait 300
0AF9: "/engine"
wait 500
0AF9: "/accept repair %d" 6@
wait 250
0AF9: "/engine"
0AC9: free_allocated_memory 0@
goto @OFF

:check_2
if 
0AD4: 30@ = scan_string 0@ format "{B8FFDB}* Mechanic %s wants to refill your car with %s fuel for 1$. Use (/accept refill %d)." 5@v 8@v 6@ 
jf @OFF

wait 300
0AF9: "/engine"
wait 500
0AF9: "/accept refill %d" 6@
wait 250
0AF9: "/engine"
0AC9: free_allocated_memory 0@
goto @OFF

:OFF
wait 0
if
3@ == 0
jf @MAIN
goto @ON


:getChatEntryText
wait 500
0AA2: 1@ = "samp.dll"
1@ += 0x212A6C
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
1@ += 0x136
0@ *= 252 
005A: 1@ += 0@
1@ += 28
0AB2: ret 1 1@

:accept
wait 0
if 3@ == 0
then
3@ = 1
0ACD: show_text_highpriority "Repair & Refill MOD ~g~enabled" time 3000
else
       3@ = 0
        0ACD: show_text_highpriority "Repair & Refill MOD ~r~disabled~w~" time 3000
end
samp.CmdRet()
goto @OFF
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
272
Code:
{$CLEO .cs}
0000: NOP
wait 2000
0B34: samp register_client_command "arepair" to @accept

while true
wait 0
if 31@ == 1
then
    0AC8: 0@ = allocate_memory_size 260
    0AB1: call @getChatEntryText 1 id 99 to 0@
    if 0AD4: 30@ = scan_string 0@ format "{B8FFDB}* Mechanic %s wants to repair your car for 1$. Use (/accept repair %d)." 5@v 20@ 
    then
        wait 300
        0AF9: "engine"
        wait 500
        0AF9: "accept repair %d" 20@
        wait 250
        0AF9: "engine"
        0AC9: free_allocated_memory 0@
    else
        if 0AD4: 30@ = scan_string 0@ format "{B8FFDB}* Mechanic %s wants to refill your car with %s fuel for 1$. Use (/accept refill %d)." 5@v 8@v 20@ 
        then
            wait 300
            0AF9: "engine"
            wait 500
            0AF9: "accept refill %d" 20@
            wait 250
            0AF9: "engine"
            0AC9: free_allocated_memory 0@
        end
    end
end
END


:getChatEntryText
wait 500
0AA2: 1@ = "samp.dll"
1@ += 0x212A6C
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
1@ += 0x136
0@ *= 252 
005A: 1@ += 0@
1@ += 28
0AB2: ret 1 1@

:accept
0B12: 31@ = 31@ XOR 1
if 31@ == 1
then 0AD1: show_text_highpriority "Repair & Refill MOD ~g~enabled" time 3000
else 0ACD: show_text_highpriority "Repair & Refill MOD ~r~disabled~w~" time 3000
end
0B43: cmd_ret

Also, one variable can store 4bytes of data, a long variable @v can store 16bytes but it also occupies the next 3 variables, so 5@v = 5@, 6@, 7@, 8@, your number being store to 6@ will get overwritten.
 

renko

Active member
Joined
Jul 8, 2014
Messages
58
Reaction score
0
springfield link said:
Code:
{$CLEO .cs}
0000: NOP
wait 2000
0B34: samp register_client_command "arepair" to @accept

while true
wait 0
if 31@ == 1
then
    0AC8: 0@ = allocate_memory_size 260
    0AB1: call @getChatEntryText 1 id 99 to 0@
    if 0AD4: 30@ = scan_string 0@ format "{B8FFDB}* Mechanic %s wants to repair your car for 1$. Use (/accept repair %d)." 5@v 20@ 
    then
        wait 300
        0AF9: "engine"
        wait 500
        0AF9: "accept repair %d" 20@
        wait 250
        0AF9: "engine"
        0AC9: free_allocated_memory 0@
    else
        if 0AD4: 30@ = scan_string 0@ format "{B8FFDB}* Mechanic %s wants to refill your car with %s fuel for 1$. Use (/accept refill %d)." 5@v 8@v 20@ 
        then
            wait 300
            0AF9: "engine"
            wait 500
            0AF9: "accept refill %d" 20@
            wait 250
            0AF9: "engine"
            0AC9: free_allocated_memory 0@
        end
    end
end
END


:getChatEntryText
wait 500
0AA2: 1@ = "samp.dll"
1@ += 0x212A6C
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
1@ += 0x136
0@ *= 252 
005A: 1@ += 0@
1@ += 28
0AB2: ret 1 1@

:accept
0B12: 31@ = 31@ XOR 1
if 31@ == 1
then 0AD1: show_text_highpriority "Repair & Refill MOD ~g~enabled" time 3000
else 0ACD: show_text_highpriority "Repair & Refill MOD ~r~disabled~w~" time 3000
end
0B43: cmd_ret

Also, one variable can store 4bytes of data, a long variable @v can store 16bytes but it also occupies the next 3 variables, so 5@v = 5@, 6@, 7@, 8@, your number being store to 6@ will get overwritten.
Aa ok but still not working...it only give me enable but when i type it again to disable it isn't working (it's saying ENABLE)

I tested it with a simple script and it work but here it isn't:
{$CLEO .cs}
0000: NOP
wait 2000
0B34: samp register_client_command "arepair" to @accept

while true
wait 0

END

:accept
0B12: 31@ = 31@ XOR 1
0AF8: "Nr: %d" color 0xCF0300 31@
0B43: cmd_ret

This is working
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
272
It's because you addead a 'wait 500' in getChatline function, and once activated cmdRet will jump in function thread. And fuck every variables up.

So, use my script and just

Code:
:getChatEntryText
wait 500
0AA2: 1@ = "samp.dll"

Remove 'wait 500'.
 

renko

Active member
Joined
Jul 8, 2014
Messages
58
Reaction score
0
springfield link said:
It's because you addead a 'wait 500' in getChatline function, and once activated cmdRet will jump in function thread. And fuck every variables up.

So, use my script and just

Code:
:getChatEntryText
wait 500
0AA2: 1@ = "samp.dll"

Remove 'wait 500'.
Oh, yes thank you renko :)  :eek:h_stop_it_u:
 
Status
Not open for further replies.
Top