[PEDIDO]Sistema de Head Shot
#1

ola galera,eu queria por favor um sistema de head shot,que desse head shot apenas com as armas de fogo,e NГO com as armas brancas,alem de ser sem bug,e,quando acertar a cabeзa,que o player morra na hora mesmo,sem nenhum lag!
e tambem quero que apareзa uma msg para o player que morreu e para o que matou,tipu:
vc tomou head shot e morreu
vc deu um head shot no fulano e matou ele
entendem?
e tbm,sem akele bug,que quando o player leva head shot,aparece o icone da caverinha la no canto da tela,e nao que ele foi morto por alguem!
entendem?
por favor me ajudem,vai fazer UM ANO que tento fazer issu!!!
por favr gente! eu imploro que me ajudem!!!!
Reply
#2

Use o search, tem vбrios.
Reply
#3

Quote:

Use o search, tem vбrios.

ja usei,mas nenhum eh deste jeito! um la da head shot so com armas de fogo,mas tem um bug! quando da head shot,aparece vinte mensagens para vc de que vc acertou a cabeзa de alguem,e alem de que aparece eh o icone da caveirinha,ao enves de que certo player matou o outro.
ja revirei a net,mas nao tem nenhum deste jeito! por isso minha unica soluзao eh pedir ajuda!
eu imploro que me ajudem por favur!
Reply
#4

Isto deve resolver o seu problema .




Apenas fiz algumas adaptaзхes neste Filterscript : https://sampforum.blast.hk/showthread.php?tid=138791 .



Lembre-se de definir isto antes de compilar :



pawn Код:
new ArmasBrancas[3] = {0,1,2};
//Dentro do [3], troque o 3 pelo total de armas que sгo "brancas".
//No {0,1,2}, vб enumerando o ID de todas as armas "brancas".

E aqui estб o Filterscript :


pawn Код:
/*************************************************
Infinite-Gaming.com Presents:
BoOm Headshot v.1 by Tannz0rz && Cyber_Punk
The closest thing to real headshots you can get in samp.

DO NOT REMOVE CREDITS
If you borrow bits of code would be nice to credit the original authors...

Thanks Kye and the Dev Team. R5+ is nice.

CONSERVATIVE mode is Recommended mode for large servers to save on processing.
This disables head shot checks when a player is holding KEY_FIRE + AIM (repeat fire).
To gain a head shot they must tap fire button. (While holding AIM)

***The Only time you can gain a headshot is in Target mode with the crosshairs.***

Left in the script is the original debug mode and "Line of Sight" (LOS) code.
To enable them just uncomment the lines below, when done simply comment them.
*************************************************/

#include <a_samp>

//======Config Options
//#define DEBUG
//#define NO_LOS //Uncomment this if you want no "Line of Sight" with your DEBUG mode
//#define FOR_EACH
#define CONSERVATIVE   //Comment for servers less than 100 players....Use @ your own risk.
#define DESTROY_LOS 500 //Time in milliseconds to remove line of sight objects
#undef MAX_PLAYERS
    #define MAX_PLAYERS 50 //Set to your max players

//======End Options

#if defined FOR_EACH
    #include <foreach>
#endif

#define KEY_AIMFIRE 132

#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

#if defined DEBUG
    new count1, count2;
#endif



new ArmasBrancas[3] = {0,1,2};
//Dentro do [3], troque o 3 pelo total de armas que sгo "brancas".
//No {0,1,2}, vб enumerando o ID de todas as armas "brancas".



//----WEAPON RANGES PULLED FROM WEAPONS.DAT--Country Rifle -10.0
new
    Float:ranges[39] =
    {
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        35.0,
        35.0,
        35.0,
        40.0,
        35.0,
        40.0,
        45.0,
        35.0,
        70.0,
        90.0,
        35.0,
        90.0,
        100.0,
        0.0,
        0.0,
        0.0,
        25.0
    };

#if defined FOR_EACH
    Itter_Create(Victim, MAX_PLAYERS);
#endif


new text[128];
#define SendClientMessageEx(%0,%1,%2);  format(text,sizeof(text),%2),SendClientMessage(%0,%1,text);
public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Infinite-Gaming.com Presents:");
    print(" BoOm Headshot v1 by Tannz0rz && Cyber_Punk");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    print("\n--------------------------------------");
    print(" BoOm Headshot UNLOADED");
    print("--------------------------------------\n");
    return 1;
}

