Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- root = getRootElement()
- loc = getLocalPlayer()
- gamble_hotDice = {}
- gamble_hotRadio = {}
- function gamble_hotCreateGUI()
- local width, height = 256, 256
- local scrWidth, scrHeight = guiGetScreenSize()
- local x = scrWidth/2 - (width/2)
- local y = scrHeight/2 - (height/2)
- if gamble_hotWindow == nil then
- gamble_hotWindow = guiCreateWindow(x,y,width,height,"Highest of Three",false)
- guiWindowSetSizable(gamble_hotWindow,false)
- gamble_hotDice[1] = guiCreateStaticImage(32,32,64,64,"images/dice/"..tostring(math.random(6))..".png",false,gamble_hotWindow)
- gamble_hotDice[2] = guiCreateStaticImage(96,32,64,64,"images/dice/"..tostring(math.random(6))..".png",false,gamble_hotWindow)
- gamble_hotDice[3] = guiCreateStaticImage(160,32,64,64,"images/dice/"..tostring(math.random(6))..".png",false,gamble_hotWindow)
- gamble_hotResultLabel = guiCreateLabel(48,110,160,16,"Results go here",false,gamble_hotWindow)
- guiLabelSetColor(gamble_hotResultLabel,255,255,255)
- guiLabelSetVerticalAlign(gamble_hotResultLabel,"top")
- guiLabelSetHorizontalAlign(gamble_hotResultLabel,"center",false)
- gamble_hotRadio[1] = guiCreateRadioButton(32,128,72,16,"1st Die",false,gamble_hotWindow)
- gamble_hotRadio[2] = guiCreateRadioButton(32,144,72,16,"2nd Die",false,gamble_hotWindow)
- gamble_hotRadio[3] = guiCreateRadioButton(32,160,72,16,"3rd Die",false,gamble_hotWindow)
- gamble_hotBetLabel = guiCreateLabel(144,128,64,16,"Bet:",false,gamble_hotWindow)
- guiLabelSetColor(gamble_hotBetLabel,255,255,255)
- guiLabelSetVerticalAlign(gamble_hotBetLabel,"top")
- guiLabelSetHorizontalAlign(gamble_hotBetLabel,"center",false)
- guiSetFont(gamble_hotBetLabel,"default-small")
- gamble_hotBetEdit = guiCreateEdit(144,144,64,16,"0",false,gamble_hotWindow)
- gamble_hotPlayButton = guiCreateButton(128,160,48,16,"Play",false,gamble_hotWindow)
- gamble_hotCloseButton = guiCreateButton(176,160,48,16,"Close",false,gamble_hotWindow)
- gamble_hotRulesImage = guiCreateStaticImage(9,184,238,63,"images/cards/flipside.png",false,gamble_hotWindow)
- addEventHandler("onClientGUIClick", gamble_hotPlayButton, gamble_hotPlay)
- addEventHandler("onClientGUIClick", gamble_hotCloseButton, gamble_hotCloseWindow)
- else
- guiSetText(gamble_hotResultLabel, "")
- end
- guiSetVisible(gamble_hotWindow, true)
- guiSetInputEnabled(true)
- showCursor(true)
- end
- addEvent("gamble_createHotWindow", true)
- addEventHandler("gamble_createHotWindow",root, gamble_hotCreateGUI)
- function gamble_hotPlay( )
- betMoney = tonumber(guiGetText(gamble_hotBetEdit))
- dieChosen = {}
- dieChosen[1],dieChosen[2],dieChosen[3] = guiRadioButtonGetSelected(gamble_hotRadio[1]),guiRadioButtonGetSelected(gamble_hotRadio[2]),guiRadioButtonGetSelected(gamble_hotRadio[3])
- if betMoney > 0 then
- triggerServerEvent("gamble_hotRequestPlay", loc, betMoney, dieChosen)
- else
- if resetTimer ~= nil then
- killTimer(resetTimer)
- end
- guiSetText(gamble_hotResultLabel, "Invalid bet")
- resetTimer = setTimer(guiSetText, 1000, 1, gamble_hotResultLabel, "")
- end
- end
- function gamble_hotCloseWindow()
- guiSetVisible(gamble_hotWindow, false)
- guiSetInputEnabled(false)
- showCursor(false)
- setElementData(loc, "gamble_nowPlaying", "none", true)
- end
- function gamble_hot_onWin( dice_result )
- guiStaticImageLoadImage( gamble_hotDice[1], "images/dice/"..tostring(dice_result[1])..".png" )
- guiStaticImageLoadImage( gamble_hotDice[2], "images/dice/"..tostring(dice_result[2])..".png" )
- guiStaticImageLoadImage( gamble_hotDice[3], "images/dice/"..tostring(dice_result[3])..".png" )
- guiSetText(gamble_hotResultLabel, "You win 3 times your bet")
- if resetTimer ~= nil then
- killTimer(resetTimer)
- end
- resetTimer = setTimer(guiSetText, 1000, 1, gamble_hotResultLabel, "")
- end
- function gamble_hot_onLose( dice_result )
- guiStaticImageLoadImage( gamble_hotDice[1], "images/dice/"..tostring(dice_result[1])..".png" )
- guiStaticImageLoadImage( gamble_hotDice[2], "images/dice/"..tostring(dice_result[2])..".png" )
- guiStaticImageLoadImage( gamble_hotDice[3], "images/dice/"..tostring(dice_result[3])..".png" )
- guiSetText(gamble_hotResultLabel, "Sorry, you lose")
- if resetTimer ~= nil then
- killTimer(resetTimer)
- end
- resetTimer = setTimer(guiSetText, 1000, 1, gamble_hotResultLabel, "")
- end
- function gamble_hot_onTie( dice_result )
- guiStaticImageLoadImage( gamble_hotDice[1], "images/dice/"..tostring(dice_result[1])..".png" )
- guiStaticImageLoadImage( gamble_hotDice[2], "images/dice/"..tostring(dice_result[2])..".png" )
- guiStaticImageLoadImage( gamble_hotDice[3], "images/dice/"..tostring(dice_result[3])..".png" )
- guiSetText(gamble_hotResultLabel, "It's a Tie. Roll Again")
- if resetTimer ~= nil then
- killTimer(resetTimer)
- end
- resetTimer = setTimer(guiSetText, 1000, 1, gamble_hotResultLabel, "")
- end
- function gamble_hot_cantAfford()
- guiSetText(gamble_hotResultLabel, "You can't afford that")
- if resetTimer ~= nil then
- killTimer(resetTimer)
- end
- resetTimer = setTimer(guiSetText, 1000, 1, gamble_hotResultLabel, "")
- end
- addEvent("gamble_hotWin", true)
- addEvent("gamble_hotLose", true)
- addEvent("gamble_hotTie", true)
- addEvent("gamble_hotCantAfford", true)
- addEventHandler("gamble_hotWin",root, gamble_hot_onWin)
- addEventHandler("gamble_hotLose",root, gamble_hot_onLose)
- addEventHandler("gamble_hotTie",root, gamble_hot_onTie)
- addEventHandler("gamble_hotCantAfford",root, gamble_hot_cantAfford)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement