Jump to content

[CLEO] How To Create a Cleo Mod That Sends an SMS To Everyone


CouldnoT
 Share

Recommended Posts

Hello my reader,

In this tutorial I'm showing you how to make a small mod that spams a message to every Non-AFK ( away from keyboard ) player.

Make sure you understand this code, because it would be useless if you just copy the code and you will remain related to others all the time.

 

First we need to start by defining the type of the mod and adding the Author's name :

 

{$CLEO .cs}
0000:
03A4: name_thread 'CouldnoT'

 

Then to avoid crashing we need to let the plugin stuck in an infinite loop until the plugin is loaded.

 

repeat
wait 0
until 0AFA: is_samp_available 

 

Then we have to undefine the command if it's already defined and replace it by an other handler 

 

0B63: "spammessage"
0B34: "spammessage" to @spammessage

 

The next step is define the Event Handler, I have chosen an XOR logic so the instruction doesn't execute until the last instruction is fully satisfied.

This code will assign a value to 3@ whether 1 ( true ) or 0 ( false ) depending on the value of 3@ so, 3@ our variable gets the value of true ONLY when the message (to be spammed) is sent to all player, we will understand this when we work on the main algorithm.

 

:spammessage
0B12: 3@ = 3@ XOR 1
samp.CmdRet()

 

This part of our plugin is the most important part, as we will inject our main algorithm which works this way : run through all numbers from 0 to 999 which is supposed to be the player's ID, test if he is AFK or not then send him the message.

 

while true
    wait 0
    IF
        3@ == 1 // if our command is executed
    THEN 
        FOR 1@ = 0 to 999 // run from 1 to 999
        IF 
            0B23: 1@ // test if the player was connected 
        THEN
            0B37: samp 4@ = get_player_color 1@ // get the player's id
            IF 
                not 4@ == 12566722 // test if our player has that grey color ( the sleep color )     
            THEN
                say "/sms %d test" 1@ // message_numb_1
                say "/sms %d test." 1@ // message_numb_2
                wait 1500
            END 
        END
    END    
    3@ = 0 // finish the instruction and wait for the code to be re-executed.       
END    


end

You may ask me why I'm sending the message to the same player twice, actually you're wrong. The B-Zone gamemode will not allow us to send the same message to player twice so if message number 1 is sent in the first loop the second message will be sent in the second loop and the invers is correct. 

The player's color has this format : AARRGGBB 

 

Now all we need is to limit the plugin to jump to the events directly so, we have a add a second infinite loop so the Spamming event will be triggered only by the command but not automatically once the plugin is enabled.

 

:cmd
wait 0
jump @cmd 

 

So, the whole code will look like this : 

 

{$CLEO .cs}
0000:
03A4: name_thread 'CouldnoT'

repeat
wait 0
until 0AFA: is_samp_available

    
0B63: "spammessage"
0B34: "spammessage" to @spammessage 

while true
    wait 0
    IF
        3@ == 1
    THEN 
        FOR 1@ = 0 to 999
        IF 
            0B23: 1@ 
        THEN
            0B37: samp 4@ = get_player_color 1@ 
            IF 
                not 4@ == 12566722     
            THEN
                say "/sms %d test" 1@ 
                say "/sms %d test." 1@ 
                wait 1500
            END 
        END
    END    
    3@ = 0        
END    


end
   
:cmd
wait 0
jump @cmd                                                           
    
      
:spammessage
0B12: 3@ = 3@ XOR 1
samp.CmdRet()


ret 0

 

Thank you for following my tutorial, you can PM me if you have any question or leave it here, also don't forget to like this post if you think it's interesting.

Have a great day ?

Edited by Tupi
Adding correct language
Link to comment
Share on other sites

  • CouldnoT locked and unlocked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.