Random msg help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Random msg help (
/showthread.php?tid=292495)
Random msg help -
sherlock - 23.10.2011
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;
}
Re: Random msg help -
SmiT - 24.10.2011
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 " );
Re: Random msg help -
sherlock - 24.10.2011
Thanks
Re: Random msg help -
sherlock - 24.10.2011
How to do it for multiple skins though?? cant seem to work that out :/
Re: Random msg help -
SmiT - 24.10.2011
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] );
}
}
}
Re: Random msg help -
sherlock - 24.10.2011
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
Re: Random msg help -
SmiT - 24.10.2011
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] );
}
}
}
Re: Random msg help -
sherlock - 24.10.2011
So that does all from 20 to 30? :P
Re: Random msg help -
SmiT - 24.10.2011
Yes, including 20 and 30.
Re: Random msg help -
sherlock - 24.10.2011
Ok thanks so i could do say 20 to 30 then 35-40 etc? do multiple ones?