CMD not working
#2

Quote:
Originally Posted by ddiioonn123
Посмотреть сообщение
Hi, i started scripting SA-MP yesterday, and i wanted to make a command called: "heal", but it's not working!
Code:


CMD:heal(playerid, params[]){
new targetid;
if(sscanf(params, "ud", targetid)) return SendClientMessage(playerid, 0xFF0000AA, "Perdorimi: /heal [ID]");
else {
new Float:currentHp;
new Float:hpmomentale = GetPlayerHealth(playerid, currentHp);
SetPlayerHealth(playerid, 100-hpmomentale);
return 1;
}
}

Any help?
Код:
CMD:heal(playerid, params[])
{
	new targetid,amount;
	if(sscanf(params, "ud", targetid,amount)) return  SendClientMessage(playerid, 0xFF0000AA, "Perdorimi: /heal [ID]");
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFF0000AA,  "Error: Invalid player ID.");
	SetPlayerHealth(targetid, amount);
	return 1;
}
Improved it a bit, you can translate the error message to your language if you want, you can also limit the amount by doing:
Код:
if(amount > 100) return SendClientMessage(playerid, 0x0xFF0000AA, "Error: Maximum amount is 100.");
Reply


Messages In This Thread
CMD not working - by ddiioonn123 - 09.12.2018, 11:24
Re: CMD not working - by Mike861 - 09.12.2018, 11:27
Re: CMD not working - by SlBIH - 09.12.2018, 11:29
Re: CMD not working - by ddiioonn123 - 09.12.2018, 11:31
Re: CMD not working - by Mike861 - 09.12.2018, 11:37
Re: CMD not working - by Kraeror - 09.12.2018, 11:47

Forum Jump:


Users browsing this thread: 1 Guest(s)