Posts: 1,276
Threads: 6
Joined: Aug 2014
First, if you're new you should know that strcmp is very slow and outdated.
I suggest you to use ZCMD and SSCANF.
Heres a command in ZCMD and sscanf.
PHP код:
CMD:sethealth(playerid, params[])
{
new Float:health;
if(sscanf(parmas, "h", health)) return SendClientMessage(playerid, -1, "[Server]: /sethealth [value]");
SetPlayerHealth(playerid, health);
}
Not tested.
PHP код:
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);
}
Heres one with ID, not tested.
Posts: 270
Threads: 7
Joined: Apr 2015
Is it a HEALME command or Admin SetHealth command ?
BTW I suggest you to use ZCMD its easier and faster to use.
ZCMD:
https://sampforum.blast.hk/showthread.php?tid=91354
Posts: 1,276
Threads: 6
Joined: Aug 2014
Quote:
Originally Posted by SoFahim
PHP код:
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;
}
Use this cmd for help ppl
|
Congratulations, you know how to copy stuff from your script! Who's to say he has a PlayerInfo variable?
Posts: 417
Threads: 40
Joined: Oct 2013
Reputation:
0
Yea, but you can use normal integer for that, too. Right?