damage based on body part doesnt lower hp!
#1

hello all i tried to make a damage based on body part by using OnPlayerTakeDamage. But when i shoot/hit a player. Their hp stays 100 again! Any help is appreciated.

Code:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
	new Float:armour;
	GetPlayerArmour(playerid,armour);
	new Float:hpplayer;
	GetPlayerHealth(playerid,hpplayer);
	if(armour>0)
	{
	    if(bodypart==9)
	    {
			new Float:hpamount,Float:amamount,Float:sethp,Float:setam;
			amamount=(amount/100)*25;
			hpamount=(amount/100)*75;
			sethp=hpplayer-hpamount;
			setam=armour-amamount;
			SetPlayerArmour(playerid,setam);
			SetPlayerHealth(playerid,sethp);
	    }
	    if(bodypart==3 || bodypart==4)
	    {
			new Float:hpamount,Float:amamount,Float:sethp,Float:setam;
			amamount=(amount/100)*50;
			hpamount=(amount/100)*50;
			sethp=hpplayer-hpamount;
			setam=armour-amamount;
			SetPlayerArmour(playerid,setam);
			SetPlayerHealth(playerid,sethp);
	    }
	    if(bodypart==5 || bodypart==6 || bodypart==7 || bodypart==8)
	    {
	        new Float:sethp;
	        sethp=hpplayer-((amount/4)*3);
			SetPlayerHealth(playerid,sethp);
	    }
	}
	else
	{
	    if(bodypart==9)
	    {
	        new Float:sethp;
	        sethp=hpplayer-(((amount/4)*3)+amount);
	        SetPlayerHealth(playerid,sethp);
	    }
	    if(bodypart==3 || bodypart==4)
	    {
	        new Float:sethp;
	        sethp=hpplayer-((amount/4)+amount);
			SetPlayerHealth(playerid,sethp);
	    }
	    if(bodypart==5 || bodypart==6 || bodypart==7 || bodypart==8)
	    {
	        new Float:sethp;
	        sethp=hpplayer-((amount/4)*3);
			SetPlayerHealth(playerid,sethp);
	    }
	}
	return 1;
}
Reply
#2

give me a moment the variable "sethp" too, please.
Reply
#3

give a moment ? what do you mean ?
Reply
#4

Quote:

SetPlayerHealth (playerid, sethp);

in that line there is a variable between that, look for that variable and pass it to see if I can help you with something, or just do it manually removing the sethp putting it, yes 25,30, bla, bla, bla. I'm sorry for my bad english, I am Latin American :/
I hope I have explained
Reply
#5

but then both a colt45 and a sniper would hit same damage. thats why game already defines a variable called amount.. i really feel stupid this should have work.
Reply
#6

Quote:
Originally Posted by grymtn
View Post
but then both a colt45 and a sniper would hit same damage. thats why game already defines a variable called amount.. i really feel stupid this should have work.
ahh, what you want to do is a real damage system right? I'm already telling you about it.
Reply
#7

so you tell me that i should use like

Code:
SetPlayerHealth(playerid,hpplayer-damagedealth);
instead of using sethp variable?
Reply
#8

