Permalink
Browse files

update ttt_turret.sp

  • Loading branch information...
Bara committed May 5, 2018
1 parent cc90502 commit ca9513b71eed71b1f3ce408fb3930830263987ab
Showing with 29 additions and 17 deletions.
  1. +29 −17 addons/sourcemod/scripting/ttt/ttt_turret.sp
@@ -14,7 +14,7 @@
#pragma newdecls required
#define PLUGIN_NAME TTT_PLUGIN_NAME ... " - turret"
#define PLUGIN_NAME TTT_PLUGIN_NAME ... " - Turret"
#define SHORT_NAME "turret"
bool g_bHasTurret[MAXPLAYERS+1];
@@ -25,7 +25,7 @@ ConVar g_cLongName = null;
ConVar g_cDiscount = null;
ConVar g_cKillTurretCount = null;
ConVar g_c_sd_turret_checkteam = null;
ConVar g_cCheckTeam = null;
public Plugin myinfo =
@@ -39,12 +39,11 @@ public Plugin myinfo =
public void OnPluginStart()
{
//TTT
LoadTranslations("ttt.phrases");
TTT_StartConfig("turret");
CreateConVar("ttt2_turret_version", TTT_PLUGIN_VERSION, TTT_PLUGIN_DESCRIPTION, FCVAR_NOTIFY | FCVAR_DONTRECORD | FCVAR_REPLICATED);
g_cLongName = AutoExecConfig_CreateConVar("turret_name", "turret", "The name of this in Shop");
g_cLongName = AutoExecConfig_CreateConVar("turret_name", "Turret", "The name of this in Shop");
g_cPrice = AutoExecConfig_CreateConVar("turret_price", "9000", "The amount of credits turret costs as traitor. 0 to disable.");
g_cPrio = AutoExecConfig_CreateConVar("turret_sort_prio", "0", "The sorting priority of the turret in the shop menu.");
g_cDiscount = AutoExecConfig_CreateConVar("turret_traitor", "0", "Should turret discountable?", _, true, 0.0, true, 1.0);
@@ -53,24 +52,25 @@ public void OnPluginStart()
TTT_EndConfig();
//
}
public void OnAllPluginsLoaded()
{
g_c_sd_turret_checkteam = FindConVar("sd_turret_checkteam");
g_cCheckTeam = FindConVar("sd_turret_checkteam");
if(g_c_sd_turret_checkteam != null){
g_c_sd_turret_checkteam.SetInt(3);
g_c_sd_turret_checkteam.AddChangeHook(ConVarChanged);
if(g_cCheckTeam != null)
{
g_cCheckTeam.SetInt(3);
g_cCheckTeam.AddChangeHook(ConVarChanged);
}
}
public void ConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
{
if(convar == g_c_sd_turret_checkteam)
g_c_sd_turret_checkteam.SetInt(3);
if(convar == g_cCheckTeam)
{
g_cCheckTeam.SetInt(3);
}
}
public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
@@ -98,11 +98,17 @@ public Action TTT_OnItemPurchased(int client, const char[] itemshort, bool count
}
LoopValidClients(client_index){
LoopValidClients(client_index)
{
int irole = TTT_GetClientRole(client_index);
if(irole == TTT_TEAM_DETECTIVE || irole == TTT_TEAM_INNOCENT)
{
SetTurretCanAttackClient(client_index,true);
else SetTurretCanAttackClient(client_index,false);
}
else
{
SetTurretCanAttackClient(client_index,false);
}
}
CreateTurret(client);
@@ -123,8 +129,13 @@ public void TTT_OnClientGetRole(int client, int role)
if (TTT_IsClientValid(client) && IsPlayerAlive(client))
{
if(role == TTT_TEAM_DETECTIVE || role == TTT_TEAM_INNOCENT)
{
SetTurretCanAttackClient(client,true);
else SetTurretCanAttackClient(client,false);
}
else
{
SetTurretCanAttackClient(client,false);
}
}
}
@@ -141,8 +152,9 @@ public void TTT_OnItemsReset()
void RegisterItem()
{
if(!Turret_Core_AVAILABLE()) {
LogError("can't find plugin turret_core.smx or turret_core.smx not running!");
if(!LibraryExists("TurretCore"))
{
LogError("can't find plugin turret_core.smx or turret_core.smx not running! https://forums.alliedmods.net/showpost.php?p=2589375&postcount=2");
return;
}

0 comments on commit ca9513b

Please sign in to comment.