SA-MP Forums Archive
Health above 256 - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Health above 256 (/showthread.php?tid=57421)



Health above 256 - Slice - 07.12.2008

Hello,
Is there a way to know if the player has a health of like 4000? GetPlayerHealth gives me like health mod 256. =/


Re: Health above 256 - Serbish - 07.12.2008

Why you don't make the max. amount of health is 100?

Like
Код:
new Float:health;
if(GetPlayerHealth(playerid,health) > 100
{
// kick or whatever
}



Re: Health above 256 - Slice - 07.12.2008

The health needs to be 2000-9000, the question is if it's possible to read the current health.
My idea is to check whenever the health goes up and remove 256 from the display value (well sorta, you get what I mean). But that will prolly not be accurate.


Re: Health above 256 - Serbish - 07.12.2008

Код:
if(strcmp("/health", cmd, true) == 0)
{
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_MAIN, "Type /health <ID>");
if(IsPlayerConnected(strval(tmp)) == 0) return SendClientMessage(playerid, COLOR_MAIN, "Enter a valid player ID!");
new player = strval(tmp);
new pname[MAX_PLAYER_NAME];
GetPlayerName(player, pname, sizeof(pname));
new string[256];
format(string, sizeof(string), "%s's health amount is %d!", pname, GetPlayerHealth(playerid));
SendClientMessage(playerid, COLOR_GREEN, string);
return 1;
}



Re: Health above 256 - Slice - 07.12.2008

If you use that command when the health is 1523 for example, then it shows 243. THAT'S my problem.


Re: Health above 256 - Serbish - 07.12.2008

Quote:
Originally Posted by Oscar4Life
If you use that command when the health is 1523 for example, then it shows 243. THAT'S my problem.
Ahh ok, now I understood.
Hmm, then I can't help you.
But why do you need to check a health above 200 for example?


Re: Health above 256 - yom - 07.12.2008

It's maxxed to 255..And you can do nothing against that.


Re: Health above 256 - Slice - 07.12.2008

First I'm setting it to 4000, then checking until it reaches 0. Well that's how it's supposed to work.


Re: Health above 256 - Serbish - 07.12.2008

Quote:
Originally Posted by Seif_
Quote:
Originally Posted by Serbish
Код:
if(strcmp("/health", cmd, true) == 0)
{
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_MAIN, "Type /health <ID>");
if(IsPlayerConnected(strval(tmp)) == 0) return SendClientMessage(playerid, COLOR_MAIN, "Enter a valid player ID!");
new player = strval(tmp);
new pname[MAX_PLAYER_NAME];
GetPlayerName(player, pname, sizeof(pname));
new string[256];
format(string, sizeof(string), "%s's health amount is %d!", pname, GetPlayerHealth(playerid));
SendClientMessage(playerid, COLOR_GREEN, string);
return 1;
}
You should at least give him a working code... indented.

Are you just doing that for a check or are you setting it to 4000 and then checking using GetPlayerHealth? If so, just store the value of the health you set in a variable.
You need glasses or why this code isn't working?


Re: Health above 256 - CracK - 08.12.2008

tried this.
pawn Код:
new Float:health[MAX_PLAYERS];

stock SetPlayerHealthEx(playerid, Float:amount)
{
  health[playerid] = amount;
  SetPlayerHealth(playerid,health[playerid]);
  return health[playerid];
}
and this
pawn Код:
stock GetPlayerHealthEx(playerid, &Float:amount)
{
      return health[playerid];
}
but GetPlayerHealthEx always returns 0.00 and there are tag mismatch warnings after compile

what's wrong here?

i've done some SetPlayerHealthEx-s before GetPlayerHealthEx...