#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;
}
Messages aren't repeated. |
#define MAX_MESSAGE_SIZE 150
new Text:RandomMsgTD, RandomMsgID;
new RandomMsgs[][MAX_MESSAGE_SIZE] =
{
"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()
{
new rID = getNewRandomMessageID();
new string[MAX_MESSAGE_SIZE + 15 /*because of the stuff infront of the actual message*/];
format(string, sizeof(string), "~r~News ~w~%s", RandomMsgs[rID]);
TextDrawSetString(RandomMsgTD, string);
return 1;
}
getNewRandomMessageID()
{
new newRandomID = random(sizeof(RandomMsgs));
return newRandomID == RandomMsgID ? getNewRandomMessageID() : newRandomID;
}
^ Marcel, a little appreciation for a newbie who at least tried to do something. However, your version isn't perfect as well...
|
^ Marcel, a little appreciation for a newbie who at least tried to do something. However, your version isn't perfect as well...
|
Originally Posted by Marcel
Fixed Version (still not worth releasing):
|