AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with CODclass and perk (https://forums.alliedmods.net/showthread.php?t=299224)

OxG 07-07-2017 17:10

Help with CODclass and perk
 
Hello everyone I have some troubles with Class and perk in COD MOD. This class and perk posted below should let you to do instant defuse, but this won't work properly. I beg you for help ;)
Best regards.

CLASS:
Code:

#include <amxmodx>
#include <amxmisc>
#include <codmod>
#include <engine>
#include <colorchat>
#include <hamsandwich>
#include <fakemeta_util>
#include <csx>

#define PLUGIN "Rusznikarz"
#define VERSION "1.0"
#define AUTHOR "Lukovsky"

new const nazwa[] = "Rusznikarz |Premium|";
new const opis[] = "Widzi niewidzialnych, ma 2 miny zadajace 25 Dmg + Inteligencja, moze natychmiastowo podlozyc/rozbroic bombe, 1/5 szans na odbicie pocisku.";
new const bronie  = (1<<CSW_MP5NAVY)|(1<<CSW_USP)|(1<<CSW_HEGRENADE);
new const zdrowie = 15;
new const kondycja = 20;
new const inteligencja = 5;
new const wytrzymalosc = 10;

new bool:ma_klase[33];

new sprite_blast_miny;
new ilosc_min_gracza[33];
new const modelMiny[] = "models/QTM_CodMod/mine.mdl"

#define m_fBombState                      96
#define m_fBombDefusing                  232
#define m_flProgressBarStartTime          605
#define m_flProgressBarEndTime          606

    // m_fBombState - flagi
#define BombState_StartDefusing          1<<0
#define BombState_PlantedC4              1<<8
   
    // m_fBombDefusing - flagi
#define BombStatus_BeingDefusing          1<<8

#define m_flDefuseCountDown              99 // Czas w ktorym zostanie rozbrojona paka
#define m_flNextPrimaryAttack          46 // Czas do nastepnego ataku

#define m_bStartedArming                78 // Zwraca true, jesli uzbrajanie paki sie zaczelo
#define m_bBombPlacedAnimation          79 // Zwraca true, jesli ruszyla animacja (nie wiem czy paki czy gracza).       
#define m_fArmedTime                    99 // Czas w ktorym zostanie podlozona paka.       

#define IsBombPlanted(%0)          (!!(get_pdata_int(%0, m_fBombState) & BombState_PlantedC4))
#define IsBombStartDefusing(%0)    (!!(get_pdata_int(%0, m_fBombState) & BombState_StartDefusing))
#define IsBombDefusing(%0)        (!!(get_pdata_int(%0, m_fBombDefusing) & BombStatus_BeingDefusing))
   
#define SetDefuseCountDown(%0,%1)  ( set_pdata_float( %0, m_flDefuseCountDown, get_gametime() + %1 ) )
#define SetProgressBarTime(%0,%1)  ( set_pdata_float( %0, m_flProgressBarStartTime, get_gametime() ), set_pdata_float( %0, m_flProgressBarEndTime, get_gametime() + %1 ) )

new MessageBarTime;
new HandleHookBarTime;

public plugin_init()
{
        register_plugin(PLUGIN, VERSION, AUTHOR);
       
        cod_register_class(nazwa, opis, bronie, zdrowie, kondycja, inteligencja, wytrzymalosc);
        register_touch("mine", "player",  "DotykMiny");
       
        register_event("HLTV", "NowaRunda_Miny", "a", "1=0", "2=0");
        RegisterHam(Ham_Spawn, "player", "fwSpawn_Miny", 1);
        RegisterHam(Ham_Use, "grenade", "Defuse_Pre", false);
        RegisterHam(Ham_Use, "grenade", "Defuse_Post", true);

        MessageBarTime = get_user_msgid("BarTime");

        register_forward(FM_TraceLine,"fw_traceline");       

        register_forward(FM_AddToFullPack, "FwdAddToFullPack", 1)
}

public plugin_precache()
{
        precache_model(modelMiny);
        sprite_blast_miny = precache_model("sprites/dexplo.spr");
}

public cod_class_enabled(id)
{
        if(!(get_user_flags(id) & ADMIN_LEVEL_H))
        {
                client_print(id, print_chat, "[VIP] Nie posiadasz VIP'a");
                return COD_STOP;
        }

        ma_klase[id] = true;
        ilosc_min_gracza[id] = 2;
        ColorChat(id, BLUE, "[Opis]:^x01 %s",opis);

        return COD_CONTINUE;       
}

public cod_class_disabled(id)
{
        ma_klase[id] = false;
        ilosc_min_gracza[id] = 0;
}

public bomb_planting(id)
{
        if(!is_user_connected(id))
                return PLUGIN_CONTINUE;
               
        if(!ma_klase[id])
                return PLUGIN_CONTINUE;
       
        new ent = fm_find_ent_by_owner(-1, "weapon_c4", id)
        if(ent)
        {
                message_begin(MSG_ONE,MessageBarTime,{0,0,0},id)
                write_byte(0)
                write_byte(0)
                message_end()
       
                set_pdata_float(ent, m_flNextPrimaryAttack , 0.0, 4);
                set_pdata_int(ent, m_bStartedArming, true, 4)
                set_pdata_int(ent, m_bBombPlacedAnimation, true, 4)
                set_pdata_float(ent, m_fArmedTime, get_pdata_float(ent, 80, 4)-3.0, 4)       
        }
        return PLUGIN_CONTINUE;
}
public Defuse_Pre( const grenade, const caller, const activator, const useType, const Float:value )
{
        if(IsBombPlanted(grenade) && is_user_connected(activator) && get_user_team(activator) == 2 && !IsBombStartDefusing(grenade) && ma_klase[activator])
        {
                HandleHookBarTime = register_message(MessageBarTime, "OnMessageBarTime" );
        }
}

public Defuse_Post( const grenade, const caller, const activator, const useType, const Float:value )
{
        if( HandleHookBarTime )
        {
                SetProgressBarTime(activator, 0);
                SetDefuseCountDown(grenade, 0);
       
                unregister_message( HandleHookBarTime, MessageBarTime );
                HandleHookBarTime = 0;
        }
}
public OnMessageBarTime( msgId, msgDest, msgEntity )
{
        if( IsBombDefusing( msgEntity ) )
        {
                set_msg_arg_int(1, ARG_SHORT, 0);
        }
}

public cod_class_skill_used(id)
{
        if(!ma_klase[id])
                return;
       
       
        if (!ilosc_min_gracza[id])
        {
                client_print(id, print_center, "[ProCOD] Ustawiles juz wszystkie miny.");
        }
        else
        {
               
                ilosc_min_gracza[id]--;
               
                new Float:origin[3];
                entity_get_vector(id, EV_VEC_origin, origin);
               
                new ent = create_entity("info_target");
                entity_set_string(ent ,EV_SZ_classname, "mine");
                entity_set_edict(ent ,EV_ENT_owner, id);
                entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS);
                entity_set_origin(ent, origin);
                entity_set_int(ent, EV_INT_solid, SOLID_BBOX);
               
                entity_set_model(ent, modelMiny);
                entity_set_size(ent,Float:{-16.0,-16.0,0.0},Float:{16.0,16.0,2.0});
               
                drop_to_floor(ent);
               
                set_rendering(ent,kRenderFxNone, 0,0,0, kRenderTransTexture,50);
        }
}

