Help me please, I need to fix this cmd!

OP
OP
R
Joined
Mar 20, 2020
Messages
21
Likes
0
Points
1
Location
Romania
1
#21
Ok so.. You're not supposed to put WHILE TRUE in a label. A label is basically :cmd, something that defined a block of code. In this case, you put a loop in a label which won't work very well.
To make it more clear (at least i'll try to) what you are essentially doing is using a command (in this case /CMD) to change the variable [email protected] In the loop, if the variable [email protected] is true (as set in the command /CMD), it will do a line of code, in this case 'chatmsg "TEST" 0xff0000. So what you want to do, using commands like /g1, /g2 etc. you change the variable. On my RP server, there are only 9 needed commands for licences gun. This means you can use variable [email protected] for licence gun, [email protected] for licence boat and [email protected] for licence fly. Using commands like /g1, /g2, change the variable to 1, 2 etc. If the variable is 1, then it will type the first part of the test. If the variable is 2, it will type the second part of the test. Use this to get through your code. Goodluck!
It will be much easier for me if you can give me the code because I am not experienced in coding and I don t understand, I tried ( I think) what you said and it is not working as well beacause it give me this error:
 

Attachments

KamikazeSripterul

Well-Known Member
Joined
Jun 30, 2019
Messages
325
Likes
25
Points
33
#23
Use this pattern. I hope you at least understand this. I cannot provide any further help because i dont know how to make it any clearer.

Code:
{$CLEO .cs}

thread 'CMD'

REPEAT
WAIT 0
UNTIL 0AFA:

// [email protected] = gun licence
// [email protected] = fly licence
// [email protected] = boat licence

chatmsg "Message when you enter game" -256

0B34: "g1" @g1
0B34: "g2" @g2 
0B34: "f1" @f1
0B34: "f2" @f2
0B34: "b1" @b1
0B34: "b2" @b2

WHILE TRUE
WAIT 0

    // Gun Licence
    IF [email protected] == 1
    THEN
        chatmsg "First part of test gun" -1
    END
    
    IF [email protected] == 2
    THEN
        chatmsg "Second part of test gun" -1
    END
    
    // Fly Licence
    IF [email protected] == 1
    THEN
        chatmsg "First part of test fly" -1
    END
    
    IF [email protected] == 2
    THEN
        chatmsg "Second part of test fly" -1
    END
    
    // Boat Licence
    IF [email protected] == 1
    THEN
        chatmsg "First part of test boat" -1
    END
    
    IF [email protected] == 2
    THEN
        chatmsg "Second part of test boat" -1
    END

END

:g1
SAMP.IsCommandTyped([email protected])
[email protected] = 1
SAMP.CmdRet()

:g2
SAMP.IsCommandTyped([email protected])
[email protected] = 2
SAMP.CmdRet()

:f1
SAMP.IsCommandTyped([email protected])
[email protected] = 1
SAMP.CmdRet()

:f2
SAMP.IsCommandTyped([email protected])
[email protected] = 2
SAMP.CmdRet()

:b1
SAMP.IsCommandTyped([email protected])
[email protected] = 1
SAMP.CmdRet()

:b2
SAMP.IsCommandTyped([email protected])
[email protected] = 2
SAMP.CmdRet()
 
OP
OP
R
Joined
Mar 20, 2020
Messages
21
Likes
0
Points
1
Location
Romania
1
#24
You have an useless 'END'.
I finally done it! :))))
Thank you so much for helping me!

Code:
{$CLEO .cs}

THREAD 'CMD'

REPEAT
    WAIT 0
UNTIL 0AFA:

0B34: samp register_client_command "g3" to_label @CMD
0B34: samp register_client_command "g4" to_label @g4

WHILE TRUE
    WAIT 0
    IF
        [email protected] == TRUE
    THEN
    0AF9: samp say_msg "Inainte de testul teoretic, o sa-ti spun cateva informatii:"
    0AF9: samp say_msg "1. Poti face DM doar pe politisti(on-duty) sau la 'clan turf'."
    0AF9: samp say_msg "2. Odata ce ai aceasta licenta, poti achizitiona arme din 'Gun Shop'."
        [email protected] = FALSE
        wait 1500
        end
        
         IF
        [email protected] == TRUE
    THEN
    0AF9: samp say_msg "Bun, sa trecem la testul teoretic:"
    0AF9: samp say_msg "1. Ai voie sa faci DM pe un politist off-duty?"
        [email protected] = FALSE   
    END
END

:CMD
[email protected] = TRUE
SAMP.CmdRet()

:g4
[email protected] = TRUE
SAMP.CmdRet()
 

KamikazeSripterul

Well-Known Member
Joined
Jun 30, 2019
Messages
325
Likes
25
Points
33
#25
You are wasting variables... Instead of using boolean (True / False) use integers (1, 2, 3 etc.). This will allow you to use a variable many times.. If [email protected] == 1 then do one thing.. if [email protected] == 2 then do another thing and so on.. you only have 31 variables which might not be enough for you.. 'Think outside the box.'.
 
Top