Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Price Modifier #6

Merged
merged 5 commits into from
Feb 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 34 additions & 22 deletions hl_gangs.sp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <store>
#include <hl_gangs_credits>

#define PLUGIN_VERSION "1.0.8"
#define PLUGIN_VERSION "1.0.9"
#define TAG " \x03[Gangs]\x04"

/* Compiler Instructions */
Expand All @@ -42,6 +42,7 @@ ConVar gcv_iSpeedPrice;
ConVar gcv_iCreateGangPrice;
ConVar gcv_iRenamePrice;
ConVar gcv_iSizePrice;
ConVar gcv_iPriceModifier;

/* Gang Globals */
GangRank ga_iRank[MAXPLAYERS + 1] = {Rank_Invalid, ...};
Expand Down Expand Up @@ -191,9 +192,10 @@ public int Native_GetGangSize(Handle plugin, int numParams)

return ga_iGangSize[client];
}

public Plugin myinfo =
{
name = "[CS:GO] Jailbreak Gangs",
name = "[CS:GO/CS:S] Jailbreak Gangs",
author = "Headline",
description = "An SQL-based gang plugin",
version = PLUGIN_VERSION,
Expand Down Expand Up @@ -232,6 +234,8 @@ public void OnPluginStart()

gcv_iRenamePrice = AutoExecConfig_CreateConVar("hl_gangs_rename_price", "40", "Price to rename");

gcv_iPriceModifier = AutoExecConfig_CreateConVar("hl_gangs_price_modifier", "0", "Price modifier for perks\n Set 0 to disable");

AutoExecConfig_ExecuteFile();
AutoExecConfig_CleanFile();

Expand Down Expand Up @@ -1441,24 +1445,28 @@ public void SQLCallback_Perks(Database db, DBResultSet results, const char[] err
}

char sDisplayBuffer[64];

int price;

price = gcv_iHealthPrice.IntValue + (gcv_iPriceModifier.IntValue * ga_iHealth[client]);
Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T [%i/10] [%i %T]", "Health", client, ga_iHealth[client], price, "Credits", client);
menu.AddItem("health", sDisplayBuffer, (ga_iHealth[client] >= 10 || GetClientCredits(client) < price)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);

Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T [%i/10] [%i %T]", "Health", client, ga_iHealth[client], gcv_iHealthPrice.IntValue, "Credits", client);
menu.AddItem("health", sDisplayBuffer, (ga_iHealth[client] >= 10 || GetClientCredits(client) < gcv_iHealthPrice.IntValue)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);


Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T [%i/10] [%i %T]", "KnifeDamage", client, ga_iDamage[client], gcv_iDamagePrice.IntValue, "Credits", client);
menu.AddItem("damage", sDisplayBuffer, (ga_iDamage[client] >= 10 || GetClientCredits(client) < gcv_iDamagePrice.IntValue)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);


Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T [%i/10] [%i %T]", "Gravity", client, ga_iGravity[client], gcv_iGravityPrice.IntValue, "Credits", client);
menu.AddItem("gravity", sDisplayBuffer, (ga_iGravity[client] >= 10 || GetClientCredits(client) < gcv_iGravityPrice.IntValue)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
price = gcv_iDamagePrice.IntValue + (gcv_iPriceModifier.IntValue * ga_iDamage[client]);
Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T [%i/10] [%i %T]", "KnifeDamage", client, ga_iDamage[client], price, "Credits", client);
menu.AddItem("damage", sDisplayBuffer, (ga_iDamage[client] >= 10 || GetClientCredits(client) < price)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);

price = gcv_iGravityPrice.IntValue + (gcv_iPriceModifier.IntValue * ga_iGravity[client]);
Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T [%i/10] [%i %T]", "Gravity", client, ga_iGravity[client], price, "Credits", client);
menu.AddItem("gravity", sDisplayBuffer, (ga_iGravity[client] >= 10 || GetClientCredits(client) < price)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);

Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T [%i/10] [%i %T]", "Speed", client, ga_iSpeed[client], gcv_iSpeedPrice.IntValue, "Credits", client);
menu.AddItem("speed", sDisplayBuffer, (ga_iSpeed[client] >= 10 || GetClientCredits(client) < gcv_iSpeedPrice.IntValue)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
price = gcv_iSpeedPrice.IntValue + (gcv_iPriceModifier.IntValue * ga_iSpeed[client]);
Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T [%i/10] [%i %T]", "Speed", client, ga_iSpeed[client], price, "Credits", client);
menu.AddItem("speed", sDisplayBuffer, (ga_iSpeed[client] >= 10 || GetClientCredits(client) < price)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);

Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T [%i/9] [%i %T]", "GangSize", client, ga_iSize[client], gcv_iSizePrice.IntValue, "Credits", client);
menu.AddItem("size", sDisplayBuffer, (ga_iSize[client] >= 9 || GetClientCredits(client) < gcv_iSizePrice.IntValue)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
price = gcv_iSizePrice.IntValue + (gcv_iPriceModifier.IntValue * ga_iSize[client]);
Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T [%i/9] [%i %T]", "GangSize", client, ga_iSize[client], price, "Credits", client);
menu.AddItem("size", sDisplayBuffer, (ga_iSize[client] >= 9 || GetClientCredits(client) < price)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);

menu.ExitBackButton = true;

Expand All @@ -1478,37 +1486,42 @@ public int PerksMenu_CallBack(Menu menu, MenuAction action, int param1, int para

if (StrEqual(sInfo, "health"))
{
SetClientCredits(param1, GetClientCredits(param1) - gcv_iHealthPrice.IntValue);
int price = gcv_iHealthPrice.IntValue + (gcv_iPriceModifier.IntValue * ga_iHealth[param1]);
SetClientCredits(param1, GetClientCredits(param1) - price);
++ga_iHealth[param1];
PrintToGang(param1, true, "%s %T", TAG, "HealthUpgrade", LANG_SERVER);
Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_groups SET health=%i WHERE gang=\"%s\"", ga_iHealth[param1], ga_sGangName[param1]);
}
else if (StrEqual(sInfo, "damage"))
{
SetClientCredits(param1, GetClientCredits(param1) - gcv_iDamagePrice.IntValue);
int price = gcv_iDamagePrice.IntValue + (gcv_iPriceModifier.IntValue * ga_iDamage[param1]);
SetClientCredits(param1, GetClientCredits(param1) - price);
++ga_iDamage[param1];
PrintToGang(param1, true, "%s %T", TAG, "DamageUpgrade", LANG_SERVER);
Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_groups SET damage=%i WHERE gang=\"%s\"", ga_iDamage[param1], ga_sGangName[param1]);
}
else if (StrEqual(sInfo, "gravity"))
{
SetClientCredits(param1, GetClientCredits(param1) - gcv_iGravityPrice.IntValue);
int price = gcv_iGravityPrice.IntValue + (gcv_iPriceModifier.IntValue * ga_iGravity[param1]);
SetClientCredits(param1, GetClientCredits(param1) - price);
PrintToGang(param1, true, "%s %T", TAG, "GravityUpgrade", LANG_SERVER);
++ga_iGravity[param1];
Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_groups SET gravity=%i WHERE gang=\"%s\"", ga_iGravity[param1], ga_sGangName[param1]);
SetEntityGravity(param1, GetClientGravityAmmount(param1));
}
else if (StrEqual(sInfo, "speed"))
{
SetClientCredits(param1, GetClientCredits(param1) - gcv_iSpeedPrice.IntValue);
int price = gcv_iSpeedPrice.IntValue + (gcv_iPriceModifier.IntValue * ga_iSpeed[param1]);
SetClientCredits(param1, GetClientCredits(param1) - price);
PrintToGang(param1, true, "%s %T", TAG, "SpeedUpgrade", LANG_SERVER);
++ga_iSpeed[param1];
Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_groups SET speed=%i WHERE gang=\"%s\"", ga_iSpeed[param1], ga_sGangName[param1]);
SetEntPropFloat(param1, Prop_Send, "m_flLaggedMovementValue", GetClientSpeedAmmount(param1));
}
else if (StrEqual(sInfo, "size"))
{
SetClientCredits(param1, GetClientCredits(param1) - gcv_iSizePrice.IntValue);
int price = gcv_iSizePrice.IntValue + (gcv_iPriceModifier.IntValue * ga_iSize[param1]);
SetClientCredits(param1, GetClientCredits(param1) - price);
PrintToGang(param1, true, "%s %T", TAG, "SizeUpgrade", LANG_SERVER);
++ga_iSize[param1];
Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_groups SET size=%i WHERE gang=\"%s\"", ga_iSize[param1], ga_sGangName[param1]);
Expand All @@ -1530,7 +1543,6 @@ public int PerksMenu_CallBack(Menu menu, MenuAction action, int param1, int para
}



/*****************************************************************
******************* LEAVE CONFIRMATION ********************
******************************************************************/
Expand Down