Tazer command!
#1

So, I have made a tazer command, but when I attempt to use it, it SPAMS 'There is no tazeable player near you'

pawn Код:
if(strcmp(cmd, "/tazer", true) == 0)
{
if(PlayerInfo[playerid][pFaction] != 11)
{
SendClientMessage(playerid, COLOR_RED, "Cops Only!");
return 1;
}
if(tazer[playerid] == 1)
{
SendClientMessage(playerid, COLOR_RED, "Your tazer is still recharging!");
return 1;
}
if(tazer[playerid] == 0)
{
SendClientMessage(playerid, COLOR_RED, "Your need a tazer from the PD armoury!");
return 1;
}
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if(Suspected[i] == 1)
{
if(GetDistanceBetweenPlayers(playerid, i) < 20)
{
GetPlayerName(i, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s shoots a tazer at %s", sendername ,giveplayer);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
GameTextForPlayer(i, "~r~Tazered", 2500, 3);
tazer[playerid] = 1;
SetTimerEx("Untazer", 20000, false, "i", i);
SetTimerEx("Recharge", 20000, false, "i", playerid);
ApplyAnimation(i, "WUZI", "CS_Dead_Guy", 4.0, 1, 0, 0, 0, 0);
TogglePlayerControllable(i,0);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "There is no tazeable player near you!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "There is no tazeable player near you!");
return 1;
}
}
}
SendClientMessage(playerid, COLOR_RED, "There is no tazeable player near you!");
return 1;
}
Reply
#2

Your Text Message needs to be OUTSIDE the FOREACH PLAYER Loop.

for (new i = 0; i < MAX_PLAYERS; i++)
{
// Anything in here for text display spams all players
}
SendClientMessage(playerid, COLOR_RED, "There is no tazeable player near you!");
Reply
#3

Kay, thx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)