Automated messages sent to players
#1

Can someone explain how I can get the rcon console to say a message randomly at any time? I want to make a few different messages and every 20 mins or so it sends one message through to the server
Reply
#2

SendRconCommand,
https://sampwiki.blast.hk/wiki/SendRconCommand

And randomize it.
Reply
#3

pawn Код:
new randomMessages[][] =
{
     "Your message",
};

new string[128], randomMsg = random(sizeof(randomMessages));
format(string, sizeof(string), "say %s", randomMessage[randomMsg]);
SendRconCommand(string);
Reply
#4

On Top.
Код:
forward SendRandomMessage(); //forward the function
ongamemodeinit();

Код:
SetTimer("SendRandomMessage", 1200000, true); //20 mins timer on loop
anywhere you wanna put:

Код:
public SendRandomMessage() //function
{
            new rand = random(2); //twomessages
	    switch(rand)
	        {
	            case 0: { //randommessage1}
	            case 1: { //randommessage2}
			}
			return 1;
			}
Reply
#5

Quote:
Originally Posted by Sid_Alexander
Посмотреть сообщение
On Top.
Код:
forward SendRandomMessage(); //forward the function
ongamemodeinit();

Код:
SetTimer("SendRandomMessage", 1200000, true); //20 mins timer on loop
anywhere you wanna put:

Код:
public SendRandomMessage() //function
{
            new rand = random(2); //twomessages
	    switch(rand)
	        {
	            case 0: { //randommessage1}
	            case 1: { //randommessage2}
			}
			return 1;
			}
Would that be a rcon say style thing or?
Reply
#6

The timers could give delays to your server, you could use the following.

pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript

#define FILTERSCRIPT

#if defined FILTERSCRIPT

#include <a_samp>
#include <zcmd>
#include <YSI\y_timers>

new bool:start_random_message;

task message_random[1000*20]()
{
    if(start_random_message != false)
    {
        new string[18];
        switch(random(10))
        {
            case 1: string = "message random 1";
            case 2: string = "message random 2";
            case 3: string = "message random 3";
            case 4: string = "message random 4";
            case 5: string = "message random 5";
            case 6: string = "message random 6";
            case 7: string = "message random 7";
            case 8: string = "message random 8";
            case 9: string = "message random 9";
        }
        SendRconCommand(string);
    }
    return true;
}


command(msgrandom, playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {
        if(start_random_message != true)
        {
            SendClientMessage(playerid, -1, "Messages random started.");
            start_random_message = true;
        }
        else if(start_random_message != false)
        {
            SendClientMessage(playerid, -1, "Messages random stop.");
            start_random_message = false;
        }
    }
    else
    {
        SendClientMessage(playerid, -1, "You are not administrator rcon.");
    }
    return true;
}

#endif
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)