2020. október 28., szerda

[ZP] Antidote

 /***************************************************************************\
            =====================================
             * ||     [ZP]  Antidote          || *
             * ||        Version 1.2         || *    
            =====================================

    -------------------
     *||DESCRIPTION||*
    -------------------

Plugin add Antidote item to Zombie Plague Special Server,you can buy on extraitem menu
or pick up from dead players, controlled by cvar from wich. Also controlled wich dead
body will drop. When Buy you will be disinfect immediately, but if pickup, you can will
activate later with command.

Item have some limit:
-     Use/Buy limited by cvar on single round.
-     Pickup limited by cvar on single round.
-     Use is limited depending on the number of zombies by cvar.
        Cvar minimum value 2(checkin always mapchange)
- Use/buy limit on map
        
Default Price 70 Ammo.
ITEM WILL DISABLE ORIGINALLY ANTIDOTE ITEM ON ZP SERVER!!

    -------------------
     *|| COMMANDS  ||*
    -------------------
    -----------------------------------------------------------------------
    +antidote                - console command for use item
    /antidote                - chat command for use item
    say antidote            - show little info on chat

    -------------------
     *||   CVARS   ||*
    -------------------
    -----------------------------------------------------------------------

    ********************************
    *    Buy & Use limit for item on single
    *
    *    INT                        'INT' value item can buy on single round
    zp_anti_use_rlimit 3          (default)    

    ********************************
    *    Pick up limit for item on single round
    *
    *    INT                     'INT' value item can pickup on single round
    zp_anti_pick_rlimit 3    (default)

        ********************************
    *    Buy & Use limit for item on single
    *
    *    INT                        'INT' value item can buy on map
    zp_anti_use_mlimit 15          (default)    

    ********************************
    *    Pick up limit for item on single round
    *
    *    INT                     'INT' value item can pickup on map
    zp_anti_pick_mlimit 30    (default)
    
    ********************************
    *    Who can pick up this item.
    *
    *    0|1|2                    0: Everybody (except specials)
    *                            1: Humans (except specials)
    *                            2: Zombies (except specials)    
    zp_anti_pickup 0          (default)    

    *********************************
    *    Who will drop this item.
    *
    *    0|1|2                    0: Everybody
    *                            1: Humans
    *                            2: Zombies
    zp_anti_drop 1          (default)    

    *********************************
    *    Zombie count limit for use item
    *
    *    INT(>1)                    Minimum value '2', last zombie can't use
    *                                this item.                        
    zp_anti_minzombie 2          (default)    

    *********************************
    *    Show hud information when pick up item
    *
    *    0|1                      0: Disable
    *                            1: Enable
    zp_anti_hud 1              (default)        
    
    *********************************
    *    Show icon when pick up item
    *
    *    0|1                      0: Disable
    *                            1: Enable
    zp_anti_icon 1          (default)        
    
    -------------------
     *||  NATIVES  ||*
    -------------------
    -----------------------------------------------------------------------
    **
    * Add item to player
    *
    * @param id                    Player index.
    * @param item_name[]        Set g_item_name (normally 'Antidote') for reach
    * @param amount                amount of given item
    * @param chat                set int if want little chat message
    * @param hud                set int if want little hud message
    * @param icon                set int if want little icon message     
    * @param sound                set int if want sound
    *
    * return true                if valid player    
    *
    give_item_ex(id,item_name[],amount,chat,hud,icon,sound)

    **
    * Remove item from player
    *
    * @param id                    Player index.
    * @param item_name[]        Set g_item_name (normally 'Antidote') for reach    
    * @param amount                amount of removed item    
    * @return true                if valid player    
    *
    remove_item_ex(id,item_name[],amount)


    **
    * Quantity of the item stored in the player
    *
    * @param id                    Player index.
    * @param item_name[]        Set g_item_name (normally 'Antidote') for reach    
    *
    * @return INT                -1 if player not valid
    *
    item_ex_quantity(id,item_name[])    

    -------------------
    *||  FORWARDS   ||*
    -------------------
    -----------------------------------------------------------------------
    
    none
    
    ---------------
     *||CREDITS||*
    ---------------

    none
    
    ------------------
     *||CHANGE LOG||*
    ------------------

    v1.0 ====> - Initial Release
    v1.1 ====> - Better natives, clean code
    
    -----------------
     *||TODO LIST||*
    -----------------    
    - Load bar for use (from scream extra item)
    - use limit from zombie min hp
    -
\***************************************************************************/
//
#define STATS_TEMP

