29.03.2011, 20:15
Well ive recently tried to make a sethp with zcmd and sscanf, but i failed hard. Was wondering if someone could give me example(i cant show you code cause i kinda raged on it). Thanks in advance.
CMD:sethp(playerid, params[]) { new player2, health; if(sscanf(params, "ud", player2, health)) SendClientMessage(playerid, COLOR_WHITE, "[USAGE]:/sethp <playerid>"); else if(IsPlayerConnected(player2)) SendClientMessage(playerid, COLOR_WHITE, "Invalid Player."); else { SetPlayerHealth(player2, health); SendClientMessage(playerid, COLOR_WHITE, "Player Health Set."); SendClientMessage(player2 , COLOR_WHITE, "Your health has been set."); return 1; } return 1; }
CMD:sethp(playerid, params[])
{
new player2, Float:health;
if(sscanf(params, "uf", player2, health)) SendClientMessage(playerid, COLOR_WHITE, "[USAGE]:/sethp <playerid> <health>");
else if(!IsPlayerConnected(player2)) SendClientMessage(playerid, COLOR_WHITE, "Invalid Player.");
else
{
SetPlayerHealth(player2, health);
SendClientMessage(playerid, COLOR_WHITE, "Player Health Set.");
SendClientMessage(player2 , COLOR_WHITE, "Your health has been set.");
return 1;
}
return 1;
}
COMMAND:sethp(playerid, params[])
{
new user, amount;
if(sscanf(params, "ui", user, amount))
return SendClientMessage(playerid, white, "USAGE: /sethp [playerid] [amount]");
SetPlayerHealth(user, amount);
SendClientMessage(user, white, "Your health has been set.");
return 1;
}
command(sethp, playerid, params[])
{
new player2, Float:health,string[128],string2[128];
if(sscanf(params, "uf", player2, health)) return SendClientMessage(playerid, COLOR_WHITE, "[USAGE]:/sethp <playerid> <health>");
if(!IsPlayerConnected(player2)) return SendClientMessage(playerid, COLOR_WHITE, "Invalid Player.");
SetPlayerHealth(player2, health);
format(string2,sizeof(string2),"Player's health set to: %d.",health);
SendClientMessage(playerid, COLOR_WHITE, string2);
format(string,sizeof(string),"Your health has been set to: %d.",health);
SendClientMessage(player2, COLOR_WHITE,string);
return 1;
}
/sethp a7x 50
[Debug] /sethp a7x 50: a7x's health has been set to 50. |