26.07.2012, 15:46
how to /set health [amount] random parameters help please.
CMD:sethealth(playerid, params[])
{
new user, health;
if(!sscanf(params, "ui", user, health))
{
if(user != INVALID_PLAYER_ID)
{
SetPlayerHealth(user, health);
}
else return SendClientMessage(playerid, red, "SERVER: Invalid ID.");
}
else return SendClientMessage(playerid, white, "USAGE: /sethealth [ID] [AMMOUNT]");
return 1;
}
pawn Code:
|
CMD:setplayerhealth(playerid,params[])
{
new gid;
if(sscanf(params,"u",gid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE:/setplayerhealth [PlayerID]");
if(!IsPlayerConnected(gid)) return SendClientMessage(playerid, COLOR_WHITE,"Player ID given is not connected.");
new Float:rand = random(100);
SetPlayerHealth(gid, rand);
new str[128], name[MAX_PLAYER_NAME];
GetPlayerName(gid, name, MAX_PLAYER_NAME);
format(str, 128, "You have set %s's health to %f", name, rand);
return SendClientMessage(playerid, COLOR_WHITE, str);
}
CMD:set(playerid,params[])
{
new option[24], targetid, Float:parameter;
if(sscanf(params, "s[24]", option))
{
SendClientMessage(playerid, -1, "Usage: /set [option]");
SendClientMessage(playerid, -1, "Available Options: Health, Armour");
return 1;
}
if(!strcmp(option, "Health", true))
{
if(sscanf(params, "s[24]uf", option, targetid, parameter)) return SendClientMessage(playerid, -1, "Usage: /set health [playerid/partofname] [amount]");
SetPlayerHealth(targetid, parameter);
}
if(!strcmp(option, "Armour", true))
{
if(sscanf(params, "s[24]uf", option, targetid, parameter)) return SendClientMessage(playerid, -1, "Usage: /set armour [playerid/partofname] [amount]");
SetPlayerArmour(targetid, parameter);
}
else return SendClientMessage(playerid, -1, "Invalid option!");
return 1;
}