problem with adjusting weapon damage for health and armor
#1

as the tittle say , i got problem after put code this

Code:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
	if(issuerid != INVALID_PLAYER_ID)
	{
	    new Float:stat[2];
    	GetPlayerHealth(playerid, stat[0]);
    	GetPlayerArmour(playerid, stat[1]);
	    if(stat[1] >= 1 )
	    {
		    if(weaponid == 1) SetPlayerHealth(playerid,stat[1]-10);
			if(weaponid == 2) SetPlayerHealth(playerid,stat[1]-20);
			if(weaponid == 3) SetPlayerHealth(playerid,stat[1]-20);
			if(weaponid == 4) SetPlayerHealth(playerid,stat[1]-50);
			if(weaponid == 5) SetPlayerHealth(playerid,stat[1]-30);
			if(weaponid == 6) SetPlayerHealth(playerid,stat[1]-25);
			if(weaponid == 7) SetPlayerHealth(playerid,stat[1]-15);
			if(weaponid == 8) SetPlayerHealth(playerid,stat[1]-75);
			if(weaponid == 9) SetPlayerHealth(playerid,stat[1]-50);
			if(weaponid == 16) SetPlayerHealth(playerid,stat[1]-500);
			if(weaponid == 22) SetPlayerHealth(playerid,stat[1]-25);
			if(weaponid == 23) SetPlayerHealth(playerid,stat[1]-25);
			if(weaponid == 24) SetPlayerHealth(playerid,stat[1]-75);
			if(weaponid == 27) SetPlayerHealth(playerid,stat[1]-75);
			if(weaponid == 28) SetPlayerHealth(playerid,stat[1]-30);
			if(weaponid == 29) SetPlayerHealth(playerid,stat[1]-35);
			if(weaponid == 30) SetPlayerHealth(playerid,stat[1]-45);
			if(weaponid == 31) SetPlayerHealth(playerid,stat[1]-45);
			if(weaponid == 32) SetPlayerHealth(playerid,stat[1]-30);
			if(weaponid == 34) SetPlayerHealth(playerid,stat[1]-100);
			if(weaponid == 35) SetPlayerHealth(playerid,stat[1]-100);
			if(weaponid == 38) SetPlayerHealth(playerid,stat[1]-100);
	    }
	    else if(stat[1] == 0)
	    {
			if(weaponid == 1) SetPlayerHealth(playerid,stat[0]-10);
			if(weaponid == 2) SetPlayerHealth(playerid,stat[0]-20);
			if(weaponid == 3) SetPlayerHealth(playerid,stat[0]-20);
			if(weaponid == 4) SetPlayerHealth(playerid,stat[0]-50);
			if(weaponid == 5) SetPlayerHealth(playerid,stat[0]-30);
			if(weaponid == 6) SetPlayerHealth(playerid,stat[0]-25);
			if(weaponid == 7) SetPlayerHealth(playerid,stat[0]-15);
			if(weaponid == 8) SetPlayerHealth(playerid,stat[0]-75);
			if(weaponid == 9) SetPlayerHealth(playerid,stat[0]-50);
			if(weaponid == 16) SetPlayerHealth(playerid,stat[0]-500);
			if(weaponid == 22) SetPlayerHealth(playerid,stat[0]-25);
			if(weaponid == 23) SetPlayerHealth(playerid,stat[0]-25);
			if(weaponid == 24) SetPlayerHealth(playerid,stat[0]-75);
			if(weaponid == 27) SetPlayerHealth(playerid,stat[0]-75);
			if(weaponid == 28) SetPlayerHealth(playerid,stat[0]-30);
			if(weaponid == 29) SetPlayerHealth(playerid,stat[0]-35);
			if(weaponid == 30) SetPlayerHealth(playerid,stat[0]-45);
			if(weaponid == 31) SetPlayerHealth(playerid,stat[0]-45);
			if(weaponid == 32) SetPlayerHealth(playerid,stat[0]-30);
			if(weaponid == 34) SetPlayerHealth(playerid,stat[0]-100);
			if(weaponid == 35) SetPlayerHealth(playerid,stat[0]-100);
			if(weaponid == 38) SetPlayerHealth(playerid,stat[0]-100);
		}
	}
	return 1;
}
I want if someone shoot the player and the armor is decreased first , and if armor = 0. the health will decreased
But i test it , if i shoot the people using armor. Armor and Health is decreased

What should i do on that code ?
Reply
#2

You can try one working 100% and without problems
http://forum.sa-mp.com/showthread.ph...52#post2718252
Reply
#3

Quote:
Originally Posted by Lidor124
View Post
You can try one working 100% and without problems
http://forum.sa-mp.com/showthread.ph...52#post2718252
but that is just Health not armor
Reply
#4

delete if(stat[1] >= 1 ) {...}
and make just one If
Reply
#5

[/CODE]public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
* * new Float:HP;
new Float:Armor
* * GetPlayerHealth(playerid, HP);
GetPlayerArmour(playerid, Armor);
* * if(weaponid == 24) SetPlayerHealth(playerid, HP-51);//DesertEagle
if(weaponid ==24) SetPlayerArmour(playerid, Armor-51); // You can continue its an example

* * if(weaponid == 22) SetPlayerHealth(playerid, HP-35);//Colt45
* * if(weaponid == 23) SetPlayerHealth(playerid, HP-30);//SilencedColt
* * if(weaponid == 31) SetPlayerHealth(playerid, HP-25);//M4
* * if(weaponid == 30) SetPlayerHealth(playerid, HP-35);//AK
* * if(weaponid == 29) SetPlayerHealth(playerid, HP-30);//MP5
* * if(weaponid == 34) SetPlayerHealth(playerid, HP-100);//SniperRifle
* * if(weaponid == 33) SetPlayerHealth(playerid, HP-50);//CountryRifle
* * if(weaponid == 25) SetPlayerHealth(playerid, HP-40);//PumpShotgun
* * if(weaponid == 27) SetPlayerHealth(playerid, HP-25);//Spaz12
* * //SOUND
* * if(issuerid != INVALID_PLAYER_ID) PlayerPlaySound(issuerid,17802,0.0,0.0,0.0), PlayerPlaySound(playerid,17802,0.0,0.0,0.0);
* * return 1;
}[/code]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)