02.11.2014, 19:15
What your code is doing is it will check through the first player in the loop and if they're not in range then it will say that there is no player in range. If you think about the logic of this:
-> Foreach executes
-> Pick first person in the Foreach loop (lets say ID 0)
-> Code determines ID 0 isn't in range
->
is called
-> Loop stops there.
So what you want to do is this:
-> Foreach executes
-> Pick first person in the Foreach loop (lets say ID 0)
-> Code determines ID 0 isn't in range
->
pawn Код:
return SCM(playerid, red, "[ERROR]"COL_WHITE" No player is in range.");
-> Loop stops there.
So what you want to do is this:
pawn Код:
CMD:nuke(playerid,params[])
{
new string[150];
if(InDMArena[playerid] == 1) return SCM(playerid, red, "[ERROR]"COL_WHITE" You cannot use this command while in the DM stadium.");
if(gTeam[playerid] != TEAM_TFH) return SCM(playerid, red, "[ERROR]"COL_WHITE" Only horsemen can nuke players.");
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER or GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
{
SendClientMessage(playerid,COLOR_ERROR,"[ERROR]"COL_WHITE" You cannot burn someone while in a vehicle. Exit the vehicle first.");
return 1;
}
if(HasNukedRecently[playerid] >= 1)
{
format(string, sizeof(string),"[ERROR]"COL_WHITE" Please wait "COL_RED"%d seconds"COL_WHITE" before burning someone again.",HasNukedRecently[playerid]);
SCM(playerid,red,string);
return 1;
}
if(pInfo[playerid][XP] < 2000)
{
return SCM(playerid,red,"[ERROR]"COL_WHITE" Insufficient XP (2000)");
}
foreach(Player, i)
{
if(GetDistanceBetweenPlayers(playerid,i) <= 4 and i != playerid)
{
new Float:ARMOUR, Float:HEALTH;
GetPlayerArmour(playerid, ARMOUR);
GetPlayerHealth(playerid, HEALTH);
HasNukedRecently[playerid] =500;
new xp = pInfo[playerid][XP];
pInfo[playerid][XP] =xp-2000;
new Float:x, Float:y, Float:z;
if(aDuty[i] == 0 and gTeam[i] != TEAM_TFH)
{
GetPlayerPos(i, x, y, z);
CreateExplosion(x, y , z + 2, 1, 10);
SetPlayerHealth(i, 0);
format(Jstring,sizeof(Jstring),"[NUKE]"COL_WHITE" Horseman %s[%d] has used his/her nuke abillity.",GetName(playerid),playerid);
SendClientMessageToAll(COLOR_TFH,Jstring);
format(Jstring, sizeof(Jstring),"[NUKED]"COL_WHITE" %s[%d] has been killed by horseman %s[%d]'s nuke abillity.", GetName(i), i, GetName(playerid), playerid);
SCMToAll(red, Jstring);
SetPlayerArmour(playerid, ARMOUR);
SetPlayerHealth(playerid, HEALTH);
}
return 1;
}
}
return SCM(playerid, red, "[ERROR]"COL_WHITE" No player is in range.");
}