Thanks Guys! I updated the code with your suggestions and it works great!
Final solution:
PHP Code:
stock void TF2_SwitchtoSlot(int client, int slot)
{
if (slot >= 0 && slot <= 5 && IsClientInGame(client) && IsPlayerAlive(client))
{
char wepclassname[64];
int wep = GetPlayerWeaponSlot(client, slot);
if (wep > MaxClients && IsValidEdict(wep) && GetEdictClassname(wep, wepclassname, sizeof(wepclassname)))
{
FakeClientCommandEx(client, "use %s", wepclassname);
SetEntPropEnt(client, Prop_Send, "m_hActiveWeapon", wep);
}
}
}