[Include] Arma Especial - Rocket System
#1

Estб Include possui 2 funзхes:
- GivePlayerSpecialWeapon(playerid, ammo)
Dб uma arma especial com X ammo ao playerid

- ResetPlayerSpecialWeapon(playerid)
Retira a arma especial do playerid


A arma especial й um lanзador de misseis que perseguem o alvo, caso nгo tenha alvo, o missel seque reto de acordo pra onde vocк estб mirando O lanзador de misseis e representado pela arma SPAZ, e para ativa-lб/desativa-lб (caso tenha a arma especial) basta apertar Y, ao atirar o missel a arma e trocada automaticamente para a SPAZ normal e apуs 5 segundos volta automaticamente ao lanзador de misseis. O missel persegue o alvo por 5 segundos, apуs isso ele explode, o mesmo serve caso nгo tenha alvo.

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

Download:
pawn Code:
#include <a_samp>

#define KEY_AIM 128

new Missel[MAX_OBJECTS], m;

enum WeaponInfo
{
    Ammo1,
    Ammo2,
    bool:Have,
    bool:Lauch,
    Timer,
    bool:Wating
}

new WI[MAX_PLAYERS][WeaponInfo];

// Filter by Gustavo Bonomo

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_YES && GetPlayerWeapon(playerid) == 27 && WI[playerid][Have] == true && WI[playerid][Wating] == false)
    {
        if(WI[playerid][Lauch] == false)
        {
            new ammo, weapon;
            GetPlayerWeaponData(playerid, 3, weapon, ammo);
            WI[playerid][Ammo2] = ammo;
            RemovePlayerWeapon(playerid, 27);
            WI[playerid][Lauch] = true;
            GivePlayerWeapon(playerid, 27, WI[playerid][Ammo1]);
            GameTextForPlayer(playerid, "ON", 1000, 4);
            ApplyAnimation(playerid, "UZI", "UZI_reload", 4.1, 0, 1, 1, 1, 1, 1);
        }
        else
        {
            RemovePlayerWeapon(playerid, 27);
            WI[playerid][Lauch] = false;
            GivePlayerWeapon(playerid, 27, WI[playerid][Ammo2]);
            GameTextForPlayer(playerid, "OFF", 1000, 4);
            ApplyAnimation(playerid, "UZI", "UZI_reload", 4.1, 0, 1, 1, 1, 1, 1);
        }
    }
    else if((newkeys & KEY_FIRE && newkeys & KEY_AIM || newkeys == KEY_FIRE) && GetPlayerWeapon(playerid) == 27 && WI[playerid][Have] == true && WI[playerid][Lauch] == true && WI[playerid][Wating] == false)
    {
        new target = GetPlayerTargetPlayer(playerid);
        LancarMissel(playerid, target);
        RemovePlayerWeapon(playerid, 27);
        WI[playerid][Wating] = true;
        WI[playerid][Ammo1] --;
        GivePlayerWeapon(playerid, 27, WI[playerid][Ammo2]);
        GameTextForPlayer(playerid, "OFF", 1000, 4);
        ApplyAnimation(playerid, "UZI", "UZI_reload", 4.1, 0, 1, 1, 1, 1, 1);
        SetTimerEx("Liberar", 5000, false, "i", playerid);
    }
    return 1;
}

#if defined _ALS_OnPlayerKeyStateChange
    #undef OnPlayerKeyStateChange
#else
    #define _ALS_OnPlayerKeyStateChange
#endif
#define OnPlayerKeyStateChange gb_OnPlayerKeyStateChange
forward gb_OnPlayerKeyStateChange();

forward Liberar(playerid);
public Liberar(playerid)
{
    RemovePlayerWeapon(playerid, 27);
    WI[playerid][Wating] = false;
    GivePlayerWeapon(playerid, 27, WI[playerid][Ammo1]);
    GameTextForPlayer(playerid, "ON", 1000, 4);
    ApplyAnimation(playerid, "UZI", "UZI_reload", 4.1, 0, 1, 1, 1, 1, 1);
    return 1;
}

forward AtualizarMissel(playerid, objid);
public AtualizarMissel(playerid, objid)
{
    new Float:PosT[3];
    GetPlayerPos(playerid, PosT[0], PosT[1], PosT[2]);
    if(ObjectToPoint(2.0, objid, PosT[0], PosT[1], PosT[2]))
    {
        CreateExplosion(PosT[0], PosT[1], PosT[2], 5, 10.0);
        DestroyObject(objid);
        KillTimer(WI[playerid][Timer]);
    }
    else if(PosT[0] != GetPVarFloat(playerid, "playerX") || PosT[1] != GetPVarFloat(playerid, "playerY") || PosT[2] != GetPVarFloat(playerid, "playerZ"))
    {
        SetPVarFloat(playerid, "playerX", PosT[0]), SetPVarFloat(playerid, "playerY", PosT[1]), SetPVarFloat(playerid, "playerZ", PosT[2]);
        StopObject(objid);
        MoveObject(objid, PosT[0], PosT[1], PosT[2], 10.0);
    }
    return 1;
}

forward FinalizarMissel(objid);
public FinalizarMissel(objid)
{
    new Float:Pos[3];
    GetObjectPos(objid, Pos[0], Pos[1], Pos[2]);
    CreateExplosion(Pos[0], Pos[1], Pos[2], 5, 10.0);
    DestroyObject(objid);
    return 1;
}

