try this:
PHP Code:
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#include <cstrike>
bool bIsAdmin[MAXPLAYERS+1];
public void OnPluginStart()
{
AddCommandListener(Cmd_JoinTeam, "jointeam");
HookEvent("player_spawn", PlayerSpawn);
}
public void OnClientPostAdminCheck(int client)
{
if(0 < client <= MaxClients) bIsAdmin[client] = CheckCommandAccess(client, "sm_admin", ADMFLAG_GENERIC);
}
public Action PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if(!IsFakeClient(client)) ChangeTeam(client, GetClientTeam(client), bIsAdmin[client]);
}
public Action Cmd_JoinTeam(int client, const char[] command, int argc)
{
if(argc == 0 || client == 0 || !IsClientConnected(client) || !IsClientInGame(client) || IsFakeClient(client)) return Plugin_Continue;
char team[4];
GetCmdArg(1, team, sizeof(team));
ChangeTeam(client, StringToInt(team), bIsAdmin[client]);
return Plugin_Continue;
}
void ChangeTeam(int client, int team, bool admin)
{
if((admin && team == CS_TEAM_CT) || (!admin && team == CS_TEAM_T))
{
ChangeClientTeam(client, bIsAdmin[client] ? CS_TEAM_T : CS_TEAM_CT);
CS_RespawnPlayer(client);
}
}
Need SM1.8 to compile
__________________