announce text draw
#1

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;
}
Reply
#2

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.
Reply
#3

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.
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)