Raised This Month: $ Target: $400
 0% 

player model problems


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
drumzplaya13
Senior Member
Join Date: Feb 2008
Location: TEXAS
Old 10-25-2009 , 05:48   player model problems
Reply With Quote #1

I didnt make this plugin, I do though find it useful and I AM using it on my server. There is a problem with it though and I was wondering if someone could help me out with it. The models precache fine, they run the first round. CT model work. Sometimes the CT skin gets on a T, also the T models go back to default once the round ends, instead of using the T player model I specified in it. Can someone help me with the problem, here is the code.


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/player1/player1.mdl");
    precache_model("models/player/player2/player2.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(id, currentmodel, charsmax(currentmodel));
            
            new terrmodel[32];
            
            if(equal(currentmodel, "terror")) {terrmodel = "player1";}
            else if(equal(currentmodel, "guerilla")) {terrmodel = "player1";}
            else if(equal(currentmodel, "leet")) {terrmodel = "player1";}
            else if(equal(currentmodel, "arctic")) {terrmodel = "player1";}
            else if(equal(currentmodel, "militia")) {terrmodel = "player1";}
            
            copy(g_player_model[id], charsmax(g_player_model[]), terrmodel);
            
            if(!equal(currentmodel, g_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[]), "player2");
            
            new currentmodel[32];
            fm_get_user_model(id, currentmodel, charsmax(currentmodel));
            
            if(!equal(currentmodel, g_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(id, currentmodel, charsmax(currentmodel));
    
    if(!equal(currentmodel, g_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_ClientUserInfoChanged, id, engfunc(EngFunc_GetInfoKeyBuffer, id));
    g_has_custom_model[id] = false;
}

stock fm_get_user_model(id, model[], len) {
    engfunc(EngFunc_InfoKeyValue, engfunc(EngFunc_GetInfoKeyBuffer, id), "model", model, len);
}

public fm_set_user_model(id) {
    id -= MODELSET_TASK;
    engfunc(EngFunc_SetClientKeyValue, id, engfunc(EngFunc_GetInfoKeyBuffer, id), "model", g_player_model[id]);
    g_has_custom_model[id] = true;
}
__________________
Think Positive - Stay Positive

Last edited by drumzplaya13; 10-25-2009 at 05:55.
drumzplaya13 is offline
 



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 17:47.


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