SA-MP Forums Archive
Help with Headshot System - 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: Help with Headshot System (/showthread.php?tid=625649)



Help with Headshot System - nahum2003 - 04.01.2017

Hello all, friends of our samp comunity. I am here, becoz i have a problem with my Headshot system. Players can kill Admin on duty. And that is some annoying for everyone (in special admins) i want to fix that problem. I've made a headshot system but i want that can't kill on duty admin.

Sorry for ma bad english. Here code

Код:
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
            {
                new str[90];
                format(str, sizeof(str), "%s has headshotted %s", pName(issuerid), pName(playerid));
                GameTextForPlayer(issuerid, "~r~Headshot!", 3000, 5);
                GameTextForPlayer(playerid, "~r~Headshotted!", 3000, 5);
                SendClientMessageToAll(0x5BC178FF, str);
                SetPlayerHealth(playerid, 0.0); // We will always use float integer because health is in float!
            }
        }
    }
    return 1;
}



Re: Help with Headshot System - SyS - 04.01.2017

Check the issuserid is not admin on duty


Respuesta: Re: Help with Headshot System - nahum2003 - 04.01.2017

Quote:
Originally Posted by Sreyas
Посмотреть сообщение
Check the issuserid is not admin on duty
What do you mean brother? When admin enter on duty, it change to TEAM_NONE. It's the team which admin enter. So, what i should do? Thanks for answer btw


Re: Help with Headshot System - Lordzy - 04.01.2017

You can check if the playerid's team is NO_TEAM or not.
pawn Код:
((GetPlayerTeam(playerid) != GetPlayerTeam(issuerid)) && GetPlayerTeam(playerid) != NO_TEAM)
(Assign 'GetPlayerTeam(playerid)' to a variable to avoid invoking it twice.


Respuesta: Help with Headshot System - nahum2003 - 04.01.2017

cancel


Respuesta: Help with Headshot System - nahum2003 - 05.01.2017

I am still having problems with code D:, here code again

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    if(gTeam[issuerid] == gTeam[playerid])
	{
	   	GameTextForPlayer(issuerid,"~r~Don't attack your team mates!", 3000, 3);
	}
	if(issuerid != INVALID_PLAYER_ID)
	{
	  	new str[26];
	  	format(str, sizeof(str),"-%.0f", amount);
      	SetPlayerChatBubble(playerid, str, 0xFF0000FF, 100.0, 2000);
      	PlayerPlaySound(issuerid,17802,0.0,0.0,0.0);
	}
	new Float:x, Float:y, Float:z;
	if(PlayerInfo[playerid][OnDuty] == 1 || PlayerInfo[playerid][God] == 1)
	{
		    SetPlayerHealth(playerid, 100000000.0);
		    new Float:Health; GetPlayerHealth(issuerid,Health);
		    GameTextForPlayer(issuerid,"~w~dont~n~~p~Attack~n~~p~onduty~n~~w~admins", 3000, 3);
		    GetPlayerPos(issuerid,x,y,z); SetPlayerPos(issuerid,x,y,z+5);
        	}
    if(issuerid != INVALID_PLAYER_ID)
    {
        if(GetPlayerTeam(playerid) != GetPlayerTeam(issuerid) && GetPlayerTeam(playerid) != NO_TEAM)
        {
            if(weaponid == 34 && bodypart == 9) // checking the weapon and body part
            {
                new str[90];
                format(str, sizeof(str), "%s has headshotted %s", pName(issuerid), pName(playerid));
                GameTextForPlayer(issuerid, "~r~Headshot!", 3000, 5);
                GameTextForPlayer(playerid, "~r~Headshotted!", 3000, 5);
                SendClientMessageToAll(0x5BC178FF, str);
                SetPlayerHealth(playerid, 0.0);
            }
        }
    }
    return 1;
}



Respuesta: Help with Headshot System - Whillyrez - 05.01.2017

What's the problem?


Respuesta: Help with Headshot System - nahum2003 - 05.01.2017

Normal player can kill admin on duty with headshot


