View Single Post
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 06-05-2020 , 13:20   Re: access flags that have knifes
Reply With Quote #17

Quote:
Originally Posted by itoxicreal View Post
Thank you,Can you also make it for vip model? with access t
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
#include <fakemeta>

#define FLAG_HERE "t" //you change needed flag here
#define V_KNIFE "models/knife_t.mdl" //you change your path to model here

/***************************************/
enum _:ModelsInfo
{
    
Flag,
    
CTModel[32],
    
TModel[32]
}
new const 
g_eModels[][ModelsInfo] =
{
    { 
ADMIN_LEVEL_H"vip_ct""vip_t" }
}
new 
Trie:g_tModels

/***************************************/

public plugin_init() 
{
    
register_plugin("""""")
    
    
RegisterHam(Ham_Spawn"player""OnPlayerSpawn"1)

    
register_event("CurWeapon""knife""be""1=1")
}


public 
plugin_end()
    
TrieDestroy(g_tModels)

public 
plugin_precache() 
{
    
precache_model(V_KNIFE)
    
    
g_tModels TrieCreate()
    
    for(new 
isizeof(g_eModels); i++)
    {
        
precache_player_model(g_eModels[i][CTModel])
    
precache_player_model(g_eModels[i][TModel])
    }
    
}


public 
knife(id)
{
    new 
is_knife read_data(2)
    if(
has_flag(idFLAG_HERE))
    {
        if(
is_knife == CSW_KNIFE)
        {
            
set_pev(idpev_viewmodel2V_KNIFE);
            
//set_pev(id, pev_weaponmodel2, V_KNIFE); //remove first "//" if you use weapon model, its a model that other players see
        
}
    }

/*****************************/
//        VIP Model          //
/*****************************/

public OnPlayerSpawn(id)
{
    if(
is_user_alive(id))
    {
        static 
bool:bMatchiFlagsi
        bMatch 
false
        
        
for(iFlags get_user_flags(id), 0sizeof(g_eModels); i++)
        {
            if(
iFlags g_eModels[i][Flag])
            {
                switch(
cs_get_user_team(id))
                {
                    case 
CS_TEAM_CTcs_set_user_model(idg_eModels[i][CTModel])
                    case 
CS_TEAM_Tcs_set_user_model(idg_eModels[i][TModel])
                }
                
                
bMatch true
                
break
            }
        }
        
        if(!
bMatch)
        {
            static 
szModel[32]
            
cs_get_user_model(idszModelcharsmax(szModel))
            
            if(
TrieKeyExists(g_tModelsszModel))
                
cs_reset_user_model(id)
        }
    }
}

precache_player_model(szModel[])
{
    
TrieSetCell(g_tModelsszModel1)
    
    static 
szFile[128]
    
formatex(szFilecharsmax(szFile), "models/player/%s/%s.mdl"szModelszModel)
    
precache_model(szFile)
    
replace(szFilecharsmax(szFile), ".mdl""T.mdl")
    
    if(
file_exists(szFile))
        
precache_model(szFile)

Supremache is offline