/*================================================================================
 [Includes]
=================================================================================*/    
#include <amxmodx>
#include <fakemeta>
#include <fakemeta_util>
#include <zombie_plague_special>

/*================================================================================
 [Defines]
=================================================================================*/
#define is_valid_user(%1) (1 <= %1 <= g_maxplayers && is_user_connected(%1))

// Plug info.
new const PLUGIN[] = "[ZP][ITEM][Z] Antidote"
new const VERSION[] = "1.0"
new const AUTHOR[] = "Furion"
/*================================================================================
 [CUSTOMIZE SECTION]
=================================================================================*/
new g_item_name[] = "Antidote"
new const g_AntidoteClassname[ ] = "antidote_entity";
new const szModelKit[ ] = "models/zombie_plague/items/ammodrop_red.mdl";
new const szPickupSound[ ] = "zombie_plague/ammodrop.wav";
new const szIcon[] = "cross"

#if defined STATS_TEMP
    //db_size for temp save increase if need
    const MAX_TEMP_SAVE = 64

#endif
/*================================================================================
 [global vars]
=================================================================================*/
// Class ID
new g_item_antidote;
new g_maxplayers;
new bool:g_roundlive  = false;

//entity spec
enum _: iCoords
{
    x = 0,
    y,
    z
};
new gGMsgItemPickup;

//cvars
#if defined STATS_TEMP
    new cvar_antidote_usemaplimit,cvar_antidote_pickupmaplimit
#endif
new cvar_antidote_pickuproundlimit,cvar_antidote_useroundlimit
new cvar_antidote_drop,cvar_antidote_pickup
new cvar_antidote_hud,cvar_antidote_icon,cvar_antidote_minzombie;

#if defined STATS_TEMP
    new g_pcvar_antidote_usemaplimit,g_pcvar_antidote_pickupmaplimit
#endif
new g_pcvar_antidote_pickuproundlimit ,g_pcvar_antidote_useroundlimit
new g_pcvar_antidote_pickup ,g_pcvar_antidote_drop
new g_pcvar_antidote_hud,g_pcvar_antidote_icon,g_pcvar_antidote_minzombie;

//player specific
#if defined STATS_TEMP
new g_AntiUsedOnMap[33],g_AntiPickedOnMap[33]
#endif

new g_antidote[33], g_AntiUsedOnRound[33],g_AntiPickedOnRound[33]
new bool:g_info[33]

#if defined STATS_TEMP
    // Temporary Database vars (used to restore players stats in case they get disconnected)
    new g_steamid[33][35]
    new db_steamid[MAX_TEMP_SAVE][35], db_antidote[MAX_TEMP_SAVE], db_pickedonmap[MAX_TEMP_SAVE],db_usedonmap[MAX_TEMP_SAVE]
    new Float:db_time[MAX_TEMP_SAVE]
#endif
/*================================================================================
 [Init, CFG and Precache]
=================================================================================*/

