Player's armour refills to 100 when taking damage
#1

When a player has armour and it gets near low and a player shoots them it sets their armour to 100 again, i dont know whats causing this but here is my onplayertakedamage

Code:
	if(weaponid == 24) // DEAGLE
	{

  		if (armour > 3.0)
  		{
     		SetPlayerArmour(playerid, armour-45.0);
  		}
  		else if (armour < 4.0)
  		{
     		SetPlayerArmour(playerid, 0);
  		}
    	if (health > 3.0 && armour < 1)
  		{
     		SetPlayerHealth(playerid, health-27.0);
  		}
    	else if (health < 3.0 && armour < 1)
     	{
       		SetPlayerHealth(playerid, 0.0);
  		}
 	}
it happens with all guns but all the weaponids are the same layout as this above.
Reply
#2

What do you want to do? I don't understand how this code can work.
Reply
#3

Try this
PHP Code:
if(weaponid == 24// DEAGLE
    
{

          if (
armour 45.0)
          {
             
SetPlayerArmour(playeridarmour-45.0);
          }
          else if (
armour 45.0)
          {
             
SetPlayerArmour(playerid0);
          }
        if (
health 27.0 && armour 1)
          {
             
SetPlayerHealth(playeridhealth-27.0);
          }
        else if (
health 27.0 && armour 1)
         {
               
SetPlayerHealth(playerid0.0);
          }
     } 
Reply
#4

Press CTRL+f and search "SetPlayerArmour(playerid, 100);". Maybe you are using a timer or OnPlayerUpdate which sets the players armour to 100 in every seconds. You cand search also for "SetPlayerArmour(i, 100);", SetPlayerArmour(x, 100); in case that you are using foreach.
Reply
#5

Quote:
Originally Posted by xTURBOx
View Post
Try this
PHP Code:
          if (armour 45.0)
          {
             
SetPlayerArmour(playeridarmour-45.0);
          } 
That should do it. Because this:
Quote:
Originally Posted by Matical
View Post
Code:
  		if (armour > 3.0)
  		{
     		SetPlayerArmour(playerid, armour-45.0);
  		}
Makes absolutely no sense. If a player has 5.0 armor and you subtract 45 then the armor will be set to -40. And because armor can only be set to values between 0 and 255, that value of -40 will wrap around and actually become 216.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)