• Gambling ttt issue
    4 replies, posted
So this is the script that im using for my ttt server the problem is that only 1 player receives the winning pool when bidding the rest dont get anything and I want this fixed any help? The code taht im using [CODE]local gamblebetwin = 2 -- Multiply betting points by gamblebetwin. local gamblemenucommand = "!gamble" if CLIENT then -- Localizing Variables -- Points And Team local pointsnumber local teamselected local teamselectedname local gamblemenu -- The Main Menu local function CreateMenu() gamblemenu = vgui.Create("DFrame") gamblemenu:SetTitle("") gamblemenu:SetPos(450, 280) gamblemenu:SetSize(500, 200) gamblemenu:SetDeleteOnClose(false) gamblemenu:MakePopup() gamblemenu.Paint = function(_, w, h) surface.SetDrawColor(0, 0, 0) surface.DrawRect(0, 0, w, h) surface.SetDrawColor(0, 0, 0) surface.DrawOutlinedRect(0, 0, w, h) surface.DrawLine(0, 23, w, 23) draw.RoundedBox(2, 4, 4, gamblemenu:GetWide() - 8, gamblemenu:GetTall() - 8, Color(105, 105, 105)) end -- The Gamble Title local gambletitle = vgui.Create("DLabel", gamblemenu) gambletitle:SetText("Gamble Menu") gambletitle:SetPos(180, 0) gambletitle:SetFont("Trebuchet24") gambletitle:SetColor(Color(255, 255, 255)) gambletitle:SizeToContents() -- The Gamble Text local gambletext = vgui.Create("DLabel", gamblemenu) gambletext:SetText("Please select a team and the betting money. If you win the bet, you will earn " ..gamblebetwin.. "x of your bet.") gambletext:SetPos(18, 30) gambletext:SetColor(Color(255, 255, 255)) gambletext:SizeToContents() -- The Gamble Category local gamblecategory = vgui.Create("DCollapsibleCategory", gamblemenu) gamblecategory:SetPos(100, 60) gamblecategory:SetSize(300, 50) gamblecategory:SetLabel(" Bet For A Team") gamblecategory:SetExpanded(0) -- The Gamble Category Image local gamblecategoryimage = vgui.Create("DImage", gamblecategory) gamblecategoryimage:SetPos(5, 2) gamblecategoryimage:SetImage("materials/icon16/coins_add.png") gamblecategoryimage:SetSize(16, 16) -- The Gamble Category Image 2 local gamblecategoryimage2 = vgui.Create("DImage", gamblecategory) gamblecategoryimage2:SetPos(280, 2) gamblecategoryimage2:SetImage("materials/icon16/coins_delete.png") gamblecategoryimage2:SetSize(16, 16) -- The Gamble Category List local gamblecategorylist = vgui.Create("DPanelList") gamblecategorylist:SetAutoSize(true) gamblecategorylist:SetSpacing(5) gamblecategory:SetContents(gamblecategorylist) -- Gamble Points Label local gamblepointslabel = vgui.Create("DLabel", gamblecategory) gamblepointslabel:SetPos(2, 25) gamblepointslabel:SetText("Points:") gamblepointslabel:SetFont("Trebuchet18") gamblepointslabel:SetColor(Color(255, 255, 255)) -- Gamble Points Textbox local gamblepointstextbox = vgui.Create("DTextEntry", gamblecategory) gamblepointstextbox:SetPos(44, 25) gamblepointstextbox:SetSize(270, 20) -- Gamble Teams Label local gambleteamslabel = vgui.Create("DLabel", gamblecategory) gambleteamslabel:SetPos(2, 50) gambleteamslabel:SetText("Team:") gambleteamslabel:SetFont("Trebuchet18") gambleteamslabel:SetColor(Color(255, 255, 255)) -- Gamble Teams Selector local gambleteamsselector = vgui.Create("DComboBox", gamblecategory) gambleteamsselector:SetPos(44, 50) gambleteamsselector:SetSize(270, 20) gambleteamsselector:SetText("Select A Team") gambleteamsselector:AddChoice("Innocents", WIN_INNOCENT) gambleteamsselector:AddChoice("Traitors", WIN_TRAITOR) gambleteamsselector:AddChoice("Tie", WIN_TIMELIMIT) gambleteamsselector.OnSelect = function(panel, index, value, data) teamselectedname = value teamselected = data end -- Gamble Confirm Button local gambleconfirmbutton = vgui.Create("DButton", gamblecategory) gambleconfirmbutton:SetPos(2, 75) gambleconfirmbutton:SetSize(300, 25) gambleconfirmbutton:SetText("Submit Gamble Request") gambleconfirmbutton.Paint = function() draw.RoundedBox(2, 4, 4, gambleconfirmbutton:GetWide(), gambleconfirmbutton:GetTall(), Color(0, 191, 255)) end gambleconfirmbutton.DoClick = function() surface.PlaySound("buttons/button14.wav") pointsnumber = tonumber(gamblepointstextbox:GetValue()) if teamselectedname == nil then chat.AddText( Color(0, 0, 0), "[GAMBLER] ", Color(255, 255, 255), "Please select a team." ) elseif pointsnumber != nil then net.Start("gamblerequest") net.WriteString(LocalPlayer():SteamID()) net.WriteUInt(teamselected, 8) net.WriteString(teamselectedname) net.WriteUInt(pointsnumber, 32) net.SendToServer() gamblemenu:SetVisible(false) end end end -- Chat Command And Alive Check local function gamblemenuopen(ply, strText, bTeamOnly, bPlayerIsDead) if ply == LocalPlayer() and ply:Alive() and ply:Team() != TEAM_SPECTATOR and string.lower(strText) == gamblemenucommand then chat.AddText( Color(0, 0, 0), "[GAMBLER] ", Color(255, 255, 255), "You need to be ", Color(255, 0, 0), "dead", Color(255, 255, 255), " to use the menu." ) elseif ply == LocalPlayer() and string.lower(strText) == gamblemenucommand then CreateMenu() end end hook.Add("OnPlayerChat", "gamblemenuopen", gamblemenuopen) -- Gamble No Points Error local function gamblenopointserror() chat.AddText( Color(0, 0, 0), "[GAMBLER] ", Color(255, 255, 255), "You have an ", Color(255, 0, 0), "insufficiant ", Color(255, 255, 255), "amount of ", Color(255, 255, 0), "points", Color(255, 255, 255), "." ) end net.Receive("gamblenopoints", gamblenopointserror) -- Gamble Winners Broadcast local function gamblewinnersbroadcast() local winnername = net.ReadString() local winneramount = net.ReadUInt(32) local winnerteam = net.ReadString() chat.AddText( Color(0, 0, 0), "[GAMBLER] ", Color(255, 0, 0), winnername, Color(255, 255, 255), " has won ", Color(255, 255, 255), tostring(winneramount), Color(255, 255, 0), " points ", Color(255, 255, 255), "by betting on this team: ", Color(0, 0, 255), winnerteam, Color(255, 255, 255), "." ) end net.Receive("gamblewinner", gamblewinnersbroadcast) -- Gamble Wrong Points local function gamblewrongpoints() local smallamount = net.ReadUInt(32) local bigamount = net.ReadUInt(32) chat.AddText( Color(0, 0, 0), "[GAMBLER] ", Color(255, 255, 255), "Please pick a number between ", Color(255, 0, 0), tostring(smallamount), Color(255, 255, 255), " and ", Color(0, 255, 0), tostring(bigamount), Color(255, 255, 255), "." ) end net.Receive("gamblewrongnumber", gamblewrongpoints) elseif SERVER then
Whats the error you're getting?
[QUOTE=_Jacob;44558425]Whats the error you're getting?[/QUOTE] He wouldn't be getting an error, I think what he needs to do is create a table for everyone that bets, then check in the table what their bet was, then at end of round loop through table, if bet won the for each steam id do the winning function
[QUOTE=AnonTakesOver;44558509]He wouldn't be getting an error, I think what he needs to do is create a table for everyone that won instead of using a single var "p"[/QUOTE] exactly the thing is that sometimes few people receive it sometimes they dont that confuses me much
[QUOTE=snakethetroll;44558517]exactly the thing is that sometimes few people receive it sometimes they dont that confuses me much[/QUOTE] Could you create a table called bets then inside it have the teams then store steam id's, example [LUA] bets = { TRAITOR = {"SteamID1, SteamID2"}, INNOCENT = {"SteamID3", "SteamID4"} } [/LUA] Would that be a good solution or do others have better solutions
Sorry, you need to Log In to post a reply to this thread.