CLEO Help WAIT problem

CLEO related
Status
Not open for further replies.

andrein2

Member
Joined
Jun 21, 2014
Messages
8
Reaction score
0
Hi, I want to pause my code for 5 seconds but when I initialize the command, the text is send immediate but, I want to wait 5 seconds after the code send the text.


Code:
:cmd_121
SAMP.IsCommandTyped(20@)
wait 0
if
0AD4: 20@ = scan_string 20@ format "%d" 21@
then
    0B36: samp 1@ = get_player_nickname 21@
    30@ = SAMP.GetPlayerColor(21@)
    Wait 5000
    0AF9: samp say_msg "%s, are culoarea %d" 1@ 30@    
else
    chatmsg "{0066ff}CopCMD: {ffffff}Foloseste /testdialog <ID>" -1
end
SAMP.CmdRet()

Sorry for my bad English. And I am new in cleo scripting.
 

4changesLeft

Well-known member
Joined
Apr 10, 2015
Messages
365
Reaction score
3
andrein2 said:
Hi, I want to pause my code for 5 seconds but when I initialize the command, the text is send immediate but, I want to wait 5 seconds after the code send the text.


Code:
:cmd_121
SAMP.IsCommandTyped(20@)
wait 0
if
0AD4: 20@ = scan_string 20@ format "%d" 21@
then
    0B36: samp 1@ = get_player_nickname 21@
    30@ = SAMP.GetPlayerColor(21@)
    Wait 5000
    0AF9: samp say_msg "%s, are culoarea %d" 1@ 30@    
else
    chatmsg "{0066ff}CopCMD: {ffffff}Foloseste /testdialog <ID>" -1
end
SAMP.CmdRet()

Sorry for my bad English. And I am new in cleo scripting.

It's because "wait" doesnt count in cmd functions like this, it just bypasses it. What you need is a loop function in which you make the magic
This should work:
 
Code:
:loop
wait 0
if
0@ == 1 //check if the cmd var is true
jf @loop
Wait 5000
0AF9: samp say_msg "%s, are culoarea %d" 1@ 30@  
jump @loop

:cmd_121
SAMP.IsCommandTyped(20@)
if
0AD4: 20@ = scan_string 20@ format "%d" 21@
jf @ERROR
0B36: samp 1@ = get_player_nickname 21@
30@ = SAMP.GetPlayerColor(21@)  
0@ = 1 //make the cmd var true
SAMP.CmdRet()
jump @loop

:ERR0R
wait 0
chatmsg "{0066ff}CopCMD: {ffffff}Foloseste /testdialog <ID>" -1
0@ = 0 //make the cmd var false
SAMP.CmdRet()
jump @loop


Also, if you dont have a command variable already, it's simple, just put a "0@ = 0" at the start of the code, or whatever number u want for it
 

andrein2

Member
Joined
Jun 21, 2014
Messages
8
Reaction score
0
So .. I put a debug message.. but is show only debug 1 when I type the command
Code:
:ero
wait 0
chatmsg "{0066ff}CopCMD: {ffffff}Foloseste /testdialog <ID>" -1
0@ = 0 //make the cmd var false
SAMP.CmdRet()
jump @loop

:loop
wait 0
if
0@ == 1 //check if the cmd var is true
jf @loop
chatmsg "debug 2" -1
Wait 5000
chatmsg "debug 3" -1
0AF9: samp say_msg "%s, are culoarea %d" 1@ 30@  
jump @loop

:cmd_121
SAMP.IsCommandTyped(20@)
if
0AD4: 20@ = scan_string 20@ format "%d" 21@
jf @ero
0B36: samp 1@ = get_player_nickname 21@
30@ = SAMP.GetPlayerColor(21@)  
0@ = 1 //make the cmd var true
chatmsg "debug 1" -1
SAMP.CmdRet()
jump @loop
 

4changesLeft

Well-known member
Joined
Apr 10, 2015
Messages
365
Reaction score
3
It's because the error function should be below the cmd function, loops should always be the 1st function of the script.
 

andrein2

Member
Joined
Jun 21, 2014
Messages
8
Reaction score
0
Error function is working but the loop no, I put the loop before the first command, but he is not jump to Loop function from command check attachment.
 

Attachments

  • FacCMD.txt
    16.7 KB · Views: 47

monday

Expert
Joined
Jun 23, 2014
Messages
1,126
Solutions
1
Reaction score
158
when you call a command and use samp.cmdret() then the code will jump at the place where it was before you called that command. So "jump @loop" won't be called if you use it like this:

SAMP.CmdRet()
jump @loop
 

andrein2

Member
Joined
Jun 21, 2014
Messages
8
Reaction score
0
monday said:
when you call a command and use samp.cmdret() then the code will jump at the place where it was before you called that command. So "jump @loop" won't be called if you use it like this:

SAMP.CmdRet()
jump @loop

