inital commit
This commit is contained in:
180
spawn_protect_css.sp
Normal file
180
spawn_protect_css.sp
Normal file
@@ -0,0 +1,180 @@
|
||||
/* Plugin Template generated by Pawn Studio */
|
||||
|
||||
#include <sourcemod>
|
||||
|
||||
new client_pro[MAXPLAYERS+1];
|
||||
new client_hp[MAXPLAYERS+1];
|
||||
new Handle:timer_handle[MAXPLAYERS+1];
|
||||
new Handle:h_time, Handle:h_color_r, Handle:h_color_g, Handle:h_color_b;
|
||||
new Float:time_amount, amount_r, amount_g, amount_b;
|
||||
|
||||
public Plugin:myinfo =
|
||||
{
|
||||
name = "SpawnProtection",
|
||||
author = "Chefe",
|
||||
description = "SpawnProtection",
|
||||
version = "1.4",
|
||||
url = "www.chefgaming.de"
|
||||
}
|
||||
|
||||
public OnPluginStart()
|
||||
{
|
||||
//Hooks
|
||||
HookEvent("player_spawn", Event_PlayerSpawn);
|
||||
HookEvent("player_death", Event_PlayerDeath);
|
||||
HookEvent("player_hurt", Event_PlayerHurt);
|
||||
HookEvent("player_class", Event_PlayerChangeclass);
|
||||
|
||||
//ConVars
|
||||
h_time = CreateConVar("sm_sp_time", "5.0", "Set the time for Spawn Protection", _, true, 0.1);
|
||||
h_color_r = CreateConVar("sm_sp_color_r", "0", "Set the red color part");
|
||||
h_color_g = CreateConVar("sm_sp_color_g", "255", "Set the green color part");
|
||||
h_color_b = CreateConVar("sm_sp_color_b", "0", "Set the blue color part");
|
||||
|
||||
//Get the values
|
||||
time_amount = GetConVarFloat(h_time);
|
||||
amount_r = GetConVarInt(h_color_r);
|
||||
amount_g = GetConVarInt(h_color_g);
|
||||
amount_b = GetConVarInt(h_color_b);
|
||||
|
||||
//ConVar Change Callbacks
|
||||
HookConVarChange(h_time, TimeChanged);
|
||||
HookConVarChange(h_color_r, ColorR);
|
||||
HookConVarChange(h_color_g, ColorG);
|
||||
HookConVarChange(h_color_b, ColorB);
|
||||
|
||||
AutoExecConfig(true);
|
||||
}
|
||||
|
||||
public TimeChanged(Handle:cvar, const String:oldVal[], const String:newVal[])
|
||||
{
|
||||
time_amount = StringToFloat(newVal);
|
||||
}
|
||||
|
||||
public ColorR(Handle:cvar, const String:oldVal[], const String:newVal[])
|
||||
{
|
||||
amount_r = StringToInt(newVal);
|
||||
}
|
||||
|
||||
public ColorG(Handle:cvar, const String:oldVal[], const String:newVal[])
|
||||
{
|
||||
amount_g = StringToInt(newVal);
|
||||
}
|
||||
|
||||
public ColorB(Handle:cvar, const String:oldVal[], const String:newVal[])
|
||||
{
|
||||
amount_b = StringToInt(newVal);
|
||||
}
|
||||
|
||||
|
||||
public OnClientConnected(client)
|
||||
{
|
||||
client_pro[client] = 0;
|
||||
|
||||
if (timer_handle[client] != INVALID_HANDLE)
|
||||
{
|
||||
KillTimer(timer_handle[client]);
|
||||
}
|
||||
|
||||
timer_handle[client] = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
public OnClientDisconnect(client)
|
||||
{
|
||||
client_pro[client] = 0;
|
||||
|
||||
if (timer_handle[client] != INVALID_HANDLE)
|
||||
{
|
||||
KillTimer(timer_handle[client]);
|
||||
}
|
||||
|
||||
timer_handle[client] = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
new userid = GetEventInt(event, "userid");
|
||||
new client = GetClientOfUserId(userid);
|
||||
|
||||
if (IsClientInGame(client) && IsPlayerAlive(client))
|
||||
{
|
||||
SetEntityRenderColor(client, amount_r, amount_g, amount_b, 255);
|
||||
client_hp[client] = GetClientHealth(client);
|
||||
client_pro[client] = 1;
|
||||
PrintToChat(client, "\x01[\x04SP\x01] Spawn-Protection \x04ON\x01!")
|
||||
timer_handle[client] = CreateTimer(time_amount, DestroyProtection, client);
|
||||
}
|
||||
}
|
||||
|
||||
public Action:DestroyProtection(Handle:timer, any:client)
|
||||
{
|
||||
client_pro[client] = 0;
|
||||
timer_handle[client] = INVALID_HANDLE;
|
||||
|
||||
if (IsClientInGame(client))
|
||||
{
|
||||
if (IsPlayerAlive(client))
|
||||
{
|
||||
SetEntityRenderColor(client, 255, 255, 255, 255);
|
||||
PrintToChat(client, "\x01[\x04SP\x01] Spawn-Protection \x04OFF\x01! Slide!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
new client = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||
|
||||
client_pro[client] = 0;
|
||||
|
||||
if (timer_handle[client] != INVALID_HANDLE)
|
||||
{
|
||||
KillTimer(timer_handle[client]);
|
||||
timer_handle[client] = INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
public Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
new client = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||
|
||||
if (client_pro[client])
|
||||
{
|
||||
SetEntData(client, FindDataMapOffs(client, "m_iMaxHealth"), client_hp[client], 4, true);
|
||||
SetEntData(client, FindDataMapOffs(client, "m_iHealth"), client_hp[client], 4, true);
|
||||
}
|
||||
}
|
||||
|
||||
public Event_RoundWin(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
new clients = GetClientCount(true);
|
||||
|
||||
for (new i = 1; i != clients; i++)
|
||||
{
|
||||
if (timer_handle[i] != INVALID_HANDLE)
|
||||
{
|
||||
KillTimer(timer_handle[i])
|
||||
timer_handle[i] = INVALID_HANDLE;
|
||||
client_pro[i] = 0;
|
||||
|
||||
if (IsPlayerAlive(i))
|
||||
{
|
||||
SetEntityRenderColor(i, 255, 255, 255, 255);
|
||||
PrintToChat(i, "\x01[\x04SP\x01] Round end. Spawn Protection \x04OFF\x01!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Event_PlayerChangeclass(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
new userid = GetEventInt(event, "userid");
|
||||
new client = GetClientOfUserId(userid);
|
||||
|
||||
if (timer_handle[client] != INVALID_HANDLE)
|
||||
{
|
||||
KillTimer(timer_handle[client]);
|
||||
timer_handle[client] = INVALID_HANDLE;
|
||||
}
|
||||
client_pro[client] = 0;
|
||||
}
|
Reference in New Issue
Block a user