Advertisement
Guest User

Izanagi

a guest
Feb 13th, 2010
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.40 KB | None | 0 0
  1. root = getRootElement()
  2. loc = getLocalPlayer()
  3. gamble_hotDice = {}
  4. gamble_hotRadio = {}
  5.  
  6. function gamble_hotCreateGUI()
  7.     local width, height = 256, 256
  8.     local scrWidth, scrHeight = guiGetScreenSize()
  9.     local x = scrWidth/2 - (width/2)
  10.     local y = scrHeight/2 - (height/2)
  11.  
  12.     if gamble_hotWindow == nil then
  13.         gamble_hotWindow = guiCreateWindow(x,y,width,height,"Highest of Three",false)
  14.         guiWindowSetSizable(gamble_hotWindow,false)
  15.        
  16.         gamble_hotDice[1] = guiCreateStaticImage(32,32,64,64,"images/dice/"..tostring(math.random(6))..".png",false,gamble_hotWindow)
  17.         gamble_hotDice[2] = guiCreateStaticImage(96,32,64,64,"images/dice/"..tostring(math.random(6))..".png",false,gamble_hotWindow)
  18.         gamble_hotDice[3] = guiCreateStaticImage(160,32,64,64,"images/dice/"..tostring(math.random(6))..".png",false,gamble_hotWindow)
  19.        
  20.         gamble_hotResultLabel = guiCreateLabel(48,110,160,16,"Results go here",false,gamble_hotWindow)
  21.         guiLabelSetColor(gamble_hotResultLabel,255,255,255)
  22.         guiLabelSetVerticalAlign(gamble_hotResultLabel,"top")
  23.         guiLabelSetHorizontalAlign(gamble_hotResultLabel,"center",false)
  24.        
  25.         gamble_hotRadio[1] = guiCreateRadioButton(32,128,72,16,"1st Die",false,gamble_hotWindow)
  26.         gamble_hotRadio[2] = guiCreateRadioButton(32,144,72,16,"2nd Die",false,gamble_hotWindow)
  27.         gamble_hotRadio[3] = guiCreateRadioButton(32,160,72,16,"3rd Die",false,gamble_hotWindow)
  28.  
  29.        
  30.         gamble_hotBetLabel = guiCreateLabel(144,128,64,16,"Bet:",false,gamble_hotWindow)
  31.         guiLabelSetColor(gamble_hotBetLabel,255,255,255)
  32.         guiLabelSetVerticalAlign(gamble_hotBetLabel,"top")
  33.         guiLabelSetHorizontalAlign(gamble_hotBetLabel,"center",false)
  34.         guiSetFont(gamble_hotBetLabel,"default-small")
  35.        
  36.         gamble_hotBetEdit = guiCreateEdit(144,144,64,16,"0",false,gamble_hotWindow)
  37.        
  38.         gamble_hotPlayButton = guiCreateButton(128,160,48,16,"Play",false,gamble_hotWindow)
  39.         gamble_hotCloseButton = guiCreateButton(176,160,48,16,"Close",false,gamble_hotWindow)
  40.        
  41.         gamble_hotRulesImage = guiCreateStaticImage(9,184,238,63,"images/cards/flipside.png",false,gamble_hotWindow)
  42.        
  43.         addEventHandler("onClientGUIClick", gamble_hotPlayButton, gamble_hotPlay)
  44.         addEventHandler("onClientGUIClick", gamble_hotCloseButton, gamble_hotCloseWindow)
  45.     else
  46.         guiSetText(gamble_hotResultLabel, "")
  47.     end
  48.     guiSetVisible(gamble_hotWindow, true)
  49.     guiSetInputEnabled(true)
  50.     showCursor(true)
  51. end
  52.  
  53. addEvent("gamble_createHotWindow", true)
  54. addEventHandler("gamble_createHotWindow",root, gamble_hotCreateGUI)
  55.  
  56. function gamble_hotPlay( )
  57.     betMoney = tonumber(guiGetText(gamble_hotBetEdit))
  58.     dieChosen = {}
  59.     dieChosen[1],dieChosen[2],dieChosen[3] = guiRadioButtonGetSelected(gamble_hotRadio[1]),guiRadioButtonGetSelected(gamble_hotRadio[2]),guiRadioButtonGetSelected(gamble_hotRadio[3])
  60.     if betMoney > 0 then
  61.         triggerServerEvent("gamble_hotRequestPlay", loc, betMoney, dieChosen)
  62.     else
  63.         if resetTimer ~= nil then
  64.             killTimer(resetTimer)
  65.         end
  66.         guiSetText(gamble_hotResultLabel, "Invalid bet")
  67.         resetTimer = setTimer(guiSetText, 1000, 1, gamble_hotResultLabel, "")
  68.     end
  69. end
  70.  
  71. function gamble_hotCloseWindow()
  72.     guiSetVisible(gamble_hotWindow, false)
  73.     guiSetInputEnabled(false)
  74.     showCursor(false)
  75.     setElementData(loc, "gamble_nowPlaying", "none", true)
  76. end
  77.  
  78. function gamble_hot_onWin( dice_result )
  79.  
  80.         guiStaticImageLoadImage( gamble_hotDice[1], "images/dice/"..tostring(dice_result[1])..".png" )
  81.         guiStaticImageLoadImage( gamble_hotDice[2], "images/dice/"..tostring(dice_result[2])..".png" )
  82.         guiStaticImageLoadImage( gamble_hotDice[3], "images/dice/"..tostring(dice_result[3])..".png" )
  83.  
  84.         guiSetText(gamble_hotResultLabel, "You win 3 times your bet")
  85.         if resetTimer ~= nil then
  86.             killTimer(resetTimer)
  87.         end
  88.         resetTimer = setTimer(guiSetText, 1000, 1, gamble_hotResultLabel, "")
  89. end
  90. function gamble_hot_onLose( dice_result )
  91.  
  92.         guiStaticImageLoadImage( gamble_hotDice[1], "images/dice/"..tostring(dice_result[1])..".png" )
  93.         guiStaticImageLoadImage( gamble_hotDice[2], "images/dice/"..tostring(dice_result[2])..".png" )
  94.         guiStaticImageLoadImage( gamble_hotDice[3], "images/dice/"..tostring(dice_result[3])..".png" )
  95.  
  96.         guiSetText(gamble_hotResultLabel, "Sorry, you lose")
  97.         if resetTimer ~= nil then
  98.             killTimer(resetTimer)
  99.         end
  100.         resetTimer = setTimer(guiSetText, 1000, 1, gamble_hotResultLabel, "")
  101. end
  102. function gamble_hot_onTie( dice_result )
  103.  
  104.         guiStaticImageLoadImage( gamble_hotDice[1], "images/dice/"..tostring(dice_result[1])..".png" )
  105.         guiStaticImageLoadImage( gamble_hotDice[2], "images/dice/"..tostring(dice_result[2])..".png" )
  106.         guiStaticImageLoadImage( gamble_hotDice[3], "images/dice/"..tostring(dice_result[3])..".png" )
  107.  
  108.         guiSetText(gamble_hotResultLabel, "It's a Tie. Roll Again")
  109.         if resetTimer ~= nil then
  110.             killTimer(resetTimer)
  111.         end
  112.         resetTimer = setTimer(guiSetText, 1000, 1, gamble_hotResultLabel, "")
  113. end
  114. function gamble_hot_cantAfford()
  115.         guiSetText(gamble_hotResultLabel, "You can't afford that")
  116.         if resetTimer ~= nil then
  117.             killTimer(resetTimer)
  118.         end
  119.         resetTimer = setTimer(guiSetText, 1000, 1, gamble_hotResultLabel, "")
  120. end
  121.  
  122. addEvent("gamble_hotWin", true)
  123. addEvent("gamble_hotLose", true)
  124. addEvent("gamble_hotTie", true)
  125. addEvent("gamble_hotCantAfford", true)
  126.  
  127. addEventHandler("gamble_hotWin",root, gamble_hot_onWin)
  128. addEventHandler("gamble_hotLose",root, gamble_hot_onLose)
  129. addEventHandler("gamble_hotTie",root, gamble_hot_onTie)
  130. addEventHandler("gamble_hotCantAfford",root, gamble_hot_cantAfford)
  131.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement