Anti Team Kill
#1

I need help making a proper anti team kill. What i want it to do is, if a player from the same team, attacks each other, it doesn't get rid of there health. How can i do this?



This is what I have, but it isn't good at all. People use fake kill to hack against it.



pawn Код:
if(gTeam[killerid] == TEAM_COP && gTeam[playerid] == TEAM_COP && IsSpawned[killerid] == 1 && Jailed[killerid] == 0) {
    teamkiller[killerid] +=1;
    if(teamkiller[killerid] >=3) {
    new str[100];
    GetPlayerName(killerid, str, 24);
    format(str, 100, "**(AUTO KICK)** %s(%d) Too Many Team Kills(TeamKiller)", str,killerid);
    SendClientMessageToAll(0xFF7F50AA, str);
    printf("%s", str);
    SetPlayerInterior(killerid,10);
    SetPlayerPos(killerid,219.6257,111.2549,999.0156);
    SetPlayerFacingAngle(killerid,2.2339);
    SetCameraBehindPlayer(killerid);
    teamkiller[killerid] =0;
    Kicking[killerid] =1;
    SetTimer("KickPlayer",700,0);
    return 1;
}
    SendClientMessage(killerid,COLOR_RED, "TEAM KILL - Do not kill other Law Enforcement agents (Blue/Purple)");
    SendClientMessage(killerid,COLOR_RED, "If you continue to kill other Law Enforcement agents you will be kicked/banned");
    SendDeathMessage(killerid,playerid,reason);
    SetPlayerColor(playerid,COLOR_DEADCONNECT);
    oscore = GetPlayerScore(killerid);
    SetPlayerScore(killerid, oscore -1);
    return 1;
}

    if(gTeam[killerid] == TEAM_ARMY && gTeam[playerid] == TEAM_ARMY && IsSpawned[killerid] == 1 && Jailed[killerid] == 0) {
    teamkiller[killerid] +=1;
    if(teamkiller[killerid] >=3) {
    new str[100];
    GetPlayerName(killerid, str, 24);
    format(str, 100, "**(AUTO KICK)** %s(%d) Too Many Team Kills(TeamKiller)", str,killerid);
    SendClientMessageToAll(0xFF7F50AA, str);
    printf("%s", str);
    SetPlayerInterior(killerid,10);
    SetPlayerPos(killerid,219.6257,111.2549,999.0156);
    SetPlayerFacingAngle(killerid,2.2339);
    SetCameraBehindPlayer(killerid);
    teamkiller[killerid] =0;
    Kicking[killerid] =1;
    SetTimer("KickPlayer",700,0);
    return 1;
}
    SendClientMessage(killerid,COLOR_RED, "TEAM KILL - Do not kill other Law Enforcement agents (Blue/Purple)");
    SendClientMessage(killerid,COLOR_RED, "If you continue to kill other Law Enforcement agents you will be kicked/banned");
    SendDeathMessage(killerid,playerid,reason);
    SetPlayerColor(playerid,COLOR_DEADCONNECT);
    oscore = GetPlayerScore(killerid);
    SetPlayerScore(killerid, oscore -1);
    return 1;
}

    if(gTeam[killerid] == TEAM_ARMY && gTeam[playerid] == TEAM_COP && IsSpawned[killerid] == 1 && Jailed[killerid] == 0) {
    teamkiller[killerid] +=1;
    if(teamkiller[killerid] >=3) {
    new str[100];
    GetPlayerName(killerid, str, 24);
    format(str, 100, "**(AUTO KICK)** %s(%d) Too Many Team Kills(TeamKiller)", str,killerid);
    SendClientMessageToAll(0xFF7F50AA, str);
    printf("%s", str);
    SetPlayerInterior(killerid,10);
    SetPlayerPos(killerid,219.6257,111.2549,999.0156);
    SetPlayerFacingAngle(killerid,2.2339);
    SetCameraBehindPlayer(killerid);
    teamkiller[killerid] =0;
    Kicking[killerid] =1;
    SetTimer("KickPlayer",700,0);
    return 1;
}
    SendClientMessage(killerid,COLOR_RED, "TEAM KILL - Do not kill other Law Enforcement agents (Blue/Purple)");
    SendClientMessage(killerid,COLOR_RED, "If you continue to kill other Law Enforcement agents you will be kicked/banned");
    SendDeathMessage(killerid,playerid,reason);
    SetPlayerColor(playerid,COLOR_DEADCONNECT);
    oscore = GetPlayerScore(killerid);
    SetPlayerScore(killerid, oscore -1);
    return 1;
}
Reply
#2

What do you mean with: Fake Kill??

Edit: You can use: if(gTeam[killerid] == gTeam[playerid]);
Reply
#3

Quote:
Originally Posted by CAR
Посмотреть сообщение
What do you mean with: Fake Kill??
So, when people use hacks, they use fake kill. What my code does is, it checks to see if a player killed a player under onplayerdeath and checks to see if they are on the same team, if so, it gives them a warning.


When people use fakekill (hacks) they don't actually kill each other, it's just a fake death and it makes it look like a player killed another which makes them get kicked.


So how do i make it, players just don't lose health
Reply
#4

You mean when a player (killerid) kills another player the death one gets kicked?
Reply
#5

Noooo, What I'm asking is, How can I make it so if TEAM_COP attakcs TEAM_COP health is not lost.
Reply
#6

Now this'll be probably stupid but SetPlayerTeam already does anti-teamkill with players not loosing health.

More to your topic:
Try saving his HP/AP as much as possible in a variable (OnPlayerUpdate?) and set it back to what it was when it was last called.
Reply
#7

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
Now this'll be probably stupid but SetPlayerTeam already does anti-teamkill with players not loosing health.

More to your topic:
Try saving his HP/AP as much as possible in a variable (OnPlayerUpdate?) and set it back to what it was when it was last called.
I've Tried SetPlayerTeam, And It didn't work for me. I guess I'm doing it wrong?
Reply
#8

I get it,
but with OnPlayerUpdate you can't get something like, shooterid on the player, and he wants that if the shooter is in another team the HP gets lost, but when it's the same team the HP doesn't get lost.

And we all know there isn't an function like OnPlayerShootAtPlayer(shooterid, playerid, hplost); or something. So I think it's impossible
Reply
#9

Should be added for future versions actually ^^.

Possible solution for your fake kill:
Check if the "dead" playerid is actually dead by retrieving his health.
Reply
#10

But maybe you can set by OnPlayerDeath the health again to 100 but I don't know if that works..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)