Can you guys help me? How can i set after the player type !afk he will be moved after x seconds?
Code:
#pragma newdecls required
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <cstrike>
public Plugin myinfo =
{
name = "Send player to spec",
author = "Arkarr",
description = "A simple spectator manager.",
version = "1.0",
url = "http://www.sourcemod.net"
};
public void OnPluginStart()
{
RegConsoleCmd("sm_spec", Command_Spectator, "Send player to spec team.");
RegConsoleCmd("sm_afk", Command_Spectator, "Send player to spec team.");
RegAdminCmd("sm_fspec", ForceSendPlayerAFK, ADMFLAG_GENERIC, "sage: sm_fspec <#userid|name>");
LoadTranslations("common.phrases");
}
public Action Command_Spectator(int client, int args)
{
if (client) // commands can be executed by Console (client == 0)
{
if(GetClientCount() >= 12)
{
SendPlayerToSpectators(client);
}
else
{
PrintToChat(client, "[SM] You cannot use the command yet.");
}
}
return Plugin_Handled;
}
public Action ForceSendPlayerAFK(int client, int args)
{
if (args < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_fspec <#userid|name>");
return Plugin_Handled;
}
char arg[MAX_TARGET_LENGTH];
GetCmdArg(1, arg, sizeof(arg));
char target_name[MAX_TARGET_LENGTH];
int target_list[MAXPLAYERS], target_count;
bool tn_is_ml;
if ((target_count = ProcessTargetString(
arg,
client,
target_list,
MAXPLAYERS,
COMMAND_FILTER_CONNECTED,
target_name,
sizeof(target_name),
tn_is_ml)) > 0)
{
for (int i = 0; i < target_count; i++)
{
SendPlayerToSpectators(target_list[i]);
}
}
else
{
ReplyToTargetError(client, target_count);
}
return Plugin_Handled;
}
void SendPlayerToSpectators(int client)
{
if (GetClientTeam(client) != CS_TEAM_SPECTATOR)
{
if (IsPlayerAlive(client))
{
ForcePlayerSuicide(client);
}
ChangeClientTeam(client, CS_TEAM_SPECTATOR);
}
}