Raised This Month: $ Target: $400
 0% 

Setting player models


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 


Thread Tools
Display Modes

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