public OnPlayerConnect(playerid)
{
#if defined FOR_EACH
    Itter_Add(HSVictim, playerid);
#endif
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
#if defined FOR_EACH
    Itter_Remove(HSVictim, playerid);
#endif
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_AIMFIRE) && NoBadCam(playerid))
    {
        switch(GetPlayerWeapon(playerid))
        {
            #if !defined CONSERVATIVE
                case WEAPON_SNIPER:
                    if(GetPlayerWeaponState(playerid) == WEAPONSTATE_LAST_BULLET) CheckHeadShot(playerid);
                case 22..33,38:
                {
                    SetTimerEx("HSTimer", 100, 0, "i", playerid);
                }
            #else
                case WEAPON_SNIPER, WEAPON_SHOTGUN:
                    if(GetPlayerWeaponState(playerid) == WEAPONSTATE_LAST_BULLET) CheckHeadShot(playerid);
                case WEAPON_RIFLE:
                    if(GetPlayerWeaponState(playerid) != WEAPONSTATE_RELOADING) CheckHeadShot(playerid);
                case 22..24,26..32,38:
                    if(GetPlayerWeaponState(playerid) != WEAPONSTATE_RELOADING) CheckHeadShot(playerid);
            #endif
        }
    }
    return 1;
}

forward HSTimer(playerid);
public HSTimer(playerid)
{
    new keys, ud, lr;
    GetPlayerKeys(playerid, keys, ud, lr);
    if((keys & KEY_FIRE) == (KEY_FIRE) && NoBadCam(playerid))
    {
        switch(GetPlayerWeapon(playerid))
        {
            case WEAPON_COLT45, WEAPON_UZI, WEAPON_TEC9, WEAPON_MP5, WEAPON_AK47, WEAPON_M4:{
                if(GetPlayerWeaponState(playerid) != WEAPONSTATE_RELOADING){
                    CheckHeadShot(playerid);
                    SetTimerEx("HSTimer", 150, 0, "i", playerid);
                }
            }
            case WEAPON_SHOTGSPA, WEAPON_SAWEDOFF:{
                if(GetPlayerWeaponState(playerid) != WEAPONSTATE_RELOADING){
                    CheckHeadShot(playerid);
                    SetTimerEx("HSTimer", 300, 0, "i", playerid);
                }
            }
            case WEAPON_SILENCED:{
                if(GetPlayerWeaponState(playerid) != WEAPONSTATE_RELOADING){
                    CheckHeadShot(playerid);
                    SetTimerEx("HSTimer", 500, 0, "i", playerid);
                }
            }
            case WEAPON_DEAGLE:{
                if(GetPlayerWeaponState(playerid) != WEAPONSTATE_RELOADING){
                    CheckHeadShot(playerid);
                    SetTimerEx("HSTimer", 800, 0, "i", playerid);
                }
            }
            case WEAPON_SHOTGUN:
            {
                if(GetPlayerWeaponState(playerid) != WEAPONSTATE_NO_BULLETS){
                    CheckHeadShot(playerid);
                    SetTimerEx("HSTimer", 900, 0, "i", playerid);
                }
            }
            case WEAPON_RIFLE:
            {
                if(GetPlayerWeaponState(playerid) != WEAPONSTATE_RELOADING){
                    CheckHeadShot(playerid);
                    SetTimerEx("HSTimer", 1000, 0, "i", playerid);
                }
            }
        }
    }
    return 1;
}


