Armour / Health problem -
Ananisiki - 16.02.2013
~~~~~~~~~~
Re: Armour / Health problem -
park4bmx - 16.02.2013
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
Re: Armour / Health problem -
Ananisiki - 17.02.2013
~~~~~~~~
Re: Armour / Health problem -
PT - 17.02.2013
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;
}
}
AW: Re: Armour / Health problem -
Nero_3D - 17.02.2013
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);
}
Re: Armour / Health problem -
Ananisiki - 17.02.2013
~~~~~~~~
Re: Armour / Health problem -
PT - 17.02.2013
nothing :P