Wrong GetPlayerHealth
#1

Hi everyone.

I had a little (Mhh big too) on my SA-MP Server.
I explain, this is a Zombie RP Server, so Zombie have got more health than humans
(1000 HP)

But, there is a problem because when i want to know my health, it's say me i've only 232 HP.
So , I tested with a cleo mod to show my life, it's show me i had 1000 HP, so it's have good.

This is a big problem because i use custom damage, so when a player shot on a zombie, his player life (1000 HP) become 232...

Why did say me i've only 232 HP?

Code :

Код:
	if	(!strcmp(cmd, "/test", true))
	{
		new string1[100];
		new Float:healthzombie;
		GetPlayerHealth(playerid, healthzombie);
		format(string1, sizeof(string1), "%f HP", healthzombie);
		SendClientMessage(playerid, ROUGE, string1);
	  	return 1;
  	}
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
	if(issuerid != INVALID_PLAYER_ID)
	{
		new Float:HP;
		//new stringvie[256];
		GetPlayerHealth(playerid, HP);
		printf("ISSUEUR %f", HP);
		if(weaponid == 0 && !IsLigotte[issuerid]) //Poings
		{
			if(PlayerInfo[issuerid][pMforce] >= 23) { AC_BS_SetPlayerHealth(playerid, HP-15.0); }
			else if(PlayerInfo[issuerid][pMforce] >= 20) { AC_BS_SetPlayerHealth(playerid, HP-14.0); }
			else if(PlayerInfo[issuerid][pMforce] >= 18) { AC_BS_SetPlayerHealth(playerid, HP-13.0); }
			else if(PlayerInfo[issuerid][pMforce] >= 14) { AC_BS_SetPlayerHealth(playerid, HP-12.0); }
			else if(PlayerInfo[issuerid][pMforce] >= 11) { AC_BS_SetPlayerHealth(playerid, HP-11.0); }
			else if(PlayerInfo[issuerid][pMforce] >= 9) { AC_BS_SetPlayerHealth(playerid, HP-10.0); }
			else if(PlayerInfo[issuerid][pMforce] >= 7) { AC_BS_SetPlayerHealth(playerid, HP-9.0); }
			else if(PlayerInfo[issuerid][pMforce] >= 5) { AC_BS_SetPlayerHealth(playerid, HP-8.0); }
			else if(PlayerInfo[issuerid][pMforce] >= 3) { AC_BS_SetPlayerHealth(playerid, HP-7.0); }
			else if(PlayerInfo[issuerid][pMforce] >= 1) { AC_BS_SetPlayerHealth(playerid, HP-6.0); }
			else { AC_BS_SetPlayerHealth(playerid, HP-5.0); }
		}
 //etc...
Thank you for your help and sorry for my bad english :S
Reply
#2

I dont how HP, Ac bs came there?

pawn Код:
AC_BS_SetPlayerHealth(playerid, HP-6.0); }
Try only :-
pawn Код:
SetPlayerHealth(playerid, -6.0); }
Reply
#3

It's the Anticheat fonction, For Health Hack, but i tried with only SetPlayerHealth, same result :\
Reply
#4

Quote:
Originally Posted by totalgaara
Посмотреть сообщение
It's the Anticheat fonction, For Health Hack, but i tried with only SetPlayerHealth, same result :\
Alright, Chuck it then.

Why you used playerid here?

Код:
 GetPlayerHealth(playerid, healthzombie);
Reply
#5

the command "/test", it's just a debug command, to see what's wrong.
So it's just for show my life.

I tested with my brother (i've 2 pc), when my brother shot me,
My life (1000) became 232 HP (Approximatively, it's not always the same..)

I don't understand why i have this bug :\
Reply
#6

This is likely because the server only allocates 8 bits to store the health. This means that it can only store 256 values (0 - 255). Anything larger will just overflow. If we apply a modulus of 256 to 1000 we get, surprise, 232!
Reply
#7

What can i do so ?
Reply
#8

Anybody Know solution to bypass this limitation of 8 bits ?

(sorry for double post :S)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)