Code:
			{
         		switch(weaponid)
			 	{
				    case 22,23:
					{
					    switch(bodypart)
					 	{
							case 3,4: damage = 45.0;
							case 5..8: damage = 20.0;
							case 9: damage = 200.0;
						}
		    		}
                    case 24:
				 	{
					    switch(bodypart)
					 	{
							case 3,4: damage = 70.0;
							case 5..8: damage = 35.0;
							case 9: damage = 200.0;
						}
                    }
       				case 25..27:
			   		{
		 	    		switch(bodypart)
					 	{
							case 3,4: damage = 90.0;
							case 5..8: damage = 50.0;
							case 9: damage = 200.0;
						}
				 	}
     				case 28,32:
				  	{
					    switch(bodypart)
					 	{
							case 3,4: damage = 45.0;
							case 5..8: damage = 20.0;
							case 9: damage = 200.0;
						}
                    }
		          	case 29:
				  	{
					    switch(bodypart)
					 	{
							case 3,4: damage = 55.0;
							case 5..8: damage = 30.0;
							case 9: damage = 200.0;
						}
                    }
	         		case 30:
				 	{
         				switch(bodypart)
					 	{
							case 3,4: damage = 65.0;
							case 5..8: damage = 40.0;
							case 9: damage = 200.0;
						}
                    }
		         	case 31:
				 	{
					    switch(bodypart)
					 	{
							case 3,4: damage = 60.0;
							case 5..8: damage = 35.0;
							case 9: damage = 200.0;
						}
                    }
		         	case 33:
				 	{
					    switch(bodypart)
					 	{
							case 3,4: damage = 80.0;
							case 5..8: damage = 40.0;
							case 9: damage= 200.0;
						}
                    }
		         	case 34:
				 	{
					    switch(bodypart)
					 	{
							case 3,4: damage = 100.0;
							case 5..8: damage = 60.0;
							case 9: damage = 200.0;
						}
                    }
                    default: danio = amount;
           		}
           		format(string, sizeof(string), "damage you received per shot: %f", damage);
				SendClientMessage(-1, playerid, string);
				format(string, sizeof(string), "Damage you've taken with the shot: %f", damage);
				SendClientMessage(-1, issuerid, string);
           		FadePlayerScreen(playerid, 0xE20000FF, 25);
			}
		}
It would be something like this, look, in each case there are the ID's of the weapons, you can find them also in the wiki-samp, look at damage to side would be the damage that would do and also in the part of the body that would give the same, bone I do not know if I explain myself because I do not know almost English, what I want to tell you, next to damage, is, bone, example

case 3,4: / * body part where it would give the damage * / damage = 100.0 // the damage it would do

it would be something like this, try to imagine something like fix it, if you have more doubts go to the priv and there we talk better

These are images of the parts of the body in which they are enabled.


sorry for the disorder of the code, what happens is that I made copy paste of a system that had kept here.
Reply
#9

I have the system code, but it's in Spanish, it's was put down by me. I will pass it to you so that you take a look and look to see that.

