AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Topcolor problem (https://forums.alliedmods.net/showthread.php?t=127291)

hzqst 05-19-2010 10:42

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(playermodelsizeof playermodel 1"models/player/%s/%s.mdl"mdl_scoutmdl_scout)
 
engfunc(EngFunc_PrecacheModelplayermodel)
 
formatex(playermodelsizeof playermodel 1"models/player/%s/%s.mdl"mdl_heavymdl_heavy)
 
engfunc(EngFunc_PrecacheModelplayermodel)
}
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(idg_model[id])
 if(
get_user_team(id) == CS_TEAM_Tformat(g_modelcolor[id], sizeof g_modelcolor[] - 1"%d"COLOR_RED)
 else 
format(g_modelcolor[id], sizeof g_modelcolor[] - 1"%d"COLOR_BLU)
 
engfunc(EngFunc_SetClientKeyValueidengfunc(EngFunc_GetInfoKeyBufferid), "topcolor"g_modelcolor[id])
}
stock fm_set_user_model(id, const modelname[]){
 
engfunc(EngFunc_SetClientKeyValueidengfunc(EngFunc_GetInfoKeyBufferid), "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_Tformat(g_modelcolor[id], sizeof g_modelcolor[] - 1"%d"0)
 else 
format(g_modelcolor[id], sizeof g_modelcolor[] - 1"%d"150)
 
engfunc(EngFunc_SetClientKeyValueidengfunc(EngFunc_GetInfoKeyBufferid), "topcolor"g_modelcolor[id])
 new 
text[32]
 
get_user_info(id"model"textsizeof text 1)
 if(!
equal(textg_model[id])){
  
fm_set_user_model(idg_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


All times are GMT -4. The time now is 03:32.

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