Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********************************************************************************************************************
- * Wersja 1.0 pierwszę wypuszczenie pluginu. *
- * Wersja 1.1 Dodano nieograniczone stawki, pokazywanie % szans na wygranie pod !jackpot, możliwość anulowania *
- * stawiania pieniędzy(np. wpiszesz !jackpot i wybierzesz złe stawki) wystarczy wpisać cancel *
- * Dodano wsparcie dla store by Zephyrus(wersja 1.4 używa sm_jackpotshopuse) * *
- * Wersja 1.2 Dodano możliwość ustawienia nazwy waluty przez ConVar sm_jackpotcurrency *
- * Pokazywanie aktualnej puli pod hud *
- * Dodano pokaz wplaconych pieniędzy pod hud *
- * Dodano obliczanie % szans na wygranie pod hud *
- * Wersja 1.3 Zmieniono pozycję napisu danych stawek *
- * Dodano !jm - otwiera menu z wyborem preferencji HUD. *
- * Wersja 1.4 Dodano tłumaczenia oraz dodano automatyczne wykrywanie sklepów którego ma używać jackpot *
- * Można również ustawić poprzez ConVar którego sklepu ma używać. *
- * sm_jackpotshopuse 0-Auto detect 1-DR Shop by Brum Brum 2-Store by Zephyrus 3-Shop by FrozDark 4-Yamakashi Credits *
- * Zmieniono sposób losowania gracza, z slota na userid *
- * Poprawiono błąd przez który czasem nie losowało wygranego gracza. *
- * Dodano możliwość zmiany TAGu na czacie i menu przez cvar *
- * Dodano pokazywanie ilości graczy, którzy biorą udział w jackpocie *
- * Dodano ConVar przez który można wybrać tryb jackpota(0-standardowy losowanie na końcu rundy *
- * 1-Od pierwszej wpłaty na daną stawkę jest X(zależy od cvara) sekund na wpłatę) *
- ********************************************************************************************************************/
- #include <dr_shop>
- #include <store>
- #include <shop>
- #include <GoMod>
- #include <credits>
- #include <multicolors>
- #include <clientprefs>
- #pragma semicolon 1
- #pragma newdecls required
- //#define MOD_TAG "\x01\x0B★ \x07[ADEPT-Jackpot]\x04 "
- ConVar gc_MOD_TAG;
- ConVar Currency, ShopDetect, gc_JackpotMode;
- ConVar LowPriceJackpotMin, MediumPriceJackpotMin, HighPriceJackpotMin;
- ConVar LowPriceJackpotMax, MediumPriceJackpotMax, HighPriceJackpotMax;
- ConVar gc_JackpotTimer;
- char MOD_TAG[64];
- char CurrencyString[32];
- ArrayList JackpotLowPrice, JackpotMediumPrice, JackpotHighPrice, JackpotUnlimitedPrice;
- bool g_Used[MAXPLAYERS + 1];
- bool LowPrice[MAXPLAYERS + 1], MediumPrice[MAXPLAYERS + 1], HighPrice[MAXPLAYERS + 1], UnlimitedPrice[MAXPLAYERS + 1];
- bool g_bLow[MAXPLAYERS + 1], g_bMedium[MAXPLAYERS + 1], g_bHigh[MAXPLAYERS + 1], g_bUnlimited[MAXPLAYERS + 1];
- bool g_bShopBrum, g_bShopZephyrus, g_bShopFrozeDark, g_bShopYamakashi, g_bShopGoMod;
- int g_iSpend[MAXPLAYERS + 1];
- int HudMode[MAXPLAYERS + 1];
- Handle g_hLowTime, g_hMediumTime, g_hHighTime, g_hUnlimitedTime;
- int LowTime, MediumTime, HighTime, UnlimitedTime;
- float HudCoords1[][] = { { 0.02, 0.37 }, { 0.02, 0.05 }, { 0.02, 0.60 }, { 0.35, 0.06 }, { 0.35, 0.43 } };
- float HudCoords2[][] = { { 0.02, 0.40 }, { 0.02, 0.08 }, { 0.02, 0.63 }, { 0.35, 0.09 }, { 0.35, 0.46 } };
- float HudCoords3[][] = { { 0.02, 0.43 }, { 0.02, 0.11 }, { 0.02, 0.66 }, { 0.35, 0.12 }, { 0.35, 0.49 } };
- float HudCoords4[][] = { { 0.02, 0.49 }, { 0.02, 0.17 }, { 0.02, 0.72 }, { 0.35, 0.18 }, { 0.35, 0.55 } };
- float HudCoords5[][] = { { 0.02, 0.52 }, { 0.02, 0.20 }, { 0.02, 0.75 }, { 0.35, 0.21 }, { 0.35, 0.58 } };
- Handle HudPostion;
- /************************************
- ****Uga Buga Bioły Uga Uga Buga******
- *************************************/
- public Plugin myinfo =
- {
- name = "ADEPT -> Jackpot",
- description = "Autorski plugin studioADEPT.net",
- author = "Brum Brum",
- version = "1.4",
- url = "http://www.StudioADEPT.net"
- };
- public void OnPluginStart()
- {
- JackpotLowPrice = new ArrayList();
- JackpotMediumPrice = new ArrayList();
- JackpotHighPrice = new ArrayList();
- JackpotUnlimitedPrice = new ArrayList();
- gc_JackpotMode = CreateConVar("sm_jackpot_mode", "0", "0-Default 1-Timer(60 seconds from the first payment)");
- gc_JackpotTimer = CreateConVar("sm_jackpot_timer", "60", "Działa tylko i wyłącznie z cvarem sm_jackpot_mode 1");
- LowPriceJackpotMin = CreateConVar("sm_jackpotlowpricemin", "250", "Minimum amount at low rates");
- LowPriceJackpotMax = CreateConVar("sm_jackpotlowpricemax", "1500", "Maximum amount at low rates");
- MediumPriceJackpotMin = CreateConVar("sm_jackpotmediumpricemin", "1500", "Minimum amount at average rates");
- MediumPriceJackpotMax = CreateConVar("sm_jackpotmediumpricemax", "4500", "Maximum amount at average rates");
- HighPriceJackpotMin = CreateConVar("sm_jackpothighpricemin", "4500", "Minimum amount at high rates");
- HighPriceJackpotMax = CreateConVar("sm_jackpothighpricemax", "10500", "Maximum amount at high rates");
- ShopDetect = CreateConVar("sm_jackpotshopuse", "0", "0-Auto detect 1-DR Shop by Brum Brum 2-Store by Zephyrus 3-Shop by FrozDark 4-Yamakshi Credits 5 -GoMod");
- gc_MOD_TAG = CreateConVar("sm_jackpot_mod_tag", "ADEPT", "TAG shown in chat and menu");
- Currency = CreateConVar("sm_jackpotcurrency", "$", "Currency name");
- Currency.AddChangeHook(CurrencyNameChanged);
- Currency.GetString(CurrencyString, sizeof(CurrencyString));
- gc_MOD_TAG.AddChangeHook(MOD_TAGNameChanged);
- gc_MOD_TAG.GetString(MOD_TAG, sizeof(MOD_TAG));
- HudPostion = RegClientCookie("sm_jackpothudpostion", "Saving HUD Postion", CookieAccess_Protected);
- RegConsoleCmd("say", ClientSay);
- RegConsoleCmd("say_team", ClientSay);
- RegConsoleCmd("sm_jackpot", CMD_Jackpot);
- RegConsoleCmd("sm_jm", CMD_JackpotMenu);
- HookEvent("round_end", Event_RoundEnd);
- AutoExecConfig(true, "ADEPT_Jackpot");
- LoadTranslations("ADEPT_Jackpot.phrases.txt");
- if (!ShopDetect.BoolValue)
- {
- g_bShopBrum = LibraryExists("dr_shop");
- if (g_bShopBrum) {
- NotifyServer();
- return;
- }
- g_bShopZephyrus = LibraryExists("store_zephyrus");
- if (g_bShopZephyrus) {
- NotifyServer();
- return;
- }
- g_bShopFrozeDark = LibraryExists("shop");
- if (g_bShopFrozeDark) {
- NotifyServer();
- return;
- }
- g_bShopYamakashi = LibraryExists("credits");
- if (g_bShopYamakashi) {
- NotifyServer();
- return;
- }
- g_bShopGoMod = LibraryExists("GoMod");
- if (g_bShopGoMod) {
- NotifyServer();
- return;
- }
- }
- else
- {
- if (ShopDetect.IntValue == 1 && LibraryExists("dr_shop"))g_bShopBrum = true;
- else if (ShopDetect.IntValue == 2 && LibraryExists("store_zephyrus"))g_bShopZephyrus = true;
- else if (ShopDetect.IntValue == 3 && LibraryExists("shop"))g_bShopFrozeDark = true;
- else if (ShopDetect.IntValue == 4 && LibraryExists("credits"))g_bShopYamakashi = true;
- else if (ShopDetect.IntValue == 5 && LibraryExists("GoMod"))g_bShopGoMod = true;
- NotifyServer();
- }
- }
- public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
- {
- MarkNativeAsOptional("dr_GetMoneyAmount");
- MarkNativeAsOptional("dr_RemoveMoney");
- MarkNativeAsOptional("dr_AddMoney");
- MarkNativeAsOptional("Store_SetClientCredits");
- MarkNativeAsOptional("Store_GetClientCredits");
- MarkNativeAsOptional("Shop_SetClientCredits");
- MarkNativeAsOptional("Shop_GetClientCredits");
- MarkNativeAsOptional("shop_add_credits");
- MarkNativeAsOptional("shop_get_credits");
- MarkNativeAsOptional("shop_set_credits");
- return APLRes_Success;
- }
- public void OnPluginEnd()
- {
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsValidPlayer(i))
- {
- g_Used[i] = false;
- LowPrice[i] = false;
- MediumPrice[i] = false;
- HighPrice[i] = false;
- UnlimitedPrice[i] = false;
- g_bLow[i] = false;
- g_bMedium[i] = false;
- g_bHigh[i] = false;
- g_bUnlimited[i] = false;
- g_iSpend[i] = 0;
- }
- }
- LowTime = 0;
- MediumTime = 0;
- HighTime = 0;
- UnlimitedTime = 0;
- g_hLowTime = INVALID_HANDLE;
- g_hMediumTime = INVALID_HANDLE;
- g_hHighTime = INVALID_HANDLE;
- g_hUnlimitedTime = INVALID_HANDLE;
- JackpotLowPrice.Clear();
- JackpotMediumPrice.Clear();
- JackpotHighPrice.Clear();
- JackpotUnlimitedPrice.Clear();
- }
- public void MOD_TAGNameChanged(ConVar convar, const char[] oldValue, const char[] newValue)
- {
- Format(MOD_TAG, sizeof(MOD_TAG), newValue);
- }
- public void CurrencyNameChanged(ConVar convar, const char[] oldValue, const char[] newValue)
- {
- Format(CurrencyString, sizeof(CurrencyString), newValue);
- }
- public void OnLibraryAdded(const char[] name)
- {
- if (!ShopDetect.BoolValue)
- {
- if (StrEqual(name, "dr_shop")) {
- g_bShopBrum = true;
- PrintToServer("Jackpot using dr_shop by Brum Brum");
- return;
- }
- else if (StrEqual(name, "store_zephyrus")) {
- g_bShopZephyrus = true;
- PrintToServer("Jackpot using Store by Zephyrus");
- return;
- }
- else if (StrEqual(name, "shop")) {
- g_bShopFrozeDark = true;
- PrintToServer("Jackpot using Shop by FrozDark");
- return;
- }
- else if (StrEqual(name, "credits")) {
- g_bShopYamakashi = true;
- PrintToServer("Jackpot using Credits by Yamakashi");
- return;
- }
- else if (StrEqual(name, "GoMod")) {
- g_bShopGoMod = true;
- PrintToServer("Jackpot using Credits by GoMod");
- return;
- }
- }
- else
- {
- if (ShopDetect.IntValue == 1 && StrEqual(name, "dr_shop"))g_bShopBrum = true;
- else if (ShopDetect.IntValue == 2 && StrEqual(name, "store_zephyrus"))g_bShopZephyrus = true;
- else if (ShopDetect.IntValue == 3 && StrEqual(name, "shop"))g_bShopFrozeDark = true;
- else if (ShopDetect.IntValue == 4 && StrEqual(name, "credits"))g_bShopYamakashi = true;
- else if (ShopDetect.IntValue == 5 && StrEqual(name, "GoMod"))g_bShopGoMod = true;
- NotifyServer();
- }
- }
- public void OnLibraryRemoved(const char[] name)
- {
- if (StrEqual(name, "dr_shop"))g_bShopBrum = false;
- else if (StrEqual(name, "store_zephyrus"))g_bShopZephyrus = false;
- else if (StrEqual(name, "shop"))g_bShopFrozeDark = false;
- else if (StrEqual(name, "credits"))g_bShopYamakashi = false;
- else if (StrEqual(name, "GoMod"))g_bShopGoMod = false;
- }
- public void OnClientCookiesCached(int client)
- {
- char Value[11];
- GetClientCookie(client, HudPostion, Value, sizeof(Value));
- HudMode[client] = StringToInt(Value);
- }
- public void OnClientDisconnect(int client)
- {
- g_Used[client] = false;
- LowPrice[client] = false;
- MediumPrice[client] = false;
- HighPrice[client] = false;
- UnlimitedPrice[client] = false;
- g_bLow[client] = false;
- g_bMedium[client] = false;
- g_bHigh[client] = false;
- g_bUnlimited[client] = false;
- g_iSpend[client] = 0;
- }
- public Action Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
- {
- if (gc_JackpotMode.IntValue == 0)
- {
- ForceWinJackpot(JackpotLowPrice, true, false, false, false);
- ForceWinJackpot(JackpotMediumPrice, false, true, false, false);
- ForceWinJackpot(JackpotHighPrice, false, false, true, false);
- ForceWinJackpot(JackpotUnlimitedPrice, false, false, false, true);
- }
- }
- public Action ClientSay(int client, int args)
- {
- int minlowprice = LowPriceJackpotMin.IntValue;
- int maxlowprice = LowPriceJackpotMax.IntValue;
- int minmediumprice = MediumPriceJackpotMin.IntValue;
- int maxmediumprice = MediumPriceJackpotMax.IntValue;
- int minhighprice = HighPriceJackpotMin.IntValue;
- int maxhighprice = HighPriceJackpotMax.IntValue;
- if (LowPrice[client] && !g_Used[client])
- {
- char arg[11];
- GetCmdArg(1, arg, sizeof(arg));
- if (StrContains(arg, "cancel", false) != -1 || StrContains(arg, "anuluj", false) != -1) {
- g_Used[client] = false;
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Cancel");
- LowPrice[client] = false;
- g_bLow[client] = false;
- return Plugin_Handled;
- }
- int placed = StringToInt(arg);
- if (placed > GetMoney(client)) {
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Betting more than you have");
- LowPrice[client] = false;
- return Plugin_Handled;
- }
- if (placed < minlowprice) {
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Minimum amount low", minlowprice, CurrencyString);
- return Plugin_Handled;
- }
- else if (placed > maxlowprice) {
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Max amount low", maxlowprice, CurrencyString);
- return Plugin_Handled;
- }
- else {
- g_Used[client] = true;
- RemoveMoney(client, placed);
- g_iSpend[client] = placed;
- for (int i = 0; i < placed; i++) {
- JackpotLowPrice.Push(GetClientUserId(client));
- }
- if (gc_JackpotMode.IntValue == 1) {
- if (g_hLowTime == INVALID_HANDLE) {
- LowTime = gc_JackpotTimer.IntValue;
- g_hLowTime = CreateTimer(1.0, Timer_LowTime, _, TIMER_REPEAT);
- }
- }
- CreateTimer(0.9, JackpotHudRefresh, GetClientUserId(client), TIMER_REPEAT);
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Placed Low", placed, CurrencyString, float(placed) / float(JackpotLowPrice.Length) * 100.0, JackpotLowPrice.Length, CurrencyString);
- }
- return Plugin_Handled;
- }
- else if (MediumPrice[client] && !g_Used[client])
- {
- char arg[11];
- GetCmdArg(1, arg, sizeof(arg));
- if (StrContains(arg, "cancel", false) != -1 || StrContains(arg, "anuluj", false) != -1) {
- g_Used[client] = false;
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Cancel");
- MediumPrice[client] = false;
- g_bMedium[client] = false;
- return Plugin_Handled;
- }
- int placed = StringToInt(arg);
- if (placed > GetMoney(client)) {
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Betting more than you have");
- MediumPrice[client] = false;
- return Plugin_Handled;
- }
- if (placed < minmediumprice) {
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Minimum amount medium", minmediumprice, CurrencyString);
- return Plugin_Handled;
- }
- else if (placed > maxmediumprice) {
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Max amount medium", maxmediumprice, CurrencyString);
- return Plugin_Handled;
- }
- else {
- g_Used[client] = true;
- RemoveMoney(client, placed);
- g_iSpend[client] = placed;
- for (int i = 0; i < placed; i++) {
- JackpotMediumPrice.Push(GetClientUserId(client));
- }
- if (gc_JackpotMode.IntValue == 1) {
- if (g_hMediumTime == INVALID_HANDLE) {
- MediumTime = gc_JackpotTimer.IntValue;
- g_hMediumTime = CreateTimer(1.0, Timer_MediumTime, _, TIMER_REPEAT);
- }
- }
- CreateTimer(0.9, JackpotHudRefresh, GetClientUserId(client), TIMER_REPEAT);
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Placed Medium", placed, CurrencyString, float(placed) / float(JackpotMediumPrice.Length) * 100.0, JackpotMediumPrice.Length, CurrencyString);
- }
- return Plugin_Handled;
- }
- else if (HighPrice[client] && !g_Used[client])
- {
- char arg[11];
- GetCmdArg(1, arg, sizeof(arg));
- if (StrContains(arg, "cancel", false) != -1 || StrContains(arg, "anuluj", false) != -1) {
- g_Used[client] = false;
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Cancel");
- HighPrice[client] = false;
- g_bHigh[client] = false;
- return Plugin_Handled;
- }
- int placed = StringToInt(arg);
- if (placed > GetMoney(client)) {
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Betting more than you have");
- HighPrice[client] = false;
- return Plugin_Handled;
- }
- if (placed < minhighprice) {
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Minimum amount high", minhighprice, CurrencyString);
- return Plugin_Handled;
- }
- else if (placed > maxhighprice) {
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Max amount high", maxhighprice, CurrencyString);
- return Plugin_Handled;
- }
- else {
- g_Used[client] = true;
- RemoveMoney(client, placed);
- g_iSpend[client] = placed;
- for (int i = 0; i < placed; i++) {
- JackpotHighPrice.Push(GetClientUserId(client));
- }
- if (gc_JackpotMode.IntValue == 1) {
- if (g_hHighTime == INVALID_HANDLE) {
- HighTime = gc_JackpotTimer.IntValue;
- g_hHighTime = CreateTimer(1.0, Timer_HighTime, _, TIMER_REPEAT);
- }
- }
- CreateTimer(0.9, JackpotHudRefresh, GetClientUserId(client), TIMER_REPEAT);
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Placed High", placed, CurrencyString, float(placed) / float(JackpotHighPrice.Length) * 100.0, JackpotHighPrice.Length, CurrencyString);
- }
- return Plugin_Handled;
- }
- else if (UnlimitedPrice[client] && !g_Used[client])
- {
- char arg[11];
- GetCmdArg(1, arg, sizeof(arg));
- if (StrContains(arg, "cancel", false) != -1 || StrContains(arg, "anuluj", false) != -1) {
- g_Used[client] = false;
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Cancel");
- UnlimitedPrice[client] = false;
- g_bUnlimited[client] = false;
- return Plugin_Handled;
- }
- int placed = StringToInt(arg);
- if (placed > GetMoney(client)) {
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Betting more than you have");
- UnlimitedPrice[client] = false;
- return Plugin_Handled;
- }
- if (placed <= 0) {
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "You cant bet less zero");
- return Plugin_Handled;
- }
- else {
- g_Used[client] = true;
- RemoveMoney(client, placed);
- g_iSpend[client] = placed;
- for (int i = 0; i < placed; i++) {
- JackpotUnlimitedPrice.Push(GetClientUserId(client));
- }
- if (gc_JackpotMode.IntValue == 1) {
- if (g_hUnlimitedTime == INVALID_HANDLE) {
- UnlimitedTime = gc_JackpotTimer.IntValue;
- g_hUnlimitedTime = CreateTimer(1.0, Timer_UnlimitedTime, _, TIMER_REPEAT);
- }
- }
- CreateTimer(0.9, JackpotHudRefresh, GetClientUserId(client), TIMER_REPEAT);
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Placed Unlimited", placed, CurrencyString, float(placed) / float(JackpotUnlimitedPrice.Length) * 100.0, JackpotUnlimitedPrice.Length, CurrencyString);
- }
- return Plugin_Handled;
- }
- return Plugin_Continue;
- }
- public Action CMD_Jackpot(int client, int args)
- {
- if (client == 0) {
- PrintToServer("Komenda dostępna tylko z poziomu gracza");
- return Plugin_Handled;
- }
- char title[128], bet[128];
- Menu menu = new Menu(Menu_Handler);
- Format(title, sizeof(title), "%s -> Jackpot\n%t", MOD_TAG, "Menu Current Money", GetMoney(client), CurrencyString);
- menu.SetTitle(title);
- Format(bet, sizeof(bet), "%t", "Menu Low rates", JackpotLowPrice.Length, CurrencyString);
- menu.AddItem("", bet);
- Format(bet, sizeof(bet), "%t", "Menu Medium rates", JackpotMediumPrice.Length, CurrencyString);
- menu.AddItem("", bet);
- Format(bet, sizeof(bet), "%t", "Menu High rates", JackpotHighPrice.Length, CurrencyString);
- menu.AddItem("", bet);
- Format(bet, sizeof(bet), "%t", "Menu Unlimited rates", JackpotUnlimitedPrice.Length, CurrencyString);
- menu.AddItem("", bet);
- menu.ExitButton = true;
- menu.Display(client, MENU_TIME_FOREVER);
- return Plugin_Handled;
- }
- public Action CMD_JackpotMenu(int client, int args)
- {
- if (client == 0) {
- PrintToServer("Komenda dostępna tylko z poziomu gracza");
- return Plugin_Handled;
- }
- char translation[128];
- Menu menu = new Menu(Jackpot_Menu_Handler);
- Format(translation, sizeof(translation), "%s -> Jackpot\n%t", MOD_TAG, "Menu HUD Title");
- menu.SetTitle(translation);
- Format(translation, sizeof(translation), "%t", "Menu HUD Default");
- menu.AddItem("", translation);
- Format(translation, sizeof(translation), "%t", "Menu HUD Upper left corner");
- menu.AddItem("", translation);
- Format(translation, sizeof(translation), "%t", "Menu HUD Above the chat");
- menu.AddItem("", translation);
- Format(translation, sizeof(translation), "%t", "Menu HUD Under result");
- menu.AddItem("", translation);
- Format(translation, sizeof(translation), "%t", "Menu HUD Center");
- menu.AddItem("", translation);
- menu.ExitButton = true;
- menu.Display(client, 60);
- return Plugin_Handled;
- }
- public int Menu_Handler(Menu menu, MenuAction action, int client, int item)
- {
- if (!IsValidPlayer(client))return;
- switch (action)
- {
- case MenuAction_Select:
- {
- switch (item)
- {
- case 0:
- {
- if (!g_Used[client])
- {
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Before Bet");
- LowPrice[client] = true;
- g_bLow[client] = true;
- } else CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "After Bet");
- }
- case 1:
- {
- if (!g_Used[client])
- {
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Before Bet");
- MediumPrice[client] = true;
- g_bMedium[client] = true;
- } else CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "After Bet");
- }
- case 2:
- {
- if (!g_Used[client])
- {
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Before Bet");
- HighPrice[client] = true;
- g_bHigh[client] = true;
- } else CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "After Bet");
- }
- case 3:
- {
- if (!g_Used[client])
- {
- CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Before Bet");
- UnlimitedPrice[client] = true;
- g_bUnlimited[client] = true;
- } else CPrintToChat(client, "\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "After Bet");
- }
- }
- }
- case MenuAction_End:delete menu;
- }
- }
- public int Jackpot_Menu_Handler(Menu menu, MenuAction action, int client, int item)
- {
- if (!IsValidPlayer(client))return;
- if (action == MenuAction_Select)
- {
- HudMode[client] = item;
- char Value[11];
- Format(Value, sizeof(Value), "%d", HudMode[client]);
- SetClientCookie(client, HudPostion, Value);
- }
- else if (action == MenuAction_End)delete menu;
- }
- public Action JackpotHudRefresh(Handle timer, int userid)
- {
- int client = GetClientOfUserId(userid);
- if (!IsValidPlayer(client))return Plugin_Stop;
- float blow = float(g_iSpend[client]) / float(JackpotLowPrice.Length) * 100.0;
- float bmedium = float(g_iSpend[client]) / float(JackpotMediumPrice.Length) * 100.0;
- float bhigh = float(g_iSpend[client]) / float(JackpotHighPrice.Length) * 100.0;
- float bunlimited = float(g_iSpend[client]) / float(JackpotUnlimitedPrice.Length) * 100.0;
- if (LowPrice[client])
- {
- SetHudTextParams(HudCoords1[HudMode[client]][0], HudCoords1[HudMode[client]][1], 1.0, 255, 0, 0, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD Low rates name");
- SetHudTextParams(HudCoords2[HudMode[client]][0], HudCoords2[HudMode[client]][1], 1.0, 0, 162, 232, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD Low rates pot", JackpotLowPrice.Length, CurrencyString);
- SetHudTextParams(HudCoords3[HudMode[client]][0], HudCoords3[HudMode[client]][1], 1.0, 6, 231, 1, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD Low rates placed", g_iSpend[client], CurrencyString, blow);
- SetHudTextParams(HudCoords4[HudMode[client]][0], HudCoords4[HudMode[client]][1], 1.0, 200, 255, 0, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD Low rates player count", GetPlayerCount(true, false, false, false));
- if (gc_JackpotMode.IntValue == 1) {
- SetHudTextParams(HudCoords5[HudMode[client]][0], HudCoords5[HudMode[client]][1], 1.0, 20, 50, 255, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD Low rates timeleft", LowTime);
- }
- }
- else if (MediumPrice[client])
- {
- SetHudTextParams(HudCoords1[HudMode[client]][0], HudCoords1[HudMode[client]][1], 1.0, 255, 0, 0, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD Medium rates name");
- SetHudTextParams(HudCoords2[HudMode[client]][0], HudCoords2[HudMode[client]][1], 1.0, 0, 162, 232, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD Medium rates pot", JackpotMediumPrice.Length, CurrencyString);
- SetHudTextParams(HudCoords3[HudMode[client]][0], HudCoords3[HudMode[client]][1], 1.0, 6, 231, 1, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD Medium rates placed", g_iSpend[client], CurrencyString, bmedium);
- SetHudTextParams(HudCoords4[HudMode[client]][0], HudCoords4[HudMode[client]][1], 1.0, 200, 255, 0, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD Medium rates player count", GetPlayerCount(false, true, false, false));
- if (gc_JackpotMode.IntValue == 1) {
- SetHudTextParams(HudCoords5[HudMode[client]][0], HudCoords5[HudMode[client]][1], 1.0, 20, 50, 255, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD Medium rates timeleft", MediumTime);
- }
- }
- else if (HighPrice[client])
- {
- SetHudTextParams(HudCoords1[HudMode[client]][0], HudCoords1[HudMode[client]][1], 1.0, 255, 0, 0, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD High rates name");
- SetHudTextParams(HudCoords2[HudMode[client]][0], HudCoords2[HudMode[client]][1], 1.0, 0, 162, 232, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD High rates pot", JackpotHighPrice.Length, CurrencyString);
- SetHudTextParams(HudCoords3[HudMode[client]][0], HudCoords3[HudMode[client]][1], 1.0, 6, 231, 1, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD High rates placed", g_iSpend[client], CurrencyString, bhigh);
- SetHudTextParams(HudCoords4[HudMode[client]][0], HudCoords4[HudMode[client]][1], 1.0, 200, 255, 0, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD High rates player count", GetPlayerCount(false, false, true, false));
- if (gc_JackpotMode.IntValue == 1) {
- SetHudTextParams(HudCoords5[HudMode[client]][0], HudCoords5[HudMode[client]][1], 1.0, 20, 50, 255, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD High rates timeleft", HighTime);
- }
- }
- else if (UnlimitedPrice[client])
- {
- SetHudTextParams(HudCoords1[HudMode[client]][0], HudCoords1[HudMode[client]][1], 1.0, 255, 0, 0, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD Unlimited rates name");
- SetHudTextParams(HudCoords2[HudMode[client]][0], HudCoords2[HudMode[client]][1], 1.0, 0, 162, 232, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD Unlimited rates pot", JackpotUnlimitedPrice.Length, CurrencyString);
- SetHudTextParams(HudCoords3[HudMode[client]][0], HudCoords3[HudMode[client]][1], 1.0, 6, 231, 1, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD Unlimited rates placed", g_iSpend[client], CurrencyString, bunlimited);
- SetHudTextParams(HudCoords4[HudMode[client]][0], HudCoords4[HudMode[client]][1], 1.0, 200, 255, 0, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD Unlimited rates player count", GetPlayerCount(false, false, false, true));
- if (gc_JackpotMode.IntValue == 1) {
- SetHudTextParams(HudCoords5[HudMode[client]][0], HudCoords5[HudMode[client]][1], 1.0, 20, 50, 255, 255, 0, 10.0, 0.0, 0.0);
- ShowHudText(client, -1, "%t", "HUD Unlimited rates timeleft", UnlimitedTime);
- }
- }
- else return Plugin_Stop;
- return Plugin_Continue;
- }
- public Action Timer_LowTime(Handle timer)
- {
- if (g_hLowTime == INVALID_HANDLE)return Plugin_Stop;
- if (gc_JackpotMode.IntValue != 1)return Plugin_Stop;
- LowTime--;
- if (LowTime == 0) {
- g_hLowTime = INVALID_HANDLE;
- ForceWinJackpot(JackpotLowPrice, true, false, false, false);
- }
- return Plugin_Continue;
- }
- public Action Timer_MediumTime(Handle timer)
- {
- if (g_hMediumTime == INVALID_HANDLE)return Plugin_Stop;
- if (gc_JackpotMode.IntValue != 1)return Plugin_Stop;
- MediumTime--;
- if (MediumTime == 0) {
- g_hMediumTime = INVALID_HANDLE;
- ForceWinJackpot(JackpotMediumPrice, false, true, false, false);
- }
- return Plugin_Continue;
- }
- public Action Timer_HighTime(Handle timer)
- {
- if (g_hHighTime == INVALID_HANDLE)return Plugin_Stop;
- if (gc_JackpotMode.IntValue != 1)return Plugin_Stop;
- HighTime--;
- if (HighTime == 0) {
- g_hHighTime = INVALID_HANDLE;
- ForceWinJackpot(JackpotHighPrice, false, false, true, false);
- }
- return Plugin_Continue;
- }
- public Action Timer_UnlimitedTime(Handle timer)
- {
- if (g_hUnlimitedTime == INVALID_HANDLE)return Plugin_Stop;
- if (gc_JackpotMode.IntValue != 1)return Plugin_Stop;
- UnlimitedTime--;
- if (UnlimitedTime == 0) {
- g_hUnlimitedTime = INVALID_HANDLE;
- ForceWinJackpot(JackpotUnlimitedPrice, false, false, false, true);
- }
- return Plugin_Continue;
- }
- void ForceWinJackpot(ArrayList Jackpot, bool low, bool medium, bool high, bool unlimited)
- {
- if (Jackpot.Length > 0)
- {
- int winner = Jackpot.Get(GetRandomInt(0, Jackpot.Length - 1));
- int winner_jackpot = GetClientOfUserId(winner);
- if (!IsValidPlayer(winner_jackpot))
- {
- CPrintToChatAll("\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Winner no found");
- for (int i = 0; i < Jackpot.Length; i++)
- {
- winner = Jackpot.Get(GetRandomInt(0, Jackpot.Length - 1));
- winner_jackpot = GetClientOfUserId(winner);
- if (IsValidPlayer(winner_jackpot))break;
- }
- }
- if (!IsValidPlayer(winner_jackpot)) {
- CPrintToChatAll("\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Nobody is winner", Jackpot.Length, CurrencyString);
- if (low)JackpotLowPrice.Clear();
- else if (medium)JackpotMediumPrice.Clear();
- else if (high)JackpotHighPrice.Clear();
- else if (unlimited)JackpotUnlimitedPrice.Clear();
- return;
- }
- AddMoney(winner_jackpot, Jackpot.Length);
- if (low)
- {
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsValidPlayer(i) && LowPrice[i])
- {
- g_Used[i] = false;
- LowPrice[i] = false;
- g_bLow[i] = false;
- g_iSpend[i] = 0;
- }
- }
- CPrintToChatAll("\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Low Price Winner", winner_jackpot, Jackpot.Length, CurrencyString);
- JackpotLowPrice.Clear();
- }
- else if (medium)
- {
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsValidPlayer(i) && MediumPrice[i])
- {
- g_Used[i] = false;
- MediumPrice[i] = false;
- g_bMedium[i] = false;
- g_iSpend[i] = 0;
- }
- }
- CPrintToChatAll("\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Medium Price Winner", winner_jackpot, Jackpot.Length, CurrencyString);
- JackpotMediumPrice.Clear();
- }
- else if (high)
- {
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsValidPlayer(i) && HighPrice[i])
- {
- g_Used[i] = false;
- HighPrice[i] = false;
- g_bHigh[i] = false;
- g_iSpend[i] = 0;
- }
- }
- CPrintToChatAll("\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "High Price Winner", winner_jackpot, Jackpot.Length, CurrencyString);
- JackpotHighPrice.Clear();
- }
- else if (unlimited)
- {
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsValidPlayer(i) && UnlimitedPrice[i])
- {
- g_Used[i] = false;
- UnlimitedPrice[i] = false;
- g_bUnlimited[i] = false;
- g_iSpend[i] = 0;
- }
- }
- CPrintToChatAll("\x01\x0B★ \x07[%s -> Jackpot]\x04 %t", MOD_TAG, "Unlimited Price Winner", winner_jackpot, Jackpot.Length, CurrencyString);
- JackpotUnlimitedPrice.Clear();
- }
- }
- }
- int GetPlayerCount(bool low, bool medium, bool high, bool unlimited)
- {
- int count;
- if (low) {
- for (int i = 1; i <= MaxClients; i++) {
- if (IsValidPlayer(i) && LowPrice[i])count++;
- }
- }
- else if (medium) {
- for (int i = 1; i <= MaxClients; i++) {
- if (IsValidPlayer(i) && MediumPrice[i])count++;
- }
- }
- else if (high) {
- for (int i = 1; i <= MaxClients; i++) {
- if (IsValidPlayer(i) && HighPrice[i])count++;
- }
- }
- else if (unlimited) {
- for (int i = 1; i <= MaxClients; i++) {
- if (IsValidPlayer(i) && UnlimitedPrice[i])count++;
- }
- }
- return count;
- }
- void NotifyServer()
- {
- if (g_bShopBrum)PrintToServer("Jackpot using dr_shop by Brum Brum");
- else if (g_bShopZephyrus)PrintToServer("Jackpot using Store by Zephyrus");
- else if (g_bShopFrozeDark)PrintToServer("Jackpot using Shop by FrozDark");
- else if (g_bShopYamakashi)PrintToServer("Jackpot using Credits by Yamakashi");
- else if (g_bShopGoMod)PrintToServer("Jackpot using Credits by GoMod");
- }
- void AddMoney(int client, int count)
- {
- if (!IsValidPlayer(client))return;
- if (!g_bShopBrum && !g_bShopZephyrus && !g_bShopFrozeDark && !g_bShopYamakashi && !g_bShopGoMod) {
- LogError("[ERROR] Jackpot cannot detect any shop [ERROR]");
- return;
- }
- if (g_bShopBrum)dr_AddMoney(client, count);
- else if (g_bShopZephyrus)Store_SetClientCredits(client, Store_GetClientCredits(client) + count);
- else if (g_bShopFrozeDark)Shop_SetClientCredits(client, Shop_GetClientCredits(client) + count);
- else if (g_bShopYamakashi)shop_add_credits(client, count);
- else if (g_bShopGoMod)GoMod_AddEuro(client, count);
- }
- int GetMoney(int client)
- {
- if (!IsValidPlayer(client))return -1;
- if (!g_bShopBrum && !g_bShopZephyrus && !g_bShopFrozeDark && !g_bShopYamakashi && !g_bShopGoMod) {
- LogError("[ERROR] Jackpot cannot detect any shop [ERROR]");
- return -1;
- }
- if (g_bShopBrum)return dr_GetMoneyAmount(client);
- else if (g_bShopZephyrus)return Store_GetClientCredits(client);
- else if (g_bShopFrozeDark)return Shop_GetClientCredits(client);
- else if (g_bShopYamakashi)return shop_get_credits(client);
- else if (g_bShopGoMod)return GoMod_GetEuro(client);
- return -1;
- }
- void RemoveMoney(int client, int count)
- {
- if (!IsValidPlayer(client))return;
- if (!g_bShopBrum && !g_bShopZephyrus && !g_bShopFrozeDark && !g_bShopYamakashi && !g_bShopGoMod) {
- LogError("[ERROR] Jackpot cannot detect any shop [ERROR]");
- return;
- }
- if (g_bShopBrum)dr_RemoveMoney(client, count);
- else if (g_bShopZephyrus)Store_SetClientCredits(client, Store_GetClientCredits(client) - count);
- else if (g_bShopFrozeDark)Shop_SetClientCredits(client, Shop_GetClientCredits(client) - count);
- else if (g_bShopYamakashi)shop_set_credits(client, shop_get_credits(client) - count);
- else if (g_bShopGoMod)GoMod_AddEuro(client, GoMod_GetEuro(client) - count);
- }
- public bool IsValidPlayer(int client)
- {
- if (!(1 <= client <= MaxClients) || !IsClientInGame(client) || !IsClientConnected(client) || IsFakeClient(client) || IsClientSourceTV(client))
- return false;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement