Page 1 of 1

Spawn Protection 1.0

Posted: 23 Apr 2019, 13:06
by LondoN eXtream
Descriere: Aceasta este versiunea mea de Spawn Protection. Aceasta ofera un glow rosu sau albastru in functie de echipa si nu puteti fi omorati timp de x secunde.

Descarcare: https://www73.zippyshare.com/v/TtY9i9sT/file.html
Sursa:
SpawnProtection.sma | Afiseaza codul
#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;
}
Instalare:
1. Fisierul amx_settings_api.sma il puneti in addons/amxmodx/scripting
2. Fisierul amx_settings_api.amxx il puneti in addons/amxmodx/plugins
3. Fisierul SpawnProtection.sma il puneti in addons/amxmodx/scripting
4. Fisierul SpawnProtection.amxx il puneti in addons/amxmodx/plugins
5. Fisierul amx_settings_api.inc il puneti in addons/amxmodx/scripting/include
6. In plugins.ini adaugati:

Code: Select all

amx_settings_api.amxx
SpawnProtection.amxx
Configurare:
Dupa ce rulati pluginul in folderul configs va aparea un fisier SpawnProtection.ini
| Afiseaza codul
[Spawn Protection]
ENABLED = 1 // Spawn Protection este activat sau nu?
SECONDS = 5 // Cate secunde sa fie protejat?