#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <fakemeta>
#include <hamsandwich>
// Special Include
#include <amx_settings_api>
// User is not an entity
#define is_user_valid(%1) (1 <= %1 <= g_iMaxClients)
new const PLUGIN[] = "Spawn Protection";
new const VERSION[] = "1.0";
new const AUTHOR[] = "LondoN eXtream";
// Where Storing Values
new const FILE_SETTINGS[] = "SpawnProtection.ini";
// Active or Not?
new bool: g_bSpawnProtection = true;
// Protected
new g_iSpawnProtectionTime = 5;
// Color by Team
new g_SpawnColors[3][3] = {{0, 0, 0}, {255, 0, 0}, {0, 0, 255}};
// Storing
new g_iMaxClients;
public plugin_precache()
{
if(!amx_load_setting_int(FILE_SETTINGS, "Spawn Protection", "ENABLED", g_bSpawnProtection))
amx_save_setting_int(FILE_SETTINGS, "Spawn Protection", "ENABLED", g_bSpawnProtection);
if(!amx_load_setting_int(FILE_SETTINGS, "Spawn Protection", "SECONDS", g_iSpawnProtectionTime))
amx_save_setting_int(FILE_SETTINGS, "Spawn Protection", "SECONDS", g_iSpawnProtectionTime);
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
RegisterHam(Ham_Spawn, "player", "fw_HamPlayerSpawn_Post", 1);
g_iMaxClients = get_maxplayers();
}
public fw_HamPlayerSpawn_Post(Player)
{
if(!is_user_alive(Player) || !is_user_valid(Player))
return;
if(!g_bSpawnProtection)
return;
new Team = get_user_team(Player);
set_rendering(Player, kRenderFxGlowShell, g_SpawnColors[Team][0], g_SpawnColors[Team][1], g_SpawnColors[Team][2], kRenderNormal, 255);
set_pev(Player, pev_takedamage, 0.0);
set_task(float(g_iSpawnProtectionTime), "RemoveProtection", Player);
}
public RemoveProtection(Player)
{
set_rendering(Player, kRenderFxNone, 0, 0, 0, kRenderNormal, 0);
set_pev(Player, pev_takedamage, 2.0);
}
stock set_rendering(Player, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, Amount = 16)
{
set_pev(Player, pev_renderfx, fx);
new Float: g_PlayerColor[3];
g_PlayerColor[0] = float(r);
g_PlayerColor[1] = float(g);
g_PlayerColor[2] = float(b);
set_pev(Player, pev_rendercolor, g_PlayerColor);
set_pev(Player, pev_rendermode, render);
set_pev(Player, pev_renderamt, float(Amount));
return;
}