[INC] Fakemeta Utilities

For scripting examples for learning how to use AMXX.
User avatar
Archive-Poster
Posts: 1327
Gender:
United States of America

[INC] Fakemeta Utilities

Post by Archive-Poster »

Using this is HIGHLY NOT RECOMMENDED!!! Stick with using Engine, Fun, CStrike, Ham, etc. They do all these functions much quicker and more efficiently. You are only teaching yourself bad coding habits by using these.

"Fakemeta Utilities" is a library of functions for the Fakemeta module. It includes:
almost all engine/fun natives (represented as a marcos/stocks)
engine's stock functions
the below custom functions

Code: Select all

bool:fm_is_in_viewcone(index, const Float:point[3])
bool:fm_is_visible(index, const Float:point[3])
fm_set_kvd(entity, const key[], const value[], const class[] = "")
fm_find_ent_by_integer(index, pev_field, value)
fm_find_ent_by_flags(index, pev_field, flags)
Float:fm_distance_to_box(Float:point[3], Float:mins[3], Float:maxs[3])
Float:fm_boxes_distance(Float:mins1[3], Float:maxs1[3], Float:mins2[3], Float:maxs2[3])
Float:fm_distance_to_boxent(ent, boxent)
Float:fm_boxents_distance(boxent1, boxent2)
fm_get_user_weapon_entity(id, wid = 0)
fm_kill_entity(index)
bool:fm_strip_user_gun(index, wid = 0, const wname[] = "")
bool:fm_transfer_user_gun(index1, index2, wid = 0, const wname[] = "")
Float:fm_distance_to_floor(index)
bool:fm_is_ent_visible(index, entity)
fm_get_aim_origin(index, Float:origin[3])
bool:fm_get_user_longjump(index)
fm_set_user_longjump(index, bool:longjump = true, bool:tempicon = true)
bool:fm_get_user_suit(index)
fm_set_user_suit(index, bool:suit = true, bool:sound = true)
fm_cs_remove_decals(index = 0)
bool:fm_is_ent_classname(index, const classname[])
fm_user_kill(index, flag = 0)
Float:fm_get_view_angle_diff(index, const Float:point[3])
fm_get_weaponbox_type(entity)
fm_remove_weaponbox(entity) 
Attachments
fakemeta_util_171.zip
(12.11 KiB) Downloaded 6 times
fakemeta_util.inc.zip
(6.25 KiB) Downloaded 6 times
User avatar
Archive-Poster
Posts: 1327
Gender:
United States of America

Re: [INC] Fakemeta Utilities

Post by Archive-Poster »

Should use #defines, not stocks. Stocks add another function call; #define is direct sub, and thus faster.
Attachments
engine_to_fm_const.inc.zip
(451 Bytes) Downloaded 6 times
engine_to_fm.inc.zip
(2.03 KiB) Downloaded 4 times
User avatar
Archive-Poster
Posts: 1327
Gender:
United States of America

Re: [INC] Fakemeta Utilities

Post by Archive-Poster »

Here is get_user_hitzones and set_user_hitzones ported to Fakemeta
Now are fm_get_user_hitzones and fm_set_user_hitzones
Attachments
fm_user_hitzones.sma.zip
(1.06 KiB) Downloaded 6 times
User avatar
Archive-Poster
Posts: 1327
Gender:
United States of America

Re: [INC] Fakemeta Utilities

Post by Archive-Poster »

I get this error with your hitzone code:

