Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sdktools>
- #include <store>
- new bool:Low[66];
- new bool:Medium[66];
- new bool:High[66];
- new bool:Gamble[66];
- new bool:InsideLow[66];
- new bool:InsideMedium[66];
- new bool:InsideHigh[66];
- new Handle:g_hJackpotLow;
- new Handle:g_hJackpotMedium;
- new Handle:g_hJackpotHigh;
- new g_iSpendLow[66];
- new g_iSpendMedium[66];
- new g_iSpendHigh[66];
- public Plugin:myinfo =
- {
- name = "jackpot",
- description = "Gamble system for store!",
- author = "liljekvist",
- version = "1.2",
- url = ""
- };
- public void:OnPluginStart()
- {
- RegConsoleCmd("sm_gamble", OnGamble, "[Gamble] Enter the gambling area!", 0);
- RegConsoleCmd("sm_bet", OnBet, "[Gamble] Place a bet!", 0);
- RegConsoleCmd("sm_jackpot", OnJackpot, "[Gamble] Show current jackpots", 0);
- g_hJackpotLow = CreateArray(1, 0);
- g_hJackpotMedium = CreateArray(1, 0);
- g_hJackpotHigh = CreateArray(1, 0);
- return void:0;
- }
- public OnGambleMenu(client)
- {
- Gamble[client] = 1;
- new String:jackpot[128];
- new String:info[128];
- new String:playerbet[128];
- new potlow = GetArraySize(g_hJackpotLow);
- new potmedium = GetArraySize(g_hJackpotMedium);
- new pothigh = GetArraySize(g_hJackpotHigh);
- new CurrentCredits = Store_GetClientCredits(client);
- if (Low[client] >= true)
- {
- Format(info, 128, "This is (Low pot) area! Jackpot draw in: 30\n!bet <1-10.000> Credits: %d", CurrentCredits);
- if (InsideLow[client] >= true)
- {
- Format(playerbet, 128, "%N: %d (%.2f%%)", client, g_iSpendLow[client], float(g_iSpendLow[client]) / float(GetArraySize(g_hJackpotLow)) * 100.0);
- Format(jackpot, 128, "Jackpot: %d", potlow);
- }
- else
- {
- Format(jackpot, 128, "Currently no one betting in here!");
- }
- }
- else
- {
- if (Medium[client] >= true)
- {
- Format(info, 128, "This is (Medium pot) area! Jackpot draw in: 30\n!bet <1-100.000> Credits: %d", CurrentCredits);
- if (InsideMedium[client] >= true)
- {
- Format(playerbet, 128, "%N: %d (%.2f%%)", client, g_iSpendMedium[client], float(g_iSpendMedium[client]) / float(GetArraySize(g_hJackpotMedium)) * 100.0);
- Format(jackpot, 128, "Jackpot: %d", potmedium);
- }
- else
- {
- Format(jackpot, 128, "Currently no one betting in here!");
- }
- }
- if (High[client] >= true)
- {
- Format(info, 128, "This is (High pot) area! Jackpot draw in: 30\n!bet <1-1.000.000> Credits: %d", CurrentCredits);
- if (InsideHigh[client] >= true)
- {
- Format(playerbet, 128, "%N: %d (%.2f%%)", client, g_iSpendHigh[client], float(g_iSpendHigh[client]) / float(GetArraySize(g_hJackpotHigh)) * 100.0);
- Format(jackpot, 128, "Jackpot: %d", pothigh);
- }
- else
- {
- Format(jackpot, 128, "Currently no one betting in here!");
- }
- }
- Format(info, 128, "Welcome to gambling area! Select a pot to continue!");
- }
- new Handle:panel = CreatePanel(Handle:0);
- SetPanelTitle(panel, info, false);
- DrawPanelItem(panel, "Low pot - 2. Medium pot - 3. High pot", 0);
- DrawPanelItem(panel, "", 8);
- DrawPanelItem(panel, playerbet, 2);
- DrawPanelItem(panel, jackpot, 2);
- DrawPanelItem(panel, "", 8);
- SetPanelCurrentKey(panel, 8);
- DrawPanelItem(panel, "Leave gambling area\n ", 0);
- SetPanelCurrentKey(panel, 9);
- DrawPanelItem(panel, "Close", 0);
- SetPanelKeys(panel, 391);
- SendPanelToClient(panel, client, Gambles, 100000);
- return 0;
- }
- public Gambles(Handle:panel, MenuAction:action, client, param2)
- {
- if (action == MenuAction:4)
- {
- if (param2 == 1)
- {
- Low[client] = 1;
- Medium[client] = 0;
- High[client] = 0;
- OnGambleMenu(client);
- }
- if (param2 == 2)
- {
- Medium[client] = 1;
- High[client] = 0;
- Low[client] = 0;
- OnGambleMenu(client);
- }
- if (param2 == 3)
- {
- High[client] = 1;
- Medium[client] = 0;
- Low[client] = 0;
- OnGambleMenu(client);
- }
- if (param2 == 8)
- {
- CloseHandle(panel);
- PrintToChat(client, "%s You have left the gambling area!", " \x08[\x07Gamble\x08]");
- Gamble[client] = 0;
- High[client] = 0;
- Medium[client] = 0;
- Low[client] = 0;
- InsideHigh[client] = 0;
- InsideMedium[client] = 0;
- InsideLow[client] = 0;
- }
- if (param2 == 9)
- {
- CloseHandle(panel);
- PrintToChat(client, "%s You'r still inside Gambling area, type \x07!gamble\x08 to open the menu again or make a bet!", " \x08[\x07Gamble\x08]");
- }
- if (false <= Gamble[client])
- {
- return 0;
- }
- }
- return 0;
- }
- public Action:OnBet(client, args)
- {
- if (!(Gamble[client] >= true))
- {
- PrintToChat(client, "%s You need to enter the gambling area before you can make a bet!(\x07!gamble\x08)", " \x08[\x07Gamble\x08]");
- }
- new var1;
- if (args < 1 && Gamble[client] >= true)
- {
- PrintToChat(client, "%s Usage: \x07sm_bet\x08 <\x07amount\x08>", " \x08[\x07Gamble\x08]");
- return Action:0;
- }
- new String:arg1[16];
- GetCmdArg(1, arg1, 15);
- new arg1int = StringToInt(arg1, 10);
- new Credss = Store_GetClientCredits(client);
- if (Credss < arg1int)
- {
- PrintToChat(client, "%s Not enough credits! Current: \x07%d \x08credits", " \x08[\x07Gamble\x08]", Credss);
- return Action:0;
- }
- new String:buffer[32];
- GetCmdArg(1, buffer, 32);
- new credits = StringToInt(buffer, 10);
- new credits2 = Store_GetClientCredits(client);
- new var2;
- if (Low[client] >= true && Gamble[client] >= true)
- {
- if (credits < 1)
- {
- PrintToChat(client, "%s You have to spend atleast \x04%d\x08 credits.", " \x08[\x07Gamble\x08]", 1);
- return Action:0;
- }
- if (credits > 10000)
- {
- PrintToChat(client, "%s You can't spend that much credits (\x04Max: %d\x08).", " \x08[\x07Gamble\x08]", 10000);
- return Action:0;
- }
- if (Gamble[client] >= true)
- {
- CreateTimer(30.0, TimerLow, any:0, 0);
- OnGambleMenu(client);
- g_iSpendLow[client] = arg1int;
- Store_SetClientCredits(client, credits2 - arg1int);
- new i;
- while (i < arg1int)
- {
- PushArrayCell(g_hJackpotLow, client);
- i++;
- }
- new i = 1;
- while (i <= MaxClients)
- {
- if (Gamble[client] >= true)
- {
- new Handle:packlow = CreateDataPack();
- WritePackCell(packlow, client);
- WritePackCell(packlow, credits);
- }
- k++;
- }
- }
- new i = 1;
- while (i <= MaxClients)
- {
- if (Gamble[i] >= true)
- {
- OnGambleMenu(i);
- InsideLow[i] = 1;
- }
- i++;
- }
- PrintToChatAll("%s \x04%N\x08 has entered the (\x04Low pot\x08) with \x04%d\x08 credits!(\x08Chance: \x04%.2f%%% \x08Jackpot: \x04%d \x08credits)", " \x08[\x07Gamble\x08]", client, g_iSpendLow[client], float(g_iSpendLow[client]) / float(GetArraySize(g_hJackpotLow)) * 100.0, GetArraySize(g_hJackpotLow));
- OnGambleMenu(client);
- }
- new var3;
- if (Medium[client] >= true && Gamble[client] >= true)
- {
- if (credits < 1)
- {
- PrintToChat(client, "%s You have to spend atleast \x07%d\x08 credits.", " \x08[\x07Gamble\x08]", 1);
- return Action:0;
- }
- if (credits > 100000)
- {
- PrintToChat(client, "%s You can't spend that much credits (\x07Max: %d\x08).", " \x08[\x07Gamble\x08]", 100000);
- return Action:0;
- }
- if (Gamble[client] >= true)
- {
- CreateTimer(30.0, TimerMedium, any:0, 0);
- g_iSpendMedium[client] = arg1int;
- Store_SetClientCredits(client, credits2 - arg1int);
- new i;
- while (i < arg1int)
- {
- PushArrayCell(g_hJackpotMedium, client);
- i++;
- }
- new i = 1;
- while (i <= MaxClients)
- {
- if (Gamble[client] >= true)
- {
- new Handle:packmedium = CreateDataPack();
- WritePackCell(packmedium, client);
- WritePackCell(packmedium, credits);
- }
- i++;
- }
- }
- new i = 1;
- while (i <= MaxClients)
- {
- if (Gamble[i] >= true)
- {
- OnGambleMenu(i);
- InsideMedium[i] = 1;
- }
- i++;
- }
- PrintToChatAll("%s \x09%N\x08 has entered the (\x09Medium pot\x08) with \x09%d\x08 credits!(\x08Chance: \x09%.2f%%% \x08Jackpot: \x09%d \x08credits)", " \x08[\x07Gamble\x08]", client, g_iSpendMedium[client], float(g_iSpendMedium[client]) / float(GetArraySize(g_hJackpotMedium)) * 100.0, GetArraySize(g_hJackpotMedium));
- OnGambleMenu(client);
- }
- new var4;
- if (High[client] >= true && Gamble[client] >= true)
- {
- if (credits < 1)
- {
- PrintToChat(client, "%s You have to spend atleast \x07%d\x08 credits.", " \x08[\x07Gamble\x08]", 1);
- return Action:0;
- }
- if (credits > 1000000)
- {
- PrintToChat(client, "%s You can't spend that much credits (\x07Max: %d\x08).", " \x08[\x07Gamble\x08]", 1000000);
- return Action:0;
- }
- if (Gamble[client] >= true)
- {
- CreateTimer(30.0, TimerHigh, any:0, 0);
- g_iSpendHigh[client] = arg1int;
- Store_SetClientCredits(client, credits2 - arg1int);
- new i;
- while (i < arg1int)
- {
- PushArrayCell(g_hJackpotHigh, client);
- i++;
- }
- new i = 1;
- while (i <= MaxClients)
- {
- if (Gamble[client] >= true)
- {
- new Handle:packhigh = CreateDataPack();
- WritePackCell(packhigh, client);
- WritePackCell(packhigh, credits);
- }
- i++;
- }
- }
- new i = 1;
- while (i <= MaxClients)
- {
- if (Gamble[i] >= true)
- {
- OnGambleMenu(i);
- InsideHigh[i] = 1;
- }
- i++;
- }
- PrintToChatAll("%s \x07%N\x08 has entered the (\x07High pot\x08) with \x07%d\x08 credits!(\x08Chance: \x07%.2f%%% \x08Jackpot: \x07%d \x08credits)", " \x08[\x07Gamble\x08]", client, g_iSpendHigh[client], float(g_iSpendHigh[client]) / float(GetArraySize(g_hJackpotHigh)) * 100.0, GetArraySize(g_hJackpotHigh));
- OnGambleMenu(client);
- }
- return Action:0;
- }
- public Action:OnGamble(client, args)
- {
- if (Gamble[client] >= true)
- {
- OnGambleMenu(client);
- PrintToChat(client, "%s You have already entered the gambling area!", " \x08[\x07Gamble\x08]");
- return Action:0;
- }
- OnGambleMenu(client);
- PrintToChat(client, "%s You have entered the gambling area(\x07100%% at own risk!\x08)", " \x08[\x07Gamble\x08]");
- return Action:0;
- }
- public Action:TimerLow(Handle:timer)
- {
- new jackpot = GetArraySize(g_hJackpotLow);
- if (0 >= jackpot)
- {
- return Action:0;
- }
- new winner = GetArrayCell(g_hJackpotLow, GetRandomInt(0, jackpot + -1), 0, false);
- new ticket = GetRandomInt(12425, 192849);
- new var1;
- if (winner == -1 || !IsClientInGame(winner))
- {
- PrintToChatAll("%s Winner has left the game but won \x07%d\x08 credits on \x07low\x08 pot!", " \x08[\x07Gamble\x08]", jackpot);
- }
- else
- {
- PrintToChatAll("%s Jackpot (\x04Low pot\x08) winner: \x04%N\x08 (Ticket: \x04#%d\x08) (Chance: \x04%.2f%%\x08) Jackpot: \x04%d\x08 credits", " \x08[\x07Gamble\x08]", winner, ticket, float(g_iSpendLow[winner]) / float(GetArraySize(g_hJackpotLow)) * 100.0, jackpot);
- }
- IsClientInGame(winner);
- new creds = Store_GetClientCredits(winner);
- Store_SetClientCredits(winner, jackpot + creds);
- new i = 1;
- while (i <= MaxClients)
- {
- g_iSpendLow[i] = 0;
- InsideLow[i] = 0;
- if (Gamble[i] >= true)
- {
- OnGambleMenu(i);
- }
- i++;
- }
- ClearArray(g_hJackpotLow);
- return Action:0;
- }
- public Action:TimerMedium(Handle:timer)
- {
- new jackpot = GetArraySize(g_hJackpotMedium);
- if (0 >= jackpot)
- {
- return Action:0;
- }
- new winner = GetArrayCell(g_hJackpotMedium, GetRandomInt(0, jackpot + -1), 0, false);
- new ticket = GetRandomInt(12425, 192849);
- new var1;
- if (winner == -1 || !IsClientInGame(winner))
- {
- PrintToChatAll("%s Winner has left the game but won \x07%d\x08 credits on \x07medium\x08 pot!", " \x08[\x07Gamble\x08]", jackpot);
- }
- else
- {
- PrintToChatAll("%s Jackpot (\x09Medium pot\x08) winner: \x09%N\x08 (Ticket: \x09#%d\x08) (Chance: \x09%.2f%%\x08) Jackpot: \x09%d\x08", " \x08[\x07Gamble\x08]", winner, ticket, float(g_iSpendMedium[winner]) / float(GetArraySize(g_hJackpotMedium)) * 100.0, jackpot);
- }
- IsClientInGame(winner);
- new creds = Store_GetClientCredits(winner);
- Store_SetClientCredits(winner, jackpot + creds);
- new i = 1;
- while (i <= MaxClients)
- {
- g_iSpendMedium[i] = 0;
- InsideMedium[i] = 0;
- if (Gamble[i] >= true)
- {
- OnGambleMenu(i);
- }
- i++;
- }
- ClearArray(g_hJackpotMedium);
- return Action:0;
- }
- public Action:TimerHigh(Handle:timer)
- {
- new jackpot = GetArraySize(g_hJackpotHigh);
- if (0 >= jackpot)
- {
- return Action:0;
- }
- new winner = GetArrayCell(g_hJackpotHigh, GetRandomInt(0, jackpot + -1), 0, false);
- new ticket = GetRandomInt(12425, 192849);
- if (IsClientInGame(winner))
- {
- PrintToChatAll("%s Jackpot (\x07High pot\x08) winner: \x07%N\x08 (Ticket: \x07#%d\x08) (Chance: \x07%.2f%%\x08) \x08Jackpot: \x07%d\x08", " \x08[\x07Gamble\x08]", winner, ticket, float(g_iSpendHigh[winner]) / float(GetArraySize(g_hJackpotHigh)) * 100.0, jackpot);
- }
- else
- {
- PrintToChatAll("%s Winner has left the game, no one won the pot! Jackpot was: \x07%d\x08", " \x08[\x07Gamble\x08]", jackpot);
- }
- IsClientInGame(winner);
- new creds = Store_GetClientCredits(winner);
- Store_SetClientCredits(winner, jackpot + creds);
- new i = 1;
- while (i <= MaxClients)
- {
- g_iSpendHigh[i] = 0;
- InsideHigh[i] = 0;
- if (Gamble[i] >= true)
- {
- OnGambleMenu(i);
- }
- i++;
- }
- ClearArray(g_hJackpotHigh);
- return Action:0;
- }
- public Action:OnJackpot(client, args)
- {
- if (Gamble[client] >= true)
- {
- new LowPot = GetArraySize(g_hJackpotLow);
- new MediumPot = GetArraySize(g_hJackpotMedium);
- new HighPot = GetArraySize(g_hJackpotHigh);
- PrintToChat(client, "%s (\x04Low pot\x08) - \x04%d\x08 credits!", " \x08[\x07Gamble\x08]", LowPot);
- PrintToChat(client, "%s (\x09Medium pot\x08) - \x09%d\x08 credits!", " \x08[\x07Gamble\x08]", MediumPot);
- PrintToChat(client, "%s (\x07High pot\x08) - \x07%d\x08 credits!", " \x08[\x07Gamble\x08]", HighPot);
- }
- else
- {
- PrintToChat(client, "%s You need to enter the gambling area before you can see the jackpots!(\x07!gamble\x08)", " \x08[\x07Gamble\x08]");
- }
- return Action:3;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement