Can anyone help me with the script?
#1

Hello, i need pawn script on how to put random messages o the server.. m totally noob ad new i the scripting.. dot think that m spamming.. i earlier checked the tutorial by twisted_insane on how to add random message i was totally lost.. what to do and how to do? ca anyone tell me whole script for random message n where to put it in starting or at middle or at the end..
thanks again..
n yes as soon as i get 50 post ill give u guys +rep
Reply
#2

Well, first your random message defines,
pawn Код:
#define     RANDOM_MESSAGE1     "- Message here."
#define     RANDOM_MESSAGE2     "- Message here"
#define     RANDOM_MESSAGE3     "- Message here. "
#define     RANDOM_MSGTIME     20
The set the timer to show up your random messages in the gamemode init
pawn Код:
SetTimer("RandomMessage", RANDOM_MSGTIME*60000, true);
Then your public of the RandomMessage
pawn Код:
forward RandomMessage();
public RandomMessage()
{
    new RandSelect= random(3);

    switch(RandSelect) {

        case 0: {
            return SendClientMessageToAll(COLOR_WHITE, RANDOM_MESSAGE1);
        }
        case 1: {
            return SendClientMessageToAll(COLOR_WHITE, RANDOM_MESSAGE2);
        }
        case 2: {
            return SendClientMessageToAll(COLOR_WHITE, RANDOM_MESSAGE3);
        }
    }
    return 1;
}
Note: You can define more messages as per your wish to show more of them. Also you can rep now which stays pending till you reach 50 posts.
Reply
#3

pawn Код:
#define MSG_TIME    120
//This will define the number of seconds between each message. This one is 120 second (2 minute) intervals.

new RandMessages[][128] =
{
    "This is my first random message.",
    "This is my second random message that will be used to tell them something funny.",
    "I'm kind of running out of stuff to write about, but this is my third message to send.",
    "Oh why not, let's add a fourth message."
};
//NOTE: You must put a ',' after every message, except for the last one.

public OnGameModeInit() //Called when the gamemode script is loaded
{
    SetTimer("SendRandomMessage", MSG_TIME * 1000, true); //Sets a timer for the time defined in 'MSG_TIME' and repeats.
    //Rest of your code..
    return 1;
}

forward SendRandomMessage(); //This should be the same name as the timer in OnGameModeInit.
public SendRandomMessage()
{
    SendClientMessageToAll(0xFF0000FF, RandMessages[random(sizeof(RandMessages))]);
    //Send the random message to everyone. '0xFF0000FF' is RED.
    return 1;
}
Reply
#4

Thanks for the help laurey and thres.. i made it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)