public fwSpawn_Miny(id)
{
        if(!ma_klase[id])
                return;
       
        if(is_user_alive(id))
                ilosc_min_gracza[id] = 2;
}

public DotykMiny(ent, id)
{
        if(!is_valid_ent(ent))
                return;
       
        new attacker = entity_get_edict(ent, EV_ENT_owner);
        if (get_user_team(attacker) != get_user_team(id))
        {
                new Float:fOrigin[3];
                entity_get_vector( ent, EV_VEC_origin, fOrigin);
               
                new iOrigin[3];
                for(new i=0;i<3;i++)
                        iOrigin[i] = floatround(fOrigin[i]);
               
                message_begin(MSG_BROADCAST,SVC_TEMPENTITY, iOrigin);
                write_byte(TE_EXPLOSION);
                write_coord(iOrigin[0]);
                write_coord(iOrigin[1]);
                write_coord(iOrigin[2]);
                write_short(sprite_blast_miny);
                write_byte(32);
                write_byte(20);
                write_byte(0);
                message_end();
               
                new entlist[33];
                new numfound = find_sphere_class(ent,"player", 90.0 ,entlist, 32);
               
                for (new i=0; i < numfound; i++)
                {
                        new pid = entlist[i];
                       
                        if (!is_user_alive(pid) || get_user_team(attacker) == get_user_team(pid))
                                continue;
                       
                        if(cod_get_user_class(pid) == cod_get_classid("Kameleon") || cod_get_user_class(pid) == cod_get_classid("|PREMIUM| SWAT") || cod_get_user_class(pid) == cod_get_classid("Komandos |200|"))
                                continue;
                       
                        cod_inflict_damage(attacker, pid, 25.0, 0.55, ent, (1<<24));
                }
                remove_entity(ent);
        }
}

public NowaRunda_Miny()
{
        new entMiny = find_ent_by_class(-1, "mine");
        while(entMiny > 0)
        {
                remove_entity(entMiny);
                entMiny = find_ent_by_class(entMiny, "mine");
        }
}

public client_disconnect(id)
{
        new entMiny = find_ent_by_class(0, "mine");
        while(entMiny > 0)
        {
                if(entity_get_edict(entMiny, EV_ENT_owner) == id)
                        remove_entity(entMiny);
                entMiny = find_ent_by_class(entMiny, "mine");
        }
}

