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);
}
}
}
}
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. |
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;
}
Why do you have a return statement in your loop? That ensures that your loop will run only once.
|
for( new i = 0; i > MAX_PLAYERS; i++)
Your parameters are correct for the SetTimerEx function above.
Код:
for( new i = 0; i > MAX_PLAYERS; i++) |