Raised This Month: $ Target: $400
 0% 

Multiple Models


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Gasior
Member
Join Date: Mar 2012
Old 08-12-2013 , 20:54   Re: Multiple Models
Reply With Quote #1

One more thing, /mreset resets model just in the current round in the next one it switches to last chosen model. Could you fix it for me?
Final code:
PHP Code:
#include <amxmodx>
#include <cstrike>

#define ADMIN_FLAG_X (1<<23)
#define ctod(%0) %0-48

new model[33];
new 
modelfiles[][][] = {
    {
"admin_te""admin_ct"},
    {
"vip1""vip3"},
    {
"vip2""vip4"}
}

public 
plugin_init() {
    
register_plugin("Modele VIP""1.0""Gasior");
    
    
register_event("ResetHUD""resetModel""b");
    
    
register_clcmd("say /modele1""modelevip");
    
register_clcmd("say /modele2""modelevip");
    
register_clcmd("say /modele3""modelevip");
    
register_clcmd("say /mreset""modelreset");
    
    return 
PLUGIN_CONTINUE;
}

public 
plugin_precache() {

    new 
tempfile[128];
    
    for ( new 
sizeof modelfiles i++ ) {
        for ( new 
j++ ) {
            
formatex(tempfile127"models/player/%s/%s.mdl"modelfiles[i][j], modelfiles[i][j]);
            
precache_model(tempfile);
        }
    }
    
    return 
PLUGIN_CONTINUE;


public 
client_authorized(id) {
    
model[id] = 0;
}

public 
modelevip(id) {
    if ( ! ( 
get_user_flags(id) & ADMIN_FLAG_X ) )
        return;
    
    new 
arg[32];
    
read_argv(1arg31);
    
    
model[id] = clamp(ctod(arg[7]), 0sizeof modelfiles);
}

public 
resetModel(id) {
    new 
userTeam2CsTeams:userTeam cs_get_user_team(id);
    
    switch ( 
userTeam ) {
        case 
CS_TEAM_TuserTeam2 1;
        case 
CS_TEAM_CTuserTeam2 2;
    }
    if ( 
model[id] && userTeam2 )
        
cs_set_user_model(idmodelfiles[model[id] - 1][userTeam2 1]);
    else
        
cs_reset_user_model(id);

    return;
}

public 
modelreset(id) {
    if ( ! ( 
get_user_flags(id) & ADMIN_FLAG_X ) )
        return;
    else
    
cs_reset_user_model(id);
    return;


Last edited by Gasior; 08-18-2013 at 11:28.
Gasior is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-12-2013 , 21:14   Re: Multiple Models
Reply With Quote #2

Code:
public modelreset(id) {     if ( ! ( get_user_flags(id) & ADMIN_FLAG_X ) )         return;     // else <- This is not needed because of "return" being the first case.     cs_reset_user_model(id);     model[id] = 0; // Add this line and you should be fine.     // return; <- You can remove this to ease up your code aswell since the default function is to return blank. }

I made this line on purpose so you could write /modele0 to reset if you wanted to. As long as that command was registered of course.
But it's completely up to you.
Code:
model[id] = clamp(ctod(arg[7]), 0, sizeof modelfiles); //                              ^
__________________

Last edited by Black Rose; 08-12-2013 at 21:22.
Black Rose is offline
Gasior
Member
Join Date: Mar 2012
Old 08-13-2013 , 03:49   Re: Multiple Models
Reply With Quote #3

I don't want to be invasive but I wonder if there is a way to make it all in a menu. Like they write /modele and it shows all 4 options. I've tried to make it by my own, but present code is way too complicated for me.
Gasior is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-13-2013 , 15:46   Re: Multiple Models
Reply With Quote #4

This would be the easiest menu solution.
The new menu system really makes it easy to create menus.
Code:
#include <amxmodx> #include <cstrike> #pragma semicolon 1 #define ADMIN_FLAG_X        (1<<23) #define MENUITEM_DISABLED   (1<<26) new g_Model[33]; new g_ModelFiles[][][] = {     {"terror", "urban"},     {"leet", "gsg9"},     {"arctic", "sas"},     {"guerilla", "gign"} }; new g_ModelNames[][] = {     "Model 1",     "Model 2",     "Model 3",     "Model 4" }; #if ( sizeof g_ModelNames != sizeof g_ModelFiles )     #error You have to format the g_ModelFiles to the same size as g_ModelNames #endif public plugin_init() {     register_plugin("Modele VIP", "1.0", "Gasior");         register_event("ResetHUD", "resetModel", "b");     register_clcmd("say /modele", "modelevip");         return PLUGIN_CONTINUE; } public plugin_precache() {     new tempfile[128];         for ( new i = 0 ; i < sizeof g_ModelFiles ; i++ ) {         for ( new j = 0 ; j < 2 ; j++ ) {             formatex(tempfile, 127, "models/player/%s/%s.mdl", g_ModelFiles[i][j], g_ModelFiles[i][j]);             precache_model(tempfile);         }     } } public client_connect(id) {     g_Model[id] = 0; } public modelevip(id) {     if ( ! ( get_user_flags(id) & ADMIN_FLAG_X ) )         return;         new menu = menu_create( "\yChose your model:", "menu_handler" );         new i;     for ( i = 0 ; i < sizeof g_ModelFiles ; i++ ) {         new menuitem[64];         formatex(menuitem, charsmax(menuitem), "\%c%s", g_Model[id] - 1 == i ? 'd' : 'w', g_ModelNames[i]);         menu_additem(menu, menuitem,_, g_Model[id] - 1 == i ? MENUITEM_DISABLED : 0);     }         menu_addblank(menu, 0);     menu_additem(menu, "Default Model");         menu_display(id, menu); } public menu_handler(id, menu, item) {     if ( item == MENU_EXIT ) {         menu_destroy(menu);         return PLUGIN_HANDLED;     }     if ( item == sizeof g_ModelFiles )         g_Model[id] = 0;     else         g_Model[id] = item + 1;         resetModel(id);         return PLUGIN_CONTINUE; } public resetModel(id) {     if ( ! is_user_connected(id) )         return;         new userTeam2, CsTeams:userTeam = cs_get_user_team(id);         switch ( userTeam ) {         case CS_TEAM_T: userTeam2 = 1;         case CS_TEAM_CT: userTeam2 = 2;     }         if ( g_Model[id] && userTeam2 )         cs_set_user_model(id, g_ModelFiles[g_Model[id] - 1][userTeam2 - 1]);     else         cs_reset_user_model(id);     return; }
__________________

Last edited by Black Rose; 08-13-2013 at 15:51.
Black Rose is offline
Gasior
Member
Join Date: Mar 2012
Old 08-13-2013 , 21:13   Re: Multiple Models
Reply With Quote #5

Thank you very much, the plugin is great.
Gasior is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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