CLEO Help Restart CMD

CLEO related
Status
Not open for further replies.

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
I tried making a code in-game so I don't have to keep quiting the game and re-enter and so on so my question is, why doesn't this work?

Code:
{$CLEO}
{$INCLUDE SF}
0000:
thread "TestsCMD"

repeat
wait 0
until SAMP.Available()

0B34: "restart" @restart


WHILE TRUE
WAIT 0

END

:restart
SAMP.IsCommandTyped(20@)
0459: end_thread_named "%s.cs" 20@
0C62: exec_console_command "cs %s.cs" 20@
SAMP.CmdRet()
 
Last edited:

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
268
Location
Pluto
I tried making a code in-game so I don't have to keep quiting the game and re-enter and so on so my question is, why doesn't this work?

Code:
{$CLEO}
{$INCLUDE SF}
0000:
thread "TestsCMD"

repeat
wait 0
until SAMP.Available()

0B34: "restart" @restart


WHILE TRUE
WAIT 0

END

:restart
SAMP.IsCommandTyped(20@)
0459: end_thread_named "%s.cs" 20@
0C62: exec_console_command "cs %s.cs" 20@
SAMP.CmdRet()
As how I understand your statement, you want an Auto-Reconnect Script .

Also, at your script, I don't get the sense Why you are trying to restart a certain Cleo thread.
 

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
As how I understand your statement, you want an Auto-Reconnect Script .

Also, at your script, I don't get the sense Why you are trying to restart a certain Cleo thread.
If you are testing something and don't want to keep quit the game and enter again for the cleo to update, I tried updating from in game however I wanted to make a command that has the parameter as the name of the file instead of putting this command in every cleo i will create at one point.
 

SpnKO

Member
Joined
Mar 17, 2014
Messages
17
Reaction score
3
0B34: samp register_client_command "reload" to_label @Noname_132 - top of script right after SAMP.Available loop

:Noname_132 - bottom of script
chatmsg "reloading" -1
0A92: create_custom_thread "test.cs"
0A93: end_custom_thread
0B43: samp cmd_ret

make sure you rename test.cs to w/e u wanna call ur cleo.
 

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
0B34: samp register_client_command "reload" to_label @Noname_132 - top of script right after SAMP.Available loop

:Noname_132 - bottom of script
chatmsg "reloading" -1
0A92: create_custom_thread "test.cs"
0A93: end_custom_thread
0B43: samp cmd_ret

make sure you rename test.cs to w/e u wanna call ur cleo.
So I will have to put this in all scripts?
 

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
268
Location
Pluto
So I will have to put this in all scripts?
It is not necessary to put that code on all of your scripts. Only put that code on the script that you are currently testing. I expect that you test one script at a time, so when you are finished testing. Remove/comment that debugging code.

You might also consider creating one script which job is to restart a specific thread/script when needed. So that you wouldn't need to put that debugging code on all scripts, but only change the target script that needs to be restarted via INI File...
 

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
It is not necessary to put that code on all of your scripts. Only put that code on the script that you are currently testing. I expect that you test one script at a time, so when you are finished testing. Remove/comment that debugging code.

You might also consider creating one script which job is to restart a specific thread/script when needed. So that you wouldn't need to put that debugging code on all scripts, but only change the target script that needs to be restarted via INI File...
That is what I explained in the description of the post but I guess I just explained it badly because I already have @SpnKO 's suggestion. I am struggling on this idea of having a main code that restarts the written one but I don't understand why it doesn't work.
 

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
268
Location
Pluto
That is what I explained in the description of the post but I guess I just explained it badly because I already have @SpnKO 's suggestion. I am struggling on this idea of having a main code that restarts the written one but I don't understand why it doesn't work.

Here is an example of how it can be done, this code will only work on scripts with a filename of 7 characters below. Kinda sucks but it is just a demonstration of mine, also I haven't tested it since I only coded it by phone, you can improve it further if you are interested:
Code:
{$CLEO .cs}
0000: cleo restarter

{
 usage:
 /cleorestart test.cs
 
 NOTE: last parameter must be 7 characters below. above 7 characters will not work according to its documentary
}

REPEAT
 wait 0
UNTIL 0AFA: is_samp_available

0B34: samp register_client_command "cleorestart" to_label @manualrestart

0BDE: pause_thread 0 // We don't need an infinite loop, so just pause the script

:manualrestart
 0B35: samp 31@ = get_last_command_params
 05DD: end_custom_thread_named 31@
 05DE: create_custom_thread 31@
0B43: samp cmd_ret
 
Status
Not open for further replies.
Top