C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Oxide.Core;
using Oxide.Core.Configuration;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Lottery", "Sami37", "1.2.5", ResourceId = 2145)]
internal class Lottery : RustPlugin
{
#region Economy Support
[PluginReference("Economics")]
Plugin Economy;
#endregion
#region serverreward
[PluginReference("ServerRewards")]
Plugin ServerRewards;
#endregion
#region humanNPC
[PluginReference("HumanNPC")]
Plugin HumanNPC;
#endregion
#region generalClass/function
internal class playerinfo
{
public int multiplicator { get; set; } = 1;
public double currentbet { get; set; }
public double totalbet { get; set; }
}
int[] GetIntArray(int num)
{
List<int> listOfInts = new List<int>();
while(num > 0)
{
listOfInts.Add(num % 10);
num = num / 10;
}
listOfInts.Reverse();
return listOfInts.ToArray();
}
private object DoRay(Vector3 Pos, Vector3 Aim)
{
var hits = Physics.RaycastAll(Pos, Aim);
float distance = 3f;
object target = false;
foreach (var hit in hits)
{
if (hit.distance < distance)
{
distance = hit.distance;
target = hit.GetEntity();
}
}
return target;
}
#endregion
#region general_variable
private bool newConfig, UseSR, UseNPC, AutoCloseAfterPlaceingBet;
public Dictionary<ulong, playerinfo> Currentbet = new Dictionary<ulong, playerinfo>();
private string container, containerwin, BackgroundUrl, BackgroundColor, WinBackgroundUrl, WinBackgroundColor, anchorMin, anchorMax;
private DynamicConfigFile data;
private List<object> NPCID = new List<object>();
private double jackpot, SRMinBet, SRjackpot, MinBetjackpot, MinBetjackpotEco;
private int JackpotNumber, SRJackpotNumber, DefaultMaxRange, DefaultMinRange;
public Dictionary<string, object> IndividualRates { get; private set; }
public Dictionary<string, int> SRRates { get; private set; }
private Dictionary<string, object> DefaultWinRates = null;
private Dictionary<string, object> SRWinRates = null;
private List<object> DefaultBasePoint = null;
private FieldInfo serverinput;
private Vector3 eyesAdjust;
private string MainContainer = "MainContainer";
#endregion
#region config
private T GetConfigValue<T>(string category, string setting, T defaultValue)
{
var data = Config[category] as Dictionary<string, object>;
object value;
if (data == null)
{
data = new Dictionary<string, object>();
Config[category] = data;
newConfig = true;
}
if (data.TryGetValue(setting, out value)) return (T)Convert.ChangeType(value, typeof(T));
value = defaultValue;
data[setting] = value;
newConfig = true;
return (T)Convert.ChangeType(value, typeof(T));
}
private void SetConfigValue<T>(string category, string setting, T newValue)
{
var data = Config[category] as Dictionary<string, object>;
object value;
if (data != null && data.TryGetValue(setting, out value))
{
value = newValue;
data[setting] = value;
newConfig = true;
}
SaveConfig();
}
protected override void LoadDefaultConfig()
{
Config.Clear();
LoadConfig();
}
void LoadConfig()
{
jackpot = GetConfigValue("Global", "Jackpot", 50000);
DefaultWinRates = GetConfigValue("Global", "WinRate", DefaultPay());
DefaultBasePoint = GetConfigValue("ServerRewards", "Match", DefaultSRPay());
SRWinRates = GetConfigValue("ServerRewards", "WinPoint", DefautSRWinPay());
SRjackpot = GetConfigValue("ServerRewards", "Jackpot", 10);
SRMinBet = GetConfigValue("ServerRewards", "MinBet", 1000);
MinBetjackpot = GetConfigValue("ServerRewards", "MinBetJackpot", 100000);
MinBetjackpotEco = GetConfigValue("Global", "MinBetJackpot", 100000);
SRJackpotNumber = GetConfigValue("ServerRewards", "JackpotMatch", 1869);
JackpotNumber = GetConfigValue("Global", "JackpotMatch", 1058);
DefaultMinRange = GetConfigValue("Global", "RollMinRange", 1000);
DefaultMaxRange = GetConfigValue("Global", "RollMaxRange", 9999);
UseSR = GetConfigValue("ServerRewards", "Enabled", false);
AutoCloseAfterPlaceingBet = GetConfigValue("Global", "Place Bet Auto-close", false);
UseNPC = GetConfigValue("HumanNPC", "Enabled", false);
NPCID = GetConfigValue("HumanNPC", "npcID", new List<object>());
BackgroundUrl = GetConfigValue("UI", "BackgroundMainURL",
"http://wac.450f.edgecastcdn.net/80450F/kool1079.com/files/2016/05/RS2397_126989085.jpg");
BackgroundColor = GetConfigValue("UI", "BackgroundMainColor",
"0.1 0.1 0.1 1");
WinBackgroundUrl = GetConfigValue("UI", "BackgroundWinURL",
"http://wac.450f.edgecastcdn.net/80450F/kool1079.com/files/2016/05/RS2397_126989085.jpg");
WinBackgroundColor = GetConfigValue("UI", "BackgroundWinColor",
"0.1 0.1 0.1 1");
anchorMin = GetConfigValue("CUI", "anchorMin", "0.8 0.2");
anchorMax = GetConfigValue("CUI", "anchorMax", "1 0.8");
if (!newConfig) return;
SaveConfig();
newConfig = false;
}
static Dictionary<string, object> DefaultPay()
{
var d = new Dictionary<string, object>
{
{ "111x", 1 },
{ "222x", 10 },
{ "333x", 50 },
{ "444x", 10 },
{ "555x", 75 },
{ "666x", 5 },
{ "777x", 75 },
{ "888x", 56 },
{ "999x", 42 },
{ "99x9", 52 },
{ "9x99", 57 },
{ "x999", 85 },
{ "99xx", 86 },
{ "9xxx", 86 }
};
return d;
}
static List<object> DefaultSRPay()
{
var d = new List<object>
{
"111x",
"222x",
"333x",
"444x",
"555x",
"666x",
"777x",
"888x",
"999x",
"99x9",
"9x99",
"x999",
"99xx",
"9xxx"
};
return d;
}
static Dictionary<string, object> DefautSRWinPay()
{
var d = new Dictionary<string, object>
{
{ "Match1Number", 1 },
{ "Match2Number", 2 },
{ "Match3Number", 3 },
{ "Match4Number", 4 }
};
return d;
}
#endregion
#region data_init
void LoadDefaultMessages()
{
var messages = new Dictionary<string, string>
{
{"NoPerm", "You don't have permission to do it."},
{"NoWin", "You roll {0} but don't win anything."},
{"NoPoint", "You don't have any point to use."},
{"NoEconomy", "Economics isn't installed."},
{"NoServerRewards", "Server Rewards isn't installed."},
{"NotEnoughMoney", "You don't have enough money."},
{"AddedNPC", "You successfully added the npc to the usable list."},
{"NotInList", "The npc you are looking is not in the list."},
{"RemovedNPC", "You successfully removed the npc to the usable list."},
{"Win", "You roll {0} and won {1}$"},
{"WinPoints", "You roll {0} and won {1} point(s)"},
{"NoBet", "You must bet before."},
{"NPCOnly", "You must find the NPC to use the lottery."},
{"Balance", "Your current balance is {0}$"},
{"BalanceSR", "Your current balance is {0} point(s)"},
{"CurrentBet", "Your current bet is {0}$"},
{"CurrentBetSR", "Your current bet is {0} point(s)"},
{"Roll", "Roll {0} to win \nthe current jackpot:\n {1}$"},
{"Jackpot", "You roll {0} and won the jackpot : {1}$ !!!!!!"},
{"MiniSRBet", "You need to bet more to place bet.(Min: {0})"},
{"BetMore", "If you had bet more you could win the jackpot.(Min: {0})"},
{"MinimumSRBet", "Minimum bet of {0} to win the current jackpot: {1} point(s)"},
{"CantOpen", "You must have Economics or ServerRewards installed and loaded."},
{"WinRateText", "Win rate"},
{"PointsText", "{0} : {1} point(s)"},
{"MultiplierText", "Multiplier : x{0}"},
{"BetmodifiersText", "Bet modifiers :"}
};
lang.RegisterMessages(messages, this);
Puts("Messages loaded...");
}
void OnServerInitialized() {
LoadConfig();
LoadDefaultMessages();
permission.RegisterPermission("Lottery.canuse", this);
permission.RegisterPermission("Lottery.canconfig", this);
if (DefaultWinRates != null)
{
IndividualRates = new Dictionary<string, object>();
foreach (var entry in DefaultWinRates)
{
int rate;
if (!int.TryParse(entry.Value.ToString(), out rate)) continue;
IndividualRates.Add(entry.Key, rate);
}
}
if (SRWinRates != null)
{
var serverRewardsDict = SRWinRates;
SRRates = new Dictionary<string, int>();
if (serverRewardsDict != null)
{
foreach (var entry in serverRewardsDict)
{
int rate;
if (!int.TryParse(entry.Value.ToString(), out rate)) continue;
SRRates.Add(entry.Key, rate);
}
}
}
data = Interface.Oxide.DataFileSystem.GetFile(Name);
try
{
Currentbet = data.ReadObject<Dictionary<ulong, playerinfo>>();
}
catch (Exception e)
{
Currentbet = new Dictionary<ulong, playerinfo>();
Puts(e.Message);
}
data.WriteObject(Currentbet);
serverinput = typeof(BasePlayer).GetField("serverInput", (BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic));
eyesAdjust = new Vector3(0f, 1.5f, 0f);
}
void Unload()
{
foreach (var player in BasePlayer.activePlayerList)
{
GUIDestroy(player);
GUIDestroy(player);
}
Puts("Data saved.");
if(Currentbet != null)
SaveData(Currentbet);
}
#endregion
#region save_data
void SaveData(Dictionary<ulong, playerinfo> datas)
{
data.WriteObject(datas);
}
#endregion
#region Lotery
private CuiElement CreateImage(string panelName, bool win = false)
{
var element = new CuiElement();
var url = !win ? BackgroundUrl : WinBackgroundUrl;
var color = !win ? BackgroundColor : WinBackgroundColor;
var image = new CuiRawImageComponent
{
Url = url,
Color = color
};
var rectTransform = new CuiRectTransformComponent
{
AnchorMin = "0 0",
AnchorMax = "1 1"
};
element.Components.Add(image);
element.Components.Add(rectTransform);
element.Name = CuiHelper.GetGuid();
element.Parent = panelName;
return element;
}
void RefreshUI(BasePlayer player, string[] args)
{
CuiHelper.DestroyUi(player, "containerLotery");
CuiHelper.DestroyUi(player, "containerwinLotery");
CuiHelper.DestroyUi(player, "ButtonBackLotery");
CuiHelper.DestroyUi(player, "ButtonForwardLotery");
if(Economy != null && Economy.IsLoaded && !UseSR)
ShowLotery(player, args);
else if(ServerRewards != null && ServerRewards.IsLoaded)
ShowSrLotery(player, args);
}
void GUIDestroy(BasePlayer player)
{
CuiHelper.DestroyUi(player, "MainContainer");
CuiHelper.DestroyUi(player, "containerLotery");
CuiHelper.DestroyUi(player, "containerwinLotery");
CuiHelper.DestroyUi(player, "ButtonBackLotery");
CuiHelper.DestroyUi(player, "ButtonForwardLotery");
}
void ShowLotery(BasePlayer player, string[] args)
{
if (Economy == null || !Economy.IsLoaded)
{
SendReply(player, lang.GetMessage("NoEconomy", this, player.UserIDString));
return;
}
int from = 0;
var currentBalance = Economy.Call("Balance", player.UserIDString);
playerinfo playerbet;
if(Currentbet == null)
Currentbet = new Dictionary<ulong, playerinfo>();
if (Currentbet.ContainsKey(player.userID))
{
Currentbet.TryGetValue(player.userID, out playerbet);
}
else
{
Currentbet.Add(player.userID, new playerinfo());
}
playerbet = Currentbet[player.userID];
if (args != null && args.Length > 0 && playerbet != null)
{
if (args[0].Contains("less") || args[0].Contains("plus"))
{
if (args[0].Contains("plus"))
{
if ((double)currentBalance >= playerbet.currentbet*(playerbet.multiplicator + 1))
{
int multiplier;
int.TryParse(args[1], out multiplier);
playerbet.multiplicator += multiplier;
}
}
if (args[0].Contains("less"))
{
if (playerbet.multiplicator > 1)
playerbet.multiplicator -= 1;
}
}
if (args[0].Contains("bet"))
{
int bet;
int.TryParse(args[1], out bet);
if((double)currentBalance < (playerbet.currentbet+bet)*playerbet.multiplicator)
SendReply(player, lang.GetMessage("NotEnoughMoney", this, player.UserIDString));
else
playerbet.currentbet += bet;
}
if (args[0].Contains("page"))
{
int.TryParse(args[1], out from);
}
}
int i = 0;
double jackpots = Math.Round(Currentbet.Sum(v => v.Value.totalbet));
jackpots += jackpot;
var win = new CuiElementContainer();
var containerwin = win.Add(new CuiPanel
{
Image =
{
Color = WinBackgroundColor
},
RectTransform =
{
AnchorMin = anchorMin,
AnchorMax = anchorMax
},
CursorEnabled = true
}, "Hud", "containerwinLotery");
win.Add(new CuiLabel
{
Text =
{
Text = lang.GetMessage("WinRateText", this, player.UserIDString),
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.1 0.85",
AnchorMax = "0.9 1"
}
}, containerwin);
var backgroundImageWin = CreateImage("containerwinLotery", true);
win.Add(backgroundImageWin);
foreach (var elem in IndividualRates)
{
if (i == 0)
{
var pos = 0.81 - (i - from)/10.0;
var pos2 = 0.86 - (i - from)/20.0;
win.Add(new CuiLabel
{
Text =
{
Text = elem.Key + ": " + elem.Value + " %",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = $"{0.1} {pos}",
AnchorMax = $"{0.9} {pos2}"
}
}, containerwin);
}
else if (i >= from && i < from + 9)
{
var pos = 0.81 - (i - from)/10.0;
var pos2 = 0.86 - (i - from)/20.0;
win.Add(new CuiLabel
{
Text =
{
Text = elem.Key + ": " + elem.Value + " %",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = $"{0.1} {pos}",
AnchorMax = $"{0.9} {pos2}"
}
}, containerwin);
}
i++;
}
var minfrom = from <= 10 ? 0 : from - 10;
var maxfrom = from + 10 >= i ? from : from + 10;
win.AddRange(ChangeBonusPage(minfrom, maxfrom));
var elements = new CuiElementContainer();
#region background
var container = elements.Add(new CuiPanel
{
Image =
{
Color = BackgroundColor
},
RectTransform =
{
AnchorMin = "0 0.2",
AnchorMax = "0.8 0.8"
},
CursorEnabled = true
}, "Hud", "containerLotery");
var backgroundImage = CreateImage("containerLotery");
elements.Add(backgroundImage);
#endregion
#region closebutton
var closeButton = new CuiButton
{
Button =
{
Command = "cmdDestroyUI",
Close = container,
Color = "0.8 0.8 0.8 0.2"
},
RectTransform =
{
AnchorMin = "0.86 0.92",
AnchorMax = "0.97 0.98"
},
Text =
{
Text = "X",
FontSize = 22,
Align = TextAnchor.MiddleCenter
}
};
elements.Add(closeButton, container);
#endregion
#region currency
elements.Add(new CuiLabel
{
Text =
{
Text = string.Format(lang.GetMessage("Balance", this, player.UserIDString), currentBalance),
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.1 0.91",
AnchorMax = "0.9 0.98"
}
}, container);
#endregion
#region multiplier
if (playerbet != null)
{
elements.Add(new CuiLabel
{
Text =
{
Text = "Multiplier : x" + playerbet.multiplicator,
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.05 0.81",
AnchorMax = "0.15 0.88"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdLess Eco",
Close = container,
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "-",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.2 0.81",
AnchorMax = "0.3 0.88"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdPlus Eco",
Close = container,
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "+",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.31 0.81",
AnchorMax = "0.41 0.88"
}
}, container);
#endregion
#region bet
elements.Add(new CuiLabel
{
Text =
{
Text = "Bet modifiers :",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.05 0.61",
AnchorMax = "0.15 0.68"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdBet 1 Eco",
Close = container,
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "+1",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.05 0.51",
AnchorMax = "0.15 0.58"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdBet 5 Eco",
Close = container,
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "+5",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.155 0.51",
AnchorMax = "0.255 0.58"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdBet 10 Eco",
Close = container,
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "+10",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.26 0.51",
AnchorMax = "0.36 0.58"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdBet 100 Eco",
Close = container,
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "+100",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.365 0.51",
AnchorMax = "0.485 0.58"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdBet 1000 Eco",
Close = container,
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "+1000",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.05 0.41",
AnchorMax = "0.15 0.48"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdBet 10000 Eco",
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "+10000",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.155 0.41",
AnchorMax = "0.255 0.48"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdPlaceBet Eco",
Close = container,
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "Place Bet",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.05 0.31",
AnchorMax = "0.255 0.38"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdResetBet lot",
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "Reset Bet",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.05 0.21",
AnchorMax = "0.255 0.28"
}
}, container);
#endregion
#region winpart
elements.Add(new CuiLabel
{
Text =
{
Text = string.Format(lang.GetMessage("CurrentBet", this, player.UserIDString), playerbet.currentbet*playerbet.multiplicator),
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.71 0.71",
AnchorMax = "0.99 0.81"
}
}, container);
elements.Add(new CuiLabel
{
Text =
{
Text = string.Format(lang.GetMessage("Roll", this, player.UserIDString), JackpotNumber, jackpots),
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.71 0.39",
AnchorMax = "0.99 0.59"
}
}, container);
}
#endregion
CuiHelper.AddUi(player, elements);
CuiHelper.AddUi(player, win);
Currentbet.Remove(player.userID);
Currentbet.Add(player.userID, playerbet);
SaveData(Currentbet);
}
void ShowSrLotery(BasePlayer player, string[] args)
{
if (ServerRewards == null || !ServerRewards.IsLoaded)
{
SendReply(player, lang.GetMessage("NoServerRewards", this, player.UserIDString));
return;
}
int from = 0;
var currentBalance = ServerRewards.Call("CheckPoints", player.userID);
if (currentBalance != null)
{
playerinfo playerbet;
if (Currentbet.ContainsKey(player.userID))
{
Currentbet.TryGetValue(player.userID, out playerbet);
}
else
{
Currentbet.Add(player.userID, new playerinfo());
Currentbet.TryGetValue(player.userID, out playerbet);
}
playerbet = Currentbet[player.userID];
if (playerbet != null && args != null && args.Length > 0)
{
if (args[0].Contains("less") || args[0].Contains("plus"))
{
if (args[0].Contains("plus"))
{
if ((int) currentBalance >= playerbet.currentbet*(playerbet.multiplicator + 1))
{
int multiplier;
int.TryParse(args[1], out multiplier);
playerbet.multiplicator += multiplier;
}
}
if (args[0].Contains("less"))
{
if (playerbet.multiplicator > 1)
playerbet.multiplicator -= 1;
}
}
if (args[0].Contains("bet"))
{
int bet;
int.TryParse(args[1], out bet);
if ((int) currentBalance < (playerbet.currentbet + bet)*playerbet.multiplicator)
SendReply(player, lang.GetMessage("NotEnoughMoney", this, player.UserIDString));
else playerbet.currentbet += bet;
}
if (args[0].Contains("page"))
{
int.TryParse(args[1], out @from);
}
}
var i = 0;
double jackpots = Math.Round(Currentbet.Sum(v => v.Value.totalbet));
jackpots += jackpot;
var win = new CuiElementContainer();
var containerwinlocal = win.Add(new CuiPanel
{
Image =
{
Color = WinBackgroundColor
},
RectTransform =
{
AnchorMin = anchorMin,
AnchorMax = anchorMax
},
CursorEnabled = true
}, "Hud", "containerwinLotery");
win.Add(new CuiLabel
{
Text =
{
Text = lang.GetMessage("WinRateText", this, player.UserIDString),
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.1 0.85",
AnchorMax = "0.9 1"
}
}, containerwinlocal);
var backgroundImageWin = CreateImage("containerwinLotery", true);
win.Add(backgroundImageWin);
foreach (var elem in SRRates)
{
var pos = 0.86 - (i - @from)/10.0;
var pos2 = 0.91 - (i - @from)/20.0;
win.Add(new CuiLabel
{
Text =
{
Text = lang.GetMessage("PointsText", this, player.UserIDString).Replace("{0}", elem.Key).Replace("{1}", elem.Value.ToString()),
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = $"{0.1} {pos}",
AnchorMax = $"{0.9} {pos2}"
}
}, containerwinlocal);
i++;
}
var elements = new CuiElementContainer();
#region background
var container = elements.Add(new CuiPanel
{
Image =
{
Color = BackgroundColor
},
RectTransform =
{
AnchorMin = "0 0.2",
AnchorMax = "0.8 0.8"
},
CursorEnabled = true
}, "Hud", "containerLotery");
var backgroundImage = CreateImage("containerLotery");
elements.Add(backgroundImage);
#endregion
#region closebutton
var closeButton = new CuiButton
{
Button =
{
Command = "cmdDestroyUI",
Close = container,
Color = "0.8 0.8 0.8 0.2"
},
RectTransform =
{
AnchorMin = "0.86 0.92",
AnchorMax = "0.97 0.98"
},
Text =
{
Text = "X",
FontSize = 22,
Align = TextAnchor.MiddleCenter
}
};
elements.Add(closeButton, container);
#endregion
#region currency
elements.Add(new CuiLabel
{
Text =
{
Text = string.Format(lang.GetMessage("BalanceSR", this, player.UserIDString), currentBalance),
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.1 0.91",
AnchorMax = "0.9 0.98"
}
}, container);
#endregion
#region multiplier
elements.Add(new CuiLabel
{
Text =
{
Text = lang.GetMessage("MultiplierText", this, player.UserIDString).Replace("{0}", playerbet.multiplicator.ToString()),
FontSize = 18,
Align = TextAnchor.MiddleLeft
},
RectTransform =
{
AnchorMin = "0.05 0.81",
AnchorMax = "0.30 0.88"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdLess",
Close = container,
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "-",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.2 0.81",
AnchorMax = "0.3 0.88"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdPlus",
Close = container,
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "+",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.31 0.81",
AnchorMax = "0.41 0.88"
}
}, container);
#endregion
#region bet
elements.Add(new CuiLabel
{
Text =
{
Text = lang.GetMessage("BetmodifiersText", this, player.UserIDString),
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.05 0.61",
AnchorMax = "0.15 0.68"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdBet 1",
Close = container,
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "+1",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.05 0.51",
AnchorMax = "0.15 0.58"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdBet 5",
Close = container,
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "+5",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.155 0.51",
AnchorMax = "0.255 0.58"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdBet 10",
Close = container,
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "+10",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.26 0.51",
AnchorMax = "0.36 0.58"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdBet 100",
Close = container,
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "+100",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.365 0.51",
AnchorMax = "0.485 0.58"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdBet 1000",
Close = container,
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "+1000",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.05 0.41",
AnchorMax = "0.15 0.48"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdBet 10000",
Close = container,
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "+10000",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.155 0.41",
AnchorMax = "0.255 0.48"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdPlaceBet",
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "Place Bet",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.05 0.31",
AnchorMax = "0.255 0.38"
}
}, container);
elements.Add(new CuiButton
{
Button =
{
Command = "cmdResetBet",
Color = "0.8 0.8 0.8 0.2"
},
Text =
{
Text = "Reset Bet",
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.05 0.21",
AnchorMax = "0.255 0.28"
}
}, container);
#endregion
#region winpart
elements.Add(new CuiLabel
{
Text =
{
Text = string.Format(lang.GetMessage("CurrentBetSR", this, player.UserIDString), playerbet.currentbet*playerbet.multiplicator),
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.71 0.71",
AnchorMax = "0.99 0.81"
}
}, container);
if (UseSR && ServerRewards.IsLoaded)
{
var mini = string.Format(lang.GetMessage("MinimumSRBet", this, player.UserIDString), MinBetjackpot, SRjackpot);
elements.Add(new CuiLabel
{
Text =
{
Text = mini,
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.71 0.39",
AnchorMax = "0.99 0.59"
}
}, container);
}
else
{
elements.Add(new CuiLabel
{
Text =
{
Text = string.Format(lang.GetMessage("Roll", this, player.UserIDString), JackpotNumber, jackpots),
FontSize = 18,
Align = TextAnchor.MiddleCenter
},
RectTransform =
{
AnchorMin = "0.71 0.39",
AnchorMax = "0.99 0.59"
}
}, container);
}
#endregion
CuiHelper.AddUi(player, elements);
CuiHelper.AddUi(player, win);
Currentbet.Remove(player.userID);
Currentbet.Add(player.userID, playerbet);
}
else
SendReply(player, lang.GetMessage("NoPoint", this, player.UserIDString));
SaveData(Currentbet);
}
private static CuiElementContainer ChangeBonusPage(int pageless, int pagemore)
{
return new CuiElementContainer
{
{
new CuiButton
{
Button = {Command = $"cmdPage page {pageless}", Color = "0.5 0.5 0.5 0.2"},
RectTransform = {AnchorMin = "0.83 0.25", AnchorMax = "0.91 0.3"},
Text = {Text = "<<", FontSize = 20, Align = TextAnchor.MiddleCenter}
},
"Hud",
"ButtonBackLotery"
},
{
// ... [Code preview truncated due to length. Full source in attached file] ...