Topcolor problem
PHP Code:
new const mdl_scout[] = { "tf2_scout_1"} new const mdl_heavy[] = { "tf2_heavy_1"} enum{ CS_TEAM_UNASSIGNED = 0, CS_TEAM_T, CS_TEAM_CT, CS_TEAM_SPECTATOR } #define COLOR_RED 0 #define COLOR_BLU 150 new g_model[33][48] new g_modelcolor[33][8] public plugin_init(){ RegisterHam(Ham_Spawn, "player", "fw_Spawn_Post", 1) register_forward(FM_SetClientKeyValue, "fw_SetClientKeyValue") register_forward(FM_ClientUserInfoChanged, "fw_ClientUserInfoChanged") server_cmd("sv_restart 5") } public plugin_precache(){ formatex(playermodel, sizeof playermodel - 1, "models/player/%s/%s.mdl", mdl_scout, mdl_scout) engfunc(EngFunc_PrecacheModel, playermodel) formatex(playermodel, sizeof playermodel - 1, "models/player/%s/%s.mdl", mdl_heavy, mdl_heavy) engfunc(EngFunc_PrecacheModel, playermodel) } public fw_Spawn_Post(id){ format(g_model[id], sizeof g_model[] - 1, "%s", (random_num(0,1)) ? mdl_heavy : mdl_scout) fm_set_user_model(id, g_model[id]) if(get_user_team(id) == CS_TEAM_T) format(g_modelcolor[id], sizeof g_modelcolor[] - 1, "%d", COLOR_RED) else format(g_modelcolor[id], sizeof g_modelcolor[] - 1, "%d", COLOR_BLU) engfunc(EngFunc_SetClientKeyValue, id, engfunc(EngFunc_GetInfoKeyBuffer, id), "topcolor", g_modelcolor[id]) } stock fm_set_user_model(id, const modelname[]){ engfunc(EngFunc_SetClientKeyValue, id, engfunc(EngFunc_GetInfoKeyBuffer, id), "model", modelname) } public fw_SetClientKeyValue(id, const infobuffer[], const key[]){ if (equal(key, "model")) return FMRES_SUPERCEDE; if (equal(key, "topcolor")) return FMRES_SUPERCEDE; return FMRES_IGNORED; } public fw_ClientUserInfoChanged(id){ if(get_user_team(id) == CS_TEAM_T) format(g_modelcolor[id], sizeof g_modelcolor[] - 1, "%d", 0) else format(g_modelcolor[id], sizeof g_modelcolor[] - 1, "%d", 150) engfunc(EngFunc_SetClientKeyValue, id, engfunc(EngFunc_GetInfoKeyBuffer, id), "topcolor", g_modelcolor[id]) new text[32] get_user_info(id, "model", text, sizeof text - 1) if(!equal(text, g_model[id])){ fm_set_user_model(id, g_model[id]) return FMRES_SUPERCEDE; } return FMRES_IGNORED; }
All includes needed were put in
It works with some bugs, when I sometimes spawned as a CT I was in red ,as a T I was in blue ,like so,
I was not able to set topcolor in console and I don't think the engine itself could set topcolor because i blocked it
|