@Markiez
Don't use ServerCommand() to call "sm_ban" but rather use BanClient() to directly call the ban function.
PHP Code:
#include <sourcemod>
#include <cstrike>
#pragma semicolon 1
#pragma newdecls required
public void OnPluginStart()
{
HookEvent("player_death", Event_PlayerDeath);
}
public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
int victim = GetClientOfUserId(event.GetInt("userid"));
int attacker = GetClientOfUserId(event.GetInt("attacker"));
if (IsValidClient(victim) && IsValidClient(attacker) && GetClientTeam(victim) == GetClientTeam(attacker) && victim != attacker)
{
BanClient(attacker, 30, BANFLAG_AUTO, "Banned for teamkilling", "You have been banned for teamkilling", "", attacker);
}
}
stock bool IsValidClient(int client)
{
return (client > 0 && client <= MaxClients && IsClientInGame(client) && !IsClientInKickQueue(client) && !IsFakeClient(client));
}
@ThatOneGuy
You don't need SDKHooks to hook player events. HookEvent() isn't a SDKHooks function.
__________________