Re: Help with Headshot System - justinnater - 05.01.2017

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    if(gTeam[issuerid] == gTeam[playerid])
	{
	   	GameTextForPlayer(issuerid,"~r~Don't attack your team mates!", 3000, 3);
	}
	if(issuerid != INVALID_PLAYER_ID)
	{
	  	new str[26];
	  	format(str, sizeof(str),"-%.0f", amount);
      	SetPlayerChatBubble(playerid, str, 0xFF0000FF, 100.0, 2000);
      	PlayerPlaySound(issuerid,17802,0.0,0.0,0.0);
	}
	new Float:x, Float:y, Float:z;
	if(PlayerInfo[playerid][OnDuty] == 1 || PlayerInfo[playerid][God] == 1)
	{
		    SetPlayerHealth(playerid, 100000000.0);
		    new Float:Health; GetPlayerHealth(issuerid,Health);
		    GameTextForPlayer(issuerid,"~w~dont~n~~p~Attack~n~~p~onduty~n~~w~admins", 3000, 3);
		    GetPlayerPos(issuerid,x,y,z); SetPlayerPos(issuerid,x,y,z+5);
        	}
    if(issuerid != INVALID_PLAYER_ID)
    {
        if(GetPlayerTeam(playerid) != GetPlayerTeam(issuerid) && GetPlayerTeam(playerid) != NO_TEAM)
        {
            if(weaponid == 34 && bodypart == 9 && PlayerInfo[playerid][OnDuty] != 1 && PlayerInfo[playerid][God] != 1) // checking the weapon and body part
            {
                new str[90];
                format(str, sizeof(str), "%s has headshotted %s", pName(issuerid), pName(playerid));
                GameTextForPlayer(issuerid, "~r~Headshot!", 3000, 5);
                GameTextForPlayer(playerid, "~r~Headshotted!", 3000, 5);
                SendClientMessageToAll(0x5BC178FF, str);
                SetPlayerHealth(playerid, 0.0);
            }
        }
    }
    return 1;
}



Respuesta: Re: Help with Headshot System - nahum2003 - 06.01.2017

Quote:
Originally Posted by justinnater
Посмотреть сообщение
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    if(gTeam[issuerid] == gTeam[playerid])
	{
	   	GameTextForPlayer(issuerid,"~r~Don't attack your team mates!", 3000, 3);
	}
	if(issuerid != INVALID_PLAYER_ID)
	{
	  	new str[26];
	  	format(str, sizeof(str),"-%.0f", amount);
      	SetPlayerChatBubble(playerid, str, 0xFF0000FF, 100.0, 2000);
      	PlayerPlaySound(issuerid,17802,0.0,0.0,0.0);
	}
	new Float:x, Float:y, Float:z;
	if(PlayerInfo[playerid][OnDuty] == 1 || PlayerInfo[playerid][God] == 1)
	{
		    SetPlayerHealth(playerid, 100000000.0);
		    new Float:Health; GetPlayerHealth(issuerid,Health);
		    GameTextForPlayer(issuerid,"~w~dont~n~~p~Attack~n~~p~onduty~n~~w~admins", 3000, 3);
		    GetPlayerPos(issuerid,x,y,z); SetPlayerPos(issuerid,x,y,z+5);
        	}
    if(issuerid != INVALID_PLAYER_ID)
    {
        if(GetPlayerTeam(playerid) != GetPlayerTeam(issuerid) && GetPlayerTeam(playerid) != NO_TEAM)
        {
            if(weaponid == 34 && bodypart == 9 && PlayerInfo[playerid][OnDuty] != 1 && PlayerInfo[playerid][God] != 1) // checking the weapon and body part
            {
                new str[90];
                format(str, sizeof(str), "%s has headshotted %s", pName(issuerid), pName(playerid));
                GameTextForPlayer(issuerid, "~r~Headshot!", 3000, 5);
                GameTextForPlayer(playerid, "~r~Headshotted!", 3000, 5);
                SendClientMessageToAll(0x5BC178FF, str);
                SetPlayerHealth(playerid, 0.0);
            }
        }
    }
    return 1;
}
Thanks bro, you really help me regards, +rep