public plugin_precache()
{
    cvar_antidote_useroundlimit = create_cvar("zp_anti_use_rlimit","3", FCVAR_NONE, "Buy/Use antidote round limit  for one player^n\
                                                                                ONLY infection & multi infection can buy & use^n\
                                                                                0 - can't buy & can't use^n\
                                                                                INT - limit value")    
    cvar_antidote_pickuproundlimit = create_cvar("zp_anti_pick_rlimit","3", FCVAR_NONE, "Pick up antidote round limit  for one player^n\
                                                                                EVERY round can pick up antidote^n\
                                                                                0 - can't pick up (no drop)^n\
                                                                                INT - limit for pick up on single round")
#if defined STATS_TEMP                                                                                
    cvar_antidote_usemaplimit = create_cvar("zp_anti_use_mlimit","15", FCVAR_NONE, "Buy/Use antidote map limit  for one player^n\
                                                                                ONLY infection & multi infection can buy & use^n\
                                                                                0 - can't buy & can't use (no drop)^n\
                                                                                INT - use limit")    
    cvar_antidote_pickupmaplimit = create_cvar("zp_anti_pick_mlimit","30", FCVAR_NONE, "Pick up antidote map limit  for one player^n\
                                                                                EVERY round can pick up antidote^n\
                                                                                0 - can't pick up (no drop)^n\
                                                                                INT - pick up limit")
#endif                                                                                
    cvar_antidote_pickup = create_cvar("zp_anti_pickup","0", FCVAR_NONE,     "Who can pick up antidote?^n\
                                                                                0 - All player(specials not)^n\
                                                                                1 - Only humans (specials not)^n\
                                                                                2 - Only Zombies (specials not)")
    cvar_antidote_drop = create_cvar("zp_anti_drop","1", FCVAR_NONE,         "Wich dead body drop antidote?^n\
                                                                                0 - All ^n\
                                                                                1 - Only humans ^n\
                                                                                2 - Only Zombies")
    cvar_antidote_minzombie = create_cvar( "zp_anti_minzombie", "3", FCVAR_NONE,    "Zombie count limit for (only) use^n\ (minimum 2)")    
    cvar_antidote_hud = create_cvar( "zp_anti_hud", "1", FCVAR_NONE,             "HUD information ON/OFF antidote pickup^n\
                                                                                0 - off^n\
                                                                                1 - on")        
    cvar_antidote_icon = create_cvar( "zp_anti_icon", "1", FCVAR_NONE,             "Icon information ON/OFF antidote pickup^n\
                                                                                0 - off^n\
                                                                                1 - on")    
    precache_model( szModelKit );
    precache_sound( szPickupSound );
}

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    //commands
    register_clcmd("say /antidote", "cmdAntidote",_,"Use antidote")  
    register_clcmd("+antidote", "cmdAntidote",_,"Use antidote")
    register_clcmd("say antidote", "cmdAntidoteHelp",_,"Antidote info")     
    
    //cvars
    g_pcvar_antidote_useroundlimit = get_pcvar_num(cvar_antidote_useroundlimit)    
    g_pcvar_antidote_pickuproundlimit = get_pcvar_num(cvar_antidote_pickuproundlimit)
#if defined STATS_TEMP    
    g_pcvar_antidote_usemaplimit = get_pcvar_num(cvar_antidote_usemaplimit)    
    g_pcvar_antidote_pickupmaplimit = get_pcvar_num(cvar_antidote_pickupmaplimit)
#endif    
    g_pcvar_antidote_pickup = get_pcvar_num(cvar_antidote_pickup)
    g_pcvar_antidote_drop = get_pcvar_num(cvar_antidote_drop)      
    g_pcvar_antidote_minzombie = get_pcvar_num(cvar_antidote_minzombie)
    if (g_pcvar_antidote_minzombie < 2) {
        g_pcvar_antidote_minzombie = 2
    }
    
    g_pcvar_antidote_hud = get_pcvar_num( cvar_antidote_hud );    
    g_pcvar_antidote_icon = get_pcvar_num( cvar_antidote_icon );    
    //events
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0")    
    register_event("DeathMsg", "Death", "a")
    //variables
    gGMsgItemPickup = get_user_msgid( "ItemPickup" );    
    g_maxplayers = get_maxplayers()
    //register extra item
    g_item_antidote = zp_register_extra_item(g_item_name, 70, ZP_TEAM_ZOMBIE)    
    //forwards
    register_forward( FM_Touch, "forward_FM_Touch" );    
}

public plugin_cfg()
{//check original zp_extra antidote and disable
    new const cvarname[] = "zp_extra_antidote"
    new i_zp_pointer = get_cvar_pointer(cvarname)
    if(i_zp_pointer)
    {    
        new iOldValue
        iOldValue = get_pcvar_num(i_zp_pointer)
        if (iOldValue)
        {
            set_pcvar_num(i_zp_pointer,0)
            log_amx("    <WARNING>         ***original '%s' set %i from %i***",cvarname,get_pcvar_num(i_zp_pointer),iOldValue)
        }
    }
}

public plugin_natives()
{
    register_native("give_item_ex", "native_give_item_ex", 1)
    register_native("remove_item_ex", "native_remove_item_ex", 1)
    register_native("use_item_ex", "native_use_item_ex", 1)// force to use jut if he not limited
    register_native("item_ex_quantity", "native_item_ex_quantity", 1)
}