public fw_traceline(Float:vecStart[3],Float:vecEnd[3],ignoreM,id,trace)
{
        if(!is_user_connected(id))
                return FMRES_IGNORED;
       
        if(!is_user_alive(id))
                return FMRES_IGNORED;       
       
        new hit = get_tr2(trace, TR_pHit)
        if(!(pev(id,pev_button) & IN_ATTACK))
                return FMRES_IGNORED;

        if(is_user_alive(hit))
        {
                if(ma_klase[hit] && random_num(0,5)==1){
                        set_tr2(trace, TR_iHitgroup, 8);
                }               
               
                return FMRES_IGNORED;             
        }
       
        return FMRES_IGNORED;
}

public FwdAddToFullPack(es_handle, e, ent, host, hostflags, player, pSet)
{
        if(!is_user_connected(host) || !is_user_connected(ent))
                return;
               
        if(!ma_klase[host])
                return;
               
        set_es(es_handle, ES_RenderAmt, 255.0);
}

PERK:
Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <codmod>
#include <hamsandwich>
#include <fakemeta_util>
#include <csx>

#define m_fBombState                      96
#define m_fBombDefusing                  232
#define m_flProgressBarStartTime          605
#define m_flProgressBarEndTime          606

    // m_fBombState - flagi
#define BombState_StartDefusing          1<<0
#define BombState_PlantedC4              1<<8
   
    // m_fBombDefusing - flagi
#define BombStatus_BeingDefusing          1<<8

#define m_flDefuseCountDown              99 // Czas w ktorym zostanie rozbrojona paka
#define m_flNextPrimaryAttack          46 // Czas do nastepnego ataku

#define m_bStartedArming                78 // Zwraca true, jesli uzbrajanie paki sie zaczelo
#define m_bBombPlacedAnimation          79 // Zwraca true, jesli ruszyla animacja (nie wiem czy paki czy gracza).       
#define m_fArmedTime                    80 // Czas w ktorym zostanie podlozona paka.       

#define IsBombPlanted(%0)          (!!(get_pdata_int(%0, m_fBombState) & BombState_PlantedC4))
#define IsBombStartDefusing(%0)    (!!(get_pdata_int(%0, m_fBombState) & BombState_StartDefusing))
#define IsBombDefusing(%0)        (!!(get_pdata_int(%0, m_fBombDefusing) & BombStatus_BeingDefusing))
   
#define SetDefuseCountDown(%0,%1)  ( set_pdata_float( %0, m_flDefuseCountDown, get_gametime() + %1 ) )
#define SetProgressBarTime(%0,%1)  ( set_pdata_float( %0, m_flProgressBarStartTime, get_gametime() ), set_pdata_float( %0, m_flProgressBarEndTime, get_gametime() + %1 ) )

new const nazwa[] = "Narzedzia Pirotechnika";
new const opis[] = "Mozesz natychmiastowo rozbroic badz podlozyc pake";

new MessageBarTime;
new HandleHookBarTime;
new bool: ma_perk[33];

public plugin_init()
{
        register_plugin(nazwa, "1.0", "Hleb");
        cod_register_perk(nazwa, opis);
        RegisterHam(Ham_Use, "grenade", "Defuse_Pre", false);
        RegisterHam(Ham_Use, "grenade", "Defuse_Post", true);
        MessageBarTime = get_user_msgid("BarTime");
}
public cod_perk_enabled(id)
{
        ma_perk[id] = true;
}
public cod_perk_disabled(id)
{
        ma_perk[id] = false;
}
public bomb_planting(id)
{
        if(!is_user_connected(id))
                return PLUGIN_CONTINUE;
               
        if(!ma_perk[id])
                return PLUGIN_CONTINUE;
       
        new ent = fm_find_ent_by_owner(-1, "weapon_c4", id)
        if(ent)
        {
                message_begin(MSG_ONE,MessageBarTime,{0,0,0},id)
                write_byte(0)
                write_byte(0)
                message_end()
       
                set_pdata_float(ent, m_flNextPrimaryAttack , 0.0, 4);
                set_pdata_int(ent, m_bStartedArming, true, 4)
                set_pdata_int(ent, m_bBombPlacedAnimation, true, 4)
                set_pdata_float(ent, m_fArmedTime, get_pdata_float(ent, 80, 4)-3.0, 4)       
        }
        return PLUGIN_CONTINUE;
}
public Defuse_Pre( const grenade, const caller, const activator, const useType, const Float:value )
{
        if(IsBombPlanted(grenade) && is_user_connected(activator) && get_user_team(activator) == 2 && !IsBombStartDefusing(grenade) && ma_perk[activator])
        {
                HandleHookBarTime = register_message(MessageBarTime, "OnMessageBarTime" );
        }
}

public Defuse_Post( const grenade, const caller, const activator, const useType, const Float:value )
{
        if( HandleHookBarTime )
        {
                SetProgressBarTime(activator, 0);
                SetDefuseCountDown(grenade, 0);
       
                unregister_message( HandleHookBarTime, MessageBarTime );
                HandleHookBarTime = 0;
        }
}
public OnMessageBarTime( msgId, msgDest, msgEntity )
{
        if( IsBombDefusing( msgEntity ) )
        {
                set_msg_arg_int(1, ARG_SHORT, 0);
        }
}



All times are GMT -4. The time now is 22:55.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.