HELP:Team Killing
#1

how to set here anti team killing with head shot

Код:
//Credit By ALEXANDRO
//Please Do not remove the Credits

#include <OPSP>
#include <a_samp>

#pragma tabsize 0

#define COLOR_RED    0xFC3535FF
#define SERVER_MAX_PLAYERS 500


new RecentlyShot[SERVER_MAX_PLAYERS];

public OnFilterScriptInit()
{
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    RecentlyShot[playerid] = 0;
    return 1;
}

public OnPlayerUpdate(playerid)
{

    return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_FIRE && newkeys & KEY_HANDBRAKE) {
        if(RecentlyShot[playerid] == 0) {
            RecentlyShot[playerid] = 1;
            SetTimerEx("AntiSpam", 1000, false, "d", playerid);
            if(GetPlayerWeapon(playerid) == 22 || GetPlayerWeapon(playerid) == 23 || GetPlayerWeapon(playerid) == 24 || GetPlayerWeapon(playerid) == 25 || GetPlayerWeapon(playerid) == 26 || GetPlayerWeapon(playerid) == 27 || GetPlayerWeapon(playerid) == 28 || GetPlayerWeapon(playerid) == 29 || GetPlayerWeapon(playerid) == 30 || GetPlayerWeapon(playerid) == 31 || GetPlayerWeapon(playerid) == 32 || GetPlayerWeapon(playerid) == 33 || GetPlayerWeapon(playerid) == 34 || GetPlayerWeapon(playerid) == 38) {
                new Float:blahx, Float:blahy, Float:blahz;
                HeadshotCheck(playerid, blahx, blahy, blahz);
                return 1;
            }
            return 1;
        }
        return 1;
    }
    return 1;
}

forward AntiSpam(playerid);
public AntiSpam(playerid) {
    RecentlyShot[playerid] = 0;
    return 1;
}

stock PlayerName(playerid) {
    new name[24];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}

stock HeadshotCheck(playerid, &Float:x, &Float:y, &Float:z)
{
    new Float:fx,Float:fy,Float:fz;
    GetPlayerCameraFrontVector(playerid, fx, fy, fz);

    new Float:cx,Float:cy,Float:cz;
    GetPlayerCameraPos(playerid, cx, cy, cz);

    for(new Float:i = 0.0; i < 50; i = i + 0.5)
    {
        x = fx * i + cx;
        y = fy * i + cy;
        z = fz * i + cz;

        #if defined SHOWPATH
        CreatePickup(1239, 4, x, y, z, -1);
        #endif

        for(new player = 0; player < SERVER_MAX_PLAYERS; player ++)
        {
            if(IsPlayerConnected(playerid))
            {
                if(player != playerid)
                {
                    if(GetPlayerSpecialAction(player) == SPECIAL_ACTION_DUCK)
                    {
                        if(IsPlayerInRangeOfPoint(player, 0.3, x, y, z))
                        {

                            GameTextForPlayer(player, "~r~Head Shot!", 2000, 2);

                            SetPlayerHealth(player, 0.0);
                            CallRemoteFunction("OnPlayerDeath", "ddd", player, playerid, 34);
                        }
                    }
                    else
                    {
                        if(IsPlayerInRangeOfPoint(player, 0.3, x, y, z - 0.7))
                        {


                            GameTextForPlayer(player, "~r~Head Shot!", 2000, 2);

                            SetPlayerHealth(player, 0.0);
                            CallRemoteFunction("OnPlayerDeath", "ddd", player, playerid, 34);
                        }
                    }
                }
            }
        }
    }
    return 1;
}
Reply
#2

Код:
put this under OnPlayerTakeDamage

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid,bodypart)
{
if(GetPlayerTeam(issuerid) != GetPlayerTeam(playerid))
{
                if((weaponid == 23 || weaponid == 33 || weaponid == 34) && bodypart == 9) 
                {
                    SetPlayerHealth(playerid, 0.0);
                    GameTextForPlayer(issuerid, "~r~Headshot", 3000, 3);
                    GameTextForPlayer(playerid, "~r~Headshot", 3000, 3);
                }
}else {GameTextForPlayer(issuerid, "~r~Team killing not allowed", 3000, 3);}
return 1;
}
i added only 3 weapons you can add more ,small code and better
Reply
#3

i don't have on player take damage
Reply
#4

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid,bodypart)
{
if(GetPlayerTeam(issuerid) != GetPlayerTeam(playerid))
{
                if((weaponid == 23 || weaponid == 33 || weaponid == 34) && bodypart == 9) 
                {
                    SetPlayerHealth(playerid, 0.0);
                    GameTextForPlayer(issuerid, "~r~Headshot", 3000, 3);
                    GameTextForPlayer(playerid, "~r~Headshot", 3000, 3);
                }
}else {GameTextForPlayer(issuerid, "~r~Team killing not allowed", 3000, 3);}
return 1;
}
You can use this code small and better ..headshot. if you find any bug tell me
Reply
#5

Quote:

C:\headshot.pwn(119) : error 025: function heading differs from prototype
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.

line 119ublic OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid,bodypart)
Reply
#6

Show me line 119
Reply
#7

OnPlayerTakeDamage...
Reply
#8

try this one , i think it will work , not sure though

pawn Код:
stock HeadshotCheck(playerid, &Float:x, &Float:y, &Float:z)
{
    new Float:fx,Float:fy,Float:fz;
    GetPlayerCameraFrontVector(playerid, fx, fy, fz);

    new Float:cx,Float:cy,Float:cz;
    GetPlayerCameraPos(playerid, cx, cy, cz);

    for(new Float:i = 0.0; i < 50; i = i + 0.5)
    {
        x = fx * i + cx;
        y = fy * i + cy;
        z = fz * i + cz;

        #if defined SHOWPATH
        CreatePickup(1239, 4, x, y, z, -1);
        #endif

        for(new player = 0; player < SERVER_MAX_PLAYERS; player ++)
        {
            if(IsPlayerConnected(playerid))
            {
                if(player != playerid)
                {
                 if(GetPlayerTeam(player) != GetPlayerTeam(playerid))
                   {
                    if(GetPlayerSpecialAction(player) == SPECIAL_ACTION_DUCK)
                    {
                        if(IsPlayerInRangeOfPoint(player, 0.3, x, y, z))
                        {

                            GameTextForPlayer(player, "~r~Head Shot!", 2000, 2);

                            SetPlayerHealth(player, 0.0);
                            CallRemoteFunction("OnPlayerDeath", "ddd", player, playerid, 34);
                        }
                     }
                   }
                    else
                    {
                    if(GetPlayerTeam(player) != GetPlayerTeam(playerid))
                      {
                        if(IsPlayerInRangeOfPoint(player, 0.3, x, y, z - 0.7))
                        {


                            GameTextForPlayer(player, "~r~Head Shot!", 2000, 2);

                            SetPlayerHealth(player, 0.0);
                            CallRemoteFunction("OnPlayerDeath", "ddd", player, playerid, 34);
                        }
                      }
                   }
               }
           }
       }
   }
    return 1;
}
Reply
#9

now we don't have headshot -.-
Reply
#10

bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)