SA-MP Forums Archive
Headshot help - 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: Headshot help (/showthread.php?tid=605578)



Headshot help - SaiyanZ - 21.04.2016

Hello, I need a little help in my headshot system, If it is right i made it, It was working fine without anti team headshot, But when i added that now i can't headshot, If i headshot my teammates they don't lose health thats good but now headshot is not working.
PHP код:
if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && weaponid == 23 && BODY_PART_HEAD == 9)
      {
      if (
gTeam[playerid] == gTeam[issuerid])
      {
      
SetPlayerHealth(playerid, -0);
      
SendClientMessage(issuerid, -1"You can't headshot your teammates");
      }
      else
      {
      
SetPlayerHealth(playerid, -100); 
Did something wrong?
No errors


Re: Headshot help - J0sh... - 21.04.2016

BODY_PART_HEAD == 9
Erm, of course it equals to 9! It should be bodypart == 9


Re: Headshot help - oMa37 - 21.04.2016

Try this

PHP код:

if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && weaponid == 23 && bodypart == 9)
      {
      if(
gTeam[playerid] == gTeam[issuerid])
      {
      
SetPlayerHealth(playerid0);
      
SendClientMessage(playerid, -1"You can't headshot your teammates");
      }
      else
      {
      
SetPlayerHealth(playerid0); 



Re: Headshot help - SaiyanZ - 21.04.2016

Quote:
Originally Posted by oMa37
Посмотреть сообщение
Try this

PHP код:

if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && weaponid == 23 && bodypart == 9)
      {
      if(
gTeam[playerid] == gTeam[issuerid])
      {
      
SetPlayerHealth(playerid0);
      
SendClientMessage(playerid, -1"You can't headshot your teammates");
      }
      else
      {
      
SetPlayerHealth(playerid0); 
Undefined symbol "bodypart"



Re: Headshot help - oMa37 - 21.04.2016

Quote:
Originally Posted by SaiyanZ
Посмотреть сообщение
Undefined symbol "bodypart"
Also try upgrading your files to the latest samp version.


Re: Headshot help - iKevin - 21.04.2016

Quote:
Originally Posted by TopShooter
Посмотреть сообщение
You need the a_samp include version which has the "BodyPart"
None does.

What callback is this? OnPlayerTakeDamage?

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && weaponid == 23 && BODY_PART_HEAD == 9)
    {
    	if (gTeam[playerid] == gTeam[issuerid])
     	{
      		SetPlayerHealth(playerid, -0);
        	SendClientMessage(issuerid, -1, "You can't headshot your teammates");
         }
         else
         {
         	SetPlayerHealth(playerid, -100);
         }
    }
}



Re: Headshot help - SaiyanZ - 21.04.2016

Quote:
Originally Posted by KevinExec
Посмотреть сообщение
None does.

What callback is this? OnPlayerTakeDamage?
Yes, Its OnPlayerTakeDamage.


Re: Headshot help - iKevin - 21.04.2016

I have edited my last post. Check if works.


Re: Headshot help - oMa37 - 21.04.2016

Try changing your whole code with this:

PHP код:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponidbodypart)
{
    if(
issuerid != INVALID_PLAYER_ID)
    {  
         if(
weaponid == 34 || weaponid == 23)
         {  
            if(
bodypart == 9
              { 
                  if(
gTeam[playerid] == gTeam[issuerid]) 
                  { 
                      
SetPlayerHealth(playerid0); 
                      
SendClientMessage(playerid, -1"You can't headshot your teammates"); 
                  } 
                  else 
                 { 
                      
SetPlayerHealth(playerid0);  
                  }
              }
          }
    }                  
    return 
1;