CLEO Help "wait" doesn't do what i want it to do

CLEO related
Status
Not open for further replies.

Ravenous

Active member
Joined
Jan 21, 2016
Messages
61
Reaction score
4
I have this piece of code, my problem with it is that it sends /mdc commands too fast, i want there to be a delay between sending commands but "wait" doesn't do anything even if i put wait 10000 the commands are still being sent instantly.


Code:
// This file was decompiled using SASCM.ini published by GTAG (http://gtag.gtagaming.com/opcode-database) on 14.6.2013
{$CLEO .cs}

//-------------MAIN---------------
thread "mdcstream" 
const
COLOR = 0xFFE3336D
end

:mdcc_1
wait 0 
if 
   SAMP.Available
else_jump @mdcc_9 
0B34: samp register_client_command "mdcc" to_label @mdcc_8823 

:mdcc_390
wait 0
jump @mdcc_390

:mdcc_1
0@ = -1 

:mdcc_2
wait 0
0@ += 1 
   not 0@ == 1000 
else_jump @mdcc_3 
   SAMP.IsPlayerConnected(0@)
else_jump @mdcc_2
1@ = SAMP.GetActorHandleByPlayerID(0@)
if 
056D:   actor 1@ defined 
else_jump @mdcc_2  
2@ = SAMP.GetSAMPPlayerIDByActorHandle(1@) 
16@ = SAMP.GetPlayerColor(0@)
if
16@ ==  COLOR
else_jump @mdcc_2
0AF9: samp say_msg "/mdc %d" 0@
wait 1000
jump @mdcc_2

:mdcc_3
chatmsg "DONE" -1
SAMP.CmdRet

What am i doing wrong?  :imoverit:
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,734
Solutions
2
Reaction score
117
I don't know if I'm right excuse me Pro scripters if I am wrong but you put "wait" after the MDC command gets sent so it sends mdc then waits you need to put wait before the mdc command is sent.
 

Codex1337

Active member
Joined
Mar 1, 2014
Messages
170
Reaction score
1
Code:
{$CLEO}
0000: NOP
repeat
wait 50
until 0AFA: is_samp_structures_available
0B34: samp register_client_command "" to_label @toggle

WHILE TRUE
wait 0
if 31@ == 1 
then
      wait 10000 (TIME IN MS)
      chatmsg "10000 ms have been passed" -1 // This message will be shown after every 10000 ms until it is turned off by the command or manually by '31@ = 0'
end
END // CLOSING WHILE TRUE STATEMENT

:toggle
0B12: 31@ = 31@ XOR 1
samp.CmdRet

//0AB1: call_scm_func @name 0
:function
0AB2: ret 0
 

Ravenous

Active member
Joined
Jan 21, 2016
Messages
61
Reaction score
4
zin link said:
I don't know if I'm right excuse me Pro scripters if I am wrong but you put "wait" after the MDC command gets sent so it sends mdc then waits you need to put wait before the mdc command is sent.

Tried putting it before the /mdc but nothing changes

Codex1337 link said:
Code:
{$CLEO}
0000: NOP
repeat
wait 50
until 0AFA: is_samp_structures_available
0B34: samp register_client_command "" to_label @toggle

WHILE TRUE
wait 0
if 31@ == 1 
then
      wait 10000 (TIME IN MS)
      chatmsg "10000 ms have been passed" -1 // This message will be shown after every 10000 ms until it is turned off by the command or manually by '31@ = 0'
end
END // CLOSING WHILE TRUE STATEMENT

:toggle
0B12: 31@ = 31@ XOR 1
samp.CmdRet

//0AB1: call_scm_func @name 0
:function
0AB2: ret 0

I cannot use this, i want my script to go trough all players from 0 to 999, to check if they ae in stream then check if they have the specified color and only then to send a command which has their id in it. Basically if a player is in stream and has a specified color i want to send a /mdc <id> command but i don't want all these commands to be sent at once i want a little delay between them.
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
272
Maybe fix your code or post the full code so we can understand wtf is with it.
ie;
- you have two labels with same name( mdcc_1 )
- you use undefined labels ( @mdcc_8823, @mdcc_9 )

Code:
:mdcc_390 //infinite loop
wait 0
jump @mdcc_390

:mdcc_1 //this is not reached/called, ever
0@ = -1

Code:
2@ = SAMP.GetSAMPPlayerIDByActorHandle(1@) //useless, id is already at 0@
16@ = SAMP.GetPlayerColor(0@)

Code:
:mdcc_3 //should crash, unless called/jumped from a SF command body
chatmsg "DONE" -1
SAMP.CmdRet

So, the wait probably works, but i doubt anybody can help you if you post gibberish.
 

Ravenous

Active member
Joined
Jan 21, 2016
Messages
61
Reaction score
4
Ok here it is:
Code:
// This file was decompiled using SASCM.ini published by GTAG (http://gtag.gtagaming.com/opcode-database) on 14.6.2013
{$CLEO .cs}

//-------------MAIN---------------
thread "mdcstream" 
const
COLOR = 0xFFE3336D
end
:mdcc_5
wait 0 
if 
   SAMP.Available
else_jump @mdcc_5
0B34: samp register_client_command "mdcc" to_label @mdcc_1 

:mdcc_390
wait 0
jump @mdcc_390

:mdcc_1
0@ = -1 

:mdcc_2
wait 0
0@ += 1 
   not 0@ == 1000 
else_jump @mdcc_3 
   SAMP.IsPlayerConnected(0@)
