CLEO Help Crash when execute custom command

CLEO related
Status
Not open for further replies.

cl0udddie

Member
Joined
Mar 18, 2017
Messages
11
Reaction score
0
Hello, I'm very new at CLEO Scripting. I think I did something wrong, I tried to add a command for spawning gun.. Instead of spawning the gun, the command made my game freeze. I also tried to change command to Hotkey Activation and its working. I just wanna know how to do it properly with the custom command.. heres my code:
Code:
{$CLEO .cs}
0000: NOP
0B34: samp register_client_command "gun" to_label @m4
31@ = 0

:MAIN
wait 0
if and
    056D: actor $PLAYER_ACTOR defined
    31@ == 1
jf @MAIN
31@ = 0
SAMP.CmdRet
jump @MAIN

:M4
wait 0
Model.Load(356)
if
    Model.Available(356)
jf @M4
01B2: give_actor $PLAYER_ACTOR weapon 31 ammo 5
0AD1: show_formatted_text_highpriority "M4 Spawned!" time 2000
31@ = 1
SAMP.CmdRet
jump @MAIN

I know I did something wrong, I just can't figure it out myself. 
Any help will be appreciated :)
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
hello, I think it was getting stuck at "Model.Available", it looks like opcode 038B must be placed after "Model.Load". Btw when you use 0B34 opcode it creates a callback at given label. When you enter a command in game by typing "/gun" and press enter the code jumps from the "MAIN" label into the "M4" callback. After it reaches "SAMP.CmdRet" it will jump back where it was before the command was entered (in this case it will go back into the "MAIN" label)

Code:
{$CLEO .cs}
0000: NOP
0B34: samp register_client_command "gun" to_label @m4

:MAIN
wait 0

wait 1000
jump @MAIN


:M4
Model.Load(356)
038B: load_requested_models
if not Model.Available(356)
then 
    0AD1: show_formatted_text_highpriority "Model is not available" time 2000
    wait 2000
    jump @M4
end
01B2: give_actor $PLAYER_ACTOR weapon 31 ammo 5
0AD1: show_formatted_text_highpriority "M4 Spawned!" time 2000
Model.Destroy(356)
SAMP.CmdRet
 

cl0udddie

Member
Joined
Mar 18, 2017
Messages
11
Reaction score
0
monday said:
hello, I think it was getting stuck at "Model.Available", it looks like opcode 038B must be placed after "Model.Load". Btw when you use 0B34 opcode it creates a callback at given label. When you enter a command in game by typing "/gun" and press enter the code jumps from the "MAIN" label into the "M4" callback. After it reaches "SAMP.CmdRet" it will jump back where it was before the command was entered (in this case it will go back into the "MAIN" label)

Code:
{$CLEO .cs}
0000: NOP
0B34: samp register_client_command "gun" to_label @m4

:MAIN
wait 0

wait 1000
jump @MAIN


:M4
Model.Load(356)
038B: load_requested_models
if not Model.Available(356)
then 
    0AD1: show_formatted_text_highpriority "Model is not available" time 2000
    wait 2000
    jump @M4
end
01B2: give_actor $PLAYER_ACTOR weapon 31 ammo 5
0AD1: show_formatted_text_highpriority "M4 Spawned!" time 2000
Model.Destroy(356)
SAMP.CmdRet
Hello monday, thank you for responding my thread and solving my problem. Anyway I have a few question.

1. This CLEO is worked before when I was using the hotkey to enable it however the ammo seems bugging, I wrote 400. The first time I activated it, its giving me M4 with 400 ammo, but when I pressed it again.. the CLEO is giving me like +- 800-1000 ammo idk. Any clue why? Is that because I didn't use Model.Destroy?
2. If I created a custom command CLEO like this script, I should end label/callback (like M4) with SAMP.CmdRet so it will return to my upper/top label in this case is :MAIN, but if I add another label above :MAIN will SAMP.CmdRet returning to the label above :MAIN?
3. When is the greatest time to add `wait` in the script? I see you adding some `wait` in the script.
4. Is there a `else if` (Just like in the another language) in Sanny Builder, or there is a way to do it? Because I tried it recently and gave me an error.

Sorry for asking too much. Thank you for helping me, replied and reading my thread it means a lot of help for me. 
I hope you can answer it or anybody else because I'm very curiuos.
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
1. Maybe the bullets just accumulate, idk...
2. It will return to the point at which it was when the command was entered regardless of the label name
3. Wait is just a delay btw there are few "special" wait statements, I don't have deep understanding of it but "wait 0" should be put after:
-label name
-"repeat" statement
-"while" statemtent
4. I don't know... you could use something like this though:
Code:
if
then
else
    if
    then
    else
    
    end
end
 

cl0udddie

Member
Joined
Mar 18, 2017
Messages
11
Reaction score
0
monday said:
1. Maybe the bullets just accumulate, idk...
2. It will return to the point at which it was when the command was entered regardless of the label name
3. Wait is just a delay btw there are few "special" wait statements, I don't have deep understanding of it but "wait 0" should be put after:
-label name
-"repeat" statement
-"while" statemtent
4. I don't know... you could use something like this though:
Code:
if
then
else
    if
    then
    else
    
    end
end
Thank you very much for answering, my problem is solved.
Thank you again monday, have a nice day! :D

P.S: You can lock this thread now mod, thank you :)
 
Status
Not open for further replies.
Top