PHP Code:
#include <a_samp>
#include <fader>
#include <foreach>
#include <sscanf2>
#include <zcmd>
new Fuerza[MAX_PLAYERS];
public 
OnFilterScriptInit()
{
    foreach(new 
iPlayer)
    {
        
SetPlayerTeam(i1);
     }
    return 
1;
}
public 
OnFilterScriptExit()
{
    foreach(new 
iPlayer)
    {
        
SetPlayerTeam(i, -1);
     }
     
Seifader_OnExit();
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    
SetPlayerTeam(playerid1);
    
Fuerza[playerid] = 1;
    return 
1;
}
public 
OnPlayerTakeDamage(playeridissueridFloatamountweaponidbodypart)
{
    new 
Float:danioFloat:vidaFloat:chalecostring[256];
    new 
fuerza Fuerza[issuerid];
    if(
issuerid != INVALID_PLAYER_ID)
    {
        if(
amount == 2.64)
        {
            if(
GetPlayerWeapon(issuerid) > 21 && GetPlayerWeapon(issuerid) < 34)
            {
                switch(
fuerza)
                {
                    case 
0..10danio 11.5;
                      case 
11..20danio 12.0;
                    case 
21..30danio 12.5;
                      case 
31..40danio 13.0;
                    case 
41..50danio 13.5;
                    case 
51..60danio 14.0;
                    case 
61..70danio 14.5;
                       case 
71..80danio 15.0;
                      case 
81..90danio 15.5;
                    case 
91..100danio 16.0;
                }
            }
        }
        else
        {
            if(
weaponid >= && weaponid 16)
            {
                switch(
weaponid)
                {
                    case 
0:
                    {
                         switch(
bodypart)
                         {
                             case 
3:
                             {
                                switch(
fuerza)
                                {
                                       case 
0..10danio 3.0;
                                    case 
11..20danio 3.5;
                                    case 
21..30danio 4.0;
                                    case 
31..40danio 4.5;
                                    case 
41..50danio 5.0;
                                    case 
51..60danio 5.5;
                                    case 
61..70danio 6.0;
                                    case 
71..80danio 6.5;
                                    case 
81..90danio 7.0;
                                    case 
91..100danio 7.5;
                                }
                            }
                            case 
4:
                             {
                                switch(
fuerza)
                                {
                                       case 
0..10danio 4.5;
                                    case 
11..20danio 5.0;
                                    case 
21..30danio 5.5;
                                    case 
31..40danio 6.0;
                                    case 
41..50danio 6.5;
                                    case 
51..60danio 7.0;
                                    case 
61..70danio 7.5;
                                    case 
71..80danio 8.0;
                                    case 
81..90danio 8.5;
                                    case 
91..100danio 9.0;
                                }
                            }
                            case 
5..8:
                             {
                                switch(
fuerza)
                                {
                                       case 
0..10danio 2.0;
                                    case 
11..20danio 2.5;
                                    case 
21..30danio 3.0;
                                    case 
31..40danio 3.5;
                                    case 
41..50danio 4.0;
                                    case 
51..60danio 4.5;
                                    case 
61..70danio 5.0;
                                    case 
71..80danio 5.5;
                                    case 
81..90danio 6.0;
                                    case 
91..100danio 6.5;
                                }
                            }
                             case 
9:
                             {
                                switch(
fuerza)
                                {
                                       case 
0..10danio 4.0;
                                    case 
11..20danio 4.5;
                                    case 
21..30danio 5.0;
                                    case 
31..40danio 5.5;
                                    case 
41..50danio 6.0;
                                    case 
51..60danio 6.5;
                                    case 
61..70danio 7.0;
                                    case 
71..80danio 7.5;
                                    case 
81..90danio 8.0;
                                    case 
91..100danio 8.5;
                                }
                            }
                        }
                    }
                     case 
1:
                     {
                         switch(
bodypart)
                         {
                             case 
3:
                             {
                                switch(
fuerza)
                                {
                                       case 
0..10danio 4.0;
                                    case 
11..20danio 4.5;
                                    case 
21..30danio 5.0;
                                    case 
31..40danio 5.5;
                                    case 
41..50danio 6.0;
                                    case 
51..60danio 6.5;
                                    case 
61..70danio 7.0;
                                    case 
71..80danio 7.5;
                                    case 
81..90danio 8.0;
                                    case 
91..100danio 8.5;
                                }
                            }
                            case 
4:
                             {
                                switch(
fuerza)
                                {
                                       case 
0..10danio 5.5;
                                    case 
11..20danio 6.0;
                                    case 
21..30danio 6.5;
                                    case 
31..40danio 7.0;
                                    case 
41..50danio 7.5;
                                    case 
51..60danio 8.0;
                                    case 
61..70danio 8.5;
                                    case 
71..80danio 9.0;
                                    case 
81..90danio 9.5;
                                    case 
91..100danio 10.0;
                                }
                            }
                            case 
5..8:
                             {
                                switch(
fuerza)
                                {
                                       case 
0..10danio 3.0;
                                    case 
11..20danio 3.5;
                                    case 
21..30danio 4.0;
                                    case 
31..40danio 4.5;
                                    case 
41..50danio 5.0;
                                    case 
51..60danio 5.5;
                                    case 
61..70danio 6.0;
                                    case 
71..80danio 6.5;
                                    case 
81..90danio 7.0;
                                    case 
91..100danio 7.5;
                                }
                            }
                             case 
9:
                             {
                                switch(
fuerza)
                                {
                                       case 
0..10danio 5.0;
                                    case 
11..20danio 5.5;
                                    case 
21..30danio 6.0;
                                    case 
31..40danio 6.5;
                                    case 
41..50danio 7.0;
                                    case 
51..60danio 7.5;
                                    case 
61..70danio 8.0;
                                    case 
71..80danio 8.5;
                                    case 
81..90danio 9.0;
                                    case 
91..100danio 9.5;
                                }
                            }
                        }
                    }
                     case 
2,3,5,6,7,15:
                     {
                         switch(
bodypart)
                         {
                             case 
3:
                             {
                                switch(
fuerza)
                                {
                                       case 
0..10danio 6.0;
                                    case 
11..20danio 6.5;
                                    case 
21..30danio 7.0;
                                    case 
31..40danio 7.5;
                                    case 
41..50danio 8.0;
                                    case 
51..60danio 8.5;
                                    case 
61..70danio 9.0;
                                    case 
71..80danio 9.5;
                                    case 
81..90danio 10.0;
                                    case 
91..100danio 10.5;
                                }
                            }
                            case 
4:
                             {
                                switch(
fuerza)
                                {
                                       case 
0..10danio 10.5;
                                    case 
11..20danio 11.0;
                                    case 
21..30danio 11.5;
                                    case 
31..40danio 12.0;
                                    case 
41..50danio 12.5;
                                    case 
51..60danio 13.0;
                                    case 
61..70danio 13.5;
                                    case 
71..80danio 14.0;
                                    case 
81..90danio 14.5;
                                    case 
91..100danio 15.0;
                                }
                            }
                            case 
5..8:
                             {
                                switch(
fuerza)
                                {
                                       case 
0..10danio 5.0;
                                    case 
11..20danio 5.5;
                                    case 
21..30danio 6.0;
                                    case 
31..40danio 6.5;
                                    case 
41..50danio 7.0;
                                    case 
51..60danio 7.5;
                                    case 
61..70danio 8.0;
                                    case 
71..80danio 8.5;
                                    case 
81..90danio 9.0;
                                    case 
91..100danio 9.5;
                                }
                            }
                             case 
9:
                             {
                                switch(
fuerza)
                                {
                                       case 
0..10danio 10.0;
                                    case 
11..20danio 10.5;
                                    case 
21..30danio 11.0;
                                    case 
31..40danio 11.5;
                                    case 
41..50danio 12.0;
                                    case 
51..60danio 12.5;
                                    case 
61..70danio 13.0;
                                    case 
71..80danio 13.5;
                                    case 
81..90danio 14.0;
                                    case 
91..100danio 14.5;
                                }
                            }
                        }
                    }
                     case 
4:
                     {
                         switch(
bodypart)
                         {
                             case 
3:
                             {
                                switch(
fuerza)
                                {
                                       case 
0..10danio 10.0;
                                    case 
11..20danio 10.5;
                                    case 
21..30danio 11.0;
                                    case 
31..40danio 11.5;
                                    case 
41..50danio 12.0;
                                    case 
51..60danio 12.5;
                                    case 
61..70danio 13.0;
                                    case 
71..80danio 13.5;
                                    case 
81..90danio 14.0;
                                    case 
91..100danio 14.5;
                                }
                            }
                            case 
4:
                             {
                                switch(
fuerza)
                                {
                                       case 
0..10danio 12.5;
                                    case 
11..20danio 13.0;
                                    case 
21..30danio 13.5;
                                    case 
31..40danio 14.0;
                                    case 
41..50danio 14.5;
                                    case 
51..60danio 15.0;
                                    case 
61..70danio 15.5;
                                    case 
71..80danio 16.0;
                                    case 
81..90danio 16.5;
                                    case 
91..100danio 17.0;
                                }
                            }
                            case 
5..8:
                             {
                                switch(
fuerza)
                                {
                                       case 
0..10danio 6.0;
                                    case 
11..20danio 6.5;
                                    case 
21..30danio 7.0;
                                    case 
31..40danio 7.5;
                                    case 
41..50danio 8.0;
                                    case 
51..60danio 8.5;
                                    case 
61..70danio 9.0;
                                    case 
71..80danio 9.5;
                                    case 
81..90danio 10.0;
                                    case 
91..100danio 10.5;
                                }
                            }
                             case 
9:
                             {
                                switch(
fuerza)
                                {
                                       case 
0..10danio 12.0;
                                    case 
11..20danio 12.5;
                                    case 
21..30danio 13.0;
                                    case 
31..40danio 13.5;
                                    case 
41..50danio 14.0;
                                    case 
51..60danio 14.5;
                                    case 
61..70danio 15.0;
                                    case 
71..80danio 15.5;
                                    case 
81..90danio 16.0;
                                    case 
91..100danio 16.5;
                                }
                            }
                        }
                    }
                     case 
8:
                     {
                         switch(
bodypart)
                         {
                             case 
3,4:
                             {
                                switch(
fuerza)
                                {
                                       case 
0..10danio 15.0;
                                    case 
11..20danio 15.5;
                                    case 
21..30danio 16.0;
                                    case 
31..40danio 16.5;
                                    case 
41..50danio 17.0;
                                    case 
51..60danio 17.5;
                                    case 
61..70danio 18.0;
                                    case 
71..80danio 18.5;
                                    case 
81..90danio 19.0;
                                    case 
91..100danio 19.5;
                                }
                            }
                            case 
5..8:
                             {
                                switch(
fuerza)
                                {
                                       case 
0..10danio 12.0;
                                    case 
11..20danio 12.5;
                                    case 
21..30danio 13.0;
                                    case 
31..40danio 13.5;
                                    case 
41..50danio 14.0;
                                    case 
51..60danio 14.5;
                                    case 
61..70danio 15.0;
                                    case 
71..80danio 15.5;
                                    case 
81..90danio 16.0;
                                    case 
91..100danio 16.5;
                                }
                            }
                             case 
9danio 200;
                        }
                    }
                    default: 
danio amount;
                 }
                 
format(stringsizeof(string), "Daсo que has recibido por el golpe/corte: %f | Fuerza del agresor: %d"daniofuerza);
                
SendClientMessage(-1playeridstring);
                
format(stringsizeof(string), "Daсo que has efectuado con el golpe/corte: %f"danio);
                
SendClientMessage(-1issueridstring);
            }
            if(
weaponid 21 && weaponid 52)
            {
                 switch(
weaponid)
                 {
                    case 
22,23:
                    {
                        switch(
bodypart)
                         {
                            case 
3,4danio 45.0;
                            case 
5..8danio 20.0;
                            case 
9danio 200.0;
                        }
                    }
                    case 
24:
                     {
                        switch(
bodypart)
                         {
                            case 
3,4danio 70.0;
                            case 
5..8danio 35.0;
                            case 
9danio 200.0;
                        }
                    }
                       case 
25..27:
                       {
                         switch(
bodypart)
                         {
                            case 
3,4danio 90.0;
                            case 
5..8danio 50.0;
                            case 
9danio 200.0;
                        }
                     }
                     case 
28,32:
                      {
                        switch(
bodypart)
                         {
                            case 
3,4danio 45.0;
                            case 
5..8danio 20.0;
                            case 
9danio 200.0;
                        }
                    }
                      case 
29:
                      {
                        switch(
bodypart)
                         {
                            case 
3,4danio 55.0;
                            case 
5..8danio 30.0;
                            case 
9danio 200.0;
                        }
                    }
                     case 
30:
                     {
                         switch(
bodypart)
                         {
                            case 
3,4danio 65.0;
                            case 
5..8danio 40.0;
                            case 
9danio 200.0;
                        }
                    }
                     case 
31:
                     {
                        switch(
bodypart)
                         {
                            case 
3,4danio 60.0;
                            case 
5..8danio 35.0;
                            case 
9danio 200.0;
                        }
                    }
                     case 
33:
                     {
                        switch(
bodypart)
                         {
                            case 
3,4danio 80.0;
                            case 
5..8danio 40.0;
                            case 
9danio 200.0;
                        }
                    }
                     case 
34:
                     {
                        switch(
bodypart)
                         {
                            case 
3,4danio 100.0;
                            case 
5..8danio 60.0;
                            case 
9danio 200.0;
                        }
                    }
                    default: 
danio amount;
                   }
                   
format(stringsizeof(string), "Daсo que has recibido por disparo: %f"danio);
                
SendClientMessage(-1playeridstring);
                
format(stringsizeof(string), "Daсo que has efectuado con el disparo: %f"danio);
                
SendClientMessage(-1issueridstring);
                   
FadePlayerScreen(playerid0xE20000FF25);
            }
        }
        
GetPlayerHealth(playeridvida);
          
GetPlayerArmour(playeridchaleco);
           if(
chaleco)
          {
            if(
chaleco danioSetPlayerArmour(playeridchaleco-danio);
             else
             {
                  
SetPlayerArmour(playerid0.0);
                
chaleco danio-chaleco;
                 if(
chaleco >= vidaSetPlayerHealth(playerid0.0);
                  else 
SetPlayerHealth(playeridvida-chaleco);
            }
        }
        else
        {
            if(
vida danioSetPlayerHealth(playeridvida-danio);
             else 
SetPlayerHealth(playerid0.0);
        }
    }
    return 
1;
}
stock Nombre(playerid)
{
    new 
nombre[32];
    
GetPlayerName(playeridnombre32);
    return 
nombre;
}
COMMAND:darfuerza(playeridparams[])
{
    if(!
sscanf(params"ui"params[0], params[1]))
    {
         if(
params[0] != INVALID_PLAYER_ID)
         {
             if(
params[1] < || params[1] > 100) return SendClientMessage(playerid, -1"[ERROR] Sуlo puedes dar entre 1 y 100 de fuerza.");
              
Fuerza[params[0]] = params[1];
              new 
string[128];
            
format(stringsizeof(string), "%s te ha dado %d de fuerza."Nombre(playerid), params[1]);
            
SendClientMessage(params[0], -1string);
        }
        else 
SendClientMessage(playerid, -1"[ERROR] El jugador seleccionado no se encuentra conectado.");
    }
    else 
SendClientMessage(playerid, -1"[USO] '/darfuerza' [ID Jugador] [Fuerza 1-100]");
      return 
1;
}
COMMAND:fuerza(playeridparams[])
{
    new 
string[128];
    
format(stringsizeof(string), "Tienes %d de fuerza."Fuerza[playerid]);
    
SendClientMessage(playerid, -1string);
      return 
1;

Reply
#10

Its okay about disordered code haha. Thanks for lighting it up for me but still this is giving basic damage to each weapon and not actually using the default damage of a weapon. Im interested in default damages if possible. +rep given for the work you gave on here
Reply
#11

pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    new Float:armour, Float:hpplayer, Float:hpamount, Float:amamount;
    GetPlayerArmour(playerid,armour);
    GetPlayerHealth(playerid,hpplayer);
    if(armour>0)
    {
        switch(bodypart)
        {
            case 3, 4:
            {
                amamount=(amount/100)*50;
                hpamount=(amount/100)*50;
                SetPlayerArmour(playerid,floatsub(hpplayer, hpamount));
                SetPlayerHealth(playerid,floatsub(armour, amamount));
            }
           
            case 5 .. 8:
            {
                hpamount = (amount/4)*3;
                SetPlayerHealth(playerid,floatsub(hpplayer, hpamount));
            }
            case 9:
            {
                amamount=(amount/100)*25;
                hpamount=(amount/100)*75;
                SetPlayerArmour(playerid,floatsub(hpplayer, hpamount));
                SetPlayerHealth(playerid,floatsub(armour, amamount));
            }
        }
    }
    else
    {
        switch(bodypart)
        {
            case 3, 4:
            {
                hpamount = (amount/4)+amount;
                SetPlayerHealth(playerid,floatsub(hpplayer, hpamount));
            }
           
            case 5 .. 8:
            {
                hpamount = (amount/4)*3;
                SetPlayerHealth(playerid,floatsub(hpplayer, hpamount));
            }
           
            case 9:
            {
                hpamount = ((amount/4)*3)+amount;
                SetPlayerHealth(playerid,floatsub(hpplayer, hpamount));
            }  
        }
    }
    return 1;
}
I'm not sure if this would fix your problem, but let me know about the outcome of it.
Reply
#12

nope still only taking hp by fisting. weapons still do no damage.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)