Line 1062 = if( pev(hit,pev_flags) & (FL_CLIENT | FL_FAKECLIENT) && shooter

Code: Select all

L 10/28/2008 - 23:44:38: [FAKEMETA] Invalid entity
L 10/28/2008 - 23:44:38: [AMXX] Displaying debug trace (plugin "aimbotdetect.amxx")
L 10/28/2008 - 23:44:38: [AMXX] Run time error 10: native error (native "pev")
L 10/28/2008 - 23:44:38: [AMXX]    [0] aimbotdetect.sma::fw_traceline (line 1062)
Replace pev(hit,pev_flags) & (FL_CLIENT | FL_FAKECLIENT) with 1 <= id <= maxplayers
Now I am getting index out of bounds

L 11/01/2008 - 14:23:06: [AMXX] Displaying debug trace (plugin "aimbotdetect.amxx")
L 11/01/2008 - 14:23:06: [AMXX] Run time error 4: index out of bounds
L 11/01/2008 - 14:23:06: [AMXX] [0] aimbotdetect.sma::fw_traceline (line 1093)

Line 1093:
if( !(g_bodyhits[shooter][hit] & 1<<hitGroup) )

Code: Select all

public fw_traceline(Float:v1[3], Float:v2[3], NoMonsters, shooter, ptr)
{
    if(!shooter) return FMRES_IGNORED;
    
    new hit = get_tr2(ptr,TR_pHit);
    
    if(  (1 <= shooter <= g_MaxPlayers) && (pev(shooter,pev_flags) & (FL_CLIENT | FL_FAKECLIENT)) )
    {
        new hitGroup = get_tr2(ptr,TR_iHitgroup);
        
         if( !(g_bodyhits[shooter][hit] & 1<<hitGroup) )
            set_tr2(ptr,TR_flFraction,1.0);
    }
    
    return FMRES_IGNORED;
}

Code: Select all

public fw_traceline(Float:v1[3], Float:v2[3], NoMonsters, shooter, ptr)
{
    if( NoMonsters || !( 1 <= shooter <= g_iMaxPlayers) )
        return FMRES_IGNORED;
    
    new hit = get_tr2(ptr,TR_pHit);
    if( 1 <= hit <= g_iMaxPlayers )
    {
        if(   !( g_bodyhits[shooter][hit] & (1<<get_tr2(ptr,TR_iHitgroup)) )   )
        {
            set_tr2(ptr,TR_flFraction,1.0);
            return FMRES_SUPERCEDE;
        }
    }
    return FMRES_IGNORED;
} 

Code: Select all

0 - Normal
1 - Flicker (first variety)
2 - Slow strong pulse
3 - Candle (first variety)
4 - Fast strobe
5 - Gentle pulse 1
6 - Flicker (second variety)
7 - Candle (second variety)
8 - Candle (third variety)
9 - Slow strobe (fourth variety)
10 - Fluorescent flicker
11 - Slow pulse not fade to black
12 - Underwater light mutation
( world.cpp )
User avatar
Archive-Poster
Posts: 1327
Gender:
United States of America

Re: [INC] Fakemeta Utilities

Post by Archive-Poster »

I have this, some stock may have to be improved.
This is just for information so people could know how to convert some code, like for cs_s/get_user_team, if you use it in your own plugin, you don't need to use those CsTeams things.

Code: Select all

#define EXTRAOFFSET_WEAPONS    4

#define OFFSET_ARMORTYPE            112 
#define OFFSET_TEAM                114 
#define OFFSET_CSMONEY                115 
#define OFFSET_PRIMARYWEAPON            116 
#define OFFSET_LASTACTIVITY            124 
#define OFFSET_INTERNALMODEL            126 
#define OFFSET_NVGOGGLES            129 
#define OFFSET_DEFUSE_PLANT            193 
#define OFFSET_VIP                209 
#define OFFSET_TK                216  // 040926
#define OFFSET_HOSTAGEKILLS            217 
#define OFFSET_MAPZONE                235 
#define OFFSET_ISDRIVING            350  // 040926
#define OFFSET_STATIONARY            362  // 040927 (363 works also!)
#define OFFSET_ZOOMTYPE                363 

#define OFFSET_AWM_AMMO                377  // 041029: All of these *_AMMO:s were changed -5
#define OFFSET_SCOUT_AMMO            378 
#define OFFSET_PARA_AMMO            379 
#define OFFSET_FAMAS_AMMO            380 
#define OFFSET_M3_AMMO                381 
#define OFFSET_USP_AMMO                382 
#define OFFSET_FIVESEVEN_AMMO            383 
#define OFFSET_DEAGLE_AMMO            384 
#define OFFSET_P228_AMMO            385 
#define OFFSET_GLOCK_AMMO            386 
#define OFFSET_FLASH_AMMO            387 
#define OFFSET_HE_AMMO                388 
#define OFFSET_SMOKE_AMMO            389 
#define OFFSET_C4_AMMO                390    

#define OFFSET_CSDEATHS                444  // 040926
#define OFFSET_SHIELD                510 

// "weapon_*" entities
#define OFFSET_WEAPONTYPE        43
#define OFFSET_CLIPAMMO            51
#define OFFSET_SILENCER_FIREMODE    74

// "hostage_entity" entities
#define OFFSET_HOSTAGEFOLLOW        86 
#define OFFSET_HOSTAGE_NEXTUSE        100 
#define OFFSET_HOSTAGE_LASTUSE        483 
#define OFFSET_HOSTAGEID        487 

// "armoury_entity"
#define OFFSET_ARMOURY_TYPE        34

// C4 offsets
#define OFFSET_C4_EXPLODE_TIME        100 
#define OFFSET_C4_DEFUSING        0x181

#define HAS_SHIELD      (1<<24)

#define M4A1_SILENCED                (1<<2)
#define M4A1_ATTACHSILENCEANIM            6
#define M4A1_DETACHSILENCEANIM            13
#define USP_SILENCED                (1<<0)
#define USP_ATTACHSILENCEANIM            7
#define USP_DETACHSILENCEANIM            15

#define GLOCK_SEMIAUTOMATIC                0
#define GLOCK_BURSTMODE                    2
#define FAMAS_AUTOMATIC                    0
#define FAMAS_BURSTMODE                    16

#define PLAYER_IS_VIP                    (1<<8)

#define PLAYER_IN_BUYZONE                (1<<0)

#define CS_MAPZONE_BUY             (1<<0)
#define CS_MAPZONE_BOMBTARGET         (1<<1)
#define CS_MAPZONE_HOSTAGE_RESCUE     (1<<2)
#define CS_MAPZONE_ESCAPE        (1<<3)
#define CS_MAPZONE_VIP_SAFETY         (1<<4)

/*#define TEAM_UNASSIGNED                    0
*#define TEAM_T                        1
*#define TEAM_CT                        2
*#define TEAM_SPECTATOR                    3*/

#define CAN_PLANT_BOMB                    (1<<8) // 256
#define HAS_DEFUSE_KIT                    (1<<16) // 65536

#define DEFUSER_COLOUR_R                0
#define DEFUSER_COLOUR_G                160
#define DEFUSER_COLOUR_B                0

#define HAS_NVGOGGLES                    (1<<0)

#define SCOREATTRIB_NOTHING                0
#define SCOREATTRIB_DEAD                1
#define SCOREATTRIB_BOMB                2 // t only
#define SCOREATTRIB_VIP                    4

/*#define CS_ARMOR_NONE                0
#define CS_ARMOR_KEVLAR                1*/
#define CS_ARMOR_ASSAULTSUIT            2

#define CS_FIRST_ZOOM                0x28
#define CS_SECOND_AWP_ZOOM            0xA
#define CS_SECOND_NONAWP_ZOOM            0xF
#define CS_AUGSG552_ZOOM            0x37
#define CS_NO_ZOOM                0x5A

#define cs_get_user_buyzone(%1)    (get_pdata_int(%1,OFFSET_MAPZONE)&PLAYER_IN_BUYZONE)
#define cs_get_user_hasprim(%1) get_pdata_int(%1,OFFSET_PRIMARYWEAPON)
#define cs_get_user_mapzones(%1)    get_pdata_int(%1,OFFSET_MAPZONE)
#define cs_get_user_plant(%1)    (get_pdata_int(%1,OFFSET_DEFUSE_PLANT)&CAN_PLANT_BOMB)
#define cs_get_user_tked(%1)    get_pdata_int(%1,OFFSET_TK)
#define cs_get_user_deaths(%1)    get_pdata_int(%1,OFFSET_CSDEATHS)
#define cs_get_user_defuse(%1)    (get_pdata_int(%1,OFFSET_DEFUSE_PLANT)&HAS_DEFUSE_KIT)
#define cs_get_user_driving(%1)    get_pdata_int(%1, OFFSET_ISDRIVING)
#define cs_get_user_money(%1)        get_pdata_int(%1,OFFSET_CSMONEY)
#define cs_get_user_nvg(%1)    (get_pdata_int(%1,OFFSET_NVGOGGLES) & HAS_NVGOGGLES)
#define cs_get_user_shield(%1)    (get_pdata_int(%1,OFFSET_SHIELD)&HAS_SHIELD)
#define cs_get_user_stationary(%1)    get_pdata_int(%1,OFFSET_STATIONARY)
#define cs_get_user_vip(%1) (get_pdata_int(id, OFFSET_VIP) & PLAYER_IS_VIP)

#define cs_get_weapon_id(%1) get_pdata_int(%1,OFFSET_WEAPONTYPE,EXTRAOFFSET_WEAPONS)
#define cs_get_weapon_ammo(%1)    get_pdata_int(%1,OFFSET_CLIPAMMO,EXTRAOFFSET_WEAPONS)
#define cs_set_weapon_ammo(%1,%2)    set_pdata_int(%1,OFFSET_CLIPAMMO,%2,EXTRAOFFSET_WEAPONS)

enum CsTeams {
    CS_TEAM_UNASSIGNED,
    CS_TEAM_T,
    CS_TEAM_CT,
    CS_TEAM_SPECTATOR
};

enum CS_Internal_Models {
    CS_DONTCHANGE = 0,
    CS_CT_URBAN = 1,
    CS_T_TERROR = 2,
    CS_T_LEET = 3,
    CS_T_ARCTIC = 4,
    CS_CT_GSG9 = 5,
    CS_CT_GIGN = 6,
    CS_CT_SAS = 7,
    CS_T_GUERILLA = 8,
    CS_CT_VIP = 9,
    CZ_T_MILITIA = 10,
    CZ_CT_SPETSNAZ = 11
};

enum
{
    CS_RESET_ZOOM = 0,
    CS_SET_NO_ZOOM,
    CS_SET_FIRST_ZOOM,
    CS_SET_SECOND_ZOOM,
    CS_SET_AUGSG552_ZOOM,
};

enum CsArmorType {
    CS_ARMOR_NONE = 0, // no armor
    CS_ARMOR_KEVLAR = 1, // armor
    CS_ARMOR_VESTHELM = 2 // armor and helmet
};

stock cs_get_user_armor(id, &CsArmorType:iArmorType)
{
    new Float:flArmorValue;
    pev(id, pev_armorvalue, flArmorValue);

    iArmorType = CsArmorType:get_pdata_int(id, OFFSET_ARMORTYPE);

    return floatround(flArmorValue);
}

stock cs_set_user_armor(id, iArmorValue, CsArmorType:iArmorType)
{
    set_pdata_int(id , OFFSET_ARMORTYPE, _:iArmorType);
    set_pev(id, pev_armorvalue, float(_:iArmorValue));

    if ( iArmorType )
    {
        static iMsgArmorType;
        if( !iMsgArmorType )
        {
            iMsgArmorType = get_user_msgid("ArmorType");
        }
        message_begin( MSG_ONE_UNRELIABLE , iMsgArmorType , _ , id );
        write_byte( iArmorType == CS_ARMOR_VESTHELM ? 1 : 0 );
        message_end();
    }
}

stock cs_get_user_bpammo(id, iWeapon)
{
    new iOffset;
    switch(iWeapon)
    {
        case CSW_AWP: iOffset = OFFSET_AWM_AMMO;
        case CSW_SCOUT, CSW_AK47, CSW_G3SG1: iOffset = OFFSET_SCOUT_AMMO;
        case CSW_M249: iOffset = OFFSET_PARA_AMMO;
        case CSW_FAMAS, CSW_M4A1, CSW_AUG, CSW_SG550, CSW_GALI, CSW_SG552: iOffset = OFFSET_FAMAS_AMMO;
        case CSW_M3, CSW_XM1014: iOffset = OFFSET_M3_AMMO;
        case CSW_USP, CSW_UMP45, CSW_MAC10: iOffset = OFFSET_USP_AMMO;
        case CSW_FIVESEVEN, CSW_P90: iOffset = OFFSET_FIVESEVEN_AMMO;
        case CSW_DEAGLE: iOffset = OFFSET_DEAGLE_AMMO;
        case CSW_P228: iOffset = OFFSET_P228_AMMO;
        case CSW_GLOCK18, CSW_MP5NAVY, CSW_TMP, CSW_ELITE: iOffset = OFFSET_GLOCK_AMMO;
        case CSW_FLASHBANG: iOffset = OFFSET_FLASH_AMMO;
        case CSW_HEGRENADE: iOffset = OFFSET_HE_AMMO;
        case CSW_SMOKEGRENADE: iOffset = OFFSET_SMOKE_AMMO;
        case CSW_C4: iOffset = OFFSET_C4_AMMO;
        default:return 0;
    }
    return get_pdata_int(id, iOffset);
}

stock cs_set_user_bpammo(id, iWeapon, iAmount)
{
    new iOffset;
    switch(iWeapon)
    {
        case CSW_AWP: iOffset = OFFSET_AWM_AMMO;
        case CSW_SCOUT, CSW_AK47, CSW_G3SG1: iOffset = OFFSET_SCOUT_AMMO;
        case CSW_M249: iOffset = OFFSET_PARA_AMMO;
        case CSW_FAMAS, CSW_M4A1, CSW_AUG, CSW_SG550, CSW_GALI, CSW_SG552: iOffset = OFFSET_FAMAS_AMMO;
        case CSW_M3, CSW_XM1014: iOffset = OFFSET_M3_AMMO;
        case CSW_USP, CSW_UMP45, CSW_MAC10: iOffset = OFFSET_USP_AMMO;
        case CSW_FIVESEVEN, CSW_P90: iOffset = OFFSET_FIVESEVEN_AMMO;
        case CSW_DEAGLE: iOffset = OFFSET_DEAGLE_AMMO;
        case CSW_P228: iOffset = OFFSET_P228_AMMO;
        case CSW_GLOCK18, CSW_MP5NAVY, CSW_TMP, CSW_ELITE: iOffset = OFFSET_GLOCK_AMMO;
        case CSW_FLASHBANG: iOffset = OFFSET_FLASH_AMMO;
        case CSW_HEGRENADE: iOffset = OFFSET_HE_AMMO;
        case CSW_SMOKEGRENADE: iOffset = OFFSET_SMOKE_AMMO;
        case CSW_C4: iOffset = OFFSET_C4_AMMO;
        default:return;
    }
    set_pdata_int(id, iOffset, iAmount);
}

stock cs_set_user_plant(id, plant = 1, showbombicon = 1, backpack = 0)
{
    static iMsgStatusIcon;
    if( !iMsgStatusIcon )
    {
        iMsgStatusIcon = get_user_msgid("StatusIcon");
    }

    if( plant )
    {
        if(backpack)
        {
            set_pev(id, pev_body, 1);
        }

        set_pdata_int(id,OFFSET_DEFUSE_PLANT, cs_get_user_plant(id) | CAN_PLANT_BOMB);
        if( showbombicon )
        {
            message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id);
            write_byte(1);
            write_string("c4");
            write_byte(DEFUSER_COLOUR_R);
            write_byte(DEFUSER_COLOUR_G);
            write_byte(DEFUSER_COLOUR_B);
            message_end();
        }
    }
    else
    {
        set_pdata_int(id,OFFSET_DEFUSE_PLANT, cs_get_user_plant(id) & ~CAN_PLANT_BOMB);
        message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id);
        write_byte(0);
        write_string("c4");
        message_end();

        if(backpack)
        {
            set_pev(id, pev_body, 0);
        }
    }
}

