SA-MP Forums Archive
[FilterScript] Sistema de colete(kevlar) "Real" - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+----- Forum: Lançamentos/Releases (https://sampforum.blast.hk/forumdisplay.php?fid=56)
+----- Thread: [FilterScript] Sistema de colete(kevlar) "Real" (/showthread.php?tid=496833)



Sistema de colete(kevlar) "Real" - DrTHE - 24.02.2014

Boa noite, no inicio da semana passada tive uma ideia de criar um sistema de colete "real" sem o uso de progress bar's, entгo pensei que talvez conseguiria algo detectando o tiro no objeto de 'colete' no jogador atravйs de OnPlayerWeaponShot, mas como o objeto nгo ficou "sуlido" minhas esperanзas se foram..

Porйm hoje de manhг tive a ideia de tentar contornar esse grave problema, descobri que era possнvel fazer essa detecзгo usando o offset 'z' do jogador, e com isso o sistema funcionou bem, estimo que com cerca de 80% de precisгo.

Vнdeo: [ame]http://www.youtube.com/watch?v=S_AJPGlu4F0[/ame]

Funзгo:
Код:
SetPlayerKevlarHealth(playerid, Float:amount);
Ela seta o health do colete para o jogador, й bem fбcil o seu uso.

Comando utilizado:
pawn Код:
CMD:colete(playerid, params[]) {
    SetPlayerKevlarHealth(strval(params), 300.0);
    return 1;
}
Cуdigo:
pawn Код:
#include a_samp
#include zcmd

#define SLOT_INDEX 0

enum weapon_info { weapon_id, Float:_amount };
new
    Float:playerKevlarHealth[MAX_PLAYERS],
    bool:haveKevlar[MAX_PLAYERS],
    weapon_data[][weapon_info] = {
    {24, 50.0},
    {22, 50.0},
    {32, 10.0},
    {28, 10.0},
    {23, 50.0},
    {31, 35.0},
    {30, 40.0},
    {29, 18.0},
    {34, 300.0},
    {33, 35.0},
    {25, 100.0},
    {27, 70.0}
};

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    if(hittype == BULLET_HIT_TYPE_PLAYER && (0 < fZ < 0.5)) {
        if(haveKevlar[hitid] == true) {

            new slot = -1;

            for(new i; i < sizeof(weapon_data); ++i)
                if(weapon_data[i][weapon_id] == weaponid)
                    slot = i;
                   
            if(slot != -1) {
                playerKevlarHealth[hitid] -= weapon_data[slot][_amount];

                if(playerKevlarHealth[hitid] <= 0.0) {
                    new Float:fHealth;
                    GetPlayerHealth(hitid, fHealth);
                    SetPlayerHealth(hitid, playerKevlarHealth[hitid]+fHealth);

                    haveKevlar[hitid] = false;
                    playerKevlarHealth[hitid] = 0.0;
                    RemovePlayerAttachedObject(hitid, SLOT_INDEX);
                }
                return 0;
            }
        }
    }
    return 1;
}

stock SetPlayerKevlarHealth(playerid, Float:amount) {
    playerKevlarHealth[playerid] = amount;
    haveKevlar[playerid] = true;
    SetPlayerAttachedObject(playerid, SLOT_INDEX, 19142, 1, 0.084367, 0.041716, 0.017513, 3.662353, 355.182006, 0.181060, 1.000000, 1.000000, 1.000000);
    return 1;
}

CMD:colete(playerid, params[]) {
    SetPlayerKevlarHealth(strval(params), 300.0);
    return 1;
}
*A definiзгo SLOT_INDEX й referente ao parвmetro "index" da funзгo SetPlayerAttachedObject
*Esse sistema da suporte a apenas as armas declaradas em "weapon_data"
*Agora quando o dano й superior ao health do colete o jogador receberб o dano restante. (Agradecimentos a CyNiC)

Esse pequeno "sistema" foi criado em forma de filterscript, mas podem adaptб-lo como quiserem.

Crйditos a mim, Oolsk(Brinquedo), meu irmгo pelo canal do ******* e zDevon pelos dados de armas.

Obrigado


Re: Sistema de colete(kevlar) "Real" - WLSF - 24.02.2014

Eu olhei sу o vнdeo, achei criativo, massa


Re: Sistema de colete(kevlar) "Real" - Sky™ - 24.02.2014

interessante ^^


Re: Sistema de colete(kevlar) "Real" - feliphemort - 24.02.2014

Creative :3


Re: Sistema de colete(kevlar) "Real" - dPlaYer_ - 24.02.2014

Nice, good work.

where are my credits?


Respuesta: Sistema de colete(kevlar) "Real" - AlieN_ - 24.02.2014

hahaha criativo e legal, p/beins


Re: Sistema de colete(kevlar) "Real" - CyNiC - 24.02.2014

Curti, bem criativa tua ideia.

Notei um pequeno problema: Digamos que o jogador tenha 1% do colete e receba um tiro de Deagle, a vida dele tambйm deveria diminuir.


Re: Sistema de colete(kevlar) "Real" - ViniBorn - 24.02.2014

Excelente trabalho.
rep += 8;


Re: Sistema de colete(kevlar) "Real" - zSuYaNw - 24.02.2014

Уtimo projeto! esta бrea precisa de coisas novas como esta.. parabйns!


Re: Sistema de colete(kevlar) "Real" - DrTHE - 24.02.2014

Obrigado a todos

Quote:
Originally Posted by dPlaYer_
Посмотреть сообщение
Nice, good work.

where are my credits?
Se pelo menos tivesse me respondido na hora de gravar rsrs.

Quote:
Originally Posted by CyNiC
Посмотреть сообщение
Curti, bem criativa tua ideia.

Notei um pequeno problema: Digamos que o jogador tenha 1% do colete e receba um tiro de Deagle, a vida dele tambйm deveria diminuir.
Verdade, faz todo sentido, mais tarde eu adiciono isso e atualizo o tуpico.

Thanks.

~ Adicionado
Код:
                    new Float:fHealth;
                    GetPlayerHealth(hitid, fHealth);
                    SetPlayerHealth(hitid, playerKevlarHealth[hitid]+fHealth);