Public onplayerCommandText (playerid,cmdtext[]) { if(strcmp(cmdtext, "/setplayerhealth)) SetPlayerHealth(playerid, float); return 1; }
CMD:sethealth(playerid, params[])
{
new Float:health;
if(sscanf(parmas, "h", health)) return SendClientMessage(playerid, -1, "[Server]: /sethealth [value]");
SetPlayerHealth(playerid, health);
}
CMD:sethealth(playerid, params[])
{
new id, Float:health;
if(sscanf(parmas, "uh", id, health)) return SendClientMessage(playerid, -1, "[Server]: /sethealth [id] [value]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "[Server]: Player is offline.");
SetPlayerHealth(id, health);
}
CMD:sethealth(playerid, params[])
{
new
id,
Float: amount;
if (sscanf(params, "rf", id, amount)) return SendClientMessage(playerid, -1, "Usage: /sethealth <ID/Part Of Name> <amount>");
if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Invalid player");
//if (!(0.0 <= amount <= 100.0)) return SendClientMessage(playerid, -1, "You can set an amount of health between 0.0 and 100.0");
SetPlayerHealth(id, amount);
return 1;
}
if(strcmp(cmd, "/sethp", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sethp [playerid/PartOfName] [health]");
return 1;
}
new playa;
new health;
playa = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sethp [playerid/PartOfName] [health]");
return 1;
}
health = strvalEx(tmp);
if(PlayerInfo[playerid][pAdmin] >= 4)
{
if(IsPlayerConnected(playa))
{
if(playa != INVALID_PLAYER_ID)
{
if(PlayerInfo[playa][pAdmin] > PlayerInfo[playerid][pAdmin] && health == 0)
{
format(string, sizeof(string), "{AA3333}AdmCmd{FFFF00}: %s was killed, reason: Attempting to set a higher admin's health to 0.", PlayerName(playerid));
ABroadCast(COLOR_LIGHTRED, string, 1);
SetPlayerHealth(playerid,0);
return 1;
}
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;
}
PHP код:
|
Congratulations, you know how to copy stuff from your script! Who's to say he has a PlayerInfo variable?
|
As the above members already suggested, ZCMD and sscanf is a very good combination for commands.
PHP код:
|
since samp 0.3 the SetPlayerHealth amount is not float. As I know
|
native SetPlayerHealth(playerid, Float:health);
native GetPlayerHealth(playerid, &Float:health);
native SetPlayerArmour(playerid, Float:armour);
native GetPlayerArmour(playerid, &Float:armour);