stock cs_set_user_tked(id, tk = 1, subtract = 1)
{
    set_pdata_int(id, OFFSET_TK, tk ? 1 : 0);

    if( substract )
    {
        static Float:flFrags;
        pev(id, pev_frags, flFrags);
        flFrags -= float(subtract);
        set_pev(id, pev_frags, flFrags);

        static iMsgScoreInfo;
        if( iMsgScoreInfo || (iMsgScoreInfo = get_user_msgid("ScoreInfo")) )
        {
            message_begin(MSG_BROADCAST, iMsgScoreInfo);
            write_byte(id);
            write_short(floatround(flFrags));
            write_short(cs_get_user_deaths(%1));
            write_short(0);
            write_short(cs_get_user_team(id));
            message_end();
        }
    }
}

stock cs_user_spawn(id)
{
    set_pev(id, pev_deadflag, DEAD_RESPAWNABLE);
    dllfunc(DLLFunc_Spawn, id);
    set_pev(id, pev_iuser1, 0);
}

stock cs_set_user_deaths(id, iDeaths)
{
    set_pdata_int(id, OFFSET_CSDEATHS, iDeaths);

    static iMsgScoreInfo;

    static Float:flFrags;
    pev(id, pev_health, flFrags);

    if( iMsgScoreInfo || (iMsgScoreInfo = get_user_msgid("ScoreInfo")) )
    {
        message_begin(MSG_BROADCAST, iMsgScoreInfo);
        write_byte(id);
        write_short(floatround(flFrags));
        write_short(iDeaths);
        write_short(0);
        write_short(_:cs_get_user_team(id));
        message_end();
    }
}

