AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Multiple Models (https://forums.alliedmods.net/showthread.php?t=223272)

Gasior 08-11-2013 14:35

Multiple Models
 
Hi,
I am trying to do a multiple models plugin. The way it will work is by saying /madmin you get model of admin etc. So I tried lots of combination and any of them don't work correctly. My sma so far looks like that
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <hamsandwich>

#define ADMIN_FLAG_X (1<<23)

new model1[33]
new 
model2[33]
new 
model3[33]

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

public 
plugin_precache() {
        
precache_model("models/player/admin_ct/admin_ct.mdl")
        
precache_model("models/player/admin_te/admin_te.mdl")

        return 
PLUGIN_CONTINUE
}

public 
client_authorized(id)
{
model1[id] = false;
model3[id] = false;
model2[id] = false;
}

public 
modelevip(id)
{
        if(
get_user_flags(id) & ADMIN_FLAG_X) {
    
model1[id] = true;
    
model2[id] = false;
    
model3[id] = false;
}
}

public 
modele2vip(id)
{
        if(
get_user_flags(id) & ADMIN_FLAG_X) {
    
model1[id] = false;
    
model2[id] = true;
    
model3[id] = false;
}
}

public 
modele3vip(id)
{
        if(
get_user_flags(id) & ADMIN_FLAG_X) {
    
model1[id] = false;
    
model2[id] = false;
    
model3[id] = true;
}
}

public 
resetModel(idlevelcid) {
        new 
CsTeams:userTeam cs_get_user_team(id)
        if (
model1[id]) {
                if (
userTeam == CS_TEAM_T) {
                        
cs_set_user_model(id"admin_te")
                }
                else if(
userTeam == CS_TEAM_CT) {
                        
cs_set_user_model(id"admin_ct")
                }
                else {
                        
cs_reset_user_model(id)
                }
    }
        if (
model2[id]) {
                if (
userTeam == CS_TEAM_T) {
                        
cs_set_user_model(id"admin_te")
                }
                else if(
userTeam == CS_TEAM_CT) {
                        
cs_set_user_model(id"admin_ct")
                }
                else {
                        
cs_reset_user_model(id)
                }
    }
        if (
model3[id]) {
                if (
userTeam == CS_TEAM_T) {
                        
cs_set_user_model(id"admin_te")
                }
                else if(
userTeam == CS_TEAM_CT) {
                        
cs_set_user_model(id"admin_ct")
                }
                else {
                        
cs_reset_user_model(id)
                }
    }
    return 
PLUGIN_CONTINUE


I'll be thankful for any help or suggestion.

Black Rose 08-11-2013 21:03

Re: Multiple Models
 
It looks fine, what's the problem?

Just some suggestions
All you have to change with this code is modelfiles[][] = { ... }
Use whatever you want.
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"},     {"admin_te", "admin_ct"},     {"admin_te", "admin_ct"} } 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");         return PLUGIN_CONTINUE; } public plugin_precache() {     new tempfile[128];         for ( new i = 0 ; i < sizeof modelfiles ; i++ ) {         for ( new j = 0 ; j < 2 ; j++ ) {             formatex(tempfile, 127, "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(1, arg, 31);         model[id] = clamp(ctod(arg[7]), 0, sizeof modelfiles); } public resetModel(id) {     new userTeam2, CsTeams:userTeam = cs_get_user_team(id);         switch ( userTeam ) {         case CS_TEAM_T: userTeam2 = 1;         case CS_TEAM_CT: userTeam2 = 2;     }     if ( model[id] && userTeam2 )         cs_set_user_model(id, modelfiles[model[id] - 1][userTeam2 - 1]);     else         cs_reset_user_model(id); }

Gasior 08-12-2013 03:48

Re: Multiple Models
 
The problem was that server crashed.

Now your plugin is running but doesn't work :/ .

I even added client_print while changing model but it also doesn't work. Are you sure it's correct?

Black Rose 08-12-2013 13:49

Re: Multiple Models
 
Sorry i forgot this line:
Code:
precache_model(tempfile);
It should work now.

Gasior 08-12-2013 14:47

Re: Multiple Models
 
It would be perfect if it run a properly name of model. First I got this
Code:

FATAL ERROR (shutting down): Mod_NumForName: models/player/dmin_te/dmin_te.mdl not found
So I changed name of models at dmin_te and dmin_ct and then it showed
Code:

FATAL ERROR (shutting down): Mod_NumForName: models/player/admin_te/admin_te.mdl not found
Strange :/ .

YamiKaitou 08-12-2013 15:06

Re: Multiple Models
 
Does the file exist on the server?

Gasior 08-12-2013 15:50

Re: Multiple Models
 
I mean, the problem isn't nonexistent file but the fact that first it says "Where the heck is dmin_te.mdl" and then "I'd like admin_te.mdl back".
Like, it requires 2 pairs of models dmin_te, dmin_ct and admin_te, admin_ct.

YamiKaitou 08-12-2013 15:57

Re: Multiple Models
 
new modelfiles[][]

->

new modelfiles[][][]

Gasior 08-12-2013 17:34

Re: Multiple Models
 
Thank you very much guys, you're awesome.

I've also added /mreset, which allow you to come back to your basic model.

Black Rose 08-12-2013 20:13

Re: Multiple Models
 
Quote:

Originally Posted by YamiKaitou (Post 2011702)
new modelfiles[][]

->

new modelfiles[][][]

Why does it even compile with this awful mistake?


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

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