Random msg help
#1

I'm editing hiddos's random message script (not re-releasing of course) a bit and im kinda stuck on 2 bits.
I want to know if its possible to
1. Set it so only certain skins can see the msgs using GetPlayerSkin
2. How to use \n and if i can use it in a msg for a new line.
Thanks

pawn Код:
#include <a_samp>
#define CURRENT_MESSAGES 4 /*
This the the amount of messages you have. This number must be the exact number at ALL times!
*/
#define MESSAGE_COLOR 0x4169E1FF /*
This is the color you want your random messages to be
*/
#define MESSAGE_INTERVAL 60 /*
This is the amount of seconds between each randomly sent message.
*/
new RM[CURRENT_MESSAGES][128];
forward SendRandomMessage();
public OnFilterScriptInit()
{
    print("\n------------------------------------------");
    print(" Easy-to-use random message script");
    print(" Thank you for using! Created by Hiddos");
    print(" Piss on it.                         McFaik");
    print("--------------------------------------------\n");
    AddRandomMessage("3rd party mods aren't allowed on this server, cows");
    AddRandomMessage("You might wish to change those messages hehe.");
    AddRandomMessage("Adam Taylor you really are an asshole :D");
    AddRandomMessage("Server closed the connection.");
    SetTimer("SendRandomMessage", MESSAGE_INTERVAL * 1000, 1);
    return 1;
}

public SendRandomMessage()
{
    static lastmessage = 0;
    new rand = random(CURRENT_MESSAGES);
    while(rand == lastmessage && CURRENT_MESSAGES != 1) { rand = random(CURRENT_MESSAGES);  }
    lastmessage = rand;
    SendClientMessageToAll(MESSAGE_COLOR, RM[lastmessage]);
}

stock AddRandomMessage(text[])
{
    for(new m; m < CURRENT_MESSAGES; m++)
    {
        if(!strlen(RM[m]))
        {
            strmid(RM[m], text, 0, 127);
            return 1;
        }
    }
    return 0;
}
Reply
#2

1.
pawn Код:
public SendRandomMessage()
{
    static lastmessage = 0;
    new rand = random(CURRENT_MESSAGES);
    while(rand == lastmessage && CURRENT_MESSAGES != 1) { rand = random(CURRENT_MESSAGES);  }
    lastmessage = rand;
    for ( new i = 0; i != MAX_PLAYERS; ++i )
    {
        if ( GetPlayerSkin ( i ) ==  23  ) // Example skin 23
        {
            SendClientMessage( i, MESSAGE_COLOR, RM[lastmessage] );
        }
    }
}
2. SendClientMessage( playerid, -1, " First Line\nSecond Line\nThird Line " );
Reply
#3

Thanks
Reply
#4

How to do it for multiple skins though?? cant seem to work that out :/
Reply
#5

pawn Код:
public SendRandomMessage()
{
    static lastmessage = 0;
    new rand = random(CURRENT_MESSAGES);
    while(rand == lastmessage && CURRENT_MESSAGES != 1) { rand = random(CURRENT_MESSAGES);  }
    lastmessage = rand;
    for ( new i = 0; i != MAX_PLAYERS; ++i )
    {
        if ( GetPlayerSkin ( i ) ==  23  || GetPlayerSkin ( i ) == 24 || GetPlayerSkin ( i ) == 25 )
        {
            SendClientMessage( i, MESSAGE_COLOR, RM[lastmessage] );
        }
    }
}
Reply
#6

and that works for as many skins as i want? i need to put in loads.

Isnt there a way to tell the script to get all skins from x to x? example all skins from 20 to 30
Reply
#7

pawn Код:
public SendRandomMessage()
{
    static lastmessage = 0;
    new rand = random(CURRENT_MESSAGES);
    while(rand == lastmessage && CURRENT_MESSAGES != 1) { rand = random(CURRENT_MESSAGES);  }
    lastmessage = rand;
    for ( new i = 0; i != MAX_PLAYERS; ++i )
    {
        if ( GetPlayerSkin ( i ) >= 20  || GetPlayerSkin ( i ) <= 30 )
        {
            SendClientMessage( i, MESSAGE_COLOR, RM[lastmessage] );
        }
    }
}
Reply
#8

So that does all from 20 to 30? :P
Reply
#9

Yes, including 20 and 30.
Reply
#10

Ok thanks so i could do say 20 to 30 then 35-40 etc? do multiple ones?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)