stock cs_set_user_defuse(id, iDefusekit = 1, iRed = 0, iGreen = 160, iBlue = 0, icon[] = "defuser", iFlash = 0)
{
    static iMsgStatusIcon;
    if( iMsgStatusIcon || (iMsgStatusIcon = get_user_msgid("StatusIcon")) )
    {

        if( iDefusekit )
        {
            set_pev(id, pev_body, 1);

            set_pdata_int(id, OFFSET_DEFUSE_PLANT, get_pdata_int(id, OFFSET_DEFUSE_PLANT) | HAS_DEFUSE_KIT);

            message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id);
            write_byte(iFlash ? 2 : 1);
            write_string(icon);
            write_byte(iRed);
            write_byte(iGreen);
            write_byte(iBlue);
            message_end();
        }
        else
        {
            set_pdata_int(id, OFFSET_DEFUSE_PLANT, get_pdata_int(id, OFFSET_DEFUSE_PLANT) & ~HAS_DEFUSE_KIT);

            message_begin(MSG_ONE_UNRELIABLE, iMsgStatusIcon, _, id);
            write_byte(0);
            write_string(icon);
            message_end();

            set_pev(id, pev_body, 0);
        }
    }
}

stock cs_set_user_money(id, iMoney, iFlash = 0)
{
    set_pdata_int(id,OFFSET_CSMONEY,iMoney);

    static iMsgMoney;
    if( iMsgMoney || (iMsgMoney = get_user_msgid("Money")) )
    {
        message_begin(MSG_ONE_UNRELIABLE, iMsgMoney, _, id);
        write_long(iMoney);
        write_byte(iFlash ? 1 : 0);
        message_end();
    }
}