public native_give_item_ex(id,item_name[],amount,hud,icon,sound)  //ez a táska és a ládás rendszerhezz kell(sql load, vagy a ládából nyer)
{
    if (!is_valid_user(id))
        return false;
    if (equal(item_name,g_item_name))
    {
        if(!amount)    g_antidote[id]++;
        else g_antidote[id] += amount;
        if(g_info[id] == false)
        {
            client_print_color(id ,print_team_default,  "^4 Felvettél egy ellenszert. További információkért írd be chatben az '^1antidote^4' szót")
            g_info[id] = true
        }
        if (hud && g_pcvar_antidote_hud)
        {
            set_hudmessage( 0, 125, 250, -1.0, 0.4, 2, 6.0, 3.0 );
            show_hudmessage( id, "antidote (%d)",g_antidote[id]);    
        }
        if (icon && g_pcvar_antidote_icon )    UTIL_Send_PickupMessage( id, szIcon );
        if(sound)
        {        
            emit_sound( id, CHAN_ITEM, szPickupSound, VOL_NORM, ATTN_NORM, 0 , PITCH_NORM );    
        }
        return true;        
    }
    return false;
}
public native_remove_item_ex(id,item_name[],amount) //ez a  táska rendszerhez kell csak, ott is a mentéshez **** itt nem használja, csak elveszi
{
    if (!is_valid_user(id))
        return false;
    if (equal(item_name,g_item_name))
    {
        if(amount)    ((g_antidote[id] >= amount) ? (g_antidote[id] -= amount) : (g_antidote[id] = 0));
        else
        {
            if(g_antidote[id] > 0) g_antidote[id]--
            else g_antidote[id] = 0
        }
        return true;
    }
    return false
}

public native_use_item_ex(id,item_name[]) //táska rendszernél a menüből kiválasztás után ennek kell lefutnia ******használja de nem veszi el!
{
    if (!is_valid_user(id))
        return false;
    if (equal(item_name,g_item_name) && g_antidote[id] > 0 )
    {     

        if (g_pcvar_antidote_useroundlimit == 0 )     return false    
        else if (g_AntiUsedOnRound[id] >= g_pcvar_antidote_useroundlimit ) return false            
#if defined STATS_TEMP        
        else if (g_pcvar_antidote_usemaplimit == 0  )     return false    
        else if (g_AntiUsedOnMap[id] >= g_pcvar_antidote_usemaplimit ) return false    
#endif

        else if (zp_get_zombie_special_class(id) )  return false    
        else if (g_roundlive == false) return false        
        else if ( !(zp_is_infection_round() || zp_is_multi_round())  ) return false    
        else if (zp_get_zombie_count() < g_pcvar_antidote_minzombie ) return false    
        else
        {

#if defined STATS_TEMP        
            g_AntiUsedOnMap[id]++
#endif            
            g_AntiUsedOnRound[id] ++
            zp_disinfect_user(id,0);    
            return true
        }
    
    }
    return false    
}

public native_item_ex_quantity(id,item_name[])//táska rendszernél a menühöz le tudja kérni a mennyiséget
{
    if (!is_valid_user(id))
        return -1;
    if (equal(item_name,g_item_name))
        return g_antidote[id];
    else return 0
    
}












/*================================================================================
 [MAIN AMX & ZP FUNCTIONS]
=================================================================================*/



public zp_extra_item_selected_pre(id, itemid)
{
    if (itemid == g_item_antidote)
    {
        if (g_pcvar_antidote_useroundlimit == 0 )     return ZP_PLUGIN_SUPERCEDE
        if (g_AntiUsedOnRound[id] >= g_pcvar_antidote_useroundlimit ) return ZP_PLUGIN_HANDLED    
#if defined STATS_TEMP
        if ( g_pcvar_antidote_usemaplimit == 0)     return ZP_PLUGIN_SUPERCEDE
        if (g_AntiUsedOnMap[id] >= g_pcvar_antidote_usemaplimit ) return ZP_PLUGIN_HANDLED            
#endif
        if (zp_get_zombie_special_class(id) )  return ZP_PLUGIN_HANDLED    
        if (g_roundlive == false) return ZP_PLUGIN_HANDLED
        if ( !(zp_is_infection_round() || zp_is_multi_round()) ) return ZP_PLUGIN_HANDLED
        if (zp_get_zombie_count() < g_pcvar_antidote_minzombie ) return ZP_PLUGIN_HANDLED

    }    
    return PLUGIN_CONTINUE
}