forward CheckHeadShot(playerid);
public CheckHeadShot(playerid)
{
    for(new x; x != sizeof(ArmasBrancas); x++)
    {
        if(GetPlayerWeapon(playerid) == ArmasBrancas[x])
        {
            return true;
        }
    }
    #if defined DEBUG
        count1 = GetTickCount();
    #endif

    new Float:x[4], Float:y[4], Float:z[4], Float:dist = 1.0, Float:range = 0.0;
    GetPlayerCameraPos(playerid, x[0], y[0], z[0]);
    GetPlayerCameraFrontVector(playerid, x[1], y[1], z[1]);

    #if defined DEBUG
        printf("\nCamera Position: x=%.2f, y=%.2f, z=%.2f\nFrontVector: x=%.2f, y=%.2f, z=%.2f", x[0], y[0], z[0], x[1], y[1], z[1]);
    #endif

    range = ranges[GetPlayerWeapon(playerid)];

    if(range != 0.0)
    {
        switch(GetPlayerWeapon(playerid))
        {
            case WEAPON_RIFLE:
            {
                if(x[1] < 0.0 && y[1] > 0.0 )
                {
                    x[1] += 0.0155;
                    y[1] += 0.0155;
                }
                else if(x[1] > 0.0 && y[1] > 0.0)
                {
                    x[1] += 0.0155;
                    y[1] -= 0.0155;
                }
                else if(x[1] < 0.0 && y[1] < 0.0)
                {
                    x[1] -= 0.0155;
                    y[1] += 0.0155;
                }
                else if(x[1] > 0.0 && y[1] < 0.0)
                {
                    x[1] -= 0.0155;
                    y[1] -= 0.0155;
                }
                if(z[1] > 0.1) z[1] += 0.06;
                else z[1] += 0.05;
            }
            case WEAPON_AK47,WEAPON_M4:
            {
                if(x[1] < 0.0 && y[1] > 0.0 )
                {
                    x[1] += 0.0225;
                    y[1] += 0.0225;
                }
                else if(x[1] > 0.0 && y[1] > 0.0)
                {
                    x[1] += 0.0225;
                    y[1] -= 0.0225;
                }
                else if(x[1] < 0.0 && y[1] < 0.0)
                {
                    x[1] -= 0.0225;
                    y[1] += 0.0225;
                }
                else if(x[1] > 0.0 && y[1] < 0.0)
                {
                    x[1] -= 0.0225;
                    y[1] -= 0.0225;
                }
                if(z[1] > 0.0) z[1] += 0.08;
                else if(z[1] < -0.0 && z[1] > -0.5) z[1] += 0.06;
                else if(z[1] < -0.5) z[1] -= 0.05;
            }
            case 22..29,32,38:
            {
                if(x[1] < 0.0 && y[1] > 0.0 )
                {
                    x[1] += 0.0325;
                    y[1] += 0.0325;
                }
                else if(x[1] > 0.0 && y[1] > 0.0)
                {
                    x[1] += 0.0325;
                    y[1] -= 0.0325;
                }
                else if(x[1] < 0.0 && y[1] < 0.0)
                {
                    x[1] -= 0.0325;
                    y[1] += 0.0325;
                }
                else if(x[1] > 0.0 && y[1] < 0.0)
                {
                    x[1] -= 0.0325;
                    y[1] -= 0.0325;
                }
                if(z[1] > 0.0) z[1] += 0.125;
                else z[1] += 0.09;
            }
        }
        x[0] += (2.0 * x[1]);
        y[0] += (2.0 * y[1]);

        do
        {
            x[0] += (x[1] * 1.0);
            y[0] += (y[1] * 1.0);
            z[0] += (z[1] * 1.0);

            #if defined DEBUG
                #if !defined NO_LOS
                #endif
            #endif

        #if !defined FOR_EACH
            for(new i = 0; i < MAX_PLAYERS; ++i)
            #if !defined DEBUG
                if(IsPlayerConnected(i))
            #endif
        #else
            foreach(HSVictim, i)
        #endif
            {
                if( i != playerid)
                {
                    GetPlayerPos(i, x[2], y[2], z[2]);

                    if(GetPlayerSpecialAction(i) == SPECIAL_ACTION_DUCK) z[2] -= 0.6;
                    else z[2] += 0.8;
                    if(PointInRangeOfPoint(0.5, x[0], y[0], z[0], x[2], y[2], z[2]))
                    {
                        SetPlayerHealth(i, 0.0);
                        new Morto[MAX_PLAYER_NAME], Matador[MAX_PLAYER_NAME];
                        GetPlayerName(i, Morto, sizeof(Morto));
                        GetPlayerName(playerid, Matador, sizeof(Matador));
                        SendClientMessageEx(playerid,0x33CCFFAA,"Vocк deu um HeadShot no %s e matou ele !",Morto);
                        SendClientMessage(i,0x33CCFFAA,"Vocк tomou um HeadShot e morreu !");
                        #if defined DEBUG
                            count2 = GetTickCount();
                            count1 = count2 - count1;
                            printf("\n Player hit\n Max Players Looped: %d\n Max Weapon Range: %.2f\n Distance to Hit: %.2f\n Total execution time: %8d ms",i,range,dist,count1);
                            count1=count2;
                        #endif
                        return 1;
                    }
                }
            }
            dist += 1.0;
        }
        while( dist < range );
        #if defined DEBUG
            count2 = GetTickCount();
            count1 = count2 - count1;
            printf("\n Max Players Looped: %d\n Max Weapon Range: %.2f\n Total execution time: %8d ms",MAX_PLAYERS,range, count1);
            count1=count2;
        #endif
    }
    return 1;
}