stock cs_set_user_nvg(id, nvgoggles = 1)
{
    if( nvgoggles )
    {
        set_pdata_int(id, OFFSET_NVGOGGLES, get_pdata_int(id,OFFSET_NVGOGGLES) | HAS_NVGOGGLES);
    }
    else
    {
        set_pdata_int(id, OFFSET_NVGOGGLES, get_pdata_int(id,OFFSET_NVGOGGLES) & ~HAS_NVGOGGLES);
    }
}

stock CsTeams:cs_get_user_team(id, &{CsInternalModel,_}:iModel = CsInternalModel:CS_DONTCHANGE)
{
    iModel = CsInternalModel:get_pdata_int(id, OFFSET_INTERNALMODEL);
    return CsTeams:get_pdata_int(id, OFFSET_TEAM);
}

stock cs_set_user_team(id, {CsTeams,_}:iTeam, {CsInternalModel,_}:iModel = CsInternalModel:CS_DONTCHANGE)
{
    if( iTeam > CS_TEAM_SPECTATOR )
        return;

    set_pdata_int(id, OFFSET_TEAM, _:iTeam);

    if( iModel )
    {
        set_pdata_int(id, OFFSET_INTERNALMODEL, _:iModel);
    }

    dllfunc(DLLFunc_ClientUserInfoChanged, id, engfunc(EngFunc_GetInfoKeyBuffer, id));

    static const szTeams[] = { "UNASSIGNED" , "TERRORIST" , "CT" , "SPECTATOR" };

    static iMsgTeamInfo;
    if( iMsgTeamInfo || (iMsgTeamInfo = get_user_msgid("TeamInfo")) )
    {
        emessage_begin(MSG_ALL, iMsgTeamInfo);
        ewrite_byte(id);
        ewrite_string(szTeams[_:iTeam]);
        emessage_end();
    }
}

