#pragma semicolon 1
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <colors>
#pragma newdecls required
#define LoopClients(%1) for(int %1 = 1; %1 <= MaxClients; %1++)\
if(IsClientInGame(%1))
#define PREFIX "\x06[VIP RESPAWN]{default} %t"
#define PLUGIN_VERSION "1.0"
Handle sm_respawn_enabled = INVALID_HANDLE;
bool g_Respawn[MAXPLAYERS + 1] = true;
public Plugin myinfo =
{
name = "Respawn Redux",
author = "brownzilla",
description = "Allows yourself to respawn on certain maps.",
version = PLUGIN_VERSION,
url = "http://sourcemod.net"
};
public void OnPluginStart()
{
LoadTranslations("respawn_redux.phrases");
sm_respawn_enabled = CreateConVar("sm_respawn_enabled", "1", "Enable or disable the plugin: 0 = Disabled | 1 = Enabled");
RegConsoleCmd("sm_respawn", Cmd_Respawn, "Respawns a client");
HookEvent("round_start", RoundStart);
}
public Action RoundStart(Event event, const char[] name, bool dontBroadcast)
{
LoopClients(i)
g_Respawn[i] = true;
}
public void OnConfigsExecuted()
{
char map[128];
GetCurrentMap(map, sizeof(map));
if(strncmp(map, "dr_", 3, false) == 0 || (strncmp(map, "deathrun_", 9, false) == 0))
{
SetConVarInt(sm_respawn_enabled, 0);
}
else
{
SetConVarInt(sm_respawn_enabled, 1);
}
}
public Action Cmd_Respawn(int client, int args)
{
if(GetConVarInt(sm_respawn_enabled) == 1)
{
if(!g_Respawn[client])
{
if(GetClientTeam(client) != 1)
{
if(!IsPlayerAlive(client))
{
CS_RespawnPlayer(client);
g_Respawn[client] = false;
CPrintToChat(client, PREFIX, "dead");
}
else
{
CPrintToChat(client, PREFIX, "alive");
}
}
else
{
CPrintToChat(client, PREFIX, "nogame");
}
}
else
{
CPrintToChat(client, PREFIX, "cos"); // Uzyles juz respawnu w tej rundzie
}
}
else
{
CPrintToChat(client, PREFIX, "unable");
}
}