stock NoBadCam(playerid) //Don't ask but it works
{

    new Float:x, Float:y, Float:z,Float:ang;
    GetPlayerCameraFrontVector(playerid, x, y, z);
    GetPlayerFacingAngle(playerid,ang);

    if((x < 0.0 && y > 0.0) && (ang > 90.0 && ang < 300.0)) return 0;
    else if((x > 0.0 && y > 0.0) && (ang > 88.16 && ang < 275.0)) return 0;
    else if((x < 0.0 && y < 0.0) && (ang > 257.30 && ang < 360.0)) return 0;
    else if((x > 0.0 && y < 0.0) && (ang < 88.16 && ang < 257.30)) return 0;

    return 1;
}

// As taken from ******'s IsPlayerInRangeOfPoint
stock PointInRangeOfPoint(Float:range, Float:x, Float:y, Float:z, Float:X, Float:Y, Float:Z)
{
    X -= x;
    Y -= y;
    Z -= z;
    return ((X * X) + (Y * Y) + (Z * Z)) < (range * range);
}


Espero ter ajudado .
Reply
#5

Pesquise em outras boards nгo somente nesta. ou mesmo,me mande os links que eu tentarei consertб-lo.
Reply
#6

rjj,as armas brancas que eu vou setar,eh para nao dar head shot neh?
elas estao neste new ai como proibidas ou permitidas?
as que eu setar serao proibidas ou permitidas?
ah,e tambem,eh neste FS ai que ta akele bug,que aparece o icone da caveirinha,tipo que o player morreu de morte acidental,ao enves de que ele foi morto,assim,o player que mata nao ganha o dinheiro
isso tbm deve ser corrigido neste FS
pode corrigir?
Reply
#7

Quote:
Originally Posted by Detonador
Посмотреть сообщение
rjj,as armas brancas que eu vou setar,eh para nao dar head shot neh?
elas estao neste new ai como proibidas ou permitidas?
as que eu setar serao proibidas ou permitidas?
ah,e tambem,eh neste FS ai que ta akele bug,que aparece o icone da caveirinha,tipo que o player morreu de morte acidental,ao enves de que ele foi morto,assim,o player que mata nao ganha o dinheiro
isso tbm deve ser corrigido neste FS
pode corrigir?
Й pra colocar o ID das armas proibidas .



Posso sim corrigir, fiz isso , por favor pegue o cуdigo de novo que estб no meu post anterior .



E sobre a mensagem de que "ele foi morto por morte acidental", suponho que esteja se referindo б funзгo SendDeathMessage, que, deve estar em seu GameMode .



Se for isso, poste aqui no tуpico, toda a public OnPlayerDeath do GameMode.



Espero ter ajudado .
Reply
#8

rjj,a proposito,nao teria um jeito de setar as armas que podem dar head shot ao enves das que nao podem?
pq uma vez eu tentei assim,e deu bug,parou de aparecer os icones,o player nao morria,etc,por causa que deste jeito,eh preciso setar a "arma" morte por acidente,e assim,quando o player morrer pro acidente,ele vai levar head shot entende :S
Reply
#9

nao rjj,no meu gm nao tem esta linha
e axo que vc pode nao ter entendido,pq se for deste jeito,de setar a arma que nao pdoe dar head shot,alem de eu precisar setar mais armas,e dar linha muito grande,eu terei que setar como eu disse,a arma que tem o id 51,que eh explosao,e isso faz dar bug!
entende?
pq se eu nao setar,se alguem explocir o outro,podera vir a mensagem de head shot! nao teria um jeito de setar as armas que PODEM dar head shot,ao enves das que nao podem?
e tbm rjj,eh justamente esse FS que da akele bug das mensagens! da um flood! eu incrementei para aparecer as mensagens,para o player que morreu <i> e para o que matou <playerid> mas da akele flood danado de msgs!
como arrumar isso tbm??
Reply
#10

