Help with Headshot System
#1

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;
}
Reply
#2

Check the issuserid is not admin on duty
Reply
#3

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
Reply
#4

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.
Reply
#5

cancel
Reply
#6

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;
}
Reply
#7

What's the problem?
Reply
#8

Normal player can kill admin on duty with headshot
Reply
#9

Код:
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;
}
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)