Skip to content
Permalink
Browse files

Merge branch 'master' of https://github.com/Bara/TroubleinTerroristTown

  • Loading branch information
Bara committed Oct 3, 2019
2 parents 5eac8a8 + 50a750d commit fc482835ac2c7b609308053f28b4e37bcbca45ca
Showing with 53 additions and 17 deletions.
  1. +42 −14 addons/sourcemod/scripting/ttt/ttt_taser.sp
  2. +6 −1 ci/build.sh
  3. +5 −2 ci/test.sh
@@ -34,6 +34,7 @@ ConVar g_cBroadcastTaserResult = null;
ConVar g_cTDamage = null;
ConVar g_cInflictor = null;
ConVar g_cLongName = null;
ConVar g_cRoundKeep = null;
ConVar g_cTKDamage = null;
ConVar g_cTaserCooldown = null;
ConVar g_cGlowPlayer = null;
@@ -48,6 +49,7 @@ int g_iIPCount[MAXPLAYERS + 1] = { 0, ... };
int g_iDPCount[MAXPLAYERS + 1] = { 0, ... };
int g_iTPCount[MAXPLAYERS + 1] = { 0, ... };
bool g_bTaser[MAXPLAYERS + 1] = { false, ... };
bool g_bRoundTaser[MAXPLAYERS + 1] = { false, ... };

/* Block taser stuff or so... */
Handle g_hCooldown = null;
@@ -68,7 +70,7 @@ public Plugin myinfo =
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
g_hOnTased = CreateGlobalForward("TTT_OnTased", ET_Ignore, Param_Cell, Param_Cell);

RegPluginLibrary("ttt_taser");

return APLRes_Success;
@@ -97,6 +99,7 @@ public void OnPluginStart()
g_cBroadcastTaserResult = AutoExecConfig_CreateConVar("ta_broadcast_taser_result", "0", "When set to true the results of the taser message will be printed to everyone instead of the client that tased", _, true, 0.0, true, 1.0);
g_cInflictor = AutoExecConfig_CreateConVar("ta_barrel_fix", "1", "Prevent bug with taser and a explosive barrel", _, true, 0.0, true, 1.0);
g_cLongName = AutoExecConfig_CreateConVar("ta_name", "Taser", "The name of this in Shop");
g_cRoundKeep = AutoExecConfig_CreateConVar("ta_keep_to_next_round", "0", "Give the Innocents a tasers if they had one before round end?", _, true, 0.0, true, 1.0);
g_cTKDamage = AutoExecConfig_CreateConVar("ta_kill_traitor_credts", "2000", "The amount of credits an innocent or detective will recieve for discovering a traitor with their zues/taser.");
g_cTaserCooldown = AutoExecConfig_CreateConVar("ta_cooldown_after_round_start", "30.0", "Disable taser for X seconds after round starts (0.0 to disable it)");
g_cTaserCooldownMessage = AutoExecConfig_CreateConVar("ta_cooldown_after_round_start_message", "1", "Show message when tasers are enabled?", _, true, 0.0, true, 1.0);
@@ -137,7 +140,7 @@ public void TTT_OnShopReady()
void RegisterItem()
{
char sBuffer[MAX_ITEM_LENGTH];

g_cLongName.GetString(sBuffer, sizeof(sBuffer));
TTT_RegisterCustomItem(SHORT_NAME_D, sBuffer, g_cDPrice.IntValue, TTT_TEAM_DETECTIVE, g_cDPrio.IntValue);
TTT_RegisterCustomItem(SHORT_NAME, sBuffer, g_cIPrice.IntValue, TTT_TEAM_INNOCENT, g_cIPrio.IntValue);
@@ -154,7 +157,7 @@ public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] n

public void OnClientDisconnect(int client)
{
ResetTaser(client);
ResetTaser(client, true);
}