Quote:
Originally Posted by Detonador
Посмотреть сообщение
nao rjj,no meu gm nao tem esta linha
e axo que vc pode nao ter entendido,pq se for deste jeito,de setar a arma que nao pdoe dar head shot,alem de eu precisar setar mais armas,e dar linha muito grande,eu terei que setar como eu disse,a arma que tem o id 51,que eh explosao,e isso faz dar bug!
entende?
pq se eu nao setar,se alguem explocir o outro,podera vir a mensagem de head shot! nao teria um jeito de setar as armas que PODEM dar head shot,ao enves das que nao podem?
e tbm rjj,eh justamente esse FS que da akele bug das mensagens! da um flood! eu incrementei para aparecer as mensagens,para o player que morreu <i> e para o que matou <playerid> mas da akele flood danado de msgs!
como arrumar isso tbm??


Bem, jб que o seu GM nгo tem esta linha e como eu removi o "icone da caveirinha", este problema jб estб solucionado :




Quote:
Originally Posted by Detonador
akele bug,que quando o player leva head shot,aparece o icone da caverinha la no canto da tela,e nao que ele foi morto por alguem!

Esse abaixo tambйm estб solucionado, pois implementei o Filterscript com um Anti-Flood :



Quote:
Originally Posted by Detonador
um la da head shot so com armas de fogo,mas tem um bug! quando da head shot,aparece vinte mensagens para vc de que vc acertou a cabeзa de alguem

Por fim, quanto б esse problema :




Quote:
Originally Posted by Detonador
ola galera,eu queria por favor um sistema de head shot,que desse head shot apenas com as armas de fogo,e NГO com as armas brancas,alem de ser sem bug,e,quando acertar a cabeзa,que o player morra na hora mesmo,sem nenhum lag!
Quote:
Originally Posted by Detonador
e axo que vc pode nao ter entendido,pq se for deste jeito,de setar a arma que nao pdoe dar head shot,alem de eu precisar setar mais armas,e dar linha muito grande,eu terei que setar como eu disse,a arma que tem o id 51,que eh explosao,e isso faz dar bug!


Adaptei o Filterscript de modo que as armas dentro da variбvel :mgreen::



pawn Код:
new ArmasBrancas[3] = {0,1,2};
//Dentro do [3], troque o 3 pelo total de armas que sгo "brancas".
//No {0,1,2}, vб enumerando o ID de todas as armas "brancas".


Nгo se envolverгo em nenhum modo com o efeito do "HeadShot", em outras palavras, uma Bomba por exemplo, vai agir normalmente, sem fazer com que Timers, Mensagens, e outras coisas do Sistema de HeadShot sejam acionadas .



Mas, vai ter que enumerar sim as armas proibidas dentro da variбvel, como falei antes, mas agora, sу precisarб enumerar as que estiverem entre os IDs 21 e 39.



As outras, como nгo sгo "armas que atiram", jб forem restritas automaticamente.



Se a linha ficar muito grande, basta pular pra linha de baixo, exemplo ::



pawn Код:
new ArmasBrancas[3] = {0
,1
,2};


E aqui estб o FilterScript, com todas as modificaзхes citadas por min :



pawn Код:
/*************************************************
Infinite-Gaming.com Presents:
BoOm Headshot v.1 by Tannz0rz && Cyber_Punk
The closest thing to real headshots you can get in samp.

DO NOT REMOVE CREDITS
If you borrow bits of code would be nice to credit the original authors...

Thanks Kye and the Dev Team. R5+ is nice.

CONSERVATIVE mode is Recommended mode for large servers to save on processing.
This disables head shot checks when a player is holding KEY_FIRE + AIM (repeat fire).
To gain a head shot they must tap fire button. (While holding AIM)

***The Only time you can gain a headshot is in Target mode with the crosshairs.***

Left in the script is the original debug mode and "Line of Sight" (LOS) code.
To enable them just uncomment the lines below, when done simply comment them.
*************************************************/

#include <a_samp>