public zp_extra_item_selected(id, item)
{
    if(item == g_item_antidote )
    {
        if (g_pcvar_antidote_useroundlimit == 0 )     return ZP_PLUGIN_HANDLED    
        else if (g_AntiUsedOnRound[id] >= g_pcvar_antidote_useroundlimit ) return ZP_PLUGIN_HANDLED            
#if defined STATS_TEMP        
        else if (g_pcvar_antidote_usemaplimit == 0  )     return ZP_PLUGIN_HANDLED    
        else if (g_AntiUsedOnMap[id] >= g_pcvar_antidote_usemaplimit ) return ZP_PLUGIN_HANDLED    
#endif

        else if (zp_get_zombie_special_class(id) )  return ZP_PLUGIN_HANDLED    
        else if (g_roundlive == false) return ZP_PLUGIN_HANDLED        
        else if ( !(zp_is_infection_round() || zp_is_multi_round())  ) return ZP_PLUGIN_HANDLED    
        else if (zp_get_zombie_count() < g_pcvar_antidote_minzombie ) return ZP_PLUGIN_HANDLED    
        else
        {
#if defined STATS_TEMP        
            g_AntiUsedOnMap[id]++
#endif            
            g_AntiUsedOnRound[id] ++
            zp_disinfect_user(id,0);    
        }
    }
    return PLUGIN_HANDLED
}

public client_connect(id)
{
    g_antidote[id] = 0
    g_AntiUsedOnRound[id] = 0
    g_AntiPickedOnRound[id] = 0
    g_info[id] = false
#if defined STATS_TEMP        
    g_AntiUsedOnMap[id] = 0    
    g_AntiPickedOnMap[id] = 0

    if (!is_user_hltv(id))
    {
        (is_user_bot(id)) ? (get_user_name(id, g_steamid[id], charsmax(g_steamid[]))) : (get_user_authid(id, g_steamid[id], charsmax(g_steamid[])))
        load_stats(id)        
    }
#endif    
}
    
public client_disconnected(id)
{
#if defined STATS_TEMP    
    if (!is_user_hltv(id))
    {
        (is_user_bot(id)) ? (get_user_name(id, g_steamid[id], charsmax(g_steamid[]))) : (get_user_authid(id, g_steamid[id], charsmax(g_steamid[])))
        save_stats(id)        
    }
    //else get_user_name(id, g_steamid[id], charsmax(g_steamid[]))
    g_steamid[id][0] = EOS
#endif        
    g_antidote[id] = 0
    g_AntiUsedOnRound[id] = 0
    g_AntiPickedOnRound[id] = 0

}


public Death(const victim, const killer, iGib)
{
    new victim = read_data(2)
    new killer = read_data(1)
    if (!is_valid_user(victim) || !is_valid_user(killer) ) return PLUGIN_HANDLED;
    if (victim == killer) return PLUGIN_HANDLED;
    if (g_pcvar_antidote_pickuproundlimit == 0 ) return PLUGIN_HANDLED
#if defined STATS_TEMP    
    if (g_pcvar_antidote_pickupmaplimit == 0 ) return PLUGIN_HANDLED
#endif        
    if (zp_get_user_zombie(victim) && g_pcvar_antidote_drop   == 2 )return PLUGIN_HANDLED    
    if (!zp_get_user_zombie(victim) && g_pcvar_antidote_drop  == 1 )return PLUGIN_HANDLED    

    new ran = random_num(0,2)
    if (!ran)
    {
        static Float:flOrigin[ iCoords ];
        pev( victim, pev_origin, flOrigin );
        new iEnt = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "info_target" ) );
        /* --| Modify the origin a little bit. This is calculated to be set on floor */
        flOrigin[ z ] -= 39;
        flOrigin[ x ] += 3;
        flOrigin[ x ] -= 3;         
        engfunc( EngFunc_SetOrigin, iEnt, flOrigin );
        if( !pev_valid( iEnt ) )
        {
            return PLUGIN_HANDLED;
        }
        set_pev( iEnt, pev_classname, g_AntidoteClassname );
        engfunc( EngFunc_SetModel, iEnt, szModelKit );
        dllfunc( DLLFunc_Spawn, iEnt );
        set_pev( iEnt, pev_solid, SOLID_TRIGGER );
        set_pev( iEnt, pev_movetype, MOVETYPE_NONE );
        engfunc( EngFunc_SetSize, iEnt, Float:{ -3.160000, -3.660000, -0.050000 }, Float:{ 3.470000, 1.780000, 3.720000 } );   //Float:{ -3.160000, -3.660000, -0.050000 }, Float:{ 11.470000, 12.780000, 6.720000 } );
        engfunc( EngFunc_DropToFloor, iEnt );    
    
    }
    return PLUGIN_HANDLED;
}