So? How can I use it? An example?
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,126
Solutions
1
Reaction score
158
Code:
0B34: samp register_client_command "andrzej" to_label @andrzej_cmd
0B34: samp register_client_command "janusz" to_label @janusz_cmd

:main
wait 0
    if 31@ == 1
    then
    31@ = 0
    jump @andrzej_loop
    end
    
    if 31@ == 2
    then
    31@ = 0
    jump @janusz_loop
    end
jump @main

:andrzej_loop
wait 0    

jump @andrzej_loop

:janusz_loop
wait 0

jump @janusz_loop


//
//  Commands
//
:andrzej_cmd
31@ = 1
samp.CmdRet()

:janusz_cmd
31@ = 2
samp.CmdRet()
 

andrein2

Member
Joined
Jun 21, 2014
Messages
8
Reaction score
0
monday said:
Code:
0B34: samp register_client_command "andrzej" to_label @andrzej_cmd
0B34: samp register_client_command "janusz" to_label @janusz_cmd

:main
wait 0
    if 31@ == 1
    then
    31@ = 0
    jump @andrzej_loop
    end
    
    if 31@ == 2
    then
    31@ = 0
    jump @janusz_loop
    end
jump @main

:andrzej_loop
wait 0    

jump @andrzej_loop

:janusz_loop
wait 0

jump @janusz_loop


//
//  Commands
//
:andrzej_cmd
31@ = 1
samp.CmdRet()

:janusz_cmd
31@ = 2
samp.CmdRet()

So .. to be clear what I want to do, I want to make a code who can pres the down arrow automatically to select an item from a dialog. But I need to pause a part of the code.

Like This
Code:
:cmd_121
SAMP.IsCommandTyped(20@)
wait 0
if
0AD4: 20@ = scan_string 20@ format "%d" 21@
then
    0B36: samp 1@ = get_player_nickname 21@
    30@ = SAMP.GetPlayerColor(21@)
    0AF9: samp say_msg "/help"
    //Pause 1000 ms
    0B56: set_game_key 40 state 255
    //Pause 500 ms
    0B56: set_game_key 40 state 255
    //Pause 500 ms 
    0B56: set_game_key 13 state 255     
else
    chatmsg "{0066ff}CopCMD: {ffffff}Foloseste /testdialog <ID>" -1
end
SAMP.CmdRet()
 

andrein2

Member
Joined
Jun 21, 2014
Messages
8
Reaction score
0
springfield said:
If you use SF you don't need to pause anything, use the dialog related opcodes like 0B49, 0B47, 0BC9.
Like this?

Code:
:cmd_121
SAMP.IsCommandTyped(20@)
wait 0
if
0AD4: 20@ = scan_string 20@ format "%d" 21@
then
    0B36: samp 1@ = get_player_nickname 21@
    30@ = SAMP.GetPlayerColor(21@)
    0AF9: samp say_msg "/help"
    0B49: samp set_current_dialog_list_item 3   
else
    chatmsg "{0066ff}CopCMD: {ffffff}Foloseste /testdialog <ID>" -1
end
SAMP.CmdRet()
 
But the dialog appear after one second, so .. he don't select
The dialog is from server, no from cleo.
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
Then set a variable to true, check for it being true and if a certain dialog is active and call those opcodes.
As an example;

[shcode=cpp]
:mainloop
while true
   wait 0
   if and
       31@ == TRUE
       0B4C:  samp is_dialog_active XXX
   then
       31@ = FALSE
       0B49: samp set_current_dialog_list_item 3
       0B47: samp close_current_dialog_with_button 1
   end
end

:cmd
say_msg "/help"
31@ = 1
SAMP.CmdRet()
[/shcode]

You can get a specific dialog id with 0B4E, these are usually static ids and don't change unless the server owner/scripter changes them. Pass -1 to 0B4E to check for any active dialog.
 

andrein2

Member
Joined
Jun 21, 2014
Messages
8
Reaction score
0
springfield said:
Then set a variable to true, check for it being true and if a certain dialog is active and call those opcodes.
As an example;

[shcode=cpp]
:mainloop
while true
   wait 0
   if and
       31@ == TRUE
       0B4C:  samp is_dialog_active XXX
   then
       31@ = FALSE
       0B49: samp set_current_dialog_list_item 3
       0B47: samp close_current_dialog_with_button 1
   end
end

:cmd
say_msg "/help"
31@ = 1
SAMP.CmdRet()
[/shcode]

You can get a specific dialog id with 0B4E, these are usually static ids and don't change unless the server owner/scripter changes them. Pass -1 to 0B4E to check for any active dialog.

Edit: I have a problem ... The dialog what I want to select is DIALOG_STYLE_TABLIST_HEADERS no DIALOG_STYLE_LIST, so ... the itemlist cant be selected.
ok, so .. when I use 0B54: samp 1@ = listbox_items_count the code show me 22 items, and the count is right.
 
Status
Not open for further replies.
Top