SA-MP Forums Archive
Update a textdraw each X time - 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: Update a textdraw each X time (/showthread.php?tid=494212)



Update a textdraw each X time - anou1 - 12.02.2014

Hi, sorry if I post again but I have a question.

How could I do to set a TextDraw ( Per PLayerTextDraw) to update each 10 seconds for example.

Thank you.


Re: Update a textdraw each X time - PowerPC603 - 12.02.2014

Use a timer that's set to run every 10 seconds:
pawn Код:
public OnGameModeInit()
{
    // Start a timer which runs every 10 seconds
    SetTimer("Timer10000", 10000, true);

    return 1;
}

// This timer runs every 10 seconds
forward Timer10000();
public Timer10000()
{
    // Loop through all players and only run the timer for each player who's logged in
    for (new playerid; playerid < MAX_PLAYERS; playerid++)
        if (IsPlayerConnected(playerid) == 1)
            PlayerTextDrawSetString(playerid, YourTextDraw, YourMessage);
}



Re: Update a textdraw each X time - Face9000 - 12.02.2014

@PowerPC, use foreach for the loops, so you don't have to check if the player is connected. Just a hint.


Re: Update a textdraw each X time - PowerPC603 - 12.02.2014

I'm using a variable myself to check if he's logged in (after entering his password correctly).
This would already be pretty fast.

pawn Код:
if (APlayerData[playerid][LoggedIn] == true)