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



Headshot problem - Face9000 - 18.10.2012

I've a problem with my headshot system.

I can kill players even if they're in my team!

How i can fix this? It's annoying.

In the death chat the player dies without a killer.

I've anti team kill protection but with this headshot thing, if i aim at head at a player that is in my team, he gets killed.

I need to remove that

pawn Код:
public CheckHeadShot()
{
    new index;
    for(new playerid; playerid < maxPlayers; playerid++)
    {
        if(IsPlayerConnected(playerid))
        {
        index = GetPlayerAnimationIndex(playerid);
        if(index == 1173 || index == 1175 || index == 1177 || index == 1178)
        {
                SetPVarInt(playerid, "Headshotted", 1);
                SetPlayerHealth(playerid, 0);
            }
        }
    }
    return 1;
}
OnPlayerDeath:

pawn Код:
if(GetPVarInt(playerid, "Headshotted") == 1)
    {
        if (gTeam[playerid] == gTeam[killerid]) return 0;
        SetPVarInt(playerid, "Headshotted", 0);
        GameTextForPlayer(playerid, "~w~Head~r~shot!", 3000, 3);
        GameTextForPlayer(killerid, "~w~Head~r~shot!", 3000, 3);
        PlayerInfo[playerid][pHsReceived] ++;
        PlayerInfo[killerid][pHsMade] ++;
    }
As you can see, i added a gTeam check but doesn't work.


Re: Headshot problem - Danyal - 18.10.2012

Код:
public CheckHeadShot()
{
    new index;
    for(new playerid; playerid < maxPlayers; playerid++)
    {
        if(IsPlayerConnected(playerid))
        {
			index = GetPlayerAnimationIndex(playerid);
			if (gTeam[playerid] == gTeam[killerid])
			{
				return 0;
			}
			else if(index == 1173 || index == 1175 || index == 1177 || index == 1178)
			{
				SetPVarInt(playerid, "Headshotted", 1);
				SetPlayerHealth(playerid, 0);
			}
        }
    }
    return 1;
}

	if(GetPVarInt(playerid, "Headshotted") == 1)
    {
//        if (gTeam[playerid] == gTeam[killerid]) return 0;
        SetPVarInt(playerid, "Headshotted", 0);
        GameTextForPlayer(playerid, "~w~Head~r~shot!", 3000, 3);
        GameTextForPlayer(killerid, "~w~Head~r~shot!", 3000, 3);
        PlayerInfo[playerid][pHsReceived] ++;
        PlayerInfo[killerid][pHsMade] ++;
    }
Edit: Try It Hope It Will Work


Re: Headshot problem - Glint - 18.10.2012

Danyal i appreciate you helping him but you also need to tell him what you did so he can understand


Re: Headshot problem - Danyal - 18.10.2012

i have checked if player team is equal to team mate at public CheckHeadShot()
it will check every headshot if player team is equal to team mate it will return as 0 and no headshot will occur by team mates


Re: Headshot problem - Face9000 - 18.10.2012

Quote:
Originally Posted by Glint
Посмотреть сообщение
Danyal i appreciate you helping him but you also need to tell him what you did so he can understand
No problem, i understand without any explanation.

Danyal thanks very much for help, i'll try now.

Working or not you deserve +rep


Re: Headshot problem - Glint - 18.10.2012

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
No problem, i understand without any explanation.

Danyal thanks very much for help, i'll try now.

Working or not you deserve +rep
I know but there are people who want to learn


Re: Headshot problem - Face9000 - 18.10.2012

Quote:
Originally Posted by Glint
Посмотреть сообщение
I know but there are people who want to learn
Agreed

It works,thanks Danyal!