04.06.2012, 14:47
Hello can some1 help me how to make /armorall and /healall to give to all players armor/health or some1 to make for me tnx
CMD:massarmor(playerid)
{
if(PlayerInfo[playerid][pAdmin] >= 5)
{
foreach(Player, i)
{
SetPlayerArmour(i, 100);
}
BroadCast(COLOR_LIGHTBLUE, "An Admin has given Full Armor to Everyone!");
}
return 1;
}
CMD:massheal(playerid)
{
if(PlayerInfo[playerid][pAdmin] >= 9998)
{
foreach(Player, i)
{
SetPlayerHealth(i, 100);
}
BroadCast(COLOR_LIGHTBLUE, "An Admin has given full health to Everyone!");
}
return 1;
}
CMD:armorall(playerid, params[])
{
if(IsPlayerAdmin(playerid))//change to your admin system
{
SendClientMessageToAll(COLOR_GREEN, "All players healed by Admin");
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetPlayerArmour(i, 100.0);
}
}
else SendClientMessage(playerid,COLOR_RED,"You are not Admin!");
return true;
}
CMD:healall(playerid, params[])
{
if(IsPlayerAdmin(playerid))//change to your admin system
{
SendClientMessageToAll(COLOR_GREEN, "All players healed by Admin");
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetPlayerHealth(i, 100.0);
}
}
else SendClientMessage(playerid,COLOR_RED,"You are not Admin!");
return true;
}
if (strcmp("/healall", cmdtext, true, 10) == 0)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetPlayerHealth(i, 100.0);
}
return 1;
}
if (strcmp("/armourall", cmdtext, true, 10) == 0)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetPlayerArmour(i, 100.0);
}
return 1;
}
For the above example you need foreach by ****** and ZCMD by ZeeX.
Better use this: pawn Код:
|
For the first example you need foreach by ****** and ZCMD by ZeeX (for the second too).
Better use this: pawn Код:
|
It is always better to use foreach instead of using "for" (normal) loop.
-FalconX |
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerAdmin(i))
{
// code
}
}
for(new i = 0; i < MAX_PLAYERS; i++)
{
variable[i] = 0;
}