public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/smack", cmdtext, true, 6))
{
new targetid = strval(cmdtext[6]);
new Float:x, Float:y, Float:z;
new Float:health;
GetPlayerHealth(targetid, health);
new pName [MAX_PLAYER_NAME], tName [MAX_PLAYER_NAME], string [128];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
GetPlayerName(targetid, tName, MAX_PLAYER_NAME);
if(string[playerid] > '9' || string[playerid] < '0') return SendClientMessage(playerid,COLOR_RED,"ID must be a number");
if(cmdtext[6] == 0) return SendClientMessage(playerid,COLOR_RED,"USAGE: /smack <ID>");
if(GetPlayerPos(targetid, x, y, z) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Invalid ID");
if(!IsPlayerNearPlayer(playerid, targetid, 2.0)) return SendClientMessage(playerid, 0xFFFFFFFF, "Not Near");
if (health < 50.0)
{
format(string, sizeof(string), "%s(%d) has smacked %s(%d) to death",pName, playerid, tName, targetid);
SendClientMessageToAll(0xFF0000FF, string);
SetPlayerHealth(targetid, 0);
return 1;
}
else
{
format(string, sizeof(string), "%s(%d) has smacked %s(%d)",pName, playerid, tName, targetid);
SendClientMessageToAll(0xFF0000FF, string);
return 1;
}
}
if(string[playerid] > '9' || string[playerid] < '0') return SendClientMessage(playerid,COLOR_RED,"ID must be a number");
Try this. http://pastebin.com/HujHN3Y3
|