SA-MP Forums Archive
Checkpoint Timer [+REP for help] - 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: Checkpoint Timer [+REP for help] (/showthread.php?tid=504073)



Checkpoint Timer [+REP for help] - AndySedeyn - 01.04.2014

Hello
I am making a back up command for the LSPD faction.

I decided to put checkpoints but I want to refresh it every 3-4 seconds with the new position of the agent that requested back up.

Is that possible? (Note: It's not an invite system. The factions are with a tag system)
Once again, don't pay attention to the indentation. The forum fucked it up due to the CODE-tag.

This is what I've got:
pawn Код:
if(!strcmp(cmdtext, "/bk", true))
    {
        new sendername[MAX_PLAYER_NAME]; // FOR FORMATS...
        new Float:x, Float:y, Float:z;
        GetPlayerName(playerid, sendername, sizeof(sendername));
        if(IsPlayerCop(playerid))
        {
            if(ICBK[playerid] == 1) return SendClientMessage(playerid, 0xFF0000AA,"You need to wait 1 minute before calling backup again!"); // Message if player will want to spam backup..
            new string[150];
            new pName[MAX_PLAYER_NAME];
            ICBK[playerid] = 1; // Is calling backup, so player won't be able to spam it
            GetPlayerName(playerid, pName, sizeof(pName));
            format(string,sizeof(string),"* %s grabs his dispatcher pulling towards his mouth, pushes the button to talk and starts talking:", Name);
            ProxDetector(30.0, playerid, string, COLOR_DBLUE,COLOR_DBLUE,COLOR_DBLUE,COLOR_DBLUE,COLOR_DBLUE);
            GetPlayerName(playerid, pName, sizeof(pName));
            format(string, sizeof(string), "{FF0000}.:DISPATCH:.: ALL UNITS! %s is requesting immediate assistance, his location has been located on radar!", pName); // msg
            for(new i = 0; i < MAX_PLAYERS; i++) // loop...
            {
                if(IsPlayerConnected(i))
                {
                    if(IsPlayerCop(i)) // checking if player is cop
                    {
                        SendClientMessage(i,0x0FFDD349,string); // same color as in dispatch chat, and it will send msg to cops only
                        GetPlayerPos(playerid, x, y, z);
                        SetPlayerCheckpoint(i, x, y, z, 5);
                    }
                }
            }
        }



Re: Checkpoint Timer [+REP for help] - MattTucker - 01.04.2014

https://sampwiki.blast.hk/wiki/SetTimerEx
SetTimerEx("BKUpdater", 5000, true,"i",playerid);

And inside that function, you can create/copy & paste a loop for all the LSPD officers and set them the checkpoint.

PS:That "true" on SetTimerEx("BKUpdater", 5000, true,"i",playerid);
Means that the timer will be constant every 5 seconds (1 second = 1000 millisecond) so you will have to kill the timer like /nobackup command.


Re: Checkpoint Timer [+REP for help] - AndySedeyn - 02.04.2014

Quote:
Originally Posted by MattTucker
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/SetTimerEx
SetTimerEx("BKUpdater", 5000, true,"i",playerid);

And inside that function, you can create/copy & paste a loop for all the LSPD officers and set them the checkpoint.

PS:That "true" on SetTimerEx("BKUpdater", 5000, true,"i",playerid);
Means that the timer will be constant every 5 seconds (1 second = 1000 millisecond) so you will have to kill the timer like /nobackup command.
What should the parameters from the BKUpdater callback be?

This is what I've made and the checkpoint won't update.
pawn Код:
forward BKUpdater(playerid);
public BKUpdater(playerid)
{
    new Float:x, Float:y, Float:z;
    for( new i = 0; i > MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerCop(i))
            {
                DisablePlayerCheckpoint(i);
                GetPlayerPos(playerid, x, y, z);
                SetPlayerCheckpoint(i, x, y, z, 5);
            }
        }
        return 1;
    }
    return 0;
}



Re: Checkpoint Timer [+REP for help] - AndySedeyn - 02.04.2014

bump


Re: Checkpoint Timer [+REP for help] - Corekt - 02.04.2014

Why do you have a return statement in your loop? That ensures your loop will run only once.


Re: Checkpoint Timer [+REP for help] - AndySedeyn - 02.04.2014

Quote:
Originally Posted by Corekt
Посмотреть сообщение
Why do you have a return statement in your loop? That ensures that your loop will run only once.
Yeah, I noticed that as well and removed it as soon as I saw it.
Still, the checkpoint is not updating.


Re: Checkpoint Timer [+REP for help] - Corekt - 02.04.2014

Your parameters are correct for the SetTimerEx function above.

Код:
for( new i = 0; i > MAX_PLAYERS; i++)
should be i < MAX_PLAYERS


Re: Checkpoint Timer [+REP for help] - AndySedeyn - 02.04.2014

Quote:
Originally Posted by Corekt
Посмотреть сообщение
Your parameters are correct for the SetTimerEx function above.

Код:
for( new i = 0; i > MAX_PLAYERS; i++)
should be i < MAX_PLAYERS
My idea is to update the officer's location when he's in a pursuit and when he did /bk.
But at them moment it doesn't update the checkpoint, it places a checkpoint on the spot where the officer did /bk but it doesn't update it's location if the officer moves.


Re: Checkpoint Timer [+REP for help] - VerticalGaming - 02.04.2014

Solved.

edit; BTW check skype, I've sended you the gamemode you needed
Backup fixed.