12.07.2011, 16:07
I want to make a /set command where the admin can set the health, armour ect but in one command. How can I got about making it?
if(strcmp(cmd, "/sethp", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sethp [playerid/PartOfName] [health]");
new playa;
new health;
playa = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sethp [playerid/PartOfName] [health]");
health = strvalEx(tmp);
if(PlayerInfo[playerid][pAdmin] >= 4)
{
if(IsPlayerConnected(playa))
{
if(playa != INVALID_PLAYER_ID)
{
SetPlayerHealth(playa, health);
format(string, sizeof(string), " You have set %s's health to %d !",PlayerName(playa),health);
SendClientMessage(playerid, COLOR_GREY, string);
}
}
}
else SendClientMessage(playerid, COLOR_GRAD1, " You are not authorized to use that command !");
}
return 1;
}
if(strcmp(cmd, "/setarmor", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setarmor [playerid/PartOfName] [armor]");
new playa;
new armor;
playa = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sethp [playerid/PartOfName] [armor]");
armor = strvalEx(tmp);
if(PlayerInfo[playerid][pAdmin] >= 4)
{
if(IsPlayerConnected(playa))
{
if(playa != INVALID_PLAYER_ID)
{
GetPlayerName(playa, giveplayer, sizeof(giveplayer));
SetPlayerArmour(playa, armor);
format(string, sizeof(string), " You have set %s's armor to %d !", giveplayer,armor);
SendClientMessage(playerid, COLOR_GREY, string);
}
}
}
else SendClientMessage(playerid, COLOR_GRAD1, " You are not authorized to use that command !");
}
return 1;
}
COMMAND:sethp(playerid, cmdtext[])
{
new Target,Amount;
if(!sscanf(cmdtext,"ui", Target, Amount))
{
if(Target == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, " Invalid playerid");
if(Amount < 0 || Amount > 100) return SendClientMessage(playerid, -1, "Amount 0 - 100");
SetPlayerHealth(Target, Amount);
SendClientMessage(playerid, -1, "You healed someone");
} else return SendClientMessage(playerid, -1, "Usage: /sethp [playerid] [health]");
return 1;
}