CLEO Help CLEO Script Help

CLEO related
Status
Not open for further replies.

0xf0rd

Active member
Joined
Jun 20, 2014
Messages
68
Reaction score
1
Hello,

So I decided to start learning CLEO, I am writing a basic script that will turn on/off something when the user presses a key on the keyboard. However, the code compiles fine but does not run. Could anyone experienced with CLEO scripting tells me why my code is not running?

Code:
{$CLEO .cs}
:MAIN
03A4: name_thread "MAIN"
wait 1000

if
    0AA2: 1@ = load_library "kernel32.dll"
jf @END_MAIN

if
    0AA4: 30@ = get_proc_address "GetModuleHandleA" library 1@
jf @END_MAIN

0AA7: call_function 30@ num_params 1 pop 0 "samp.dll" 0@

if
    0@ > 0
jf @END_MAIN    

:GETINPUT
    wait 0
    if or
        0AB0: 107
        0AB0: 109
    jf @GETINPUT

:END_MAIN
    0A93: end_custom_thread

return

Oh by the way, I don't wanna use SAMPFunctions just yet.
 

ThermaL

Expert
Joined
Oct 23, 2013
Messages
1,593
Reaction score
3
{$CLEO} // always put this
0000: // this too

:ON // the label which activates the cleo
wait 0 // put this under the label's name, it's necesarry only if there's a loop
if
0AB0: // key
jf @ON // if key not pressed, go back to :ON and check again if it's pressed
PRINT "ACTIVATED" 2000 // activation text
// then it will continue to the label which deactivates the cleo

:OFF
wait 0
if
0AB0:
jf @OFF
PRINT "DEACTIVATED" 2000
goto @ON // go back to :ON
EDIT: Added explanations.
 

0xf0rd

Active member
Joined
Jun 20, 2014
Messages
68
Reaction score
1
Thank you for your quick answer. But, you did not tell me what was wrong with the code I wrote you just gave me a totally different code / coding style than my code.
Please could you tell me what is wrong in my code? And in what way I could fix it. Thanks again. Also please try use
Code:
[code][//code]
it just makes things easier to read
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
How do you know it's not running?
It's just an infinite loop until your press key107/109 then unloads the script.
Also 'return' is useless there, you use return only with a gosub.
 

0xf0rd

Active member
Joined
Jun 20, 2014
Messages
68
Reaction score
1
springfield link said:
How do you know it's not running?
It's just an infinite loop until your press key107/109 then unloads the script.
Also 'return' is useless there, you use return only with a gosub.

I know it didn't because when I connect to a server and press ESC it shows on the bottom left how many scripts / plugins loaded and only 3 plugins load. Anyways I think I found the problem but I don't know why it happens. Its when I try to get the proc address for GetModuleHandleA it seems to return false then jump to end thread. Is it not finding this function in kernel32? Its weird. 
 
Status
Not open for further replies.
Top