stock LancarMissel(playerid, target)
{
    m++;
    new Float:PosT[3], Float:PosP[3];
    GetPlayerPos(playerid, PosP[0], PosP[1], PosP[2]);
    if(target != INVALID_PLAYER_ID)
    {
        GetPlayerPos(target, PosT[0], PosT[1], PosT[2]);
        Missel[m] = CreateObject(354, PosP[0], PosP[1], PosP[2], 0.0, 0.0, 0.0);
        MoveObject(Missel[m], PosT[0], PosT[1], PosT[2], 10.0);
        SetPVarFloat(playerid, "playerX", PosT[0]), SetPVarFloat(playerid, "playerY", PosT[1]), SetPVarFloat(playerid, "playerZ", PosT[2]);
        WI[playerid][Timer] = SetTimerEx("AtualizarMissel", 250, true, "ii", target, Missel[m]);
        SetTimerEx("FinalizarMissel", 5000, false, "i", Missel[m]);
    }
    else
    {
        new Float:fP[3], Float:fV[3], Float:PosO[3];
        GetPlayerCameraPos(playerid, fP[0], fP[1], fP[2]);
        GetPlayerCameraFrontVector(playerid, fV[0], fV[1], fV[2]);
        PosO[0] = fP[0] + floatmul(fV[0], 60.0);
        PosO[1] = fP[1] + floatmul(fV[1], 60.0);
        PosO[2] = fP[2] + floatmul(fV[2], 60.0);
        Missel[m] = CreateObject(354, PosP[0], PosP[1], PosP[2], 0.0, 0.0, 0.0);
        MoveObject(Missel[m], PosO[0], PosO[1], PosO[2], 10.0);
        SetTimerEx("FinalizarMissel", 5000, false, "i", Missel[m]);
    }
    return 1;
}

stock RemovePlayerWeapon(playerid, weaponid)
{
    if(!IsPlayerConnected(playerid) || weaponid < 0 || weaponid > 50)
        return;

    new
        saveweapon[13],
        saveammo[13];

    for(new slot = 0; slot < 13; slot++)
        GetPlayerWeaponData(playerid, slot, saveweapon[slot], saveammo[slot]);

    ResetPlayerWeapons(playerid);

    for(new slot; slot < 13; slot++)
    {
        if(saveweapon[slot] == weaponid || saveammo[slot] == 0)
            continue;

        GivePlayerWeapon(playerid, saveweapon[slot], saveammo[slot]);
    }

    GivePlayerWeapon(playerid, 0, 1);
}

stock ObjectToPoint(Float:radi, objectid, Float:x, Float:y, Float:z)
{
    new Float:oldposx, Float:oldposy, Float:oldposz;
    new Float:tempposx, Float:tempposy, Float:tempposz;
    GetObjectPos(objectid, oldposx, oldposy, oldposz);
    tempposx = (oldposx -x);
    tempposy = (oldposy -y);
    tempposz = (oldposz -z);
    if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
    {
        return 1;
    }
    return 0;
}

stock GivePlayerSpecialWeapon(playerid, ammu)
{
    WI[playerid][Have] = true;
    WI[playerid][Ammo1] = ammu;
    new ammo, weapon;
    GetPlayerWeaponData(playerid, 3, weapon, ammo);
    WI[playerid][Ammo2] = ammo;
    RemovePlayerWeapon(playerid, 27);
    GivePlayerWeapon(playerid, 27, WI[playerid][Ammo1]);
    return 1;
}

stock ResetPlayerSpecialWeapon(playerid)
{
    Have[playerid] = false;
    Lauch[playerid] = false;
    Ammo[playerid] = 0;
    RemovePlayerWeapon(playerid, 27);
    return 1;
}
Testando e 100 por cento funcional, crйditos a mim e ao final do vнdeo mais informaзхes sobre o mesmo, sem permissгo para postar em outros lugares!
Espero que goste, comente!
Reply
#2

Bem feito,ideia legal,parabens.
Reply
#3

Quote:
Originally Posted by Gustavo_Araujo
View Post
Bem feito,ideia legal,parabens.
Brigadu *-*
Reply
#4

gostei
Reply
#5

Valeu Lucas ^^
Reply
#6

WFT ? Essa arma do video nunca sera o Rocket


@Topic
Bueno Sistema (:
Reply
#7

Quote:
Originally Posted by Ades
View Post
WFT ? Essa arma do video nunca sera o Rocket


@Topic
Bueno Sistema (:
'----'

Thanks. Se pode alterar o ID da arma horas '-'
Reply
#8

Quote:
Originally Posted by CidadeNovaRP
View Post
'----'

Thanks. Se pode alterar o ID da arma horas '-'
Hora Bolas , entгo por que vocк nгo avisou ?
Reply
#9

Quote:
Originally Posted by Ades
View Post
Hora Bolas , entгo por que vocк nгo avisou ?
Pois todos os CODEs postados aqui podem ser alterados horas kk
Reply
#10

Quote:
Originally Posted by CidadeNovaRP
View Post
Pois todos os CODEs postados aqui podem ser alterados horas kk
Hora bolas , vocк acha que sou vidente ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)