SA-MP Forums Archive
Sethp - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Sethp (/showthread.php?tid=649445)



Sethp - ivndosos - 09.02.2018

I've made a set health command but when I set my own health or someone's else's it sets it only to 1 hp.

What I've done wrong?

Код:
CMD:sethp(playerid, params[])
{
    if(connected[playerid] == true) return GameTextForPlayer(playerid, "~r~Spawn First", 5000, 5);
    if(pInfo[playerid][Admin] < 1) return SendClientMessage(playerid, -1, "{C3C3C3}(INFO) You don't have the priviliges to use this command.");
	new target, str[128], name[MAX_PLAYER_NAME],Float:hp;
	if(!IsPlayerConnected(target)) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) That player is not connected!");
	if(sscanf(params, "ud", target, hp)) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) /sethp [id] [amount]");
	GetPlayerName(target, name, sizeof(name));
	format(str, sizeof(str), "{EFB509}(INFO) You have set %s's health to %d", name, hp);
	SendClientMessage(playerid, -1, str);
	format(str, sizeof(str), "{EFB509}An admin has set your hp to %d", hp);
	SendClientMessage(target, -1, str);
	SetPlayerHealth(target, hp);
	return 1;
}



Re: Sethp - PepsiCola23 - 09.02.2018

try this

PHP код:
if(sscanf(params"ui"targethp)) 



Re: Sethp - Mugala - 09.02.2018

dont need to use float.
remove new Float:hp from the code and just left new hp;