Headshot bug
#1

i used this on my TDM GameMode so if i headshot my enemies they will die even when i headshot my team mates they die how can i make it not able to kill team mates by headshoting them help please !
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9)
    {
        // One shot to the head to kill with sniper rifle
        SetPlayerHealth(playerid, 0.0);
    }
    return 1;
}
Reply
#2

use SetPlayerTeam/GetPlayerTeam
or any other variable created by you...

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9 && GetPlayerTeam(issuerid) != GetPlayerTeam(playerid))
    {
        // One shot to the head to kill with sniper rifle
        SetPlayerHealth(playerid, 0.0);
    }
    return 1;
}
I guess smthing like that.

(before that, you need to have same teams.. "SetPlayerTeam(playerid, teamid);"

EDIT: I just read that if you have same teams, you can't hit each other. nice.... XD
Reply
#3

dude listen when i hit My team mates i can't kill them but when i headshot them they dies without sending a death message like it won't show adrien killed luis and reason it will show adrien is dead reason without killer so team script works but headshot script has bugs
Reply
#4

I made a condition there... OnPlayerTakeDamage (maybe) works even on teammates. So you have to use that condition to avoid that.

(btw... If I understand correctly, you want to stop that team-killing, yea?)

#sorryForMyEnglish,It'sBest.
Reply
#5

Players in the same team shouldn't take damage if they shoot each other with the usage of SetPlayerTeam. Check your script and try again, maybe you have used gTeam[playerid] instead of SetPlayerTeam.
Reply
#6

i use SetPlayerTeam not gteam :v
Reply
#7

Okay. Sorry, if it sounds that you are an idiot, but... Are those players in the same team ? (hundred percents?)
If yes, idk then, sorry.
Reply
#8

PHP код:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponidbodypart)
{
    if(
issuerid != INVALID_PLAYER_ID// issuerid/ the one who uses the weapon isn't invalid.
    
{
        if(
GetPlayerTeam(playerid) != GetPlayerTeam(issuerid)) // checking teams are not same
        
{
            if(
weaponid == 34 && bodypart == 9// checking the weapon and body part
            
{
                new 
str[90];
                
format(strsizeof(str), "%s has headshotted %s"pName(issuerid), pName(playerid));
                
SendClientMessageToAll(0x5BC178FFstr);
                
SetPlayerHealth(playerid0.0); // We will always use float integer because health is in float!
            
}
        }
    }
    return 
1;
}
pName(playerid)
{
    new 
nameZ[MAX_PLAYER_NAME 1];
    
GetPlayerName(playeridnameZsizeof(nameZ));
    return 
nameZ;

Should be like this.
Reply
#9

first things yes it's the same team -_-
when i put this
Код:
 public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart) 
{ 
    if(issuerid != INVALID_PLAYER_ID) // issuerid/ the one who uses the weapon isn't invalid. 
    { 
        if(GetPlayerTeam(playerid) != GetPlayerTeam(issuerid)) // checking teams are not same 
        { 
            if(weaponid == 34 && bodypart == 9) // checking the weapon and body part 
            { 
                SetPlayerHealth(playerid, 0.0); // We will always use float integer because health is in float! 
            } 
        } 
    } 
    return 1; 
}
i get this error
Код:
577) : error 025: function heading differs from prototype
Line 577 is the first line (onplayertakedamage)
Reply
#10

Quote:
Originally Posted by TheRohlikar
Посмотреть сообщение
Isn't that same ? I mean.. is there a difference between his code and yours ?
Oops, didn't look at the whole code.

Quote:
Originally Posted by adrianlouise
Посмотреть сообщение
first things yes it's the same team -_-
when i put this
// CODE HERE //
i get this error
Код:
577) : error 025: function heading differs from prototype
Line 577 is the first line (onplayertakedamage)
Are you using YSI?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)