else_jump @mdcc_2
1@ = SAMP.GetActorHandleByPlayerID(0@)
if 
056D:   actor 1@ defined 
else_jump @mdcc_2  
2@ = SAMP.GetSAMPPlayerIDByActorHandle(1@) 
16@ = SAMP.GetPlayerColor(0@)
if
16@ ==  COLOR
else_jump @mdcc_2
0AF9: samp say_msg "/mdc %d" 0@
wait 1000
jump @mdcc_2

:mdcc_3
chatmsg "DONE" -1
SAMP.CmdRet


This compiles and doesn't crash the game but this is the part where wait doesn't do anything:

0AF9: samp say_msg "/mdc %d" 0@
wait 1000
jump @mdcc_2

Here i tried doing the same thing in a slightly different way but it is still not working like it should:

// This file was decompiled using SASCM.ini published by GTAG (http://gtag.gtagaming.com/opcode-database) on 14.6.2013
{$CLEO .cs}

//-------------MAIN---------------
thread "mdcstream"
const
COLOR = 0xFFE3336D
end
32@ = 0
:mdcc_5
wait 0
if
  SAMP.Available
else_jump @mdcc_5
0B34: samp register_client_command "mdcc" to_label @toggle

:mdcc_390
wait 0
if
32@ == 1
then
jump @mdcc_1
else
jump @mdcc_390
end

:mdcc_1
0@ = -1

:mdcc_2
wait 0
0@ += 1
  not 0@ == 1000
else_jump @mdcc_3
  SAMP.IsPlayerConnected(0@)
else_jump @mdcc_2
1@ = SAMP.GetActorHandleByPlayerID(0@)
if
056D:  actor 1@ defined
else_jump @mdcc_2 
2@ = SAMP.GetSAMPPlayerIDByActorHandle(1@)
16@ = SAMP.GetPlayerColor(0@)
if
16@ ==  COLOR
else_jump @mdcc_2
0AF9: samp say_msg "/mdc %d" 0@
wait 1000
jump @mdcc_2

:mdcc_3
chatmsg "DONE" -1
32@ = 0
jump @mdcc_390

:toggle
0B12: 32@ = 32@ XOR 1
samp.CmdRet
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
272
You can't use 'wait' in SF command threads.
Alternative is to have the code run from main loop -> mdcc_390, and use the command to active it.
 

Ravenous

Active member
Joined
Jan 21, 2016
Messages
61
Reaction score
4
springfield link said:
You can't use 'wait' in SF command threads.
Alternative is to have the code run from main loop -> mdcc_390, and use the command to active it.

Thanks, afty many trial and error attempts i came up with this hobo nested ifs aproach that seems to do the trick  :forever_hurra:

Code:
// This file was decompiled using SASCM.ini published by GTAG (http://gtag.gtagaming.com/opcode-database) on 14.6.2013
{$CLEO .cs}

//-------------MAIN---------------
thread "mdcstream" 
const
COLOR = 0xFFE3336D
end
31@ = 0
:mdcc_5
wait 0 
if 
   SAMP.Available
else_jump @mdcc_5
0B34: samp register_client_command "mdcc" to_label @mdcc_1 

:mdcc_390
WHILE TRUE
wait 0
	if 31@ == 1
	then
	0@ += 1 
		if 
		0@ == 1000 
		then
		jump @mdcc_3 
		end
			if
			SAMP.IsPlayerConnected(0@)
			then
			1@ = SAMP.GetActorHandleByPlayerID(0@)
				if 
				056D:   actor 1@ defined 
				then
				2@ = SAMP.GetSAMPPlayerIDByActorHandle(1@) 
				16@ = SAMP.GetPlayerColor(0@)
					if
					16@ == COLOR
					then 
					0AF9: samp say_msg "/mdc %d" 0@
					wait 1000
					else
					jump @mdcc_390
					end
				else
				jump @mdcc_390
				end
			else
			jump @mdcc_390
			end	
		end
	end



:mdcc_1
0@ = -1 
0B12: 31@ = 31@ XOR 1
SAMP.CmdRet


:mdcc_3
chatmsg "DONE" -1
31@ = 0
jump @mdcc_390

Only downside is that it goes trough the players slower, i mean even if it doesn't find players of the specified color it still takes a while until the script finishes going trough all the players. Anyway it is in fact what i asked for, thank you.
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
272
Use a for, without 'wait 0' to do a fast loop.

Code:
{$CLEO .cs}
thread "mdcstream" 

const
COLOR = 0xFFE3336D
end

31@ = 0
REPEAT
    WAIT 40
UNTIL 0AFA:
0B34: samp register_client_command "mdcc" to_label @mdcc_1 

WHILE TRUE
WAIT 0
    IF 31@ == 1
    THEN
        FOR 0@ = 0 to 999 
            IF SAMP.IsPlayerConnected(0@)
            THEN 
                IF 1@ = SAMP.GetActorHandleByPlayerID(0@) //returns 0 is handle is not valid
                THEN
                    16@ = SAMP.GetPlayerColor(0@)
                    IF 16@ == COLOR
                    THEN 0AF9: samp say_msg "/mdc %d" 0@
                       WAIT 1000
                    END
                END
            END
        END
        //end of 1000 iterations loop
        //disable mod here, or print text..
        //31@ = 0 etc.
    END
END

:mdcc_1
0@ = -1 
0B12: 31@ = 31@ XOR 1
SAMP.CmdRet
 
Status
Not open for further replies.
Top