//======Config Options
//#define DEBUG
//#define NO_LOS //Uncomment this if you want no "Line of Sight" with your DEBUG mode
//#define FOR_EACH
#define CONSERVATIVE   //Comment for servers less than 100 players....Use @ your own risk.
#define DESTROY_LOS 500 //Time in milliseconds to remove line of sight objects
#undef MAX_PLAYERS
    #define MAX_PLAYERS 50 //Set to your max players

//======End Options

#if defined FOR_EACH
    #include <foreach>
#endif

#define KEY_AIMFIRE 132

#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

#if defined DEBUG
    new count1, count2;
#endif



new ArmasBrancas[3] = {0,1,2};
//Dentro do [3], troque o 3 pelo total de armas que sгo "brancas".
//No {0,1,2}, vб enumerando o ID de todas as armas "brancas".




new bool:AntiFloodMensagens[MAX_PLAYERS];


//----WEAPON RANGES PULLED FROM WEAPONS.DAT--Country Rifle -10.0
new
    Float:ranges[39] =
    {
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        35.0,
        35.0,
        35.0,
        40.0,
        35.0,
        40.0,
        45.0,
        35.0,
        70.0,
        90.0,
        35.0,
        90.0,
        100.0,
        0.0,
        0.0,
        0.0,
        25.0
    };

#if defined FOR_EACH
    Itter_Create(Victim, MAX_PLAYERS);
#endif


new text[128];
#define SendClientMessageEx(%0,%1,%2);  format(text,sizeof(text),%2),SendClientMessage(%0,%1,text);
public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Infinite-Gaming.com Presents:");
    print(" BoOm Headshot v1 by Tannz0rz && Cyber_Punk");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    print("\n--------------------------------------");
    print(" BoOm Headshot UNLOADED");
    print("--------------------------------------\n");
    return 1;
}

public OnPlayerConnect(playerid)
{
#if defined FOR_EACH
    Itter_Add(HSVictim, playerid);
#endif
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
#if defined FOR_EACH
    Itter_Remove(HSVictim, playerid);
#endif
    return 1;
}


public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_AIMFIRE) && NoBadCam(playerid))
    {
        switch(GetPlayerWeapon(playerid))
        {
            #if !defined CONSERVATIVE
                case WEAPON_SNIPER:
                {
                    if(GetPlayerWeaponState(playerid) == WEAPONSTATE_LAST_BULLET)
                    {
                        CheckHeadShot(playerid);
                    }
                }
                   
                case 22..33,38:
                {
                    SetTimerEx("HSTimer", 100, 0, "i", playerid);
                }
            #else
                case WEAPON_SNIPER, WEAPON_SHOTGUN:
                {
                    if(GetPlayerWeaponState(playerid) == WEAPONSTATE_LAST_BULLET)
                    {
                        CheckHeadShot(playerid);
                    }
                }
                case WEAPON_RIFLE:
                {
                    if(GetPlayerWeaponState(playerid) != WEAPONSTATE_RELOADING)
                    {
                        CheckHeadShot(playerid);
                    }
                }
                case 22..24,26..32,38:
                {
                    if(GetPlayerWeaponState(playerid) != WEAPONSTATE_RELOADING)
                    {
                        CheckHeadShot(playerid);
                    }
                }
                   
            #endif
        }
    }
    return 1;
}