stock cs_get_weapon_silen(index)
{
    switch( cs_get_weapon_id(index) )
    {
        case CSW_M4A1:
        {
            return (get_pdata_int(index,OFFSET_SILENCER_FIREMODE,EXTRAOFFSET_WEAPONS) & M4A1_SILENCED);
        }
        case CSW_USP:
        {
            return (get_pdata_int(index,OFFSET_SILENCER_FIREMODE,EXTRAOFFSET_WEAPONS) & USP_SILENCED);
        }
    }
    return 0;
}

stock cs_set_weapon_silen(index, silence = 1, draw_animation = 1)
{
    switch(cs_get_weapon_id(index))
    {
        case CSW_M4A1:
        {
            new silencemode = get_pdata_int(index,OFFSET_SILENCER_FIREMODE,EXTRAOFFSET_WEAPONS);
            if(silence)
            {
                if (!(silencemode & M4A1_SILENCED)) 
                {
                    silencemode |= M4A1_SILENCED;
                    set_pdata_int(index,OFFSET_SILENCER_FIREMODE,silencemode,EXTRAOFFSET_WEAPONS);

                    if (draw_animation)
                    {
                        new id = pev(index, pev_owner);
                        if( id )
                        {
                            set_pev(id, pev_weaponanim, M4A1_ATTACHSILENCEANIM);
                        }
                    }
                }
            }
            else if(silencemode & M4A1_SILENCED)
            {
                silencemode &= ~M4A1_SILENCED;
                set_pdata_int(index,OFFSET_SILENCER_FIREMODE,silencemode,EXTRAOFFSET_WEAPONS);

                if (draw_animation)
                {
                    new id = pev(index, pev_owner);
                    if( id )
                    {
                        set_pev(id, pev_weaponanim, M4A1_DETACHSILENCEANIM);
                    }
                }
            }
        }
        case CSW_USP:
        {
            new silencemode = get_pdata_int(index,OFFSET_SILENCER_FIREMODE,EXTRAOFFSET_WEAPONS);
            if (silence)
            {
                if (!(silencemode & USP_SILENCED))
                {
                    silencemode |= USP_SILENCED;
                    set_pdata_int(index,OFFSET_SILENCER_FIREMODE,silencemode,EXTRAOFFSET_WEAPONS);

                    if (draw_animation)
                    {
                        new id = pev(index, pev_owner);
                        if( id )
                        {
                            set_pev(id, pev_weaponanim, USP_ATTACHSILENCEANIM);
                        }
                    }
                }
            }
            else if (silencemode & USP_SILENCED)
            {
                silencemode &= ~USP_SILENCED;
                set_pdata_int(index,OFFSET_SILENCER_FIREMODE,silencemode,EXTRAOFFSET_WEAPONS);

                if (draw_animation)
                {
                    new id = pev(index, pev_owner);
                    if( id )
                    {
                        set_pev(id, pev_weaponanim, USP_DETACHSILENCEANIM);
                    }
                }
            }
        }
        default:return 0;
    }

    return 1;
}

