13.07.2012, 14:06
1. For /akill
2. For /sethealth
- On SetPlayerHealth, you don't need %s to set the playerhealth. the %s already stored in "Amount"
- %s is for string, %d or %i is for integer.
pawn Code:
COMMAND:akill(playerid, params[])
{
new toplayerid, reason[64], message[128];
if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "only admins can use this command!");
if(sscanf(params, "ds[64]", toplayerid, reason)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /akill <plaerid> <reason>");
if(toplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000FF, "that player is not connected");
SetPlayerHealth(playerid, 0);
format(message, sizeof(message), "Admin killed u reason : %s", reason);
SendClientMessage(toplayerid, 0x00FF00FF, message);
return 1;
}
pawn Code:
COMMAND:sethealth(playerid, params[])
{
new pID, amount, aName[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME], string[256];
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "[ERROR]:You need to be an Admin to Access this Commands!");
if(sscanf(params, "dd", pID, Amount)) return SendClientMessage(playerid, COLOR_WHITE, "[CMD]:/sethealth [PlayerID] [Amount]");
if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid ,COLOR_BRIGHTRED,"[ERROR]:Player not Found!");
GetPlayerName(playerid, aName, sizeof(aName));
GetPlayerName(pID, pName, sizeof(pName));
//format(string, sizeof(string),"Admin Has Healed You", aName, pName, Amount); //You can do this with SendClientMessage, aName, pName, Amount will be useless.
format(string, sizeof(string),"Admin %s Has Set %s's Health to %d", aName, pName, Amount); //Admin "playerid" has set "pID" Health to "Amount"
SendClientMessage(playerid, COLOR_BRIGHTRED, string); //Sends the message to playerid who uses the command
SendClientMessage(pID, COLOR_BRIGHTRED, string); //Sends the message to target playerid (aka pID)
SetPlayerHealth(pID, Amount); //Sets pID health to Amount
return 1;
}
- %s is for string, %d or %i is for integer.