public void OnClientPutInServer(int client)
@@ -201,12 +204,12 @@ public void TTT_OnRoundStart(int innocents, int traitors, int detective)
for(int offset = 0; offset < 128; offset += 4)
{
int weapon = GetEntDataEnt2(i, FindSendPropInfo("CBasePlayer", "m_hMyWeapons") + offset);

if (IsValidEntity(weapon))
{
char sClass[32];
GetEntityClassname(weapon, sClass, sizeof(sClass));

if (StrContains(sClass, "taser", false) != -1)
{
BlockTaser(weapon);
@@ -224,12 +227,12 @@ public Action Timer_ActivateTasers(Handle timer)
for(int offset = 0; offset < 128; offset += 4)
{
int weapon = GetEntDataEnt2(i, FindSendPropInfo("CBasePlayer", "m_hMyWeapons") + offset);

if (IsValidEntity(weapon))
{
char sClass[32];
GetEntityClassname(weapon, sClass, sizeof(sClass));

if (StrContains(sClass, "taser", false) != -1)
{
UnblockTaser(weapon);
@@ -254,6 +257,14 @@ public void TTT_OnRoundEnd(int winner, Handle array)
KillTimer(g_hCooldown);
}
g_hCooldown = null;

LoopValidClients(i)
{
if (IsPlayerAlive(i) && g_bTaser[i])
{
g_bRoundTaser[i] = true;
}
}
}

public void TTT_OnClientGetRole(int client, int role)
@@ -268,6 +279,18 @@ public void TTT_OnClientGetRole(int client, int role)
GivePlayerItem(client, "weapon_taser");
g_iDPCount[client]++;
}
else if (g_cRoundKeep.BoolValue)
{
if (!g_bRoundTaser[client])
{
return;
}

GivePlayerItem(client, "weapon_taser");
g_iDPCount[client]++;
}

g_bRoundTaser[client] = false;
}

public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
@@ -276,7 +299,7 @@ public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadca

if (TTT_IsClientValid(client))
{
ResetTaser(client);
ResetTaser(client, false);
}
}

@@ -388,13 +411,18 @@ public Action TTT_OnItemPurchased(int client, const char[] itemshort, bool count
return Plugin_Continue;
}

void ResetTaser(int client)
void ResetTaser(int client, bool fullReset)
{
g_iDPCount[client] = 0;
g_iIPCount[client] = 0;
g_iTPCount[client] = 0;

g_bTaser[client] = false;

if (fullReset)
{
g_bRoundTaser[client] = false;
}
}

public Action OnTraceAttack(int iVictim, int &iAttacker, int &inflictor, float &damage, int &damagetype, int &ammotype, int hitbox, int hitgroup)
@@ -436,7 +464,7 @@ public Action OnTraceAttack(int iVictim, int &iAttacker, int &inflictor, float &
if (StrContains(sWeapon, "taser", false) != -1)
{
char sAttackerID[32], sVictimID[32];

ConVar hTag = FindConVar("ttt_steamid_add_to_logs");
if (hTag.BoolValue)
{
@@ -456,14 +484,14 @@ public Action OnTraceAttack(int iVictim, int &iAttacker, int &inflictor, float &
GetClientAuthId(iAttacker, AuthId_SteamID64, sAttackerID, sizeof(sAttackerID));
GetClientAuthId(iVictim, AuthId_SteamID64, sVictimID, sizeof(sVictimID));
}

if (strlen(sAttackerID) > 2 && strlen(sVictimID) > 2)
{
Format(sAttackerID, sizeof(sAttackerID), " (%s)", sAttackerID);
Format(sVictimID, sizeof(sVictimID), " (%s)", sVictimID);
}
}

// TODO: Make it shorter(?) with this natives - https://github.com/Bara/TroubleinTerroristTown/issues/309
if (iRole == TTT_TEAM_TRAITOR)
{
@@ -477,7 +505,7 @@ public Action OnTraceAttack(int iVictim, int &iAttacker, int &inflictor, float &
{
CPrintToChat(iAttacker, "%s %T", g_sPluginTag, "You hurt a Traitor", iVictim, iVictim);
}

TTT_SetClientCredits(iAttacker, TTT_GetClientCredits(iAttacker) + g_cTKDamage.IntValue);
}
else if (iRole == TTT_TEAM_DETECTIVE)
@@ -506,7 +534,7 @@ public Action OnTraceAttack(int iVictim, int &iAttacker, int &inflictor, float &
CPrintToChat(iAttacker, "%s %T", g_sPluginTag, "You hurt an Innocent", iVictim, iVictim);
}
}

Call_StartForward(g_hOnTased);
Call_PushCell(iAttacker);
Call_PushCell(iVictim);
@@ -25,7 +25,12 @@ echo -e "Compile ttt plugins"
for file in addons/sourcemod/scripting/ttt/*.sp
do
echo -e -e "\nCompiling $file..."
addons/sourcemod/scripting/spcomp -E -w234 -O2 -v2 $file

if [ $1 == "1.9" ]; then
addons/sourcemod/scripting/spcomp -E -w234 -O2 -v2 $file
else
addons/sourcemod/scripting/spcomp -w234 -O2 -v2 $file
fi
done

echo -e "\nCompile 3rd-party-plugins"
@@ -11,8 +11,11 @@ chmod +x addons/sourcemod/scripting/spcomp
echo -e "Compile ttt plugins"
for file in addons/sourcemod/scripting/ttt/*.sp
do
echo -e "\nCompiling $file..."
addons/sourcemod/scripting/spcomp -E -w234 -O2 -v2 $file
if [ $1 == "1.9" ]; then
addons/sourcemod/scripting/spcomp -E -w234 -O2 -v2 $file
else
addons/sourcemod/scripting/spcomp -w234 -O2 -v2 $file
fi
done

echo -e "\nCompile 3rd-party-plugins"

0 comments on commit fc48283

Please sign in to comment.
You can’t perform that action at this time.