Textdraw based Random Messages
Features
Features
- Messages aren't repeated.
- Selected randomly.
- Very easy to add new messages.
- Textdraw based.
PHP Code:
#include a_samp
new
Text RandomMsgTD,
RandomMsgID = -1,
RandomMsgs[][] =
{
"Message number 1",
"Message number 2",
"Message number 3"
};
public OnFilterScriptInit()
{
RandomMsgTD = TextDrawCreate(8.000000, 431.000000, ~p~~h~News ~w~_.);
TextDrawBackgroundColor(RandomMsgTD, 255);
TextDrawFont(RandomMsgTD, 2);
TextDrawLetterSize(RandomMsgTD, 0.200000, 1.200000);
TextDrawColor(RandomMsgTD, -1);
TextDrawSetOutline(RandomMsgTD, 1);
TextDrawSetProportional(RandomMsgTD, 1);
TextDrawSetSelectable(RandomMsgTD, 0);
RandomMessage();
SetTimer(RandomMessage, 45000, true);
return 1;
}
public OnPlayerConnect(playerid) TextDrawShowForPlayer(playerid, RandomMsgTD);
public OnPlayerDisconnect(playerid, reason) TextDrawHideForPlayer(playerid, RandomMsgTD);
forward RandomMessage();
public RandomMessage()
{
reselect_msg
new string[150], rID = random(sizeof RandomMsgs);
if(RandomMsgID == rID) goto reselect_msg;
format(string, sizeof string, ~r~News ~w~%s, RandomMsgs[rID]);
TextDrawSetString(RandomMsgTD, string);
return 1;
}