SA-MP Forums Archive
Player's armour refills to 100 when taking damage - 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)
+--- Thread: Player's armour refills to 100 when taking damage (/showthread.php?tid=609739)



Player's armour refills to 100 when taking damage - Matical - 16.06.2016

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.


Re: Player's armour refills to 100 when taking damage - Dayrion - 16.06.2016

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


Re: Player's armour refills to 100 when taking damage - xTURBOx - 16.06.2016

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);
          }
     } 



Re: Player's armour refills to 100 when taking damage - Nin9r - 16.06.2016

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.


Re: Player's armour refills to 100 when taking damage - Vince - 16.06.2016

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.