if its just gonna be 1 model per team you could just use
PHP Code:
#define T_MODEL "models/player/tm_professional_var1.mdl"
so you wouldn't need to globally declare strings and call a function to move them into the buffer. Also the IsValidClient function is missing. Honestly no need to use a switch case for 2 things. Also instead of GetEventInt you could just use Event directly instead of Handle so you could write something like
PHP Code:
event.GetInt("userid");
PHP Code:
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#define T_PLAYER_MODEL "models/player/tm_professional_var1.mdl"
#define CT_PLAYER_MODEL "models/player/ctm_sas_varianta.mdl"
public void OnPluginStart()
{
HookEvent("player_spawn", Event_PlayerSpawn)
}
public void OnMapStart()
{
PrecacheModel(T_PLAYER_MODEL, true);
PrecacheModel(CT_PLAYER_MODEL, true);
}
public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
int userid = event.GetInt("userid");
CreateTimer(0.1, SetModels, userid);
}
public Action SetModels(Handle timer, any userid)
{
int client = GetClientOfUserId(userid);
if(!IsValidClient(client))
return;
switch(GetClientTeam(client))
{
case CS_TEAM_CT:
{
SetEntityModel(client, CT_PLAYER_MODEL);
}
case CS_TEAM_T:
{
SetEntityModel(client, T_PLAYER_MODEL);
}
}
}
bool IsValidClient(int client)
{
return (1 <= client <= MaxClients && IsClientInGame(client));
}