AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   VIP Player Model (https://forums.alliedmods.net/showthread.php?t=338405)

MeliMeli 07-02-2022 19:14

VIP Player Model
 
Hello how can I put a specific flag in this plugin for a player to be entitled to a menu of models?

PHP Code:

/*
PLUGIN INFO:
- This plugin should works fine on ZP43Fix5a & ZP50.
- For better model changes, it need a bit mp_freezetime set to 3~5 is enough.
*/

#include <amxmodx>
#include <hamsandwich>

//Server is running ZP50?

#if defined USE_ZP50
    
native zp_core_is_zombie(id)
    
native zp_class_survivor_get(id)
    
native cs_set_player_model(id, const model[])
#else
    
native zp_get_user_zombie(id)
    
native zp_get_user_survivor(id)
    
native zp_override_user_model(id, const model[], modelindex=0)
    
    
//Uncomment this to enable player modelindex
    //#define USE_PLAYER_MODELINDEX
#endif

//player model name: edit as you want
new const szModelName[][] = 
{
    
"arctic",
    
"gign",
    
"gsg9",
    
"guerilla",
    
"leet",
    
"sas",
    
"terror",
    
"urban",
    
"vip"
}

//player model name in menu: edit as you want
new const szModelMenuName[][] = 
{
    
"Arctic Munkey",
    
"GIGN",
    
"GSG9",
    
"Guerillaz",
    
"1337",
    
"SAS",
    
"Tellolist",
    
"Urban Chaos",
    
"VVIP"
}

new 
bool:bIsNewModel[33], szNewModel[33][32], bool:bIsNewRound

public plugin_precache()
{
    new 
jszText[64]
    for(
j=0sizeof szModelNamej++)
    {
        
formatex(szText63"models/player/%s/%s.mdl"szModelName[j], szModelName[j])
        
precache_model(szText)
    }
}

public 
plugin_init()
{
    
register_plugin("ZP Models Menu""0.0.2""wbyokomo")
    
    
register_event("HLTV""OnNewRound""a""1=0""2=0")
    
register_logevent("OnStartRound",2"1=Round_Start")
    
    
RegisterHam(Ham_Spawn"player""OnPlayerSpawnPost"1)
    
    
register_clcmd("say /model""CmdNewModels")
}

public 
client_disconnected(id)
{
    
bIsNewModel[id] = false
}

public 
OnNewRound()
{
    
bIsNewRound true
}

public 
OnStartRound()
{
    
bIsNewRound false
}

public 
OnPlayerSpawnPost(id)
{
    if(!
is_user_alive(id) || !bIsNewModel[id]) return;
    
    
//spawn as zombie in deathmatch, no need to change model.
    #if defined USE_ZP50
        
if(!bIsNewRound && zp_core_is_zombie(id)) return;
        
        
cs_set_player_model(idszNewModel[id])
    
#else
        
if(!bIsNewRound && zp_get_user_zombie(id)) return;
    
        
#if defined USE_PLAYER_MODELINDEX
        
if(zv_get_user_flags(id) & ZV_MULTI)

        
zp_override_user_model(idszNewModel[id], 1)
        
#else
        
zp_override_user_model(idszNewModel[id])
        
#endif
    #endif
}

#if !defined USE_ZP50
public zp_user_humanized_post(id)
{
    if(!
bIsNewModel[id] || zp_get_user_survivor(id)) return;
    
    
#if defined USE_PLAYER_MODELINDEX
    
zp_override_user_model(idszNewModel[id], 1)
    
#else
    
zp_override_user_model(idszNewModel[id])
    
#endif
}
#endif

public CmdNewModels(id)
{
    if(!
is_user_connected(id))
    {
        
log_amx("Unconnected player [%d] tried to use /model command."id)
        return 
PLUGIN_HANDLED;
    }
    
    
#if defined USE_ZP50
    
if(zp_core_is_zombie(id) || zp_class_survivor_get(id))
    
#else
    
if(zp_get_user_zombie(id) || zp_get_user_survivor(id))
    
#endif
    
{
        
client_print(idprint_chat"[MODEL] Sorry! Zombie, Nemesis, Survivor can't use custom model.")
        return 
PLUGIN_HANDLED;
    }
    
    new 
menu menu_create("Human Models:""mh_CustomModel")
    
    new 
j
    
for(j=0sizeof szModelMenuNamej++)
    {
        
menu_additem(menuszModelMenuName[j], ""0)
    }
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0)
    
    return 
PLUGIN_HANDLED;
}

public 
mh_CustomModel(idmenuitem)
{
    if(!
is_user_connected(id))
    {
        
menu_destroy(id)
        return 
PLUGIN_HANDLED;
    }
    
    
#if defined USE_ZP50
    
if(zp_core_is_zombie(id) || zp_class_survivor_get(id))
    
#else
    
if(zp_get_user_zombie(id) || zp_get_user_survivor(id))
    
#endif
    
{
        
menu_destroy(id)
        
client_print(idprint_chat"[MODEL] Sorry! Zombie, Nemesis, Survivor can't use custom model.")
        return 
PLUGIN_HANDLED;
    }
    
    if(
item == MENU_EXIT)
    {
        
menu_destroy(id)
        return 
PLUGIN_HANDLED;
    }

    new 
command[6], name[64], accesscallback

    menu_item_getinfo
(menuitemaccesscommandsizeof command 1namesizeof name 1callback)
    
    
bIsNewModel[id] = true
    
#if defined USE_ZP50
        
cs_set_player_model(idszModelName[item])
    
#else
        #if defined USE_PLAYER_MODELINDEX
        
zp_override_user_model(idszModelName[item], 1)
        
#else
        
zp_override_user_model(idszModelName[item])
        
#endif
    #endif
    
copy(szNewModel[id], 31szModelName[item])
    
client_print(idprint_chat"[MODEL] You've chosen '%s' as your new player model."szModelName[item])

    
menu_destroy(menu)

    return 
PLUGIN_HANDLED;



Fixsek Kot 07-05-2022 15:22

Re: VIP Player Model
 
hi,

as nobody has answered this post yet, I can try to help you, but you have to explain it to me a little better, because I don't understand your request.

MeliMeli 07-05-2022 18:52

Re: VIP Player Model
 
Well, I wouldn't need it anymore because I discarded this plugin, but if I want to answer, I can help to improve my learning in the future. What I asked was how to add a flag, for example "t" that is ADMIN_LEVEL_H in this plugin so that only administrators or those who have access to this flag can access the models menu

Fixsek Kot 07-06-2022 06:40

Re: VIP Player Model
 
Oh okay now I get it, it is simple:
PHP Code:

public menu(id)
{
    if(
get_user_flags(id) & ADMIN_BAN || get_user_flags(id) & ADMIN_LEVEL_H)
    {
        
//The menu
    
}
    else
    {
        
client_print(idprint_chat"This menu is only for admins and people with flag T!")
    }


Yeah I prefere checking ADMIN_BAN than something like is_user_admin, because this condition looks for any kind of flag, even ADMIN_LEVEL_H, and we want to find an administrator, those always have ADMIN_BAN flag.
Hope that helps :)


All times are GMT -4. The time now is 21:23.

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