stock cs_get_weapon_burstmode(index)
{
    switch(cs_get_weapon_id(index))
    {
        case CSW_GLOCK18:
        {
            return (get_pdata_int(index,OFFSET_SILENCER_FIREMODE,EXTRAOFFSET_WEAPONS) == GLOCK_BURSTMODE);
        }
        case CSW_FAMAS:
        {
            return (get_pdata_int(index,OFFSET_SILENCER_FIREMODE,EXTRAOFFSET_WEAPONS) == FAMAS_BURSTMODE);
        }
    }
    return 0;
}

stock cs_set_weapon_burst(index, burstmode = 1)
{
    switch (cs_get_weapon_id(index))
    {
        case CSW_GLOCK18:
        {
            if (burstmode)
            {
                if (get_pdata_int(index,OFFSET_SILENCER_FIREMODE,EXTRAOFFSET_WEAPONS) != GLOCK_BURSTMODE)
                {
                    set_pdata_int(index,OFFSET_SILENCER_FIREMODE,GLOCK_BURSTMODE,EXTRAOFFSET_WEAPONS);

                    new id = pev(index, pev_owner);
                    if( id )
                    {
                        client_print(id, print_center, "#Switch_To_BurstFire");
                    }
                }
            }
            else if (get_pdata_int(index,OFFSET_SILENCER_FIREMODE,EXTRAOFFSET_WEAPONS) != GLOCK_SEMIAUTOMATIC)
            {
                set_pdata_int(index,OFFSET_SILENCER_FIREMODE,GLOCK_SEMIAUTOMATIC,EXTRAOFFSET_WEAPONS);

                new id = pev(index, pev_owner);
                if( id )
                {
                    client_print(id, print_center, "#Switch_To_SemiAuto");
                }
            }
        }
        case CSW_FAMAS:
        {
            if (burstmode)
            {
                if (get_pdata_int(index,OFFSET_SILENCER_FIREMODE,EXTRAOFFSET_WEAPONS) != FAMAS_BURSTMODE)
                {
                    set_pdata_int(index,OFFSET_SILENCER_FIREMODE,FAMAS_BURSTMODE,EXTRAOFFSET_WEAPONS);

                    new id = pev(index, pev_owner);
                    if( id )
                    {
                        client_print(id, print_center, "#Switch_To_BurstFire");
                    }
                }
            }
            else if (get_pdata_int(index,OFFSET_SILENCER_FIREMODE,EXTRAOFFSET_WEAPONS) != FAMAS_AUTOMATIC)
            {
                set_pdata_int(index,OFFSET_SILENCER_FIREMODE,FAMAS_AUTOMATIC,EXTRAOFFSET_WEAPONS);

                new id = pev(index, pev_owner);
                if( id )
                {
                    client_print(id, print_center, "#Switch_To_FullAuto");
                }
            }
        }
        default:
        {
            return 0;
        }
    }

    return 1;
}

