Checkpoint Timer [+REP for help]
#1

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

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

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

bump
Reply
#5

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

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

Your parameters are correct for the SetTimerEx function above.

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

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

Solved.

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


Forum Jump:


Users browsing this thread: 1 Guest(s)