Damage bug
#1

Why is this killing the player instantly?
Код:
	if(issuerid != INVALID_PLAYER_ID && weaponid == 24 && (bodypart == 9))
	{
		//SetPlayerArmour(playerid, -armour);
   		SetPlayerHealth(playerid, -2);
	    SendClientMessage(playerid, COLOR_YELLOW, "DEBUG: Ai fost lovit in cap.");
	}
	if(issuerid != INVALID_PLAYER_ID && weaponid == 24 && (bodypart == 3))
	{
		//SetPlayerArmour(playerid, -armour);
   		SetPlayerHealth(playerid, -50);
	    SendClientMessage(playerid, COLOR_YELLOW, "DEBUG: Ai fost lovit in piept.");
	}
Reply
#2

Cuz you're setting the player life to -2.0. If a player life is less than zero, he have to die.
If you're trying to subtract 2.0 from player life you have to use GetPlayerHealth first (same for armour) and store it in a Float:variable, then SetPlayerHealth(playerid, variable - 2.0);

Tip: Don't mix integers and floats, use (-2.0) instead of (-2).
Reply
#3

Obviously because you're setting player's health to negative values. Health amount <= 0 will cause instant death.
EDIT : Late.
Reply
#4

Quote:

SetPlayerHealth(playerid, -2);

Should be:

new Float:hp;
GetPlayerHealth(playerid,hp);
SetPlayerHealth(playerid,hp - 2);
Reply
#5

You're setting player's health to a negative value. If you want to decrease player's health then you do GetPlayerHealth first then set player's health to returned value - amount.
Like this:
Код:
new Float:health;

GetPlayerHealth(playerid, health);
SetPlayerHealth(playerid, health - 50);
EDIT: 3 people were faster than me lol.
Reply
#6

Wow guys, thanks ALOT, I'll try to REP all of you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)