forward HSTimer(playerid);
public HSTimer(playerid)
{
    new keys, ud, lr;
    GetPlayerKeys(playerid, keys, ud, lr);
    if((keys & KEY_FIRE) == (KEY_FIRE) && NoBadCam(playerid))
    {
        switch(GetPlayerWeapon(playerid))
        {
            case WEAPON_COLT45, WEAPON_UZI, WEAPON_TEC9, WEAPON_MP5, WEAPON_AK47, WEAPON_M4:{
                if(GetPlayerWeaponState(playerid) != WEAPONSTATE_RELOADING){
                    CheckHeadShot(playerid);
                    SetTimerEx("HSTimer", 150, 0, "i", playerid);
                }
            }
            case WEAPON_SHOTGSPA, WEAPON_SAWEDOFF:{
                if(GetPlayerWeaponState(playerid) != WEAPONSTATE_RELOADING){
                    CheckHeadShot(playerid);
                    SetTimerEx("HSTimer", 300, 0, "i", playerid);
                }
            }
            case WEAPON_SILENCED:{
                if(GetPlayerWeaponState(playerid) != WEAPONSTATE_RELOADING){
                    CheckHeadShot(playerid);
                    SetTimerEx("HSTimer", 500, 0, "i", playerid);
                }
            }
            case WEAPON_DEAGLE:{
                if(GetPlayerWeaponState(playerid) != WEAPONSTATE_RELOADING){
                    CheckHeadShot(playerid);
                    SetTimerEx("HSTimer", 800, 0, "i", playerid);
                }
            }
            case WEAPON_SHOTGUN:
            {
                if(GetPlayerWeaponState(playerid) != WEAPONSTATE_NO_BULLETS){
                    CheckHeadShot(playerid);
                    SetTimerEx("HSTimer", 900, 0, "i", playerid);
                }
            }
            case WEAPON_RIFLE:
            {
                if(GetPlayerWeaponState(playerid) != WEAPONSTATE_RELOADING){
                    CheckHeadShot(playerid);
                    SetTimerEx("HSTimer", 1000, 0, "i", playerid);
                }
            }
        }
    }
    return 1;
}


forward CheckHeadShot(playerid);
public CheckHeadShot(playerid)
{
    for(new x; x != sizeof(ArmasBrancas); x++)
    {
        if(GetPlayerWeapon(playerid) == ArmasBrancas[x])
        {
            return true;
        }
    }
    #if defined DEBUG
        count1 = GetTickCount();
    #endif

    new Float:x[4], Float:y[4], Float:z[4], Float:dist = 1.0, Float:range = 0.0;
    GetPlayerCameraPos(playerid, x[0], y[0], z[0]);
    GetPlayerCameraFrontVector(playerid, x[1], y[1], z[1]);

    #if defined DEBUG
        printf("\nCamera Position: x=%.2f, y=%.2f, z=%.2f\nFrontVector: x=%.2f, y=%.2f, z=%.2f", x[0], y[0], z[0], x[1], y[1], z[1]);
    #endif

    range = ranges[GetPlayerWeapon(playerid)];

    if(range != 0.0)
    {
        switch(GetPlayerWeapon(playerid))
        {
            case WEAPON_RIFLE:
            {
                if(x[1] < 0.0 && y[1] > 0.0 )
                {
                    x[1] += 0.0155;
                    y[1] += 0.0155;
                }
                else if(x[1] > 0.0 && y[1] > 0.0)
                {
                    x[1] += 0.0155;
                    y[1] -= 0.0155;
                }
                else if(x[1] < 0.0 && y[1] < 0.0)
                {
                    x[1] -= 0.0155;
                    y[1] += 0.0155;
                }
                else if(x[1] > 0.0 && y[1] < 0.0)
                {
                    x[1] -= 0.0155;
                    y[1] -= 0.0155;
                }
                if(z[1] > 0.1) z[1] += 0.06;
                else z[1] += 0.05;
            }
            case WEAPON_AK47,WEAPON_M4:
            {
                if(x[1] < 0.0 && y[1] > 0.0 )
                {
                    x[1] += 0.0225;
                    y[1] += 0.0225;
                }
                else if(x[1] > 0.0 && y[1] > 0.0)
                {
                    x[1] += 0.0225;
                    y[1] -= 0.0225;
                }
                else if(x[1] < 0.0 && y[1] < 0.0)
                {
                    x[1] -= 0.0225;
                    y[1] += 0.0225;
                }
                else if(x[1] > 0.0 && y[1] < 0.0)
                {
                    x[1] -= 0.0225;
                    y[1] -= 0.0225;
                }
                if(z[1] > 0.0) z[1] += 0.08;
                else if(z[1] < -0.0 && z[1] > -0.5) z[1] += 0.06;
                else if(z[1] < -0.5) z[1] -= 0.05;
            }
            case 22..29,32,38:
            {
                if(x[1] < 0.0 && y[1] > 0.0 )
                {
                    x[1] += 0.0325;
                    y[1] += 0.0325;
                }
                else if(x[1] > 0.0 && y[1] > 0.0)
                {
                    x[1] += 0.0325;
                    y[1] -= 0.0325;
                }
                else if(x[1] < 0.0 && y[1] < 0.0)
                {
                    x[1] -= 0.0325;
                    y[1] += 0.0325;
                }
                else if(x[1] > 0.0 && y[1] < 0.0)
                {
                    x[1] -= 0.0325;
                    y[1] -= 0.0325;
                }
                if(z[1] > 0.0) z[1] += 0.125;
                else z[1] += 0.09;
            }
        }
        x[0] += (2.0 * x[1]);
        y[0] += (2.0 * y[1]);

        do
        {
            x[0] += (x[1] * 1.0);
            y[0] += (y[1] * 1.0);
            z[0] += (z[1] * 1.0);

            #if defined DEBUG
                #if !defined NO_LOS
                #endif
            #endif

        #if !defined FOR_EACH
            for(new i = 0; i < MAX_PLAYERS; ++i)
            #if !defined DEBUG
                if(IsPlayerConnected(i))
            #endif
        #else
            foreach(HSVictim, i)
        #endif
            {
                if( i != playerid)
                {
                    GetPlayerPos(i, x[2], y[2], z[2]);

                    if(GetPlayerSpecialAction(i) == SPECIAL_ACTION_DUCK) z[2] -= 0.6;
                    else z[2] += 0.8;
                    if(PointInRangeOfPoint(0.5, x[0], y[0], z[0], x[2], y[2], z[2]))
                    {
                        if(!AntiFloodMensagens[playerid] && !AntiFloodMensagens[i])
                        {
                            SetPlayerHealth(i, 0.0);
                            new Morto[MAX_PLAYER_NAME], Matador[MAX_PLAYER_NAME];
                            GetPlayerName(i, Morto, sizeof(Morto));
                            GetPlayerName(playerid, Matador, sizeof(Matador));
                            SendClientMessageEx(playerid,0x33CCFFAA,"Vocк deu um HeadShot no %s e matou ele !",Morto);
                            SendClientMessage(i,0x33CCFFAA,"Vocк tomou um HeadShot e morreu !");
                            AntiFloodMensagens[playerid] = true;
                            AntiFloodMensagens[i] = true;
                            SetTimerEx("AntiFloodReview", 1500, false, "dd", playerid, i);
                        }
                        #if defined DEBUG
                            count2 = GetTickCount();
                            count1 = count2 - count1;
                            printf("\n Player hit\n Max Players Looped: %d\n Max Weapon Range: %.2f\n Distance to Hit: %.2f\n Total execution time: %8d ms",i,range,dist,count1);
                            count1=count2;
                        #endif
                        return 1;
                    }
                }
            }
            dist += 1.0;
        }
        while( dist < range );
        #if defined DEBUG
            count2 = GetTickCount();
            count1 = count2 - count1;
            printf("\n Max Players Looped: %d\n Max Weapon Range: %.2f\n Total execution time: %8d ms",MAX_PLAYERS,range, count1);
            count1=count2;
        #endif
    }
    return 1;
}