public event_round_start()
{
    for (new id; id <= g_maxplayers; id++)
    {
        if (is_user_connected(id))
        {
            g_AntiUsedOnRound[id] = 0
            g_AntiPickedOnRound[id] = 0
        }
    }
    new iEntity = FM_NULLENT;
    while( ( iEntity = fm_find_ent_by_class( iEntity, g_AntidoteClassname ) ) )
    {
        engfunc( EngFunc_RemoveEntity, iEntity );
    }    
}

public zp_round_started()
{
    g_roundlive = true
}
public zp_round_ended(winteam)
{
    
    g_roundlive = false
}


/*================================================================================
 [ANTIDOTE FUNCTIONS]
=================================================================================*/
public cmdAntidoteHelp(id)
{
    if (!is_valid_user(id) ) return PLUGIN_HANDLED
    client_print_color(id ,print_team_default,  "^4Ellenszert az 'Extra eszközök' menüben vásárolhatsz vagy véletlenszerűen találhatsz a halottaknál. A menüben vásárolt^1")    
    client_print_color(id ,print_team_default,  "^4 azonnal aktiválódik, amit felveszel azt később az '^1/antidote^4' paranccsal aktiválhatod a chatben,^1")
    client_print_color(id ,print_team_default,  "^4 vagy hozzárendelhetsz egy billentyűt a '^1+antidote^4' parancshoz. Jelenleg '%i' ellenszered van^1",native_item_ex_quantity(id,g_item_name))
    client_print_color(id ,print_team_default,  "^4 Csak Normál vagy többszörös fertőzés módban használható!!!^1")

    return PLUGIN_HANDLED
}
public cmdAntidote(id)
{
    if (!is_valid_user(id) || !zp_get_user_zombie(id)) return PLUGIN_HANDLED
    if (g_pcvar_antidote_useroundlimit == 0 )    return PLUGIN_HANDLED
    if ( g_pcvar_antidote_useroundlimit <= g_AntiUsedOnRound[id]) return PLUGIN_HANDLED
#if defined STATS_TEMP        
    if (g_pcvar_antidote_usemaplimit == 0 )    return PLUGIN_HANDLED    
    if ( g_pcvar_antidote_usemaplimit <= g_AntiUsedOnMap[id]) return PLUGIN_HANDLED
#endif        
    if (zp_get_zombie_special_class(id))  return PLUGIN_HANDLED        
    if (g_roundlive == false) return PLUGIN_HANDLED    
    if (!(zp_is_infection_round() || zp_is_multi_round())) return PLUGIN_HANDLED
    if (zp_get_zombie_count() < g_pcvar_antidote_minzombie ) return PLUGIN_HANDLED
    if (g_antidote[id] < 1 ) return PLUGIN_HANDLED

    native_remove_item_ex(id,g_item_name,1)
    g_AntiUsedOnRound[id] ++
#if defined STATS_TEMP        
    g_AntiUsedOnMap[id] ++
#endif        
    zp_disinfect_user(id,0);        
    return PLUGIN_HANDLED
}

