Armour / Health problem
#1

~~~~~~~~~~
Reply
#2

pawn Код:
CMD:armour(playerid, params[])
{
new string[128], name[MAX_PLAYER_NAME];
new Float:armour;
GetPlayerArmour(playerid, armour);
if(isDead[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You Cannot Use This Command When Dead.");
if(armour >= 100) return SendClientMessage(playerid, COLOR_RED, "Your Armour Is Already Full.");
GetPlayerName(playerid, name, sizeof name);
format(string, sizeof string, "%s (%d) Has Used /armour To Refill His Armour.", name, playerid);
SendClientMessageToAll(COLOR_LIME, string);
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You Have Refilled Your Armour.");
SetPlayerArmour(playerid, 100.0);
return 1;
}
pawn Код:
CMD:heal(playerid, params[])
{
new string[128], name[MAX_PLAYER_NAME];
new Float:health;GetPlayerHealth(playerid,health);
if(isDead[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You Cannot Use This Command When Dead.");
if(health >= 100) return SendClientMessage(playerid, COLOR_RED, "Your Health Is Already Full.");
GetPlayerName(playerid, name, sizeof name);
format(string, sizeof string, "%s (%d) Has Used /heal To Heal Himself.", name, playerid);
SendClientMessageToAll(COLOR_LIME, string);
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You Have Healed Yourself.");
SetPlayerHealth(playerid, 100.0);
return 1;
}
First: you didn't assign the variables of the players Health/Armor
Second: you mixed up the checking

what i mean is you were checking if the player health is more then 100 OR anything less then 100
which makes no sense.

And for the health you made it check if the player health is anything below 100, also meaning if it equals to 99 or bellow
Reply
#3

~~~~~~~~
Reply
#4

Try this

Код:
CMD:heal(playerid, params[])
{
	new string[128], name[MAX_PLAYER_NAME], Float:health;GetPlayerHealth(playerid,health);
	if(isDead[playerid] == 1)
	{
		SendClientMessage(playerid, COLOR_RED, "You Cannot Use This Command When Dead.");
		return 1;
	}
	if(health >= 100)
	{
		SendClientMessage(playerid, COLOR_RED, "Your Health Is Already Full.");
		return 1;
	}
	else
	{
	GetPlayerName(playerid, name, sizeof name);
	format(string, sizeof string, "%s (%d) Has Used /heal To Heal Himself.", name, playerid);
	SendClientMessageToAll(COLOR_LIME, string);
	SendClientMessage(playerid, COLOR_LIGHTBLUE, "You Have Healed Yourself.");
	SetPlayerHealth(playerid, 100.0);
	return 1;
	}
}
Код:
CMD:armour(playerid, params[])
{
	new string[128], name[MAX_PLAYER_NAME], Float:armour;
	if(isDead[playerid] == 1)
	{
		SendClientMessage(playerid, COLOR_RED, "You Cannot Use This Command When Dead.");
		return 1;
	}
	GetPlayerArmour(playerid, armour);
	if(armour >= 100)
	{
		SendClientMessage(playerid, COLOR_RED, "Your Armour Is Already Full.");
		return 1;
	}
	else
	{
	GetPlayerName(playerid, name, sizeof name);
	format(string, sizeof string, "%s (%d) Has Used /armour To Refill His Armour.", name, playerid);
	SendClientMessageToAll(COLOR_LIME, string);
	SendClientMessage(playerid, COLOR_LIGHTBLUE, "You Have Refilled Your Armour.");
	SetPlayerArmour(playerid, 100.0);
	return 1;
	}
}
Reply
#5

Check if the armour / health is greater than 99.0 instead of greater or equal 100.0 because floats arn't perfectly accurate

pawn Код:
CMD:armour(playerid, params[]) {
    if(isDead[playerid] == 1)
        return SendClientMessage(playerid, COLOR_RED, "You Cannot Use This Command When Dead.");
    new
        Float: armour
    ;
    GetPlayerArmour(playerid, armour);
    if(armour > 99.0)
        return SendClientMessage(playerid, COLOR_RED, "Your Armour Is Already Full.");
    new
        tmp[128]
    ;
    GetPlayerName(playerid, tmp, MAX_PLAYER_NAME);
    format(tmp, sizeof tmp, "%s (%d) Has Used /armour To Refill His Armour.", tmp, playerid);
    SendClientMessageToAll(COLOR_LIME, tmp);
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "You Have Refilled Your Armour.");
    return SetPlayerArmour(playerid, 100.0);
}
Reply
#6

~~~~~~~~
Reply
#7

nothing :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)