stock NoBadCam(playerid) //Don't ask but it works
{

    new Float:x, Float:y, Float:z,Float:ang;
    GetPlayerCameraFrontVector(playerid, x, y, z);
    GetPlayerFacingAngle(playerid,ang);

    if((x < 0.0 && y > 0.0) && (ang > 90.0 && ang < 300.0)) return 0;
    else if((x > 0.0 && y > 0.0) && (ang > 88.16 && ang < 275.0)) return 0;
    else if((x < 0.0 && y < 0.0) && (ang > 257.30 && ang < 360.0)) return 0;
    else if((x > 0.0 && y < 0.0) && (ang < 88.16 && ang < 257.30)) return 0;

    return 1;
}


forward AntiFloodReview(playerid, i);
public AntiFloodReview(playerid, i)
{
    AntiFloodMensagens[playerid] = false;
    AntiFloodMensagens[i] = false;
    return true;
}



// As taken from ******'s IsPlayerInRangeOfPoint
stock PointInRangeOfPoint(Float:range, Float:x, Float:y, Float:z, Float:X, Float:Y, Float:Z)
{
    X -= x;
    Y -= y;
    Z -= z;
    return ((X * X) + (Y * Y) + (Z * Z)) < (range * range);
}



Com isso, os problemas do Filterscript estгo resolvidos, qualquer coisa, basta ler novamente todos os meus posts aqui no tуpico, ou, checar seu Gamemode .



Espero ter ajudado .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)