announce text draw - 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: announce text draw (
/showthread.php?tid=384427)
announce text draw -
ThamburaaN - 11.10.2012
i have added a text draw announce to my script. but its getting bugged when 2 admins send message at same time(getting stuck on screen).
is there a way to put message on hold, like if any (1st)admins message going on screen and if any other admin(2nd) send message while the message going on, that (2nd admins) message should put on hold. (time limit on each message on screen is 4 seconds, so the 2nd admins message should be send after first admins message.)or any other way to avoid this bug?
pawn Код:
dcmd_announce(playerid, params[])
{
if(AccInfo[playerid][Level] >= 1)
{
if(gettime() < GetPVarInt(playerid, "ann_limit")) return SendClientMessage(playerid, red, "Please Wait Before Sending Announcement Again");
SetPVarInt(playerid, "ann_limit", gettime()+ann_LIMIT);
textann = TextDrawCreate(350.0, 150.0," ");
TextDrawLetterSize(textann,1.0 ,2.5);
TextDrawTextSize(textann, 800.0, 500.6);
TextDrawBackgroundColor(textann, 0x000000FF);
TextDrawAlignment(textann,2);
TextDrawFont(textann, 3);
TextDrawColor(textann, 0xffffffff);
TextDrawSetOutline(textann, 1);
TextDrawSetProportional(textann, 1);
if(!params[0]) return SendClientMessage(playerid, red, "Usage: /announce [text]");
TextDrawSetString(textann, params);
TextDrawShowForAll(textann);
SetTimer("HideAnnHere", 4000, false);
}
else
{
return ErrorMessages(playerid, 7);
}
return 1;
}
Re: announce text draw -
Riddick94 - 11.10.2012
Move text draw creating to Init callback. You don't need to create a text draw every time when you calling this command. And the gettime is useless. You don't need that too.
Re: announce text draw - Glint - 11.10.2012
Make a variable then set it to one if a textdraw is shown and when another admin tries to announce check that variable if it is one or not if it is then don't allow him to post the announcement.
Re: announce text draw -
Riddick94 - 11.10.2012
No he don't need to do another useless variable or boolean enough would be GetTickCount function.
pawn Код:
public OnGameModeInit()
{
textann = TextDrawCreate(350.0, 150.0, " ");
TextDrawLetterSize(textann,1.0 ,2.5);
TextDrawTextSize(textann, 800.0, 500.6);
TextDrawBackgroundColor(textann, 0x000000FF);
TextDrawAlignment(textann,2);
TextDrawFont(textann, 3);
TextDrawColor(textann, 0xffffffff);
TextDrawSetOutline(textann, 1);
TextDrawSetProportional(textann, 1);
return true;
}
dcmd_announce(playerid, params[])
{
if(AccInfo[playerid][Level] <= 1)
{
return ErrorMessages(playerid, 7);
}
if(!params[0])return SendClientMessage(playerid, red, "Usage: /announce [text]");
TextDrawSetString(textann, params);
TextDrawShowForAll(textann);
SetTimerEx("HideAnnHere", 4000, false);
return true;
}
Show "HideAnnHere" public callback.