stock cs_set_user_vip(index, vip = 1, updateModel = 1, updateScoreboard = 1)
{
    if (vip)
    {
        set_pdata_int(id,OFFSET_VIP, get_pdata_int(id,OFFSET_VIP)|PLAYER_IS_VIP);

        if (updateModel)
        {
            set_pdata_int(id,OFFSET_INTERNALMODEL, _:CS_CT_VIP);
            dllfunc(DLLFunc_ClientUserInfoChanged, id, engfunc(EngFunc_GetInfoKeyBuffer, id));
        }

        if (updateScoreboard)
        {
            static iMsgScoreAttrib
            if( iMsgScoreAttrib || (iMsgScoreAttrib = get_user_msgid("ScoreAttrib")) )
            {
                message_begin(MSG_BROADCAST, iMsgScoreAttrib);
                write_byte(id);
                write_byte(SCOREATTRIB_VIP);
                message_end();
            }
        }
    }
    else
    {
        set_pdata_int(id,OFFSET_VIP, get_pdata_int(id,OFFSET_VIP) &= ~PLAYER_IS_VIP);

        if (updateModel)
        {
            set_pdata_int(id,OFFSET_INTERNALMODEL, _:CS_CT_GIGN); // hardcoded to gign model
            dllfunc(DLLFunc_ClientUserInfoChanged, id, engfunc(EngFunc_GetInfoKeyBuffer, id));
        }

        if (updateScoreboard)
        {
            static iMsgScoreAttrib
            if( iMsgScoreAttrib || (iMsgScoreAttrib = get_user_msgid("ScoreAttrib")) )
            {
                message_begin(MSG_BROADCAST, iMsgScoreAttrib);
                write_byte(id);
                write_byte(is_user_alive(id) ? SCOREATTRIB_NOTHING : SCOREATTRIB_DEAD);
                message_end();
            }
        }
    }

    return 1;
} 
User avatar
Archive-Poster
Posts: 1327
Gender:
United States of America

Re: [INC] Fakemeta Utilities

Post by Archive-Poster »

FM util updated.

Edit: Updated
Added cs.inc

Edit2: Update2
Added fakeengine.inc
Added chr_engine.inc
Attachments
fakemeta_util2.inc.zip
(6.43 KiB) Downloaded 4 times
chr_engine.inc.zip
(4.2 KiB) Downloaded 7 times
fakeengine.inc.zip
(911 Bytes) Downloaded 5 times
cs.inc.zip
(3.91 KiB) Downloaded 7 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest