From 5d330921ba8074287fd4a70d91a2c22bee00db65 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Apr 2026 19:28:59 +0000 Subject: [PATCH 1/4] Initial plan From 2559ee94ce70a00afa2a150734d5b857b9fc9635 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Apr 2026 19:31:12 +0000 Subject: [PATCH 2/4] feat: reduce coinflip win odds to 35% and add max bet limit of 1000 Agent-Logs-Url: https://github.com/UDL-TF/HubCore/sessions/a84a9548-59c0-4ef9-bd87-850dabdf2d53 Co-authored-by: Tolfx <57797792+Tolfx@users.noreply.github.com> --- scripting/hub.sp | 2 ++ scripting/hub/credits.sp | 15 +++++++++++++-- scripting/include/hub-defines.inc | 1 + translations/hub.phrases.txt | 5 +++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/scripting/hub.sp b/scripting/hub.sp index 196a0a3..0703517 100644 --- a/scripting/hub.sp +++ b/scripting/hub.sp @@ -31,6 +31,8 @@ ConVar Hub_Credits_Minute; ConVar Hub_Credits_Amount; ConVar Hub_Credits_Coinflip_Multiplier; ConVar Hub_Credits_Coinflip_Cooldown; +ConVar Hub_Credits_Coinflip_Win_Chance; +ConVar Hub_Credits_Coinflip_Max_Bet; // Get credits when you kill someone, either enabled or not. // When a player gets killed we take their points ConVar Hub_Credits_Kill_For_Credits; diff --git a/scripting/hub/credits.sp b/scripting/hub/credits.sp index 67db2d3..a886e37 100644 --- a/scripting/hub/credits.sp +++ b/scripting/hub/credits.sp @@ -26,6 +26,8 @@ void CreditsOnStart() Hub_Credits_Amount = CreateConVar("hub_credits_amount", "20", "How many credits to give per minute."); Hub_Credits_Coinflip_Multiplier = CreateConVar("hub_credits_coinflip_multiplier", "1.1", "How much to multiply the coinflip amount by."); Hub_Credits_Coinflip_Cooldown = CreateConVar("hub_credits_coinflip_cooldown", "15", "Cooldown in seconds between coinflip uses."); + Hub_Credits_Coinflip_Win_Chance = CreateConVar("hub_credits_coinflip_win_chance", "35", "Win chance percentage for coinflip (1-99).", _, true, 1.0, true, 99.0); + Hub_Credits_Coinflip_Max_Bet = CreateConVar("hub_credits_coinflip_max_bet", "1000", "Maximum amount a player can bet in a single coinflip.", _, true, 1.0); Hub_Credits_Kill_For_Credits = CreateConVar("hub_credits_kill_for_credits", "1", "Get credits when you kill someone, either enabled or not.", _, true, 0.0, true, 1.0); Hub_Credits_Kill_For_Credits_Points = CreateConVar("hub_credits_kill_for_credits_points", "2", "How much points to give/extract when death."); Hub_Daily_Base_Credits = CreateConVar("hub_daily_base_credits", "100", "Base credits awarded for the daily reward."); @@ -113,10 +115,11 @@ public void DecideCoinflip(int client) char name[MAX_NAME_LENGTH]; GetClientName(client, name, sizeof(name)); - int random = GetRandomInt(0, 1); + int winChance = Hub_Credits_Coinflip_Win_Chance.IntValue; + int random = GetRandomInt(1, 100); float multiplier = Hub_Credits_Coinflip_Multiplier.FloatValue; - if (random == view_as(creditPlayers[client].currentCoinflip)) + if (random <= winChance) { int payout = RoundToCeil(amount * multiplier); Core_AddPlayerCredits(client, payout); @@ -175,6 +178,14 @@ public Action CommandCoinflip(int client, int args) int currentAmount = Core_GetPlayerCredits(client); int amount = GetCmdArgInt(1); + // Can't bet more than the maximum allowed + int maxBet = Hub_Credits_Coinflip_Max_Bet.IntValue; + if (amount > maxBet) + { + CPrintToChat(client, "%t", HUB_PHRASE_CREDITS_COINFLIP_MAX_BET, maxBet); + return Plugin_Handled; + } + // Can't bet more than you have if (amount > currentAmount) { diff --git a/scripting/include/hub-defines.inc b/scripting/include/hub-defines.inc index a1336d8..78d6e8a 100644 --- a/scripting/include/hub-defines.inc +++ b/scripting/include/hub-defines.inc @@ -13,6 +13,7 @@ // Credit phrases #define HUB_PHRASE_PLAYER_CREDITS "Hub_Player_Credits" +#define HUB_PHRASE_CREDITS_COINFLIP_MAX_BET "Hub_Credits_Coinflip_Max_Bet" #define HUB_PHRASE_CREDITS_COINFLIP_USAGE "Hub_Credits_Coinflip_Usage" #define HUB_PHRASE_CREDITS_COINFLIP_NOT_ENOUGH_CREDITS "Hub_Credits_Coinflip_Not_Enough_Credits" #define HUB_PHRASE_CREDITS_COINFLIP_COOLDOWN "Hub_Credits_Coinflip_Cooldown" diff --git a/translations/hub.phrases.txt b/translations/hub.phrases.txt index d96ad54..972f3cc 100644 --- a/translations/hub.phrases.txt +++ b/translations/hub.phrases.txt @@ -15,6 +15,11 @@ { "en" "[{#95F3E3}H{#08C4CD}U{#27939D}B{#ffffff}] Usage: !coinflip " } + "Hub_Credits_Coinflip_Max_Bet" + { + "#format" "{1:i}" + "en" "[{#95F3E3}H{#08C4CD}U{#27939D}B{#ffffff}] You cannot bet more than {1} credits." + } "Hub_Credits_Coinflip_Not_Enough_Credits" { "en" "[{#95F3E3}H{#08C4CD}U{#27939D}B{#ffffff}] You do not have enough credits to do that." From 650c7e7f4ddcc466f1eaecdc74289e8c15cd5a3e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Apr 2026 19:32:33 +0000 Subject: [PATCH 3/4] refactor: remove heads/tails menu, resolve coinflip immediately on command Agent-Logs-Url: https://github.com/UDL-TF/HubCore/sessions/a84a9548-59c0-4ef9-bd87-850dabdf2d53 Co-authored-by: Tolfx <57797792+Tolfx@users.noreply.github.com> --- scripting/hub/credits.sp | 55 +--------------------------------------- 1 file changed, 1 insertion(+), 54 deletions(-) diff --git a/scripting/hub/credits.sp b/scripting/hub/credits.sp index a886e37..865f5a7 100644 --- a/scripting/hub/credits.sp +++ b/scripting/hub/credits.sp @@ -1,13 +1,6 @@ -enum Coinflip -{ - COINFLIP_HEAD, - COINFLIP_TAIL -} - enum struct CreditPlayers { Handle currentCreditsPerMinute; - Coinflip currentCoinflip; int currentCoinflipAmount; float coinflipLastUsed; } @@ -139,7 +132,6 @@ public void DecideCoinflip(int client) CPrintToChatAll("%t", HUB_PHRASE_CREDITS_COINFLIP_LOSE, amount, name); } - creditPlayers[client].currentCoinflip = view_as(INVALID_HANDLE); creditPlayers[client].currentCoinflipAmount = view_as(INVALID_HANDLE); } @@ -196,7 +188,7 @@ public Action CommandCoinflip(int client, int args) creditPlayers[client].currentCoinflipAmount = amount; creditPlayers[client].coinflipLastUsed = GetGameTime(); - DisplayCoinflipMenu(client); + DecideCoinflip(client); return Plugin_Handled; } @@ -239,51 +231,6 @@ public void CreditsOnPlayerDeath(Event hEvent, char[] strEventName, bool bDontBr } } -/* Menus */ -void DisplayCoinflipMenu(int client) -{ - Menu hMenu = new Menu(CoinflipMenuHandler); - - hMenu.SetTitle("Coinflip"); - hMenu.AddItem("0", "Heads", ITEMDRAW_DEFAULT); - hMenu.AddItem("1", "Tails", ITEMDRAW_DEFAULT); - - hMenu.ExitButton = true; - - hMenu.Display(client, MENU_TIME_FOREVER); -} - -public int CoinflipMenuHandler(Menu menu, MenuAction menuActions, int param1, int param2) -{ - switch (menuActions) - { - case MenuAction_Select: - { - char strOption[8]; - menu.GetItem(param2, strOption, sizeof(strOption)); - - int iOption = StringToInt(strOption); - - switch (iOption) - { - case 0: - { - creditPlayers[param1].currentCoinflip = COINFLIP_HEAD; - DecideCoinflip(param1); - } - - case 1: - { - creditPlayers[param1].currentCoinflip = COINFLIP_TAIL; - DecideCoinflip(param1); - } - } - } - } - - return 1; -} - /* Daily reward */ public Action CommandDaily(int client, int args) { From 5ce7670ce3d6464b658e6d6d8a288a8e34f9b17d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Apr 2026 19:33:18 +0000 Subject: [PATCH 4/4] fix: correct random range and coinflipAmount reset value Agent-Logs-Url: https://github.com/UDL-TF/HubCore/sessions/a84a9548-59c0-4ef9-bd87-850dabdf2d53 Co-authored-by: Tolfx <57797792+Tolfx@users.noreply.github.com> --- scripting/hub/credits.sp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripting/hub/credits.sp b/scripting/hub/credits.sp index 865f5a7..b33195b 100644 --- a/scripting/hub/credits.sp +++ b/scripting/hub/credits.sp @@ -109,10 +109,10 @@ public void DecideCoinflip(int client) char name[MAX_NAME_LENGTH]; GetClientName(client, name, sizeof(name)); int winChance = Hub_Credits_Coinflip_Win_Chance.IntValue; - int random = GetRandomInt(1, 100); + int random = GetRandomInt(0, 99); float multiplier = Hub_Credits_Coinflip_Multiplier.FloatValue; - if (random <= winChance) + if (random < winChance) { int payout = RoundToCeil(amount * multiplier); Core_AddPlayerCredits(client, payout); @@ -132,7 +132,7 @@ public void DecideCoinflip(int client) CPrintToChatAll("%t", HUB_PHRASE_CREDITS_COINFLIP_LOSE, amount, name); } - creditPlayers[client].currentCoinflipAmount = view_as(INVALID_HANDLE); + creditPlayers[client].currentCoinflipAmount = 0; } /* Commands */