AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   [REQ] OWNER/VIP Model (https://forums.alliedmods.net/showthread.php?t=244663)

Snitch 07-21-2014 18:43

[REQ] OWNER/VIP Model
 
i want Admin Model (no old code please without of .ini)

Code:

ADMIN_KICK = WhiteSonic.mdl
ADMIN_IMMUNITY = BlackSonic.mdl

to HidenSeek Server. thank to Helpers.

Eagle07 07-21-2014 23:34

Re: [REQ] OWNER/VIP Model
 
PHP Code:

#include <amxmodx>
#include <cstrike>
#include <hamsandwich>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define Owner_flag ADMIN_IMMUNITY
#define VIP_flag ADMIN_KICK

// model vip & owner
new const VIP_Model[] = "models/WhiteSonic.mdl"
new const Owner_Model[] = "models/BlackSonic.mdl"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...
    
RegisterHam(Ham_Spawn"player""player_spawn"1)
}

public 
plugin_precache()
{
    
// precache vip model & owner model
    
precache_model(VIP_Model)
    
precache_model(Owner_Model)
}
// when player spawn 
public player_spawn(id)
{
    
// check  if player alive 
    
if(is_user_alive(id))
    {
        
//Owner model
        
if(get_user_flags(id) & Owner_flag)
        {
        
cs_set_user_model(idOwner_Model)
        }
        
        
//VIP model
        
if(get_user_flags(id) & VIP_flag)
        {
        
cs_set_user_model(idVIP_Model)
        }
    }



HamletEagle 07-22-2014 04:18

Re: [REQ] OWNER/VIP Model
 
cs_set_user_model will crash the server,if there are too many players. Use set_user_info instead.

XControlX 07-22-2014 07:15

Re: [REQ] OWNER/VIP Model
 
PHP Code:

#include < amxmodx >
#include < cstrike >
#include < hamsandwich >

#define MAX_FLAGS    2

enum _:g_mModelsData
{
    
m_ModelName16 ],
    
m_ModelFlag
};

new const 
g_szModelsDataMAX_FLAGS ][ g_mModelsData ] =
{
    { 
"BlackSonic"ADMIN_IMMUNITY },
    { 
"WhiteSonic"ADMIN_KICK }
};

public 
plugin_init()
{
    
register_plugin"Admins Models""v1.0""xControl" );
    
    
RegisterHamHam_Spawn"player""FwdPlayerSpawn_Post");
}

public 
plugin_precache()
{
    static 
szModel100 ];
    
    for ( new 
0MAX_FLAGSi++ )
    {
        
formatexszModelcharsmaxszModel ), "models/player/%s/%s.mdl"g_szModelsData][ m_ModelName ], g_szModelsData][ m_ModelName ] );
        
        
precache_modelszModel );
    }
}

public 
FwdPlayerSpawn_Postclient )
{
    if ( !
is_user_aliveclient ) )
        return 
1;
        
    for ( new 
0MAX_FLAGSi++ )
    {
        if ( 
get_user_flagsclient ) & g_szModelsData][ m_ModelFlag ] )
        {
            
cs_set_user_modelclientg_szModelsData][ m_ModelName ] );
            
            break;
        }
    }
    
    return 
1;


:arrow: Note: the owner flag need to be before the vip flag in the array.

HamletEagle 07-22-2014 08:00

Re: [REQ] OWNER/VIP Model
 
PHP Code:

#include < amxmodx >
#include < fakemeta >
#include < cstrike >

#define ACCES1 ADMIN_IMMUNITY
#define ACCES2 ADMIN_KICK

enum _eModelData
{
    
szModel30 ],
    
iAcces
};

/*If you want more models simply add another line in this constant. Last item from constant must not have , */
new const g_szModels [ ] [ eModelData ] =
{
    { },
    { 
"BlackSonic"ACCES1 },
    { 
"WhiteSonic"ACCES1 }
};

public 
plugin_init ( ) 
{
    
register_forward(FM_SetClientKeyValue,  "@FM_OnSetClientKeyValue");
}

public 
plugin_precache ( )
{
    new 
temp 75 ];

    for(new 
1sizeof g_szModelsi++) 
    {
        
formatex(tempsizeof temp -1"models/player/%s/%s.mdl"g_szModels][ szModel ]);
        
precache_model(temp);
    }
    
    
}

@
FM_OnSetClientKeyValue id, const infobuffer[] , const key[] )
{
    if( 
equalkey"model" ) ) 
    {
        static 
model 32 ];
        
get_user_info(id"model"modelsizeof model 1);
        
        for(new 
1sizeof g_szModelsi++) 
        {
            if(
get_user_flags(id) & g_szModels][ iAcces ]) 
            {
                if(!
equal(modelg_szModels][ szModel ]))
                {
                    
set_user_info(id"model"g_szModels][ szModel ]);
                }
            }    
        }
        return 
FMRES_SUPERCEDE
    }
    return 
FMRES_IGNORED;


cs_set_user_model could crash the server very easy...

zmd94 07-22-2014 08:52

Re: [REQ] OWNER/VIP Model
 
Quote:

cs_set_user_model will crash the server, if there are too many players while cs_set_user_model could crash the server very easy. So, please use set_user_info instead.
@ HamletEagle, thank you for the advice.

You have help me a lot.


All times are GMT -4. The time now is 15:13.

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