CLEO Help Skipped Code

CLEO related
Status
Not open for further replies.

ItsRobinson

Active member
Joined
Nov 16, 2017
Messages
105
Reaction score
20
Code:
{$CLEO .cs}

:Lockpicks

thread "Lockpicks" 

:Lockpicks_10
wait 100 
SAMP.Available
else_jump @Lockpicks_10

:picklocksx325
wait 0
if and
    key_down 17
    key_down 111
jf @picklocksx325
alloc 0@ 64 
alloc 2@ 256 
alloc 3@ 0
jump @dothelocks

//This section is completely skipped
:dothelocks
wait 0 
SAMP.GetChatString(99, 2@, 3@, 4@, 5@)
if 
0C18: 0@ = strstr string1 2@ string2 "has successfully picked the lock of a vehicle." 
jf @nolock  
say "/lock"
0AF8: samp add_message_to_chat "{FFFFFF}Local Works"
free 0@ 
free 2@ 
free 3@
//
:nolock
wait 0
say "/picklock"
wait 14500
jump @dothelocks
Anyone got any idea why this is being skipped because I sure as hell don't.
 

Mila.cs ✅

Well-known member
Joined
Jun 24, 2016
Messages
247
Reaction score
10
Location
̀́̀́
It doesn't work because the code is a mess.

Code:
{$CLEO .cs}
{$INCLUDE sf}
0000:

0B34: samp register_client_command ".lockpicks" to_label @CMD

0661: "2plus2is4"
0661: "minus1thats3"
0661: "quickMAfs"

:MAIN
WAIT 0
IF 0@ == 1
ELSE_JUMP @MAIN
WAIT 0
0AC8: 10@ = allocate_memory_size 260
0B75: samp get_chat_string 99 text_to 10@ prefix_to $2plus2is4 color_to $minus1thats3 prefix_color_to $quickMAfs
IF
0C29: 1@ = stristr string1 10@ string2 "has successfully picked the lock of a vehicle." 
THEN
SAY "/lock"
CHATMSG "{FFFFFF}Local Works" 
0AC9: free_allocated_memory 10@
END  
JUMP @MAIN

:CMD
WAIT 0
0B12: 0@ = 0@ XOR 1
IF
0@ == 0
THEN
PRINT "Lockpicks ~r~deactivated." 2000
END
IF
0@ == 1
THEN
PRINT "Lockpicks ~g~activated." 2000
END     
SAMP.CmdRet()
JUMP @MAIN
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,161
Solutions
5
Reaction score
894
Location
Lithuania
Hmmm, simple code, but you doing mess.
I make this for you, wait...

@ItsRobinson

Edit.:

PHP:
{$CLEO .cs}

0000: NOP

REPEAT
wait 0
UNTIL 0AFA:

0B34: ".lockpicks" @CMD /// ACTIVATE and DE - ACTIVE with same command

0AC8: 2@ = allocate_memory_size 258
0AC8: 3@ = allocate_memory_size 258

WHILE TRUE
wait 0

FOR 1@ = 98 TO 99 /// Read line - almost last and last
0B75: samp get_chat_string 1@ text_to 2@ prefix_to 3@ color_to 4@ prefix_color_to 5@

IF
0@ == TRUE
THEN
    IF
    0C29: $NOT_USED = stristr string1 2@ string2 "has successfully picked the lock of a vehicle." /// You can edit this text 
    THEN
        say "/lock"
        0AF8: "Local Works" -1 /// -1 is white
        0AF8: "Text color: %x" -1 4@
    END
END

END /// END FOR 1@ = 98 TO 99

END /// END WHILE TRUE

:CMD
0B12: 0@ = 0@ XOR TRUE

IF
0@ == FALSE
THEN
    PRINT "Lockpicks ~r~DE - ACTIVED." 2000
ELSE
    PRINT "Lockpicks ~g~ACTIVED." 2000
END

0B43:
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
@Mila.cs ✅
I'm not sure if that was on purpose but it seems like first you're checking the last chat line to see whether the lock was picked and then use "/lock" command which probably triggers the aforementioned chat line to appear :p It would be required to either add some delay after the "/lock" command or dedicate a variable which will be set to some value once one of the hooked incoming messages arrives, without using 1 of these methods the code will compare the previous chat line because the desired chat line won't have time to arrive. Edit: (My bad)

Also "0AC9: free" is called only if the condition is true, if the condition is false then it jumps back at ":MAIN" and allocates memory again without using "0AC9". If the condition is true the 0@ variable is not reset back to 0 so the code will spam the 'CHATMSG "{FFFFFF}Local Works" ' until the command is sent again.

You could strip the ":CMD" callback of some lines and it will still work btw (it's not necessary to use wait 0 there, SAMP.cmdRet itself makes the code jump back to where it was before), like:
Code:
:CMD
0B12: 0@ = 0@ XOR 1
IF
0@ == 0
THEN
PRINT "Lockpicks ~r~deactivated." 2000
ELSE
PRINT "Lockpicks ~g~activated." 2000
END    
SAMP.CmdRet()

I'm sorry for being picky but I couldn't resist;p
 

Mila.cs ✅

Well-known member
Joined
Jun 24, 2016
Messages
247
Reaction score
10
Location
̀́̀́
monday said:
I'm sorry for being picky but I couldn't resist;p

You're right, but I've never used this ("chat reader") before therefore I was happy that it worked at all, lol.  :sadpepe:
(I'm generally a noob when it comes to memory data.)
 
Status
Not open for further replies.
Top