CLEO Help [CLEO HELP] Explane code

CLEO related
Status
Not open for further replies.

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
supahdupahnubah said:
Parazitas said:
- Possible? -

 Tell me:
How to make samp say_msg "Test" one time?
 Like sit in the car ant cleo send samp say_msg "/belt" one time ! not flood.
Make a loop, assign variable, set condition to check whenever player in the car or not, if he is then check whenever your variable 1 or 0, if it's 0 = say_msg /belt; set variable to 1, if it's 1 = ignore, if player not in a car, set your variable to 0
Who can explane , show in code how use.​
 

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
52
Location
LongForgotten <-> 0x32789
damn.. i gotta help you else your gonna spam every player pm's.
Code:
{$CLEO .cs}

0000: NOP
31@ = 0  // Toggle variable, 0@ = disabled, 1@ = enabled

// 1000 milisecond = 1 second

:mainloop
wait 0
if and   // if = if (what if, or just say check something), if and = what if bla bla and bla (use more than 1 checks)
key_down 32     // key_down = returns boolean, 32 is the code for spacebar so if key_down 32 means, if key_down 32 is true
key_down 8      // key code 8 means backspace, activation/deactivate: spacebar + backspace
then // if it is true 
    if               // then do bla bla
    31@ == 0  // if 31@ is 0
    then 
        31@ = 1 // then set 31@ to 1
        printf "~b~Anti AFK ~g~ON ~y~[%d]" 1000 31@ // print a message in the screen, printf to print with variables. " indicates a string starting/ending, so "Your Text Here" and after string the 1000 is the time in miliseconds and 31@ is the specifier %d (decimal) which is toggle variable
    else // if it is not 0  *(a.k.a 31@ is 1 or higher or activation is ON)
        31@ = 0 // set 31@ to 0
        printf "~b~Anti AFK ~r~OFF ~y~[%d]" 1000 31@ // print the off message
    end
    wait 1000
end
if 
31@ == 1  // if activated
then
    if
    Actor.Driving($PLAYER_ACTOR)   // Actor.Driving returns boolean of true of false, parameters: actor, $player_actor stands for main actor, actor is the same as a Pedestrian or player, so $player_actor is the main player, the one you contorl
    then
        say "/belt"
        wait 20000 // wait 20 seconds before continuing, you can use this to set timers on the main loop and/or create timed messages
    else
        say "Test"
        wait 20000 // wait 20 seconds before continuing, you can use this to set timers on the main loop and/or create timed messages
    end
end
jump @mainloop

// Now tell me, WAS THAT SO HARD? you pmed alot of forum users just to get 30 lines of code? pls read cleo tutorial! PLS DO


oh and // stands for a comment, a line/characters after the "//" wont be executed by the script.
/* and */ mark starting and ending of a comment, so you can use it in middle of code like for example:
Code:
if
Actor.Driving(/* message between those starting/endings wont be executed */$PLAYER_ACTOR)
then
         // bla bla lnbalbalblalbsal bla bla
end
 
Joined
Dec 31, 2015
Messages
712
Reaction score
27
Parazitas said:
Somehow I have to know what to do because  as I learn myself.​

That's good, but you have to at least show or tell what you've achieved so far, so we will know you're not just a freebie
 
Status
Not open for further replies.
Top