diff -r 000000000000 -r 67dcd379a2d5 scripting/spawnprotection.sp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripting/spawnprotection.sp Sun Jun 24 21:58:09 2007 +0000 @@ -0,0 +1,150 @@ +/** + * spawnprotection.sp + * Adds spawn protection to CS:S DM. + * This file is part of CS:S DM, Copyright (C) 2005-2007 AlliedModders LLC + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Version: $Id$ + */ + +#pragma semicolon 1 +#include +#include +#include + +#define K_RENDER_NORMAL 0 +#define K_RENDER_TRANS_COLOR 1 + +/* Plugin stuff */ +new Handle:g_ProtVar; +new Handle:g_TColorVar; +new Handle:g_CTColorVar; +new Handle:g_ProtTimeVar; +new g_NormColor[4] = {255, 255, 255, 255}; +new g_TColor[4] = {255, 0, 0, 128}; +new g_CTColor[4] = {0, 0, 255, 128}; +new g_HealthOffset; +new g_RenderModeOffset; +new g_RenderClrOffset; + +/* Player stuff */ +new Handle:g_PlayerTimers[MAXPLAYERS+1]; +new g_PlayerHealth[MAXPLAYERS+1]; + +/** PUBLIC INFO */ +public Plugin:myinfo = +{ + name = "CS:S DM Spawn Protection", + author = "AlliedModders LLC", + description = "Spawn protection for CS:S DM", + version = CSSDM_VERSION, + url = "http://www.bailopan.net/cssdm/" +}; + +public OnPluginStart() +{ + g_ProtVar = CreateConVar("cssdm_spawn_protection", "1", "Sets whether spawn protection is enabled"); + g_CTColorVar = CreateConVar("cssdm_prot_ctcolor", "0 0 255 128", "Sets the spawn color of CTs"); + g_TColorVar = CreateConVar("cssdm_prot_tcolor", "255 0 0 128", "Sets the spawn color of Ts"); + g_ProtTimeVar = CreateConVar("cssdm_prot_time", "2", "Sets time in seconds players are protected for"); + + HookConVarChange(g_CTColorVar, OnColorChange); + HookConVarChange(g_TColorVar, OnColorChange); + + g_HealthOffset = FindSendPropOffs("CCSPlayer", "m_iHealth"); + g_RenderModeOffset = FindSendPropOffs("CCSPlayer", "m_nRenderMode"); + g_RenderClrOffset = FindSendPropOffs("CCSPlayer", "m_clrRender"); +} + +public OnColorChange(Handle:convar, const String:oldValue[], const String:newValue[]) +{ + decl String:colors[4][12]; + decl clr[4]; + new num_strings = ExplodeString(newValue, " ", colors, 4, 12); + + for (new i=0; i