Raised This Month: $ Target: $400
 0% 

Setting player models


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
VMAN
Senior Member
Join Date: Oct 2007
Location: California, US
Old 10-11-2009 , 14:07   Setting player models
Reply With Quote #1

Can someone please take a look at this and tell my why nothing happens?

I have the folders in the correct places. Tried it with bots on listen server and no effect. No errors in console either. No compile warnings, loads fine.

I'm going crazy trying to figure out why it's not working.

It is supposed to give all the CT's one model, and all the T's models depending on which class they chose. (each class is set to one model for testing purposes)

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>


public plugin_init() {
    
register_plugin("Player Models""1.0""vman");
    
    
register_event("HLTV""evRoundStart""a""1=0""2=0");
    
RegisterHam(Ham_Spawn"player""fwHamPlayerSpawnPost"1);
    
register_forward(FM_SetClientKeyValue"fwSetClientKeyValue");
    
register_forward(FM_ClientUserInfoChanged"fwClientUserInfoChanged");
}

public 
plugin_precache() {
    
precache_model("models/player/vcmdl_ctcz-1/vcmdl_ctcz-1.mdl");
    
precache_model("models/player/vcmdl_tcz-1/vcmdl_tcz-1.mdl");
}

#define MODELSET_TASK 100

new Float:g_roundstarttime;
new 
Float:g_models_targettime;

new 
bool:g_has_custom_model[33];
new 
g_player_model[33][32];

public 
client_putinserver(id) {
    
g_has_custom_model[id] = false;
}

public 
evRoundStart() {
    
g_roundstarttime get_gametime();
}

public 
fwHamPlayerSpawnPost(id) {
    if(
is_user_alive(id)) {
        if(
get_user_team(id) == 1) {
            if(
task_exists(id MODELSET_TASK)) {
                
remove_task(id MODELSET_TASK);
            }
            
            
//fm_reset_user_model(id);
            
            
new currentmodel[32];
            
fm_get_user_model(idcurrentmodelcharsmax(currentmodel));
            
            new 
terrmodel[32];
            
            if(
equal(currentmodel"terror")) {terrmodel "vcmdl_tcz-1";}
            else if(
equal(currentmodel"guerilla")) {terrmodel "vcmdl_tcz-1";}
            else if(
equal(currentmodel"leet")) {terrmodel "vcmdl_tcz-1";}
            else if(
equal(currentmodel"arctic")) {terrmodel "vcmdl_tcz-1";}
            else if(
equal(currentmodel"militia")) {terrmodel "vcmdl_tcz-1";}
            
            
copy(g_player_model[id], charsmax(g_player_model[]), terrmodel);
            
            if(!
equal(currentmodelg_player_model[id])) {
                if(
get_gametime() - g_roundstarttime 5.0) {
                    
set_task(2.5"fm_update_user_model"id MODELSET_TASK);
                }
                
                else {
                    
fm_update_user_model(id MODELSET_TASK);
                }
            }
        }
        
        else if(
get_user_team(id) == 2) {
            if(
task_exists(id MODELSET_TASK)) {
                
remove_task(id MODELSET_TASK);
            }
            
            
//fm_reset_user_model(id);
            
            
copy(g_player_model[id], charsmax(g_player_model[]), "vcmdl_ctcz-1");
            
            new 
currentmodel[32];
            
fm_get_user_model(idcurrentmodelcharsmax(currentmodel));
            
            if(!
equal(currentmodelg_player_model[id])) {
                if(
get_gametime() - g_roundstarttime 5.0) {
                    
set_task(2.5"fm_update_user_model"id MODELSET_TASK);
                }
                
                else {
                    
fm_update_user_model(id MODELSET_TASK);
                }
            }
        }
    }
}

public 
fwSetClientKeyValue(id, const infobuffer[], const key[]) {
    if(
g_has_custom_model[id] && equal(key"model")) {
        return 
FMRES_SUPERCEDE;
    }
    
    return 
FMRES_IGNORED;
}

public 
fwClientUserInfoChanged(id) {
    if(!
g_has_custom_model[id]) {
        return 
FMRES_IGNORED;
    }
    
    new 
currentmodel[32];
    
fm_get_user_model(idcurrentmodelcharsmax(currentmodel));
    
    if(!
equal(currentmodelg_player_model[id]) && !task_exists(id MODELSET_TASK)) {
        
fm_set_user_model(id MODELSET_TASK);
    }
    
    return 
FMRES_IGNORED;
}

public 
fm_update_user_model(taskid) {
    new 
Float:current_time;
    
current_time get_gametime();
    
    if(
current_time g_models_targettime >= 0.5) {
        
fm_set_user_model(taskid);
        
g_models_targettime current_time;
    }
    
    else {
        
set_task((g_models_targettime 0.5) - current_time"fm_set_user_model"taskid);
        
g_models_targettime g_models_targettime 0.5;
    }
}

stock fm_reset_user_model(id) {
    
dllfunc(DLLFunc_ClientUserInfoChangedidengfunc(EngFunc_GetInfoKeyBufferid));
    
g_has_custom_model[id] = false;
}

stock fm_get_user_model(idmodel[], len) {
    
engfunc(EngFunc_InfoKeyValueengfunc(EngFunc_GetInfoKeyBufferid), "model"modellen);
}

public 
fm_set_user_model(id) {
    
id -= MODELSET_TASK;
    
engfunc(EngFunc_SetClientKeyValueidengfunc(EngFunc_GetInfoKeyBufferid), "model"g_player_model[id]);
    
g_has_custom_model[id] = true;

This is based on this tutorial
__________________

Last edited by VMAN; 10-11-2009 at 19:16.
VMAN is offline
shuttle_wave
Veteran Member
Join Date: Apr 2009
Location: New Zealand
Old 10-23-2009 , 22:45   Re: Setting player models
Reply With Quote #2

I want plugin that just replace players model eg. Replace all ct with a guard model and replace all t with Prisoner model. Like that?? If u want pm me and ill make u one
shuttle_wave is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 10-24-2009 , 02:30   Re: Setting player models
Reply With Quote #3

Just remove 'if get_user_team and if task exists( MODELSET_TASK) on the top', just remove task without any checks, put on the top of Player_Spawn.
Btw ,you didn't used the code correctly like in his code.
__________________

Last edited by xbatista; 10-24-2009 at 13:23.
xbatista is offline
Send a message via Skype™ to xbatista
VMAN
Senior Member
Join Date: Oct 2007
Location: California, US
Old 10-24-2009 , 02:39   Re: Setting player models
Reply With Quote #4

shuttle, gtfo my thread
__________________
VMAN is offline
drumzplaya13
Senior Member
Join Date: Feb 2008
Location: TEXAS
Old 10-24-2009 , 04:05   Re: Setting player models
Reply With Quote #5

LOL at VMAN telling shuffle off.

I would try what xbatista said. if it works, I am going to use this plugin if you dont mind because I have been looking for something like this for a while.
__________________
Think Positive - Stay Positive

Last edited by drumzplaya13; 10-24-2009 at 05:18.
drumzplaya13 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 22:41.


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