public forward_FM_Touch( iEnt, id )
{
    if( !pev_valid( iEnt ) || !is_user_alive(id) || is_user_bot(id) ) return FMRES_IGNORED;
    if (g_pcvar_antidote_pickuproundlimit == 0 || g_pcvar_antidote_pickuproundlimit <= g_AntiPickedOnRound[id]  ) return FMRES_IGNORED;
#if defined STATS_TEMP        
    if (g_pcvar_antidote_pickupmaplimit == 0 || g_pcvar_antidote_pickupmaplimit <= g_AntiPickedOnMap[id]  ) return FMRES_IGNORED;
#endif        
    if (zp_get_user_zombie(id) && g_pcvar_antidote_pickup ==1)  return FMRES_IGNORED;    
    if (!zp_get_user_zombie(id) && g_pcvar_antidote_pickup ==2)  return FMRES_IGNORED;    
    
    new szClassname[ 32 ];
    pev( iEnt, pev_classname, szClassname, charsmax( szClassname ) );
    if( !equal( szClassname, g_AntidoteClassname ) )    return FMRES_IGNORED;
    if (!zp_get_zombie_special_class(id) || !zp_get_human_special_class(id) )
    {
        native_give_item_ex(id,g_item_name,1,1,1,1)
        g_AntiPickedOnRound[id]++
#if defined STATS_TEMP            
        g_AntiPickedOnMap[id] ++
#endif            
        engfunc( EngFunc_RemoveEntity, iEnt );            
    }


    return FMRES_IGNORED;
}



/*================================================================================
 [TEMPORARY SAVE-LOAD FUNCTIONS]
=================================================================================*/
#if defined STATS_TEMP    

load_stats(id)
{
    // Look for a matching record
    static i
    for (i = 0; i < sizeof db_steamid; i++)
    {
        if(equal(g_steamid[id], db_steamid[i]))
        {
            // Bingo! Load
            g_antidote[id] = db_antidote[i]
            g_AntiUsedOnMap[id]    = db_pickedonmap[i]
            g_AntiPickedOnMap[id] =    db_usedonmap[i]

            return;
        }
    }
}


save_stats(id)
{
    // Look for a matching record
    new i
    new    iOldestSlot = -1
    new Float:iTime = get_gametime()
    
    for (i = 0; i < sizeof db_steamid; i++)
    {    
        if (0 < db_time[i] < iTime)
        {
            iOldestSlot = i    
            iTime = db_time[i]
        }
        // matching record, overwrite
        if(equal(g_steamid[id], db_steamid[i]) )
        {
            copy(db_steamid[i], charsmax(db_steamid[]), g_steamid[id])
            db_antidote[i] = g_antidote[id]
            db_pickedonmap[i]    = g_AntiUsedOnMap[id]
            db_usedonmap[i] =    g_AntiPickedOnMap[id]
            db_time[i] = get_gametime()
            break;
        }
        else
        {
            // slot not empty
            if(db_steamid[i][0] )
            {
                // Last slot, need overwrite oldest slot
                if(i == sizeof db_steamid - 1)
                {
                    copy(db_steamid[iOldestSlot], charsmax(db_steamid[]), g_steamid[id])
                    db_antidote[iOldestSlot] = g_antidote[id]
                    db_pickedonmap[iOldestSlot]    = g_AntiUsedOnMap[id]
                    db_usedonmap[iOldestSlot] =    g_AntiPickedOnMap[id]
                    db_time[iOldestSlot] = get_gametime()
                    break;                
                }
                //go next slot
                else
                {
                        
                    continue;
                }
            }
            // Empty slot, write data
            else
            {    
                copy(db_steamid[i], charsmax(db_steamid[]), g_steamid[id])
                db_antidote[i] = g_antidote[id]
                db_pickedonmap[i]    = g_AntiUsedOnMap[id]
                db_usedonmap[i] =    g_AntiPickedOnMap[id]        
                db_time[i] = get_gametime()
                break;
            }                
        }
    }
}    

#endif    


/*================================================================================
 [Stocks]
=================================================================================*/

stock UTIL_Send_PickupMessage( const id, const szItemName[ ] )
{
    message_begin( MSG_ONE_UNRELIABLE, gGMsgItemPickup, _, id );
        write_string( szItemName );
        message_end( );
}

Nincsenek megjegyzések:

Megjegyzés küldése

[ZP] Antidote

 /***************************************************************************\             =====================================            ...