Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 27th, 2012  |  syntax: Lua  |  size: 94.89 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2.  
  3.  
  4.  
  5.  
  6. --------------------
  7. -- Set all variables
  8. --------------------
  9.  
  10. screenWidth, screenHeight = guiGetScreenSize()
  11. function setVariables()
  12.         --killedByAfk = 0
  13.         --betPlayer = "none"
  14.         --betAmount = 0
  15.         --oldAmount = 0
  16.         --achievementActive = 0
  17. end
  18. addEventHandler("onClientResourceStart",getRootElement(),setVariables)
  19.  
  20. function vars2()
  21.         colorPickMode = false
  22.         setElementData(getLocalPlayer(),"chattingWith","none")
  23.         recentlySavedSettings = false
  24.         --customHorn = {}
  25.         --hornNum = 0
  26.         --setHornSound = 0
  27.         screenWidth,screenHeight = guiGetScreenSize()
  28.         --mainWindowWidth = 619
  29.         --mainWindowHeight = 365
  30.         --PDWindowWidth = 369
  31.         --PDWindowHeight = 370
  32.         --CNWindowWidth = 340
  33.         --CNWindowHeight = 123
  34.         --SWindowWidth = 541
  35.         --SWindowHeight = 274
  36.         --chatImageSize = 135
  37.         SkinWindowWidth = 604
  38.         SkinWindowHeight = 429
  39.         colorWindowWidth = 405
  40.         colorWindowHeight = 195
  41. end
  42. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),vars2)
  43.  
  44.  
  45.  
  46. ----------------------
  47. -- Starts
  48. ----------------------
  49.  
  50. gRoot = getRootElement()
  51. sW,sH = guiGetScreenSize()
  52.  
  53.  
  54. myCash = "???"
  55. myWinsDD = "???"
  56. myWinsDM = "???"
  57. myPlayedDD = "???"
  58. myPlayedDM = "???"
  59. myRatioDD = "???"
  60. myRatioDM = "???"
  61. myPlayedTime = "???"
  62. myHunters = "???"
  63. myMapBuys = "???"
  64. myACCount = "???"
  65. myTopTimes = "???"
  66.  
  67. --[[totalBets = "N/A"
  68. totalBetsWon = "N/A"]]--
  69.  
  70. --[[mapAuthor = "Unknow"
  71. mapName = "N/A"
  72. mapType = "N/A"
  73. totalMaps = "N/A"]]--
  74.  
  75.  
  76. topButton = {}
  77. topButtons = {}
  78. topButtons[1] = {"Top Cash","cash"}
  79. topButtons[2] = {"Top Achievements","achievements"}
  80. topButtons[3] = {"Top DDs","dds"}
  81. topButtons[4] = {"Top DMs","dms"}
  82. topButtons[5] = {"Top DD wins","ddwins"}
  83. topButtons[6] = {"Top DM wins","dmwins"}
  84. topButtons[7] = {"Top DD ratio","ddratio"}
  85. topButtons[8] = {"Top DM ratio","dmratio"}
  86. topButtons[9] = {"Top Map Buys","mapbuys"}
  87. topButtons[10] = {"Top Played Time","playedtime"}
  88. topButtons[11] = {"Top Hunters","hunters"}
  89. topButtons[12] = {"Top TopTimes","toptimes"}
  90. topButtons[13] = {"Top DD Map","ddmap"}
  91. topButtons[14] = {"Top DM Map","dmmap"}
  92.  
  93. shaders = {}
  94. shaderCheckBox = {}
  95. shaderNames ={
  96. "Car Shader",
  97. "Water Shader",
  98. "Surface Reflections",
  99. "Contrast",
  100. "Snow",
  101. "Gold",
  102. "Colored Skidmarks"
  103. }
  104. shaderHelpNames = {
  105. "Realistic vehicle reflections",
  106. "Realistic water texture and reflections",
  107. "Realistic surface texture and reflections",
  108. "HDR Contrast Shader",
  109. "Adds snow on roads and trees",
  110. "Feel like King Midas",
  111. "Useless..."
  112. }
  113.  
  114. -- Create horns
  115. hornName={
  116. "Default GTA horn",
  117. "Airhorn",
  118. "Clown",
  119. "Train",
  120. "Fog horn",
  121. "Submarine",
  122. "Military trumpet",
  123. "Mr. Whoopie"}
  124.  
  125. hornPrice={
  126. "  N/A",
  127. "  2000",
  128. "  4000",
  129. "  6000",
  130. "  8000",
  131. "  10000",
  132. "  15000",
  133. "  20000"}
  134.  
  135. hornSound={
  136. "sounds/airhorn.wav",
  137. "sounds/clownhorn.mp3",
  138. "sounds/trainhorn.mp3",
  139. "sounds/cargoshiphorn.mp3",
  140. "sounds/submarinehorn.wav",
  141. "sounds/generalleehorn.mp3",
  142. "sounds/whoopiehorn.mp3"}
  143.  
  144. PlayerDataGUI={}
  145. UserDataGUI={}
  146. UserDataNames={
  147. "Name","Age","BirthDay","Country","Languages","City","Family","Pets","Boyfriend","GirlFriend","E-mail","GG","ICQ","MSN","Site","Hobby","Interest","Fav. Car","Games","PC"
  148. }
  149.  
  150. Achievement = {}
  151. AchievementImages = {}
  152. AchievementsName = {
  153. "First Win!", -- 1sze zwyciestwo                        1
  154. "First Hunter!", -- 1szy hunter                         2
  155. "Top Winner!", -- 300 wins                              3
  156. "Awesome Winner!", -- 1000 wins                 4
  157. "Top Gamer!", -- 2000 map                               5
  158. "Long Time Player!", -- 7 dni                           6
  159. "Hunter Owner!", -- hunter 50 razy                      7
  160. "Beat my TT kid!", -- pierwszy TT                       8
  161. "5 Maps In a Row LOL!", -- 5x                           9
  162. "Triple Deathmatch!", -- 3x dm pod rzad                         10
  163. "Triple Dest. Derby!", -- 3x DD                                 11
  164. "Hunter Power", -- hunterfight z 3 graczami                     12
  165. "Map Buyer", -- 10 razy kupic mape                              13
  166. "Top Times collector!", -- 50 toptimow                          14
  167. "Rich player!", -- 1 mln                                        15
  168. "Rich player I", -- 2 mln                                       16
  169. "Hunter Owner I", -- hunter 150 razy                            17
  170. "Top Times collector I", -- 150 toptimow                                18
  171. "Hunter Power I", -- hunterfight z 8 graczami                              19
  172. }
  173.  
  174. AchievementsHelpName = {
  175. "Win a DM or DD map", -- 1st DM/DD win
  176. "Get your first hunter", -- 1st hunter
  177. "Get 300+ wins", -- 300 wins
  178. "Get 1000+ wins", -- 1000 wins
  179. "Play 2000+ maps", -- 2000 map plays
  180. "Get 7 days (play time) in stats", -- 7 days online
  181. "Get Hunter 50+ times", -- get 50 hunter
  182. "Get Your First TopTime", -- first TT
  183. "Win 5 maps in a row", -- 5 maps in a row
  184. "Win DM map 3 times in a row", -- 3x DM
  185. "Win DD map 3 times in a row", -- 3x DD
  186. "Win a hunter fight with 3+ players", -- win 3+ players hunterfight
  187. "Buy a map 10 times", -- buy 10 maps
  188. "Get 50 Top times", -- 50 toptimes
  189. "Get 1 mln $", -- 1 mln
  190. "Get 2 mln $", -- 2 mln
  191. "Get Hunter 150+ times", -- Hunter reacheds 150
  192. "Get 150 Top times", -- 150 Toptimes
  193. "Win a hunter fight with 8+ players", -- win 8+ players hunterfight
  194. }
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201. --------------------
  202. -- Set all variables
  203. --------------------
  204.  
  205. screenWidth, screenHeight = guiGetScreenSize()
  206. function setVariables()
  207.         --killedByAfk = 0
  208.         betPlayer = "none"
  209.         betAmount = 0
  210.         oldAmount = 0
  211.         --achievementActive = 0
  212. end
  213. addEventHandler("onClientResourceStart",getRootElement(),setVariables)
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220. ------------------------------------------
  221. -- Panel
  222. ------------------------------------------
  223. function startGUI()
  224.         addEventHandler ( "onClientRender", gRoot, showCash )
  225.         Tab = {}
  226.        
  227.        
  228.        
  229.         Panel = guiCreateWindow(0.2,0.2,0.5,0.6,"Special Gaming Forces - User Panel",true)
  230.         guiSetAlpha(Panel,1)
  231.         guiWindowSetSizable(Panel,false)
  232.         guiWindowSetMovable(Panel,true)
  233.         --[[Panel2 = guiCreateWindow(0.2,0.2,0.37,0.6,"Player's User Data",true)
  234.         guiSetAlpha(Panel2,1)
  235.         guiWindowSetSizable(Panel2,false)]]--
  236.        
  237.         TabPanel = guiCreateTabPanel(0.01,0.05,12,0.94,true,Panel)
  238.         Tab[1] = guiCreateTab("Achievements",TabPanel)
  239.         Tab[2] = guiCreateTab("Players",TabPanel)
  240.         --Tab[4] = guiCreateTab("Shop",TabPanel)
  241.         Tab[3] = guiCreateTab("Maps",TabPanel)
  242.         Tab[5] = guiCreateTab("Top Lists",TabPanel)
  243.         Tab[6] = guiCreateTab("Shaders",TabPanel)
  244.         Tab[7] = guiCreateTab("Stats",TabPanel)
  245.         Tab[8] = guiCreateTab("Shop",TabPanel)
  246. guiSetFont ( TabPanel, "default-bold-small" )
  247.  
  248.  
  249.         --MyStatsTextGUI = guiCreateLabel ( 0.65, 0.1, 0.3, 0.1, "Your Stats:", true , Panel )
  250.                         --guiLabelSetColor ( MyStatsTextGUI, 0, 255, 255 )
  251.         --guiSetFont ( MyStatsTextGUI, "default-bold-small" )
  252.  
  253.         -- Tab[7] PANEL STATS
  254.         myCashGUI = guiCreateLabel ( 0.65, 0.05, 0.5, 0.05, "Stats:", true , Tab[7])
  255.                  guiLabelSetColor ( myCashGUI, 255,255,255 )
  256.         guiSetFont ( myCashGUI, "default-bold-small" )
  257.         myCashGUI = guiCreateLabel ( 0.65, 0.1, 0.5, 0.05, "Money: $"..myCash.."", true , Tab[7])
  258.                  guiLabelSetColor ( myCashGUI, math.random(0, 255), math.random(0, 255), math.random(0, 255) )
  259.         guiSetFont ( myCashGUI, "default-bold-small" )
  260.                  myPlayedDMGUI = guiCreateLabel ( 0.05, 0.3, 0.15, 0.05, "[DD] Stats:", true , Tab[7])
  261.                 guiLabelSetColor ( myPlayedDMGUI, 255,255,255 )
  262.         guiSetFont ( myPlayedDMGUI, "default-bold-small" )
  263.         myPlayedDDGUI = guiCreateLabel ( 0.05, 0.35, 0.15, 0.05, "DDs: "..myPlayedDD.."", true , Tab[7])
  264.                  guiLabelSetColor ( myPlayedDDGUI, math.random(0, 255), math.random(0, 255), math.random(0, 255) )
  265.         guiSetFont ( myPlayedDDGUI, "default-bold-small" )
  266.         myWinsDDGUI = guiCreateLabel ( 0.05, 0.40, 0.15, 0.05, "Wins: "..myWinsDD.."", true , Tab[7])
  267.                  guiLabelSetColor ( myWinsDDGUI, math.random(0, 255), math.random(0, 255), math.random(0, 255) )
  268.         guiSetFont ( myWinsDDGUI, "default-bold-small" )
  269.         myRatioDDGUI = guiCreateLabel ( 0.05, 0.45, 0.15, 0.05, "Ratio: "..myRatioDD.."%", true , Tab[7])
  270.                 guiLabelSetColor ( myRatioDDGUI, math.random(0, 255), math.random(0, 255), math.random(0, 255) )
  271.         guiSetFont ( myRatioDDGUI, "default-bold-small" )
  272.         myPlayedDMGUI = guiCreateLabel ( 0.05, 0.06, 0.15, 0.05, "[DM] Stats:", true , Tab[7])
  273.                 guiLabelSetColor ( myPlayedDMGUI, 255,255,255 )
  274.         guiSetFont ( myPlayedDMGUI, "default-bold-small" )
  275.         myPlayedDMGUI = guiCreateLabel ( 0.05, 0.1, 0.15, 0.05, "DMs: "..myPlayedDM.."", true , Tab[7])
  276.                 guiLabelSetColor ( myPlayedDMGUI, math.random(0, 255), math.random(0, 255), math.random(0, 255) )
  277.         guiSetFont ( myPlayedDMGUI, "default-bold-small" )
  278.         myWinsDMGUI = guiCreateLabel ( 0.05, 0.15, 0.15, 0.05, "Wins: "..myWinsDM.."", true , Tab[7])
  279.                 guiLabelSetColor ( myWinsDMGUI, math.random(0, 255), math.random(0, 255), math.random(0, 255) )
  280.         guiSetFont ( myWinsDMGUI, "default-bold-small" )
  281.         myRatioDMGUI = guiCreateLabel ( 0.05, 0.20, 0.15, 0.05, "Ratio: "..myRatioDM.."%", true , Tab[7])
  282.                  guiLabelSetColor ( myRatioDMGUI, math.random(0, 255), math.random(0, 255), math.random(0, 255) )
  283.         guiSetFont ( myRatioDMGUI, "default-bold-small" )
  284.         myPlayedTimeGUI = guiCreateLabel ( 0.65, 0.15, 0.3, 0.05, "Played Time: "..myPlayedTime.."", true , Tab[7])
  285.                 guiLabelSetColor ( myPlayedTimeGUI, math.random(0, 255), math.random(0, 255), math.random(0, 255) )
  286.         guiSetFont ( myPlayedTimeGUI, "default-bold-small" )
  287.         myHuntersGUI = guiCreateLabel ( 0.65, 0.2, 0.3, 0.05, "Hunters: "..myHunters.."", true , Tab[7])
  288.                 guiLabelSetColor ( myHuntersGUI, 193, 255, 23 )
  289.         guiSetFont ( myHuntersGUI, "default-bold-small" )
  290.         myMapBuysGUI = guiCreateLabel ( 0.65, 0.25, 0.3, 0.05, "Map Buys: "..myMapBuys.."", true , Tab[7])
  291.                  guiLabelSetColor ( myMapBuysGUI, math.random(0, 255), math.random(0, 255), math.random(0, 255) )
  292.         guiSetFont ( myMapBuysGUI, "default-bold-small" )
  293.         myACCountGUI = guiCreateLabel ( 0.65, 0.3, 0.3, 0.05, "Achievements: "..myACCount.."/20", true , Tab[7])
  294.                  guiLabelSetColor ( myACCountGUI, math.random(0, 255), math.random(0, 255), math.random(0, 255) )
  295.         guiSetFont ( myACCountGUI, "default-bold-small" )
  296.         myTopTimesGUI = guiCreateLabel ( 0.65, 0.35, 0.3, 0.05, "Top Times: "..myTopTimes.."", true , Tab[7])
  297.                 guiLabelSetColor ( myTopTimesGUI, math.random(0, 255), math.random(0, 255), math.random(0, 255) )
  298.         guiSetFont ( myTopTimesGUI, "default-bold-small" )
  299.                  --guiCreateStaticImage ( 0.7, 0.8, 0.28, 1, "img/sgf.png", true, Panel )
  300.  
  301.  
  302.  
  303.  
  304.  
  305. ------------------------------------------
  306. -- Tab [8] Shop
  307. ------------------------------------------
  308.         -- buttons
  309.         btnOpenSkinsWindow = guiCreateButton(33,295,123,38,"Buy a skin",false,tabs[8])
  310.         btnChangeHeadlightsColor = guiCreateButton(445,295,123,38,"Headlights color",false,Tab[8])
  311.         btnChangeVehicleColor = guiCreateButton(308,295,123,38,"Vehicle color",false,Tab[8])
  312.         btnChangeNametagColor = guiCreateButton(171,295,123,38,"Buy nametag color",false,Tab[8])
  313.  
  314.         -- general elements
  315.         myCashGUI = guiCreateLabel ( 33, 266, 123, 19, "Price: $1300", true, Tab[8] )
  316.         guiLabelSetVerticalAlign ( myCashGUI, "center" )
  317.         guiLabelSetHorizontalAlign ( myCashGUI, "center", false )
  318.         guiSetFont ( PriceSkinGUI, "default-bold-small" )
  319.  
  320.         lblPriceFree1 = guiCreateLabel(445,266,123,19,"Price: FREE",false,Tab[8])
  321.         guiLabelSetVerticalAlign(lblPriceFree1,"center")
  322.         guiLabelSetHorizontalAlign(lblPriceFree1,"center",false)
  323.         guiSetFont(lblPriceFree1,"default-bold-small")
  324.  
  325.         lblPriceFree2 = guiCreateLabel(308,266,123,19,"Price: FREE",false,Tab[8])
  326.         guiLabelSetVerticalAlign(lblPriceFree2,"center")
  327.         guiLabelSetHorizontalAlign(lblPriceFree2,"center",false)
  328.         guiSetFont(lblPriceFree2,"default-bold-small")
  329.  
  330.         lblPriceNametag = guiCreateLabel(171,266,123,19,"Price: $2000",false,Tab[8])
  331.         guiLabelSetVerticalAlign(lblPriceNametag,"center")
  332.         guiLabelSetHorizontalAlign(lblPriceNametag,"center",false)
  333.         guiSetFont(lblPriceNametag,"default-bold-small")
  334.  
  335.  
  336.         lblWaterColor = guiCreateLabel(389,22,146,18,"Water color",false,Tab[8])
  337.         guiLabelSetColor(lblWaterColor,255,120,0)
  338.         guiLabelSetHorizontalAlign(lblWaterColor,"center",false)
  339.         guiSetFont(lblWaterColor,"default-bold-small")
  340.  
  341.         lblNewWaterColor = guiCreateLabel(398,40,135,14,"New color (rrr,ggg,bbb)",false,Tab[8])
  342.         guiSetFont(lblNewWaterColor,"default-bold-small")
  343.  
  344.         lblTime = guiCreateLabel(389,132,146,18,"Time",false,Tab[8])
  345.         guiLabelSetColor(lblTime,255,120,0)
  346.         guiLabelSetHorizontalAlign(lblTime,"center",false)
  347.         guiSetFont(lblTime,"default-bold-small")
  348.  
  349.         lblNewTime = guiCreateLabel(411,150,135,14,"New time (hh:mm)",false,Tab[8])
  350.         guiSetFont(lblNewTime,"default-bold-small")
  351.  
  352.         editWaterColorRed = guiCreateEdit(389,58,42,22,"",false,Tab[8])
  353.         editWaterColorGreen = guiCreateEdit(441,58,42,22,"",false,Tab[8])
  354.         editWaterColorBlue = guiCreateEdit(493,58,42,22,"",false,Tab[8])
  355.         editTimeHours = guiCreateEdit(416,171,42,22,"",false,Tab[8])
  356.         editTimeMinutes = guiCreateEdit(468,171,42,22,"",false,Tab[8])
  357.         guiEditSetMaxLength(editWaterColorRed,3)
  358.         guiEditSetMaxLength(editWaterColorGreen,3)
  359.         guiEditSetMaxLength(editWaterColorBlue,3)
  360.         guiEditSetMaxLength(editTimeHours,2)
  361.         guiEditSetMaxLength(editTimeMinutes,2)
  362.  
  363.         btnChangeWaterColor = guiCreateButton(389,90,146,23,"Change color - $400",false,Tab[8])
  364.         btnChangeTime = guiCreateButton(389,203,146,23,"Change time - $250",false,Tab[8])
  365.  
  366.  
  367.         -- horn interface
  368.         gridHorns = guiCreateGridList(24,56,191,154,false,Tab[8])
  369.         guiGridListAddColumn(gridHorns,"Horn",0.6)
  370.         guiGridListAddColumn(gridHorns,"Price",0.3)
  371.         guiGridListSetSortingEnabled(gridHorns,false)
  372.  
  373.         for _,horn in ipairs(hornName) do
  374.                 local row = guiGridListAddRow(gridHorns)
  375.                 guiGridListSetItemText(gridHorns,row,1,horn,false,false)
  376.                 guiGridListSetItemColor(gridHorns,row,1,180,180,180,255)
  377.         end
  378.  
  379.         for _,price in ipairs(hornPrice) do
  380.                 guiGridListSetItemText(gridHorns,_-1,2,price,false,false)
  381.                 guiGridListSetItemColor(gridHorns,_-1,2,180,180,180,255)
  382.         end
  383.  
  384.  
  385.         lblCustomHornInfo = guiCreateLabel(24,22,143,16,"Custom horn sounds",false,Tab[8])
  386.         guiLabelSetColor(lblCustomHornInfo,255,120,0)
  387.         guiSetFont(lblCustomHornInfo,"default-bold-small")
  388.  
  389.         btnSetHornSound = guiCreateButton(24,215,191,24,"Use selected horn",false,Tab[8])
  390.  
  391.         btnPreviewHorn = guiCreateButton(225,80,83,26,"Preview horn",false,Tab[8])
  392.  
  393.         btnBuyHorn = guiCreateButton(225,167,83,26,"Buy horn",false,Tab[8])
  394.  
  395.         lblHornPriceNot = guiCreateLabel(225,127,83,15,"Price:",false,Tab[8])
  396.         guiLabelSetHorizontalAlign(lblHornPriceNot,"center",false)
  397.         guiSetFont(lblHornPriceNot,"default-bold-small")
  398.  
  399.         lblHornPrice = guiCreateLabel(225,142,83,15,"N/A",false,Tab[8])
  400.         guiLabelSetVerticalAlign(lblHornPrice,"center")
  401.         guiLabelSetHorizontalAlign(lblHornPrice,"center",false)
  402.         guiSetFont(lblHornPrice,"default-bold-small")
  403.  
  404.         lblCurrentHorn = guiCreateLabel(24,38,175,16,"Current horn: N/A",false,Tab[8])
  405.         guiSetFont(lblCurrentHorn,"default-bold-small")
  406.  
  407.  
  408.         -- color pick window
  409.         colorWindow = guiCreateWindow(screenWidth/2-colorWindowWidth/2,screenHeight/2-colorWindowHeight/2,colorWindowWidth,colorWindowHeight,"Select your color...",false)
  410.         guiSetAlpha(colorWindow,0.95)
  411.         guiSetVisible(colorWindow,false)
  412.  
  413.         labelRed = guiCreateLabel(15,39,102,20,"RED",false,colorWindow)
  414.         guiLabelSetColor(labelRed,255,0,0)
  415.         guiLabelSetVerticalAlign(labelRed,"center")
  416.         guiLabelSetHorizontalAlign(labelRed,"left",false)
  417.         guiSetFont(labelRed,"default-bold-small")
  418.  
  419.         labelGreen = guiCreateLabel(15,78,101,20,"GREEN",false,colorWindow)
  420.         guiLabelSetColor(labelGreen,0,255,0)
  421.         guiLabelSetVerticalAlign(labelGreen,"center")
  422.         guiLabelSetHorizontalAlign(labelGreen,"left",false)
  423.         guiSetFont(labelGreen,"default-bold-small")
  424.  
  425.         labelBlue = guiCreateLabel(15,117,100,20,"BLUE",false,colorWindow)
  426.         guiLabelSetColor(labelBlue,0,30,255)
  427.         guiLabelSetVerticalAlign(labelBlue,"center")
  428.         guiLabelSetHorizontalAlign(labelBlue,"left",false)
  429.         guiSetFont(labelBlue,"default-bold-small")
  430.  
  431.         gridOne = guiCreateGridList(10000,12,0,164,false,colorWindow)
  432.         guiGridListSetSelectionMode(gridOne,2)
  433.  
  434.         gridTwo = guiCreateGridList(10000,12,0,164,false,colorWindow)
  435.         guiGridListSetSelectionMode(gridTwo,2)
  436.  
  437.         redBar = guiCreateScrollBar( 0.2, 0.2, 0.69, 0.1, true, true, colorWindow)
  438.         greenBar = guiCreateScrollBar( 0.2, 0.4, 0.69, 0.1, true, true, colorWindow)
  439.         blueBar = guiCreateScrollBar( 0.2, 0.6, 0.69, 0.1, true, true, colorWindow)
  440.  
  441.         lblColorPreview = guiCreateLabel(15,152,181,31,"Preview     [||||||||||||||]",false,colorWindow)
  442.         guiLabelSetVerticalAlign(lblColorPreview,"center")
  443.         guiLabelSetHorizontalAlign(lblColorPreview,"center",false)
  444.         guiSetFont(lblColorPreview,"default-bold-small")
  445.  
  446.         btnSaveColor = guiCreateButton(214,152,81,31,"Save",false,colorWindow)
  447.  
  448.         btnCancelColorSelection = guiCreateButton(305,152,77,31,"Cancel",false,colorWindow)
  449.  
  450.  
  451.  
  452.         -- skin window
  453.         skinsWindow = guiCreateWindow(screenWidth/2-SkinWindowWidth/2,screenHeight/2-SkinWindowHeight/2,604,429,"Skins",false)
  454.         guiWindowSetSizable(skinsWindow,false)
  455.         guiSetVisible(skinsWindow, false)
  456.  
  457.         lblSkinsText = guiCreateLabel(10,27,583,109,"Here you can change your character's skin. Changing the skin costs $1300. For your convenience, the skins are arranged in several groups. \n\nYou can preview skins by clicking on them. Your character's skin will change into the selected one for a few seconds. \n\nWhen you find a skin you want, select it and click the \"Buy skin\" button. This will save the skin to your account and you will play with it until you decide to change it again.",false,skinsWindow)
  458.         guiLabelSetHorizontalAlign(lblSkinsText,"left",true)
  459.         guiSetFont(lblSkinsText,"default-bold-small")
  460.  
  461.         skin_groupTable = guiCreateGridList(10,157,167,261,false,skinsWindow)
  462.         guiGridListSetSortingEnabled(skin_groupTable, false)
  463.         skin_groupTable_01 = guiGridListAddColumn(skin_groupTable, "Group", 0.8)
  464.         local groupTable_row = nil
  465.  
  466.         lblSkinLine = guiCreateLabel(16,136,570,11,"--------------------------------------------------------------------------------------------------------------------------------",false,skinsWindow)
  467.         guiLabelSetColor(lblSkinLine,255,120,0)
  468.         guiLabelSetHorizontalAlign(lblSkinLine,"center",false)
  469.         guiSetFont(lblSkinLine,"default-bold-small")
  470.  
  471.         skin_skinTable = guiCreateGridList(207,157,224,261,false,skinsWindow)
  472.         guiGridListSetSortingEnabled(skin_skinTable, false)
  473.         skin_skinTable_01 = guiGridListAddColumn(skin_skinTable, "ID", 0.454545)
  474.         skin_skinTable_02 = guiGridListAddColumn(skin_skinTable, "Skin Name", 0.454545)
  475.         local skinTable_row = nil
  476.  
  477.         btnCloseSkinWindow = guiCreateButton(456,382,126,36,"Close",false,skinsWindow)
  478.  
  479.         btnBuySkin = guiCreateButton(456,232,126,36,"Buy skin",false,skinsWindow)
  480.  
  481.         lblBuySelectedSkin = guiCreateLabel(456,209,126,18,"Buy the selected skin",false,skinsWindow)
  482.         guiLabelSetColor(lblBuySelectedSkin,255,120,0)
  483.         guiLabelSetHorizontalAlign(lblBuySelectedSkin,"center",false)
  484.         guiSetFont(lblBuySelectedSkin,"default-bold-small")
  485.  
  486.         lblSkinPrice = guiCreateLabel(456,285,126,18,"Price: $1300",false,skinsWindow)
  487.         guiLabelSetColor(lblSkinPrice,255,120,0)
  488.         guiLabelSetHorizontalAlign(lblSkinPrice,"center",false)
  489.         guiSetFont(lblSkinPrice,"default-bold-small")
  490.  
  491.         aSkins = aLoadSkins()
  492.         local i = guiGridListAddRow(skin_groupTable)
  493.         guiGridListSetItemText( skin_groupTable, i, skin_groupTable_01, 'All skins', false, false )
  494.         for name, group in pairs(aSkins) do
  495.                 local i = guiGridListAddRow(skin_groupTable)
  496.                 guiGridListSetItemText( skin_groupTable, i, skin_groupTable_01, name, false, false )
  497.         end
  498.         guiGridListSetSelectedItem( skin_groupTable, i, 1 )
  499.         addEventHandler('onClientGUIClick', skin_groupTable, groupSelected , false)
  500.         guiGridListSetColumnWidth(skin_skinTable,skin_skinTable_01, 50, false)
  501.         guiGridListSetColumnWidth(skin_skinTable,skin_skinTable_02, 140, false)
  502.         addEventHandler('onClientGUIClick', skin_skinTable, skinSelected , false)
  503.         fillTableSkins('All skins')
  504.  
  505.  
  506. -- Skins
  507. function openSkinsWindowCheck()
  508.         callServerFunction("checkSkinLevel",getLocalPlayer())
  509. end
  510.  
  511. function openSkinsWindow()
  512.         guiSetVisible(skinsWindow,true)
  513.         guiSetVisible(Tab[8],false)
  514.         guiBringToFront(skinsWindow)
  515. end
  516.  
  517. function closeSkinsWindow()
  518.         guiSetVisible(skinsWindow,false)
  519.         guiSetVisible(Tab[8],true)
  520. end
  521.  
  522.  
  523. function on_buySkinButton_clicked(button, state, absoluteX, absoluteY)
  524.         if (button ~= "left") or (state ~= "up") then
  525.                 return
  526.         end
  527.         if (currentSkin) then
  528.                 if type(currentSkin) =='number' then
  529.                         callServerFunction("saveSkin",getLocalPlayer(),tostring(currentSkin))
  530.                 end
  531.         else
  532.                 outputChatBox("#FF6600* #FFFFFFERROR! Please select a skin!",255,255,255,true)
  533.         end
  534. end
  535.  
  536. function skinSelected(button, state, absoluteX, absoluteY)
  537.         if (button ~= "left") or (state ~= "up") or source ~= skin_skinTable then
  538.                 return
  539.         end
  540.         local x, y = guiGridListGetSelectedItem(source)
  541.         if tonumber(x) and  tonumber(y) then
  542.                 local skinID = guiGridListGetItemText(source, x, skin_skinTable_01)
  543.                 currentSkin = getSkinID(skinID)
  544.                 if type(currentSkin) =='number' then
  545.                         backToID = backToID or getElementModel(getLocalPlayer())
  546.                         if isTimer(skinTimer) then
  547.                                 killTimer(skinTimer)
  548.                                 skinTimer = setTimer(function() setElementModel(getLocalPlayer(), backToID) backToID=nil end, 5000, 1 )
  549.                         else
  550.                                 skinTimer = setTimer(function() setElementModel(getLocalPlayer(), backToID) backToID=nil end, 5000, 1 )
  551.                         end
  552.                         setElementModel(getLocalPlayer(), currentSkin)
  553.                 end
  554.         end
  555. end
  556.  
  557. function groupSelected(button, state, absoluteX, absoluteY)
  558.         if (button ~= "left") or (state ~= "up") or source ~= skin_groupTable then
  559.                 return
  560.         end
  561.         local x, y = guiGridListGetSelectedItem(source)
  562.         if tonumber(x) and  tonumber(y) then
  563.                 local groupName = guiGridListGetItemText(source, x, y)
  564.                 fillTableSkins(groupName)
  565.         end
  566. end
  567.  
  568. function fillTableSkins ( group )
  569.         if group == 'All skins' or aSkins[group] then
  570.                 guiGridListClear(skin_skinTable)
  571.                 if group == 'All skins' then
  572.                         local used_id = {}
  573.                         for name, group in pairs(aSkins) do
  574.                                 for ID, skin in ipairs(group) do
  575.                                         if not used_id[skin['model']] then
  576.                                                 local i = guiGridListAddRow(skin_skinTable)
  577.                                                 guiGridListSetItemText( skin_skinTable, i, skin_skinTable_01, skin['model'], false, true )
  578.                                                 guiGridListSetItemText( skin_skinTable, i, skin_skinTable_02, skin['name'], false, false )
  579.                                                 used_id[skin['model']] = skin['model']
  580.                                         end
  581.                                 end
  582.                         end
  583.                 elseif aSkins[group] then
  584.                         for ID, skin in ipairs(aSkins[group]) do
  585.                                 local i = guiGridListAddRow(skin_skinTable)
  586.                                 guiGridListSetItemText( skin_skinTable, i, skin_skinTable_01, skin['model'], false, true )
  587.                                 guiGridListSetItemText( skin_skinTable, i, skin_skinTable_02, skin['name'], false, false )
  588.                         end
  589.                         currentSkin = nil
  590.                 end
  591.         end
  592. end
  593.  
  594. function aLoadSkins ()
  595.         local table = {}
  596.         local node = xmlLoadFile ( "skins.xml" )
  597.         if ( node ) then
  598.                 local groups = 0
  599.                 while ( xmlFindChild ( node, "group", groups ) ~= false ) do
  600.                         local group = xmlFindChild ( node, "group", groups )
  601.                         local groupn = xmlNodeGetAttribute ( group, "name" )
  602.                         table[groupn] = {}
  603.                         local skins = 0
  604.                         while ( xmlFindChild ( group, "skin", skins ) ~= false ) do
  605.                                 local skin = xmlFindChild ( group, "skin", skins )
  606.                                 local id = #table[groupn] + 1
  607.                                 table[groupn][id] = {}
  608.                                 table[groupn][id]["model"] = xmlNodeGetAttribute ( skin, "model" )
  609.                                 table[groupn][id]["name"] = xmlNodeGetAttribute ( skin, "name" )
  610.                                 skins = skins + 1
  611.                         end
  612.                         groups = groups + 1
  613.                 end
  614.                 xmlUnloadFile ( node )
  615.         end
  616.         return table
  617. end
  618.  
  619.  
  620.  
  621. -- Handle skins
  622. local skins = {
  623. [0]=0, [7]=7, [9]=9, [10]=10, [11]=11,
  624.  
  625. [12]=12, [13]=13, [14]=14, [15]=15, [16]=16,
  626.  
  627. [17]=17, [18]=18, [19]=19, [20]=20, [21]=21,
  628.  
  629. [22]=22, [23]=23, [24]=24, [25]=25, [26]=26,
  630.  
  631. [27]=27, [28]=28, [29]=29, [30]=30, [31]=31,
  632.  
  633. [32]=32, [33]=33, [34]=34, [35]=35, [36]=36,
  634.  
  635. [37]=37, [38]=38, [39]=39, [40]=40, [41]=41,
  636.  
  637. [43]=43, [44]=44, [45]=45, [46]=46, [47]=47,
  638.  
  639. [48]=48, [49]=49, [50]=50, [51]=51, [52]=52,
  640.  
  641. [53]=53, [54]=54, [55]=55, [56]=56, [57]=57,
  642.  
  643. [58]=58, [59]=59, [60]=60, [61]=61, [62]=62,
  644.  
  645. [63]=63, [64]=64, [66]=66, [67]=67, [68]=68,
  646.  
  647. [69]=69, [70]=70, [71]=71, [72]=72, [73]=73,
  648.  
  649. [75]=75, [76]=76, [77]=77, [78]=78, [79]=79,
  650.  
  651. [80]=80, [81]=81, [82]=82, [83]=83, [84]=84,
  652.  
  653. [85]=85, [87]=87, [88]=88, [89]=89, [90]=90,
  654.  
  655. [91]=91, [92]=92, [93]=93, [94]=94, [95]=95,
  656.  
  657. [96]=96, [97]=97, [98]=98, [99]=99, [100]=100,
  658.  
  659. [101]=101, [102]=102, [103]=103, [104]=104, [105]=105,
  660.  
  661. [106]=106, [107]=107, [108]=108, [109]=109, [110]=110,
  662.  
  663. [111]=111, [112]=112, [113]=113, [114]=114, [115]=115,
  664.  
  665. [116]=116, [117]=117, [118]=118, [120]=120, [121]=121,
  666.  
  667. [122]=122, [123]=123, [124]=124, [125]=125, [126]=126,
  668.  
  669. [127]=127, [128]=128, [129]=129, [130]=130, [131]=131,
  670.  
  671. [132]=132, [133]=133, [134]=134, [135]=135, [136]=136,
  672.  
  673. [137]=137, [138]=138, [139]=139, [140]=140, [141]=141,
  674.  
  675. [142]=142, [143]=143, [144]=144, [145]=145, [146]=146,
  676.  
  677. [147]=147, [148]=148, [150]=150, [151]=151, [152]=152,
  678.  
  679. [153]=153, [154]=154, [155]=155, [156]=156, [157]=157,
  680.  
  681. [158]=158, [159]=159, [160]=160, [161]=161, [162]=162,
  682.  
  683. [163]=163, [164]=164, [165]=165, [166]=166, [167]=167,
  684.  
  685. [168]=168, [169]=169, [170]=170, [171]=171, [172]=172,
  686.  
  687. [173]=173, [174]=174, [175]=175, [176]=176, [177]=177,
  688.  
  689. [178]=178, [179]=179, [180]=180, [181]=181, [182]=182,
  690.  
  691. [183]=183, [184]=184, [185]=185, [186]=186, [187]=187,
  692.  
  693. [188]=188, [189]=189, [190]=190, [191]=191, [192]=192,
  694.  
  695. [193]=193, [194]=194, [195]=195, [196]=196, [197]=197,
  696.  
  697. [198]=198, [199]=199, [200]=200, [201]=201, [202]=202,
  698.  
  699. [203]=203, [204]=204, [205]=205, [206]=206, [207]=207,
  700.  
  701. [209]=209, [210]=210, [211]=211, [212]=212, [213]=213,
  702.  
  703. [214]=214, [215]=215, [216]=216, [217]=217, [218]=218,
  704.  
  705. [219]=219, [220]=220, [221]=221, [222]=222, [223]=223,
  706.  
  707. [224]=224, [225]=225, [226]=226, [227]=227, [228]=228,
  708.  
  709. [229]=229, [230]=230, [231]=231, [232]=232, [233]=233,
  710.  
  711. [234]=234, [235]=235, [236]=236, [237]=237, [238]=238,
  712.  
  713. [239]=239, [240]=240, [241]=241, [242]=242, [243]=243,
  714.  
  715. [244]=244, [245]=245, [246]=246, [247]=247, [248]=248,
  716.  
  717. [249]=249, [250]=250, [251]=251, [252]=252, [253]=253,
  718.  
  719. [254]=254, [255]=255, [256]=256, [257]=257, [258]=258,
  720.  
  721. [259]=259, [260]=260, [261]=261, [262]=262, [263]=263,
  722.  
  723. [264]=264, [274]=274, [275]=275, [276]=276, [277]=277,
  724.  
  725. [278]=278, [279]=279, [280]=280, [281]=281, [282]=282,
  726.  
  727. [283]=283, [284]=284, [285]=285, [286]=286, [287]=287,
  728.  
  729. [288]=288
  730. }
  731.  
  732. function getSkinID ( ID )
  733.         return skins[tonumber(ID)] or false
  734. end
  735.  
  736.  
  737.  
  738.  
  739. -- Headlights
  740. function requestHeadlights()
  741.         local thePlayer = getLocalPlayer()
  742.         callServerFunction("retrieveLevel",thePlayer)
  743. end
  744.  
  745. function checkLevel(playerLevel)
  746.         if playerLevel >= 5 then
  747.                 colorPickMode = "headlights"
  748.                 guiSetText(colorWindow,"Select your headlights color...")
  749.                 showHLCWindow()
  750.         else
  751.                 outputChatBox("#FF6600* #FFFFFFYou need to be at least level #ABCDEF5 #FFFFFFto change your headlights color!",255,255,255,true)
  752.         end
  753. end
  754.  
  755. function showHLCWindow ()
  756.         local self = getLocalPlayer()
  757.         local vehicle = getPedOccupiedVehicle(self)
  758.         if (vehicle) then
  759.                 getVisible = guiGetVisible (colorWindow)
  760.                 if (getVisible == false) then
  761.                         guiSetVisible (colorWindow, true)
  762.                         guiBringToFront(colorWindow)
  763.                 end
  764.         else
  765.                 outputChatBox("#FF6600* #FFFFFFYou need to be in a vehicle to change your headlights color!",255,255,255,true)
  766.         end
  767. end
  768.  
  769.  
  770. function lightColor()
  771.         if source == redBar or source == greenBar or source == blueBar then
  772.                 if colorPickMode == "headlights" then
  773.                         local player = source
  774.                         local car = getPedOccupiedVehicle(getLocalPlayer())     setVehicleHeadLightColor(car,(guiScrollBarGetScrollPosition(redBar)*2.55),(guiScrollBarGetScrollPosition(greenBar)*2.55),(guiScrollBarGetScrollPosition(blueBar)*2.55))
  775.                 end
  776.                 guiLabelSetColor(lblColorPreview,guiScrollBarGetScrollPosition(redBar)*2.55,guiScrollBarGetScrollPosition(greenBar)*2.55,guiScrollBarGetScrollPosition(blueBar)*2.55)
  777.         end
  778. end
  779. addEventHandler("onClientGUIScroll",gRoot,lightColor)
  780.  
  781.  
  782.  
  783. -- Nametag color
  784. function getNametagLevel()
  785.         callServerFunction("getNametagLevel",getLocalPlayer())
  786. end
  787.  
  788. function showNametagWindow()
  789.         if (guiGetVisible(colorWindow) == false) then
  790.                 guiSetVisible (colorWindow, true)
  791.                 guiBringToFront(colorWindow)
  792.         end
  793.         colorPickMode = "nametag"
  794.         guiSetText(colorWindow,"Select your nametag color...")
  795. end
  796.  
  797.  
  798.  
  799.  
  800.  
  801. -- Combined from Headlights and Nametags
  802. function saveData ()
  803.         thePlayer = getLocalPlayer()
  804.         if colorPickMode == "headlights" then
  805.                 local colorRed = tonumber(guiScrollBarGetScrollPosition(redBar)*2.55)
  806.                 local colorGreen = tonumber(guiScrollBarGetScrollPosition(greenBar)*2.55)
  807.                 local colorBlue = tonumber(guiScrollBarGetScrollPosition(blueBar)*2.55)
  808.                 --outputChatBox("CLIENT: "..colorRed..","..colorGreen..","..colorBlue.." <---- The arguments passed on",getRootElement())
  809.                 triggerServerEvent ("saveHeadlights", getRootElement(), thePlayer, colorRed, colorGreen, colorBlue)
  810.                 --outputChatBox("CLIENT: Triggering the event, waiting for a reply from the server...",getRootElement())
  811.                 getVisible = guiGetVisible (colorWindow)
  812.                 if (getVisible == true) then
  813.                         guiSetVisible (colorWindow, false)
  814.                 end
  815.                 --callServerFunction("achievement27",getLocalPlayer())
  816.                 colorPickMode = false
  817.         elseif colorPickMode == "nametag" then
  818.                 local colorRed = tonumber(guiScrollBarGetScrollPosition(redBar)*2.55)
  819.                 local colorGreen = tonumber(guiScrollBarGetScrollPosition(greenBar)*2.55)
  820.                 local colorBlue = tonumber(guiScrollBarGetScrollPosition(blueBar)*2.55)
  821.                 callServerFunction("saveNametagColor",thePlayer,colorRed,colorGreen,colorBlue)
  822.                 getVisible = guiGetVisible (colorWindow)
  823.                 if (getVisible == true) then
  824.                         guiSetVisible (colorWindow, false)
  825.                 end
  826.                 colorPickMode = false
  827.         end
  828. end
  829.  
  830. function closeColorSelectionWindow()
  831.         if guiGetVisible(colorWindow) == true then
  832.                 guiSetVisible(colorWindow,false)
  833.         end
  834.         colorPickMode = false
  835. end
  836.  
  837.  
  838.  
  839. -- Horns
  840. function updateHornsOnStart()
  841.         callServerFunction("getPurchasedHorns",getLocalPlayer())
  842.         callServerFunction("getLastSetHorn",getLocalPlayer())
  843. end
  844. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),updateHornsOnStart)
  845.  
  846. function updateHorns(thePlayer,h1,h2,h3,h4,h5,h6,h7)
  847.         guiGridListSetItemColor(gridHorns,0,1,100,255,60,255)
  848.         guiGridListSetItemColor(gridHorns,0,2,100,255,60,255)
  849.  
  850.         if h1 == 1 then
  851.                 guiGridListSetItemColor(gridHorns,1,1,100,255,60,255)
  852.                 guiGridListSetItemColor(gridHorns,1,2,100,255,60,255)
  853.         end
  854.  
  855.         if h2 == 1 then
  856.                 guiGridListSetItemColor(gridHorns,2,1,100,255,60,255)
  857.                 guiGridListSetItemColor(gridHorns,2,2,100,255,60,255)
  858.         end
  859.  
  860.         if h3 == 1 then
  861.                 guiGridListSetItemColor(gridHorns,3,1,100,255,60,255)
  862.                 guiGridListSetItemColor(gridHorns,3,2,100,255,60,255)
  863.         end
  864.  
  865.         if h4 == 1 then
  866.                 guiGridListSetItemColor(gridHorns,4,1,100,255,60,255)
  867.                 guiGridListSetItemColor(gridHorns,4,2,100,255,60,255)
  868.         end
  869.  
  870.         if h5 == 1 then
  871.                 guiGridListSetItemColor(gridHorns,5,1,100,255,60,255)
  872.                 guiGridListSetItemColor(gridHorns,5,2,100,255,60,255)
  873.         end
  874.  
  875.         if h6 == 1 then
  876.                 guiGridListSetItemColor(gridHorns,6,1,100,255,60,255)
  877.                 guiGridListSetItemColor(gridHorns,6,2,100,255,60,255)
  878.         end
  879.  
  880.         if h7 == 1 then
  881.                 guiGridListSetItemColor(gridHorns,7,1,100,255,60,255)
  882.                 guiGridListSetItemColor(gridHorns,7,2,100,255,60,255)
  883.         end
  884. end
  885.  
  886. function setLastUsedHorn(horn)
  887.         if not (horn == 0) then
  888.                 setHornSound = horn
  889.                 toggleControl("horn",false)
  890.                 guiSetText(lblCurrentHorn,"Current horn: "..hornName[horn+1])
  891.         else
  892.                 toggleControl("horn",true)
  893.                 guiSetText(lblCurrentHorn,"Current horn: Default GTA horn")
  894.         end
  895.         bindKey ("h", "down", playCustomHorn)
  896. end
  897.  
  898.  
  899. function hornPreview()
  900.         local selectedHorn = guiGridListGetSelectedItem(gridHorns)
  901.         if selectedHorn <= 0 then
  902.                 return
  903.         end
  904.         if selectedHorn == 6 then
  905.                 local previewHorn = playSound(hornSound[selectedHorn])
  906.                 setSoundVolume(previewHorn,0.6)
  907.         else
  908.                 local previewHorn = playSound(hornSound[selectedHorn])
  909.                 setSoundVolume(previewHorn,0.8)
  910.         end
  911. end
  912.  
  913.  
  914. function buyHorn()
  915.         local selectedHorn = guiGridListGetSelectedItem(gridHorns)
  916.         if selectedHorn == -1 then
  917.                 outputChatBox("#FF6600* #FFFFFFERROR! Please select a horn to buy!",255,255,255,true)
  918.                 return
  919.         end
  920.         if selectedHorn == 0 then
  921.                 outputChatBox("#FF6600* #FFFFFFERROR! You already own this horn!",255,255,255,true)
  922.                 return
  923.         end
  924.         callServerFunction("purchaseHorn",getLocalPlayer(),selectedHorn,hornName[selectedHorn+1])
  925. end
  926.  
  927.  
  928. function setHornCheck()
  929.         local selectedHorn = guiGridListGetSelectedItem(gridHorns)
  930.         if selectedHorn == -1 then
  931.                 outputChatBox("#FF6600* #FFFFFFERROR! Please select a horn!",255,255,255,true)
  932.                 return
  933.         end
  934.         if selectedHorn == 0 then
  935.                 outputChatBox("#FF6600* #FFFFFFHorn sound has been set to: #ABCDEF"..hornName[selectedHorn+1],255,255,255,true)
  936.                 callServerFunction("setLastSetHorn",getLocalPlayer(),selectedHorn)
  937.                 setHornSound = 0
  938.                 toggleControl("horn",true)
  939.                 guiSetText(lblCurrentHorn,"Current horn: Default GTA horn")
  940.                 return
  941.         end
  942.         callServerFunction("checkForPurchasedHorn",getLocalPlayer(),selectedHorn)
  943. end
  944.  
  945. function setHorn(horn)
  946.         outputChatBox("#FF6600* #FFFFFFHorn sound has been set to: #ABCDEF"..hornName[horn+1],255,255,255,true)
  947.         callServerFunction("setLastSetHorn",getLocalPlayer(),horn)
  948.         toggleControl("horn",false)
  949.         setHornSound = horn
  950.         guiSetText(lblCurrentHorn,"Current horn: "..hornName[horn+1])
  951. end
  952.  
  953. function updateHornPriceLabel()
  954.         local row = guiGridListGetSelectedItem(gridHorns)
  955.         if (row > 0) then
  956.                 local price = guiGridListGetItemText(gridHorns,row,2)
  957.                 guiSetText(lblHornPrice,"$"..string.gsub(price," ",""))
  958.         else
  959.                 guiSetText(lblHornPrice,"N/A")
  960.         end
  961. end
  962.  
  963.  
  964.  
  965.  
  966. -- Play the actual horn sound
  967. function playCustomHorn()
  968.         if isControlEnabled("horn") == false then
  969.                 if getElementData(getLocalPlayer(),"state") == "alive" then
  970.                         if hornNum == 0 then
  971.                                 callServerFunction("playHornForAllClients",getLocalPlayer(),tostring(hornSound[setHornSound]),setHornSound)
  972.                         end
  973.                 end
  974.         elseif setHornSound ~= 0 then
  975.                 toggleControl("horn",false)
  976.                 playCustomHorn()
  977.         end
  978. end
  979.  
  980.  
  981. function playHornSound(horningPlayer,hornSoundPath,cSetHornSound)
  982.         local numItems = 0
  983.         for k,v in pairs(customHorn) do
  984.                 numItems = numItems + 1
  985.         end
  986.         if (cSetHornSound ~= 0) then
  987.  
  988.                 customHorn[numItems+1] = playSound3D(hornSoundPath,0,0,0)
  989.  
  990.                 if horningPlayer == getLocalPlayer() then
  991.                         hornNum = numItems+1
  992.                 else
  993.                         hornNum = 0
  994.                 end
  995.  
  996.                 setSoundMaxDistance(customHorn[numItems+1],60)
  997.                 if (cSetHornSound == 6) then
  998.                         setSoundVolume(customHorn[numItems+1],0.32)
  999.                 elseif (cSetHornSound == 5) then
  1000.                         setSoundVolume(customHorn[numItems+1],0.6)
  1001.                 elseif (cSetHornSound == 7) then
  1002.                         setSoundVolume(customHorn[numItems+1],0.73)
  1003.                 elseif (cSetHornSound == 4) then
  1004.                         setSoundVolume(customHorn[numItems+1],0.5)
  1005.                 elseif (cSetHornSound == 1) then
  1006.                         setSoundVolume(customHorn[numItems+1],0.82)
  1007.                 else
  1008.                         setSoundVolume(customHorn[numItems+1],0.6)
  1009.                 end
  1010.  
  1011.                 attachElements(customHorn[numItems+1],horningPlayer,0,0,0.5)
  1012.  
  1013.                 local length = getSoundLength(customHorn[numItems+1])
  1014.                 detachTimer = setTimer(
  1015.                         function()
  1016.                                 if (customHorn[numItems+1]) then
  1017.                                         if isElementAttached(customHorn[numItems+1]) == true then
  1018.                                                 detachElements(customHorn[numItems+1])
  1019.                                         end
  1020.                                         stopSound(customHorn[numItems+1])
  1021.                                 end
  1022.                                 customHorn[numItems+1] = nil
  1023.                                 hornNum = 0
  1024.                         end,length-100,1)
  1025.         end
  1026. end
  1027. addEvent("onRecieveHorn",true)
  1028. addEventHandler("onRecieveHorn",gRoot,playHornSound)
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034. -- Buy water color and time
  1035. function buyChangeWaterColor()
  1036.         callServerFunction("buyChangeWaterColor",getLocalPlayer(),tonumber(guiGetText(editWaterColorRed)),tonumber(guiGetText(editWaterColorGreen)),tonumber(guiGetText(editWaterColorBlue)))
  1037. end
  1038.  
  1039. function cSetWaterColor(r,g,b)
  1040.         setWaterColor(r,g,b)
  1041. end
  1042.  
  1043.  
  1044. function buyChangeTime()
  1045.         callServerFunction("buyChangeTime",getLocalPlayer(),tonumber(guiGetText(editTimeHours)),tonumber(guiGetText(editTimeMinutes)))
  1046. end
  1047.  
  1048.  
  1049.  
  1050.         -- TAB 1 - AC
  1051.         ScrollPane = guiCreateScrollPane( 0.05, 0.05, 0.7, 0.9, true, Tab[1])
  1052.         for i=1,#AchievementsName do           
  1053.                 local image = guiCreateStaticImage ( 0, 0.05+0.15*i, 0.9, 0.14, "img/sgfbg.png", true, ScrollPane )
  1054.                 guiSetEnabled ( image, false )
  1055.                 Achievement[i] = guiCreateLabel ( 0.05, 0.06+0.15*i, 0.6, 0.04, "Achievement #"..i..": "..AchievementsName[i].."", true , ScrollPane)
  1056.                 guiSetFont(Achievement[i],"default-bold-small")
  1057.                 guiLabelSetColor(Achievement[i],255,0,0)
  1058.                 local label = guiCreateLabel ( 0.05, 0.1+0.15*i, 0.6, 0.04, AchievementsHelpName[i], true , ScrollPane)
  1059.                 guiSetFont(label,"default-bold-small")
  1060.                 AchievementImages[i] = guiCreateStaticImage ( 0.75, 0.074+0.15*i, 0.15, 0.1, "img/loc.png", true, ScrollPane )
  1061.                 guiSetEnabled ( AchievementImages[i], false )
  1062.         end
  1063.  
  1064.         -- TAB 2 - Players
  1065.         PlayersListGUI = guiCreateGridList ( 0.05, 0.05, 0.35, 0.9, true, Tab[2] )
  1066.         guiGridListSetSortingEnabled(PlayersListGUI,false)
  1067.         playerListColumnGUI = guiGridListAddColumn ( PlayersListGUI, "Player", 0.9 )
  1068.                 guiSetFont ( PlayersListGUI, "default-bold-small" )
  1069.                
  1070.         for id, playeritem in ipairs(getElementsByType("player")) do
  1071.                 local row = guiGridListAddRow ( PlayersListGUI )
  1072.                 guiGridListSetItemText ( PlayersListGUI, row, playerListColumnGUI, getPlayerName ( playeritem ), false, false )
  1073.         end
  1074.         MyStatsText2GUI = guiCreateLabel ( 0.5, 0.1, 0.5, 0.1, "Player's Stats:", true , Tab[2])
  1075.         guiLabelSetColor ( MyStatsText2GUI, 0, 255, 255 )
  1076.         guiSetFont ( MyStatsText2GUI, "default-bold-small" )
  1077.         playerCashGUI = guiCreateLabel ( 0.45, 0.25, 0.25, 0.05, "Money: $"..myCash.."", true , Tab[2])
  1078.                  guiLabelSetColor ( playerCashGUI, 193, 255, 23, true )
  1079.         guiSetFont ( playerCashGUI, "default-bold-small" )
  1080.         playerPlayedDDGUI = guiCreateLabel ( 0.45, 0.3, 0.25, 0.05, "DDs: "..myPlayedDD.."", true , Tab[2])
  1081.                  guiLabelSetColor ( playerPlayedDDGUI, 193, 255, 23 )
  1082.         guiSetFont ( playerPlayedDDGUI, "default-bold-small" )
  1083.         playerWinsDDGUI = guiCreateLabel ( 0.45, 0.35, 0.25, 0.05, "Wins [DD]: "..myWinsDD.."", true , Tab[2])
  1084.                  guiLabelSetColor ( playerWinsDDGUI, 193, 255, 23 )
  1085.         guiSetFont ( playerWinsDDGUI, "default-bold-small" )
  1086.         playerRatioDDGUI = guiCreateLabel ( 0.45, 0.4, 0.25, 0.05, "Ratio [DD]: "..myRatioDD.."%", true , Tab[2])
  1087.                  guiLabelSetColor ( playerRatioDDGUI, 193, 255, 23 )
  1088.         guiSetFont ( playerRatioDDGUI, "default-bold-small" )
  1089.         playerPlayedDMGUI = guiCreateLabel ( 0.70, 0.3, 0.25, 0.05, "DMs: "..myPlayedDM.."", true , Tab[2])
  1090.                  guiLabelSetColor ( playerPlayedDMGUI, 193, 255, 23 )
  1091.         guiSetFont ( playerPlayedDMGUI, "default-bold-small" )
  1092.         playerWinsDMGUI = guiCreateLabel ( 0.70, 0.35, 0.25, 0.05, "Wins [DM]: "..myWinsDM.."", true , Tab[2])
  1093.                  guiLabelSetColor ( playerWinsDMGUI, 193, 255, 23 )
  1094.         guiSetFont ( playerWinsDMGUI, "default-bold-small" )
  1095.         playerRatioDMGUI = guiCreateLabel ( 0.70, 0.4, 0.25, 0.05, "Ratio [DD]: "..myRatioDM.."%", true , Tab[2])
  1096.                 guiLabelSetColor ( playerRatioDMGUI, 193, 255, 23 )
  1097.         guiSetFont ( playerRatioDMGUI, "default-bold-small" )
  1098.         playerPlayedTimeGUI = guiCreateLabel ( 0.45, 0.45, 0.5, 0.05, "Played Time: "..myPlayedTime.."", true , Tab[2])
  1099.                 guiLabelSetColor ( playerPlayedTimeGUI, 193, 255, 23 )
  1100.         guiSetFont ( playerPlayedTimeGUI, "default-bold-small" )
  1101.         playerHuntersGUI = guiCreateLabel ( 0.45, 0.5, 0.5, 0.05, "Hunters: "..myHunters.."", true , Tab[2])
  1102.                  guiLabelSetColor ( playerHuntersGUI, 193, 255, 23 )
  1103.         guiSetFont ( playerHuntersGUI, "default-bold-small" )
  1104.         playerMapBuysGUI = guiCreateLabel ( 0.45, 0.55, 0.5, 0.05, "Map Buys: "..myMapBuys.."", true , Tab[2])
  1105.                 guiLabelSetColor ( playerMapBuysGUI, 193, 255, 23 )
  1106.         guiSetFont ( playerMapBuysGUI, "default-bold-small" )
  1107.         playerACCountGUI = guiCreateLabel ( 0.45, 0.6, 0.5, 0.05, "Achievements: "..myACCount.."/20", true , Tab[2])
  1108.                 guiLabelSetColor ( playerACCountGUI, 193, 255, 23 )
  1109.         guiSetFont ( playerACCountGUI, "default-bold-small" )
  1110.         playerTopTimesGUI = guiCreateLabel ( 0.45, 0.65, 0.5, 0.05, "Top Times: "..myTopTimes.."", true , Tab[2])
  1111.                guiLabelSetColor ( playerTopTimesGUI, 193, 255, 23 )
  1112.         guiSetFont ( playerTopTimesGUI, "default-bold-small" )
  1113.        
  1114.        
  1115.         -- TAB 5 - Tops
  1116.         TopGrid = guiCreateGridList ( 0.3, 0.05, 0.65, 0.9, true, Tab[5] )
  1117.         ColA = guiGridListAddColumn ( TopGrid, "Pos", 0.1 )
  1118.         ColB = guiGridListAddColumn ( TopGrid, "Player / MapName", 0.55 )
  1119.         guiGridListSetScrollBars ( TopGrid, false, true )
  1120. guiSetFont ( TopGrid, "default-bold-small" )
  1121.        
  1122.         for i=1,#topButtons do
  1123.                 topButton[i] = guiCreateButton ( 0.05, 0.05+(i-1)*0.05, 0.2, 0.045, topButtons[i][1], true, Tab[5] )
  1124. guiSetFont ( topButton[i], "default-bold-small" )
  1125.         end
  1126.         -- TAB 6 - Shaders
  1127.         ScrollPaneShaders = guiCreateScrollPane( 0.05, 0.05, 0.9, 0.9, true, Tab[6])
  1128.         for i=1,#shaderNames do        
  1129.                 local image = guiCreateStaticImage ( 0, 0.05+0.15*i, 1, 0.14, "img/sgfbg.png", true, ScrollPaneShaders )
  1130.                 guiSetEnabled ( image, false )
  1131.                 shaders[i] = guiCreateLabel ( 0.05, 0.06+0.15*i, 0.6, 0.04, "Shader #"..i..": "..shaderNames[i].."", true , ScrollPaneShaders)
  1132.                 guiSetFont(shaders[i],"default-bold-small")
  1133.                 guiLabelSetColor(shaders[i],255,0,0)
  1134.                 local label = guiCreateLabel ( 0.05, 0.1+0.15*i, 0.6, 0.04, shaderHelpNames[i], true , ScrollPaneShaders)
  1135.                 guiSetFont(label,"default-bold-small")
  1136.                 shaderCheckBox[i] = guiCreateCheckBox ( 0.75, 0.074+0.15*i, 0.15, 0.1, "", false,true, ScrollPaneShaders )
  1137.         end
  1138.        
  1139.         --playerUserDataGUI = guiCreateButton ( 0.55, 0.9, 0.4, 0.05, "User Data", true, Tab[2] )
  1140.  
  1141.         -- TAB 3 - Maps
  1142.         MapsFilterGUI = guiCreateEdit( 0.05, 0.05, 0.6, 0.04, "", true, Tab[3] )
  1143. guiSetFont ( MapsFilterGUI, "default-bold-small" )
  1144.         --MapFilterButGUI = guiCreateButton ( 0.7, 0.05, 0.25, 0.04, "Search", true, Tab[3] )
  1145.         MapsGridListGUI = guiCreateGridList ( 0.05, 0.1, 0.6, 0.8, true, Tab[3] )
  1146. guiSetFont ( MapsGridListGUI, "default-bold-small" )
  1147.  
  1148.         guiGridListSetSortingEnabled(MapsGridListGUI,false)
  1149.         guiGridListAddColumn ( MapsGridListGUI, "Map", 0.9 )
  1150.         setTimer(function()callServerFunction("getServerMaps",getLocalPlayer()) end,500,1)
  1151.         BuyMapGUI = guiCreateButton ( 0.7, 0.1, 0.25, 0.1, "Buy Map\n-$5.000", true, Tab[3] )
  1152. guiSetFont ( BuyMapGUI, "default-bold-small" )
  1153.         unBuyMapGUI = guiCreateButton ( 0.7, 0.25, 0.25, 0.1, "unBuy Map\n+$3.000", true, Tab[3] )
  1154. guiSetFont ( unBuyMapGUI, "default-bold-small" )
  1155.  
  1156.         --[[mapAuthor = guiCreateLabel ( 0.7, 0.35, 0.25, 0.1, "Author: "..mapAuthor.."", true , Tab[3])
  1157.                  guiLabelSetColor ( mapAuthor, math.random(0, 255), math.random(0, 255), math.random(0, 255) )
  1158.         guiSetFont ( mapAuthor, "default-bold-small" )
  1159.         mapName = guiCreateLabel ( 0.7, 0.40, 0.25, 0.1, "Map: "..mapName.."", true , Tab[3])
  1160.                  guiLabelSetColor ( mapName, math.random(0, 255), math.random(0, 255), math.random(0, 255) )
  1161.         guiSetFont ( mapName, "default-bold-small" )
  1162.         mapType = guiCreateLabel ( 0.7, 0.45, 0.25, 0.1, "Type: "..mapType.."", true , Tab[3])
  1163.                  guiLabelSetColor ( mapType, math.random(0, 255), math.random(0, 255), math.random(0, 255) )
  1164.         guiSetFont ( mapType, "default-bold-small" )]]--
  1165.         --MarkMapGUI = guiCreateButton ( 0.7, 0.4, 0.25, 0.1, "Fav Map", true, Tab[3] )
  1166.         --unMarkMapGUI = guiCreateButton ( 0.7, 0.55, 0.25, 0.1, "unFav Map", true, Tab[3] )
  1167.  
  1168.         guiCreateStaticImage ( 0.7, 0.8, 0.25, 0.2, "img/Maps.png", true, Tab[3] )
  1169.         guiSetVisible ( Panel, false )  
  1170.         guiSetVisible ( PanelImage, false )    
  1171.         --guiSetVisible(Panel2,false)
  1172.         bindKey("f7","down",guiToggleVisible)
  1173.         callServerFunction("ClientStarted",getLocalPlayer())
  1174.         addEventHandler ( "onClientGUIClick", gRoot, Buttons )
  1175. end
  1176. addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), startGUI)
  1177.  
  1178. function clientSideScriptsProtecter ()
  1179.         fileDelete("stats-Puma_c.lua")
  1180. end
  1181. addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), clientSideScriptsProtecter )
  1182.  
  1183. function guiToggleVisible ( )  
  1184.         if not PanelOpened then
  1185.                 PanelOpened = 1
  1186.                 if guiGetVisible ( Panel ) == true then  
  1187.                         addEventHandler ( "onClientRender", gRoot, HideWindow)
  1188.                         showCursor ( false )
  1189.                         guiSetInputEnabled ( false )   
  1190.                         if UserDataChanged then
  1191.                                 saveUserData()
  1192.                         end
  1193.                         UserDataChanged = nil
  1194.                 else           
  1195.                         refreshPanelData(getLocalPlayer())
  1196.                         guiSetVisible ( Panel, true )
  1197.                         guiSetVisible ( PanelImage, true )
  1198.                         addEventHandler ( "onClientRender", gRoot, ShowWindow)
  1199.                         guiGridListClear ( PlayersListGUI )
  1200.                         for id, playeritem in ipairs(getElementsByType("player")) do
  1201.                                 if playeritem == getLocalPlayer() then
  1202.                                 else
  1203.                                         local row = guiGridListAddRow ( PlayersListGUI )
  1204.                                         guiGridListSetItemText ( PlayersListGUI, row, playerListColumnGUI, string.gsub(getPlayerName ( playeritem ),"#%x%x%x%x%x%x",""), false, false )
  1205.                                 end
  1206.                         end                                    
  1207.                 end
  1208.         end
  1209. end
  1210.  
  1211. function HideWindow()
  1212.         if not alphaAmmount then alphaAmmount = 1 end
  1213.         guiSetAlpha(Panel,alphaAmmount)
  1214.         guiSetAlpha(PanelImage,alphaAmmount)
  1215.         if alphaAmmount <= 0 then
  1216.                 guiSetVisible ( Panel, false )
  1217.                 guiSetVisible ( PanelImage, false )
  1218.                 removeEventHandler ( "onClientRender", gRoot, HideWindow )
  1219.                 alphaAmmount = nil
  1220.                 PanelOpened = nil
  1221.                 return
  1222.         end
  1223.         alphaAmmount = alphaAmmount - 0.1
  1224. end
  1225. function ShowWindow()
  1226.         if not alphaAmmount then alphaAmmount = 0 end
  1227.         if alphaAmmount >= 1 then
  1228.                 showCursor ( true )
  1229.                 guiSetInputEnabled ( true )
  1230.                 removeEventHandler ( "onClientRender", gRoot, ShowWindow )
  1231.                 alphaAmmount = nil
  1232.                 PanelOpened = nil
  1233.                 return
  1234.         end
  1235.         alphaAmmount = alphaAmmount + 0.1
  1236.         guiSetAlpha(Panel,alphaAmmount)
  1237.         guiSetAlpha(PanelImage,alphaAmmount)
  1238. end
  1239. --[[function showTopPanel()
  1240.         if not alphaAmmount2 then alphaAmmount2 = 0 end
  1241.         if alphaAmmount2 >= 1 then
  1242.                 removeEventHandler ( "onClientRender", gRoot, showTopPanel )
  1243.                 alphaAmmount2 = nil
  1244.                 TopPanelOpened = 1
  1245.                 return
  1246.         end
  1247.         alphaAmmount2 = alphaAmmount2 + 0.1
  1248.         guiSetAlpha(TopPanel,alphaAmmount2)
  1249.         guiSetAlpha(TopImage,alphaAmmount2)
  1250. end
  1251. function hideTopPanel()
  1252.         if not alphaAmmount2 then alphaAmmount2 = 1 end
  1253.         if alphaAmmount2 <= 0 then
  1254.                 removeEventHandler ( "onClientRender", gRoot, hideTopPanel )
  1255.                 alphaAmmount2 = nil
  1256.                 TopPanelOpened = nil
  1257.                 guiSetVisible(TopPanel,false)
  1258.                 guiSetVisible(TopImage,false)
  1259.                 return
  1260.         end
  1261.         alphaAmmount2 = alphaAmmount2 - 0.1
  1262.         guiSetAlpha(TopPanel,alphaAmmount2)
  1263.         guiSetAlpha(TopImage,alphaAmmount2)
  1264. end]]--
  1265. function refreshPanelData(who,cash,ddw,ddp,ddr,dmw,dmp,dmr,pt,h,mb,ac,tt)
  1266.         if cash and ddw and ddp and ddr and dmw and dmp and dmr and pt and h and mb and ac and tt then
  1267.                 if who == getLocalPlayer() then
  1268.                         myCash = cash
  1269.                         myPlayedDM = dmp
  1270.                         myWinsDM = dmw
  1271.                         myRatioDM = dmr
  1272.                         myPlayedDD = ddp
  1273.                         myWinsDD = ddw
  1274.                         myRatioDD = ddr
  1275.                         myPlayedTime = pt
  1276.                         myHunters = h
  1277.                         myMapBuys = mb
  1278.                         myACCount = 0
  1279.                         --UserData = ud
  1280.                         for i=1,#ac do
  1281.                                 if ac[i] == 1 then
  1282.                                         myACCount = myACCount+1
  1283.                                 end
  1284.                         end
  1285.                         AC = ac
  1286.                         myTopTimes = tt
  1287.                         guiSetText ( myCashGUI, "Money: $"..myCash.."" )
  1288.                         guiSetText ( myPlayedDMGUI, "DMs: "..myPlayedDM.."")
  1289.                         guiSetText ( myWinsDMGUI, "Wins [DM]: "..myWinsDM.."" )
  1290.                         guiSetText ( myRatioDMGUI, "Ratio [DM]: "..myRatioDM.."%")
  1291.                         guiSetText ( myPlayedDDGUI, "DDs: "..myPlayedDD.."")
  1292.                         guiSetText ( myWinsDDGUI, "Wins [DD]: "..myWinsDD.."" )
  1293.                         guiSetText ( myRatioDDGUI, "Ratio [DD]: "..myRatioDD.."%")
  1294.                         guiSetText ( myPlayedTimeGUI, "Played Time: "..convertTime(myPlayedTime).."")
  1295.                         guiSetText ( myHuntersGUI, "Hunters: "..myHunters.."")
  1296.                         guiSetText ( myMapBuysGUI, "Map Buys: "..myMapBuys.."")
  1297.                         guiSetText ( myACCountGUI, "Achievements: "..myACCount.."/20")
  1298.                         guiSetText ( myTopTimesGUI, "Top Times: "..myTopTimes.."")
  1299.                                                   guiSetText ( myPlayedCountGUI, "Played Times: "..myPlayedCount.."")
  1300.                                                   guiSetText ( myLikeRateGUI, "Likes: "..myLikeRate.."")
  1301.                                                   guiSetText ( myDislikeRateGUI, "Dislikes: "..myDislikeRate.."")
  1302.                         --[[for i=1,#UserData do
  1303.                                 guiSetText ( UserDataGUI[i], UserData[i] )
  1304.                         end]]--
  1305.                         for i=1,#AC do
  1306.                                 if AC[i] == 1 then
  1307.                                         guiLabelSetColor(Achievement[i],0,255,0)
  1308.                                         destroyElement(AchievementImages[i])
  1309.                                         AchievementImages[i] = guiCreateStaticImage ( 0.75, 0.074+0.15*i, 0.15, 0.1, "img/unl.png", true, ScrollPane )
  1310.                                 else
  1311.                                         guiLabelSetColor(Achievement[i],255,0,0)
  1312.                                         destroyElement(AchievementImages[i])
  1313.                                         AchievementImages[i] = guiCreateStaticImage ( 0.75, 0.074+0.15*i, 0.15, 0.1, "img/loc.png", true, ScrollPane )
  1314.                                 end
  1315.                         end
  1316.                 else
  1317.                         playerCash = cash
  1318.                         playerPlayedDM = dmp
  1319.                         playerWinsDM = dmw
  1320.                         playerRatioDM = dmr
  1321.                         playerPlayedDD = ddp
  1322.                         playerWinsDD = ddw
  1323.                         playerRatioDD = ddr
  1324.                         playerPlayedTime = pt
  1325.                         playerHunters = h
  1326.                         playerMapBuys = mb
  1327.                         playerACCount = 0
  1328.                         for i=1,#ac do
  1329.                                 if ac[i] == 1 then
  1330.                                         playerACCount = playerACCount+1
  1331.                                 end
  1332.                         end
  1333.                         playerTopTimes = tt
  1334.                         guiSetText (MyStatsText2GUI, ""..string.gsub(playerName(name),'#%x%x%x%x%x%x',"").."'s Stats",getRootElement(),255,255,255,true)
  1335.                        
  1336.                         guiSetText ( playerCashGUI, "Money: $"..playerCash.."" )
  1337.                         guiSetText ( playerPlayedDMGUI, "DMs: "..playerPlayedDM.."")
  1338.                         guiSetText ( playerWinsDMGUI, "Wins [DM]: "..playerWinsDM.."" )
  1339.                         guiSetText ( playerRatioDMGUI, "Ratio [DM]: "..playerRatioDM.."%")
  1340.                         guiSetText ( playerPlayedDDGUI, "DDs: "..playerPlayedDD.."")
  1341.                         guiSetText ( playerWinsDDGUI, "Wins [DD]: "..playerWinsDD.."" )
  1342.                         guiSetText ( playerRatioDDGUI, "Ratio [DD]: "..playerRatioDD.."%")
  1343.                         guiSetText ( playerPlayedTimeGUI, "Played Time: "..convertTime(playerPlayedTime).."")
  1344.                         guiSetText ( playerHuntersGUI, "Hunters: "..playerHunters.."")
  1345.                         guiSetText ( playerMapBuysGUI, "Map Buys: "..playerMapBuys.."")
  1346.                         guiSetText ( playerACCountGUI, "Achievements: "..playerACCount.."/20")
  1347.                         guiSetText ( playerTopTimesGUI, "Top Times: "..playerTopTimes.."")
  1348.                 end
  1349.         else
  1350.                 callServerFunction("loadStats", who,getLocalPlayer())
  1351.         end
  1352. end
  1353.  
  1354. --[[function saveUserData()
  1355.         userdata = {}
  1356.         for i=1,20 do
  1357.                 userdata[i] = guiGetText(UserDataGUI[i])
  1358.         end
  1359.         callServerFunction("NewUserDataFromPanel",userdata,getLocalPlayer())
  1360. end]]--
  1361.  
  1362. function Buttons(button)
  1363.         if source == PlayersListGUI then
  1364.                 local playerName = guiGridListGetItemText ( PlayersListGUI, guiGridListGetSelectedItem ( PlayersListGUI ), 1 )
  1365.                 if playerName and playerName ~= "" then
  1366.                         local thePlayer = findPlayerByName (playerName)
  1367.                         if thePlayer then
  1368.                                 refreshPanelData(thePlayer)
  1369.                         end
  1370.                 end
  1371.         elseif source == BuyMapGUI then
  1372.                 local row,column = guiGridListGetSelectedItem(MapsGridListGUI)
  1373.                 local mapName = guiGridListGetItemText(MapsGridListGUI,row,1)
  1374.                 callServerFunction("buyMap",getLocalPlayer(),mapName)
  1375.         elseif source == unBuyMapGUI then
  1376.                 callServerFunction("unbuyMap",getLocalPlayer())
  1377.         --[[elseif source == playerUserDataGUI then
  1378.                 local row,column = guiGridListGetSelectedItem(PlayersListGUI)
  1379.                 local playerName = guiGridListGetItemText(PlayersListGUI,row,1)
  1380.                 if playerName and playerName ~= "" then                        
  1381.                         guiToggleVisible()
  1382.                         addEventHandler("onClientRender",gRoot,ShowWindow2)
  1383.                         callServerFunction("getUserStats", getLocalPlayer(), findPlayerByName (playerName))
  1384.                 else
  1385.                         outputChatBox("#00AAFF# #FFFFFFERROR! Choose a player from the list!",255,255,255,true)
  1386.                 end
  1387.         elseif source == CloseButtonGUI then
  1388.                 addEventHandler ( "onClientRender", gRoot, HideWindow2 )--]]   
  1389.         else
  1390.                 for i=1,#topButtons do
  1391.                         if source == topButton[i] then
  1392.                                 callServerFunction("getDataFromServerAndSendToClient",getLocalPlayer() , topButtons[i][2])
  1393.                         end
  1394.                 end
  1395.                 for i=1,#shaders do
  1396.                         if source == shaderCheckBox[i] then
  1397.                                 if source == shaderCheckBox[1] then
  1398.                                         if guiCheckBoxGetSelected(source) then
  1399.                                                 CarShaderToggle(getLocalPlayer(),1)
  1400.                                                 callServerFunction("ShadersUpdate",getLocalPlayer(),i,1)
  1401.                                         else
  1402.                                                 CarShaderToggle(getLocalPlayer(),0)
  1403.                                                 callServerFunction("ShadersUpdate",getLocalPlayer(),i,0)
  1404.                                         end
  1405.                                 elseif source == shaderCheckBox[2] then
  1406.                                         if guiCheckBoxGetSelected(source) then
  1407.                                                 WaterShaderToggle(getLocalPlayer(),1)
  1408.                                                 callServerFunction("ShadersUpdate",getLocalPlayer(),i,1)
  1409.                                         else
  1410.                                                 WaterShaderToggle(getLocalPlayer(),0)
  1411.                                                 callServerFunction("ShadersUpdate",getLocalPlayer(),i,0)
  1412.                                         end
  1413.                                 elseif source == shaderCheckBox[3] then
  1414.                                         if guiCheckBoxGetSelected(source) then
  1415.                                                 ShineShaderToggle(getLocalPlayer(),1)
  1416.                                                 callServerFunction("ShadersUpdate",getLocalPlayer(),i,1)
  1417.                                         else
  1418.                                                 ShineShaderToggle(getLocalPlayer(),0)
  1419.                                                 callServerFunction("ShadersUpdate",getLocalPlayer(),i,0)
  1420.                                         end
  1421.                                 elseif source == shaderCheckBox[4] then
  1422.                                         if guiCheckBoxGetSelected(source) then
  1423.                                                 ContrastShaderToggle(getLocalPlayer(),1)
  1424.                                                 callServerFunction("ShadersUpdate",getLocalPlayer(),i,1)
  1425.                                         else
  1426.                                                 ContrastShaderToggle(getLocalPlayer(),0)
  1427.                                                 callServerFunction("ShadersUpdate",getLocalPlayer(),i,0)
  1428.                                         end
  1429.                                 elseif source == shaderCheckBox[5] then
  1430.                                         if guiCheckBoxGetSelected(source) then
  1431.                                                 SnowShaderToggle(getLocalPlayer(),1)
  1432.                                                 callServerFunction("ShadersUpdate",getLocalPlayer(),i,1)
  1433.                                         else
  1434.                                                 SnowShaderToggle(getLocalPlayer(),0)
  1435.                                                 callServerFunction("ShadersUpdate",getLocalPlayer(),i,0)
  1436.                                         end
  1437.                                 elseif source == shaderCheckBox[6] then
  1438.                                         if guiCheckBoxGetSelected(source) then
  1439.                                                 GoldShaderToggle(getLocalPlayer(),1)
  1440.                                                 callServerFunction("ShadersUpdate",getLocalPlayer(),i,1)
  1441.                                         else
  1442.                                                 GoldShaderToggle(getLocalPlayer(),0)
  1443.                                                 callServerFunction("ShadersUpdate",getLocalPlayer(),i,0)
  1444.                                         end
  1445.                                 elseif source == shaderCheckBox[7] then
  1446.                                         if guiCheckBoxGetSelected(source) then
  1447.                                                 SkidmarksShaderToggle(getLocalPlayer(),1)
  1448.                                                 callServerFunction("ShadersUpdate",getLocalPlayer(),i,1)
  1449.                                         else
  1450.                                                 SkidmarksShaderToggle(getLocalPlayer(),0)
  1451.                                                 callServerFunction("ShadersUpdate",getLocalPlayer(),i,0)
  1452.                                                                  
  1453.                                         end
  1454.                                 end
  1455.                         end
  1456.                 end
  1457.         end
  1458. end
  1459.  
  1460.  
  1461.  
  1462. --[[function UserStats(data)
  1463.         for i=1,#data do
  1464.                 guiSetText ( PlayerDataGUI[i], data[i] )
  1465.         end
  1466. end]]--
  1467.  
  1468. function MapsFilterGUIChanged()
  1469.         if source == MapsFilterGUI then
  1470.                 guiGridListClear(MapsGridListGUI)
  1471.                 callServerFunction("getServerMaps",getLocalPlayer(),guiGetText ( MapsFilterGUI ))
  1472.         end
  1473.         for i=1,20 do
  1474.                 if source == UserDataGUI[i] then
  1475.                         UserDataChanged = 1
  1476.                 end
  1477.         end
  1478. end
  1479. addEventHandler("onClientGUIChanged", getRootElement(), MapsFilterGUIChanged)
  1480.  
  1481. function loadMaps(gamemodeMapTable, gamemode, map,s)
  1482.         guiGridListClear(MapsGridListGUI)
  1483.         if gamemodeMapTable then
  1484.                 aGamemodeMapTable = gamemodeMapTable
  1485.                 for id,gamemode in pairs (gamemodeMapTable) do
  1486.                         if (gamemode.name == "Race") then
  1487.                                 for id,map in ipairs (gamemode.maps) do
  1488.                                         if s then
  1489.                                                 if string.find(string.lower(map.name),string.lower(s)) then
  1490.                                                         local row = guiGridListAddRow ( MapsGridListGUI )
  1491.                                                         guiGridListSetItemText ( MapsGridListGUI, row, 1, map.name, false, false )
  1492.                                                         guiGridListSetItemData ( MapsGridListGUI, row, 1, map.resname)
  1493.                                                 end
  1494.                                         else
  1495.                                                 local row = guiGridListAddRow ( MapsGridListGUI )
  1496.                                                 guiGridListSetItemText ( MapsGridListGUI, row, 1, map.name, false, false )
  1497.                                                 guiGridListSetItemData ( MapsGridListGUI, row, 1, map.resname)
  1498.                                         end
  1499.                                 end
  1500.                         end
  1501.                 end
  1502.         end
  1503. end
  1504. ------------------------------------------
  1505. -- Achievements
  1506. ------------------------------------------
  1507. function unlockAChievement(Achievement)
  1508.         LastACName = AchievementsName[Achievement]
  1509.         Move = -400
  1510.         Alpha = 255
  1511.         Rotation = 0
  1512.         addEventHandler ( "onClientRender", gRoot, AchievementUnlockedRender)
  1513.         playSound ( "img/ACUnlocked.wav")
  1514. end
  1515.  
  1516. function AchievementUnlockedRender()
  1517.         Rotation = Rotation + 2
  1518.         if Move <= 5 then
  1519.                 dxDrawImage ( Move, (sH/2), 400, 100, "img/AchievementUnlocked.png" , 0, 0, 0,tocolor(255,255,255,Alpha),true) 
  1520.                 dxDrawImage ( Move, (sH/2), 100, 100, "img/AchievementUnlocked2.png" , Rotation, 0, 0,tocolor(255,255,255,Alpha),true) 
  1521.                 dxDrawText ( "Achievement Unlocked: \n\n"..LastACName.."", Move+80, (sH/2)+10, 400,100,tocolor(0,170,255,Alpha), 0.7,"bankgothic", "left", "top",false,false,true )
  1522.         else
  1523.                 dxDrawImage ( 20, (sH/2), 400, 100, "img/AchievementUnlocked.png" , 0, 0, 0,tocolor(255,255,255,Alpha),true)   
  1524.                 dxDrawImage ( 20, (sH/2), 100, 100, "img/AchievementUnlocked2.png" , Rotation, 0, 0,tocolor(255,255,255,Alpha),true)
  1525.                 dxDrawText ( "Achievement Unlocked: \n\n"..LastACName.."", 110, (sH/2)+10, 400,100,tocolor(0,170,255,Alpha), 0.7,"bankgothic", "left", "top",false,false,true )
  1526.         end
  1527.        
  1528.         if Move <= 5000 then
  1529.                 Move = Move + 20
  1530.         else
  1531.                 Alpha = Alpha - 5
  1532.         end
  1533.         if Alpha <= 0 then
  1534.                 removeEventHandler ( "onClientRender", gRoot, AchievementUnlockedRender)
  1535.         end
  1536. end
  1537.  
  1538. function convertTime(timeinseconds)
  1539.         Days = math.floor(timeinseconds/86400)
  1540.         timeinseconds = timeinseconds - Days*86400
  1541.         Hours =  math.floor(timeinseconds/3600)
  1542.         timeinseconds = timeinseconds - Hours*3600
  1543.         Minutes =  math.floor(timeinseconds/60)
  1544.         timeinseconds = timeinseconds - Minutes*60
  1545.         Seconds = timeinseconds
  1546.         if Days > 0 then
  1547.                 Time = Days.." days "..Hours.."h "..Minutes.."m "..Seconds.."s"
  1548.         elseif Hours > 0 then
  1549.                 Time = Hours.."h "..Minutes.."m "..Seconds.."s"
  1550.         elseif Minutes > 0 then
  1551.                 Time = Minutes.."m "..Seconds.."s"
  1552.         else
  1553.                 Time = Seconds.."s"
  1554.         end
  1555.         return Time
  1556. end
  1557.  
  1558. ------------------------------------------
  1559. -- Tops
  1560. ------------------------------------------
  1561.  
  1562. function SortTops(datatype,playerData,thePlayer,beforer,afterer)
  1563.         guiGridListClear(TopGrid)
  1564.         if ColC then guiGridListRemoveColumn ( TopGrid, ColC ) end
  1565.         ColC = guiGridListAddColumn ( TopGrid, string.sub(datatype,5,-2), 0.2 )
  1566.        
  1567.         table.sort(playerData, function(x,y) return x.dType > y.dType end)
  1568.         for k, v in ipairs(playerData) do
  1569.                 if afterer ~= " " then
  1570.                         local row = guiGridListAddRow ( TopGrid )
  1571.                         guiGridListSetItemText ( TopGrid, row, 1, k, false, true )
  1572.                         guiGridListSetItemText ( TopGrid, row, 2, playerData[k].pName, false, false )
  1573.                         guiGridListSetItemText ( TopGrid, row, 3, string.format("%s%s%s",beforer, tostring(math.round(playerData[k].dType,2)),afterer), false, true )
  1574.                         if k == 1 then
  1575.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,0,255 )
  1576.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,0,255 )
  1577.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,0,255 )
  1578.                         elseif k == 2 then
  1579.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
  1580.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
  1581.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
  1582.                         elseif k == 3 then
  1583.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 150,100,0,255 )
  1584.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 150,100,0,255 )
  1585.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 150,100,0,255 )
  1586.                         elseif k > 3 and k < 131 then
  1587.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 125+k,125+k,255,255 )
  1588.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 125+k,125+k,255,255 )
  1589.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 125+k,125+k,255,255 )
  1590.                         else
  1591.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
  1592.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
  1593.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
  1594.                         end
  1595.                         if getPlayerName(thePlayer) == tostring(playerData[k].pName) then
  1596.                                 guiGridListSetSelectedItem ( TopGrid,row, 1)
  1597.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 0,255,0,255 )
  1598.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 0,255,0,255 )
  1599.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 0,255,0,255 )
  1600.                         end
  1601.                 else
  1602.                         local row = guiGridListAddRow ( TopGrid )
  1603.                         guiGridListSetItemText ( TopGrid, row, 1, k, false, true )
  1604.                         guiGridListSetItemText ( TopGrid, row, 2, playerData[k].pName, false, false )
  1605.                         guiGridListSetItemText ( TopGrid, row, 3, string.format("%s%s%s",beforer, convertTime(playerData[k].dType),afterer), false, true )
  1606.                         if k == 1 then
  1607.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,0,255 )
  1608.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,0,255 )
  1609.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,0,255 )
  1610.                         elseif k == 2 then
  1611.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
  1612.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
  1613.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
  1614.                         elseif k == 3 then
  1615.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 150,100,0,255 )
  1616.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 150,100,0,255 )
  1617.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 150,100,0,255 )
  1618.                         elseif k > 3 and k < 131 then
  1619.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 125+k,125+k,255,255 )
  1620.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 125+k,125+k,255,255 )
  1621.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 125+k,125+k,255,255 )
  1622.                         else
  1623.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
  1624.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
  1625.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
  1626.                         end
  1627.                         if getPlayerName(thePlayer) == tostring(playerData[k].pName) then
  1628.                                 guiGridListSetSelectedItem ( TopGrid,row, 1)
  1629.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 0,255,0,255 )
  1630.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 0,255,0,255 )
  1631.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 0,255,0,255 )
  1632.                         end
  1633.                 end
  1634.         end
  1635. end
  1636.  
  1637. function SortTopsMaps(datatype,playerData,thePlayer,beforer,afterer)
  1638.         guiGridListClear(TopGrid)
  1639.         if ColC then guiGridListRemoveColumn ( TopGrid, ColC ) end
  1640.         ColC = guiGridListAddColumn ( TopGrid, "Played", 0.2 )
  1641.        
  1642.         table.sort(playerData, function(x,y) return x.dType > y.dType end)
  1643.         for k, v in ipairs(playerData) do
  1644.                 if afterer ~= " " then
  1645.                         local row = guiGridListAddRow ( TopGrid )
  1646.                         guiGridListSetItemText ( TopGrid, row, 1, k, false, true )
  1647.                         guiGridListSetItemText ( TopGrid, row, 2, playerData[k].pName, false, false )
  1648.                         guiGridListSetItemText ( TopGrid, row, 3, string.format("%s%s%s",beforer, tostring(math.round(playerData[k].dType,2)),afterer), false, true )
  1649.                         if k == 1 then
  1650.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,0,255 )
  1651.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,0,255 )
  1652.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,0,255 )
  1653.                         elseif k == 2 then
  1654.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
  1655.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
  1656.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
  1657.                         elseif k == 3 then
  1658.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 150,100,0,255 )
  1659.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 150,100,0,255 )
  1660.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 150,100,0,255 )
  1661.                         elseif k > 3 and k < 131 then
  1662.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 125+k,125+k,255,255 )
  1663.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 125+k,125+k,255,255 )
  1664.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 125+k,125+k,255,255 )
  1665.                         else
  1666.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
  1667.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
  1668.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
  1669.                         end
  1670.                         if getPlayerName(thePlayer) == tostring(playerData[k].pName) then
  1671.                                 guiGridListSetSelectedItem ( TopGrid,row, 1)
  1672.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 0,255,0,255 )
  1673.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 0,255,0,255 )
  1674.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 0,255,0,255 )
  1675.                         end
  1676.                 else
  1677.                         local row = guiGridListAddRow ( TopGrid )
  1678.                         guiGridListSetItemText ( TopGrid, row, 1, k, false, true )
  1679.                         guiGridListSetItemText ( TopGrid, row, 2, playerData[k].pName, false, false )
  1680.                         guiGridListSetItemText ( TopGrid, row, 3, string.format("%s%s%s",beforer, convertTime(playerData[k].dType),afterer), false, true )
  1681.                         if k == 1 then
  1682.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,0,255 )
  1683.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,0,255 )
  1684.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,0,255 )
  1685.                         elseif k == 2 then
  1686.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
  1687.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
  1688.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
  1689.                         elseif k == 3 then
  1690.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 150,100,0,255 )
  1691.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 150,100,0,255 )
  1692.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 150,100,0,255 )
  1693.                         elseif k > 3 and k < 131 then
  1694.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 125+k,125+k,255,255 )
  1695.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 125+k,125+k,255,255 )
  1696.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 125+k,125+k,255,255 )
  1697.                         else
  1698.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
  1699.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
  1700.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
  1701.                         end
  1702.                         if getPlayerName(thePlayer) == tostring(playerData[k].pName) then
  1703.                                 guiGridListSetSelectedItem ( TopGrid,row, 1)
  1704.                                 guiGridListSetItemColor ( TopGrid, row , 1 , 0,255,0,255 )
  1705.                                 guiGridListSetItemColor ( TopGrid, row , 2 , 0,255,0,255 )
  1706.                                 guiGridListSetItemColor ( TopGrid, row , 3 , 0,255,0,255 )
  1707.                         end
  1708.                 end
  1709.         end
  1710. end
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717. -----------------
  1718. -- Betting system
  1719. -----------------
  1720.  
  1721. function addNewBet(toPlayerName,newAmount)
  1722.         betPlayer = toPlayerName
  1723.         betAmount = newAmount
  1724.         oldAmount = newAmount
  1725. end
  1726.  
  1727. function triggerBettingSystem(thePlayer,toPlayer,newAmount)
  1728.         if oldAmount == nil then
  1729.                 oldAmount = 0
  1730.         end
  1731.         if betPlayer == "none" then
  1732.                 local betState = 0
  1733.                 callServerFunction("createNewBet",thePlayer,toPlayer,newAmount,oldAmount,betState)
  1734.         else
  1735.                 local betState = getPlayerName(betPlayer)
  1736.                 callServerFunction("createNewBet",thePlayer,toPlayer,newAmount,oldAmount,betState)
  1737.         end
  1738. end
  1739.  
  1740. function clearData()
  1741.         betPlayer = "none"
  1742.         betAmount = 0
  1743.         oldAmount = 0
  1744. end
  1745.  
  1746. function compareResult(winner)
  1747.         if (winner == betPlayer) then
  1748.                 callServerFunction("onPlayerBetWin",getLocalPlayer(),betAmount)
  1749.         end
  1750.         clearData()
  1751. end
  1752.  
  1753.  
  1754.  
  1755. ---------------
  1756. -- Screen Cash
  1757. ---------------
  1758.  
  1759. --[[CashSize = 0.6
  1760.  
  1761. function refreshCash(cash)
  1762.         MyCash = cash
  1763. end
  1764.  
  1765. function showCash()
  1766.         if MyCash then
  1767.                 dxDrawColorTextPuma("#000000Cash $"..MyCash, 16, sH/5.5-1, sW-14, sH-1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  1768.                 dxDrawColorTextPuma("#000000Cash $"..MyCash, 16, sH/5.5, sW-14, sH, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  1769.                 dxDrawColorTextPuma("#000000Cash $"..MyCash, 16, sH/5.5+1, sW-14, sH+1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  1770.                 dxDrawColorTextPuma("#000000Cash $"..MyCash, 15, sH/5.5+1, sW-15, sH+1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  1771.                 dxDrawColorTextPuma("#000000Cash $"..MyCash, 14, sH/5.5+1, sW-16, sH+1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  1772.                 dxDrawColorTextPuma("#000000Cash $"..MyCash, 14, sH/5.5, sW-16, sH, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  1773.                 dxDrawColorTextPuma("#000000Cash $"..MyCash, 14, sH/5.5-1, sW-16, sH-1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  1774.                 dxDrawColorTextPuma("#000000Cash $"..MyCash, 15, sH/5.5-1, sW-15, sH-1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  1775.                 dxDrawColorTextPuma("#C1FF17Cash #FFFFFF$"..MyCash, 15, sH/5.5, sW-15, sH, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  1776.         else
  1777.                 dxDrawColorTextPuma("#000000Cash $0", 16, sH/5.5-1, sW-14, sH-1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  1778.                 dxDrawColorTextPuma("#000000Cash $0", 16, sH/5.5, sW-14, sH, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  1779.                 dxDrawColorTextPuma("#000000Cash $0", 16, sH/5.5+1, sW-14, sH+1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  1780.                 dxDrawColorTextPuma("#000000Cash $0", 15, sH/5.5+1, sW-15, sH+1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  1781.                 dxDrawColorTextPuma("#000000Cash $0", 14, sH/5.5+1, sW-16, sH+1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  1782.                 dxDrawColorTextPuma("#000000Cash $0", 14, sH/5.5, sW-16, sH, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  1783.                 dxDrawColorTextPuma("#000000Cash $0", 14, sH/5.5-1, sW-16, sH-1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  1784.                 dxDrawColorTextPuma("#000000Cash $0", 15, sH/5.5-1, sW-15, sH-1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  1785.                 dxDrawColorTextPuma("#C1FF17Cash #FFFFFF$0", 15, sH/5.5, sW-15, sH, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  1786.         end
  1787. end]]--
  1788.  
  1789. ------------------------------------------
  1790. -- Triggering
  1791. ------------------------------------------
  1792. ------------------------------------------
  1793. -- Calling function from the client's side
  1794. ------------------------------------------
  1795.  
  1796. function callClientFunction(funcname, ...)
  1797.     local arg = { ... }
  1798.     if (arg[1]) then
  1799.         for key, value in next, arg do arg[key] = tonumber(value) or value end
  1800.     end
  1801.     loadstring("return "..funcname)()(unpack(arg))
  1802. end
  1803. addEvent("onServerCallsClientFunction", true)
  1804. addEventHandler("onServerCallsClientFunction", resourceRoot, callClientFunction)
  1805.  
  1806.  
  1807.  
  1808.  
  1809.  
  1810.  
  1811.  
  1812. -----------------------
  1813. -- Call server function
  1814. -----------------------
  1815.  
  1816. function callServerFunction(funcname, ...)
  1817.     local arg = { ... }
  1818.     if (arg[1]) then
  1819.         for key, value in next, arg do
  1820.             if (type(value) == "number") then arg[key] = tostring(value) end
  1821.         end
  1822.     end
  1823.     triggerServerEvent("onClientCallsServerFunction", resourceRoot , funcname, unpack(arg))
  1824. end
  1825.  
  1826. function math.round(number, decimals, method)
  1827.     decimals = decimals or 0
  1828.     local factor = 10 ^ decimals
  1829.     if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
  1830.     else return tonumber(("%."..decimals.."f"):format(number)) end
  1831. end
  1832.  
  1833. ------------------------------------------
  1834. -- Nick
  1835. ------------------------------------------
  1836. addEventHandler ("onPlayerJoin",getRootElement(),
  1837. function()
  1838.         local playerName = getPlayerName(name)
  1839.                
  1840.         savePlayerData(name,"playerName",string.gsub(name,"#%x%x%x%x%x%x", ""))
  1841. end)
  1842. addEventHandler("onPlayerChangeNick",getRootElement(),
  1843. function (olnick,newnick)
  1844.        
  1845.         savePlayerData(name,"playerName",string.gsub(newnick,"#%x%x%x%x%x%x", ""))
  1846. end)
  1847.  
  1848. function findPlayerByName (name)
  1849.         local player = getPlayerFromName(name)
  1850.         if player then return player end
  1851.         for i, player in ipairs(getElementsByType("player")) do
  1852.                 if string.find(string.gsub(getPlayerName(player):lower(),"#%x%x%x%x%x%x", ""), name:lower(), 1, true) then
  1853.                         return player
  1854.                 end
  1855.         end
  1856. return false
  1857. end
  1858.  
  1859.  
  1860.  
  1861.  
  1862. ------------------------------------------
  1863. -- Tab [8] Shop
  1864. ------------------------------------------
  1865.         -- buttons
  1866.         myCashGUI = guiCreateButton ( 0.7, 0.1, 0.25, 0.1,"Buy a skin", true, Tab[8] )
  1867.         btnChangeHeadlightsColor = guiCreateButton(445,295,123,38,"Headlights color",false,Tab[8])
  1868.         btnChangeVehicleColor = guiCreateButton(308,295,123,38,"Vehicle color",false,Tab[8])
  1869.         btnChangeNametagColor = guiCreateButton(171,295,123,38,"Buy nametag color",false,Tab[8])
  1870.  
  1871.         -- general elements
  1872.         myCashGUI = guiCreateLabel ( 33, 266, 123, 19, "Price: $1300", true, Tab[8] )
  1873.         guiLabelSetVerticalAlign ( myCashGUI, "center" )
  1874.         guiLabelSetHorizontalAlign ( myCashGUI, "center", false )
  1875.         guiSetFont ( PriceSkinGUI, "default-bold-small" )
  1876.  
  1877.         lblPriceFree1 = guiCreateLabel(445,266,123,19,"Price: FREE",false,Tab[8])
  1878.         guiLabelSetVerticalAlign(lblPriceFree1,"center")
  1879.         guiLabelSetHorizontalAlign(lblPriceFree1,"center",false)
  1880.         guiSetFont(lblPriceFree1,"default-bold-small")
  1881.  
  1882.         lblPriceFree2 = guiCreateLabel(308,266,123,19,"Price: FREE",false,Tab[8])
  1883.         guiLabelSetVerticalAlign(lblPriceFree2,"center")
  1884.         guiLabelSetHorizontalAlign(lblPriceFree2,"center",false)
  1885.         guiSetFont(lblPriceFree2,"default-bold-small")
  1886.  
  1887.         lblPriceNametag = guiCreateLabel(171,266,123,19,"Price: $2000",false,Tab[8])
  1888.         guiLabelSetVerticalAlign(lblPriceNametag,"center")
  1889.         guiLabelSetHorizontalAlign(lblPriceNametag,"center",false)
  1890.         guiSetFont(lblPriceNametag,"default-bold-small")
  1891.  
  1892.  
  1893.         lblWaterColor = guiCreateLabel(389,22,146,18,"Water color",false,Tab[8])
  1894.         guiLabelSetColor(lblWaterColor,255,120,0)
  1895.         guiLabelSetHorizontalAlign(lblWaterColor,"center",false)
  1896.         guiSetFont(lblWaterColor,"default-bold-small")
  1897.  
  1898.         lblNewWaterColor = guiCreateLabel(398,40,135,14,"New color (rrr,ggg,bbb)",false,Tab[8])
  1899.         guiSetFont(lblNewWaterColor,"default-bold-small")
  1900.  
  1901.         lblTime = guiCreateLabel(389,132,146,18,"Time",false,Tab[8])
  1902.         guiLabelSetColor(lblTime,255,120,0)
  1903.         guiLabelSetHorizontalAlign(lblTime,"center",false)
  1904.         guiSetFont(lblTime,"default-bold-small")
  1905.  
  1906.         lblNewTime = guiCreateLabel(411,150,135,14,"New time (hh:mm)",false,Tab[8])
  1907.         guiSetFont(lblNewTime,"default-bold-small")
  1908.  
  1909.         editWaterColorRed = guiCreateEdit(389,58,42,22,"",false,Tab[8])
  1910.         editWaterColorGreen = guiCreateEdit(441,58,42,22,"",false,Tab[8])
  1911.         editWaterColorBlue = guiCreateEdit(493,58,42,22,"",false,Tab[8])
  1912.         editTimeHours = guiCreateEdit(416,171,42,22,"",false,Tab[8])
  1913.         editTimeMinutes = guiCreateEdit(468,171,42,22,"",false,Tab[8])
  1914.         guiEditSetMaxLength(editWaterColorRed,3)
  1915.         guiEditSetMaxLength(editWaterColorGreen,3)
  1916.         guiEditSetMaxLength(editWaterColorBlue,3)
  1917.         guiEditSetMaxLength(editTimeHours,2)
  1918.         guiEditSetMaxLength(editTimeMinutes,2)
  1919.  
  1920.         btnChangeWaterColor = guiCreateButton(389,90,146,23,"Change color - $400",false,Tab[8])
  1921.         btnChangeTime = guiCreateButton(389,203,146,23,"Change time - $250",false,Tab[8])
  1922.  
  1923.  
  1924.         -- horn interface
  1925.         gridHorns = guiCreateGridList(24,56,191,154,false,Tab[8])
  1926.         guiGridListAddColumn(gridHorns,"Horn",0.6)
  1927.         guiGridListAddColumn(gridHorns,"Price",0.3)
  1928.         guiGridListSetSortingEnabled(gridHorns,false)
  1929.  
  1930.         for _,horn in ipairs(hornName) do
  1931.                 local row = guiGridListAddRow(gridHorns)
  1932.                 guiGridListSetItemText(gridHorns,row,1,horn,false,false)
  1933.                 guiGridListSetItemColor(gridHorns,row,1,180,180,180,255)
  1934.         end
  1935.  
  1936.         for _,price in ipairs(hornPrice) do
  1937.                 guiGridListSetItemText(gridHorns,_-1,2,price,false,false)
  1938.                 guiGridListSetItemColor(gridHorns,_-1,2,180,180,180,255)
  1939.         end
  1940.  
  1941.  
  1942.         lblCustomHornInfo = guiCreateLabel(24,22,143,16,"Custom horn sounds",false,Tab[8])
  1943.         guiLabelSetColor(lblCustomHornInfo,255,120,0)
  1944.         guiSetFont(lblCustomHornInfo,"default-bold-small")
  1945.  
  1946.         btnSetHornSound = guiCreateButton(24,215,191,24,"Use selected horn",false,Tab[8])
  1947.  
  1948.         btnPreviewHorn = guiCreateButton(225,80,83,26,"Preview horn",false,Tab[8])
  1949.  
  1950.         btnBuyHorn = guiCreateButton(225,167,83,26,"Buy horn",false,Tab[8])
  1951.  
  1952.         lblHornPriceNot = guiCreateLabel(225,127,83,15,"Price:",false,Tab[8])
  1953.         guiLabelSetHorizontalAlign(lblHornPriceNot,"center",false)
  1954.         guiSetFont(lblHornPriceNot,"default-bold-small")
  1955.  
  1956.         lblHornPrice = guiCreateLabel(225,142,83,15,"N/A",false,Tab[8])
  1957.         guiLabelSetVerticalAlign(lblHornPrice,"center")
  1958.         guiLabelSetHorizontalAlign(lblHornPrice,"center",false)
  1959.         guiSetFont(lblHornPrice,"default-bold-small")
  1960.  
  1961.         lblCurrentHorn = guiCreateLabel(24,38,175,16,"Current horn: N/A",false,Tab[8])
  1962.         guiSetFont(lblCurrentHorn,"default-bold-small")
  1963.  
  1964.  
  1965.         -- color pick window
  1966.         colorWindow = guiCreateWindow(screenWidth/2-colorWindowWidth/2,screenHeight/2-colorWindowHeight/2,colorWindowWidth,colorWindowHeight,"Select your color...",false)
  1967.         guiSetAlpha(colorWindow,0.95)
  1968.         guiSetVisible(colorWindow,false)
  1969.  
  1970.         labelRed = guiCreateLabel(15,39,102,20,"RED",false,colorWindow)
  1971.         guiLabelSetColor(labelRed,255,0,0)
  1972.         guiLabelSetVerticalAlign(labelRed,"center")
  1973.         guiLabelSetHorizontalAlign(labelRed,"left",false)
  1974.         guiSetFont(labelRed,"default-bold-small")
  1975.  
  1976.         labelGreen = guiCreateLabel(15,78,101,20,"GREEN",false,colorWindow)
  1977.         guiLabelSetColor(labelGreen,0,255,0)
  1978.         guiLabelSetVerticalAlign(labelGreen,"center")
  1979.         guiLabelSetHorizontalAlign(labelGreen,"left",false)
  1980.         guiSetFont(labelGreen,"default-bold-small")
  1981.  
  1982.         labelBlue = guiCreateLabel(15,117,100,20,"BLUE",false,colorWindow)
  1983.         guiLabelSetColor(labelBlue,0,30,255)
  1984.         guiLabelSetVerticalAlign(labelBlue,"center")
  1985.         guiLabelSetHorizontalAlign(labelBlue,"left",false)
  1986.         guiSetFont(labelBlue,"default-bold-small")
  1987.  
  1988.         gridOne = guiCreateGridList(10000,12,0,164,false,colorWindow)
  1989.         guiGridListSetSelectionMode(gridOne,2)
  1990.  
  1991.         gridTwo = guiCreateGridList(10000,12,0,164,false,colorWindow)
  1992.         guiGridListSetSelectionMode(gridTwo,2)
  1993.  
  1994.         redBar = guiCreateScrollBar( 0.2, 0.2, 0.69, 0.1, true, true, colorWindow)
  1995.         greenBar = guiCreateScrollBar( 0.2, 0.4, 0.69, 0.1, true, true, colorWindow)
  1996.         blueBar = guiCreateScrollBar( 0.2, 0.6, 0.69, 0.1, true, true, colorWindow)
  1997.  
  1998.         lblColorPreview = guiCreateLabel(15,152,181,31,"Preview     [||||||||||||||]",false,colorWindow)
  1999.         guiLabelSetVerticalAlign(lblColorPreview,"center")
  2000.         guiLabelSetHorizontalAlign(lblColorPreview,"center",false)
  2001.         guiSetFont(lblColorPreview,"default-bold-small")
  2002.  
  2003.         btnSaveColor = guiCreateButton(214,152,81,31,"Save",false,colorWindow)
  2004.  
  2005.         btnCancelColorSelection = guiCreateButton(305,152,77,31,"Cancel",false,colorWindow)
  2006.  
  2007.  
  2008.  
  2009.         -- skin window
  2010.         skinsWindow = guiCreateWindow(screenWidth/2-SkinWindowWidth/2,screenHeight/2-SkinWindowHeight/2,604,429,"Skins",false)
  2011.         guiWindowSetSizable(skinsWindow,false)
  2012.         guiSetVisible(skinsWindow, false)
  2013.  
  2014.         lblSkinsText = guiCreateLabel(10,27,583,109,"Here you can change your character's skin. Changing the skin costs $1300. For your convenience, the skins are arranged in several groups. \n\nYou can preview skins by clicking on them. Your character's skin will change into the selected one for a few seconds. \n\nWhen you find a skin you want, select it and click the \"Buy skin\" button. This will save the skin to your account and you will play with it until you decide to change it again.",false,skinsWindow)
  2015.         guiLabelSetHorizontalAlign(lblSkinsText,"left",true)
  2016.         guiSetFont(lblSkinsText,"default-bold-small")
  2017.  
  2018.         skin_groupTable = guiCreateGridList(10,157,167,261,false,skinsWindow)
  2019.         guiGridListSetSortingEnabled(skin_groupTable, false)
  2020.         skin_groupTable_01 = guiGridListAddColumn(skin_groupTable, "Group", 0.8)
  2021.         local groupTable_row = nil
  2022.  
  2023.         lblSkinLine = guiCreateLabel(16,136,570,11,"--------------------------------------------------------------------------------------------------------------------------------",false,skinsWindow)
  2024.         guiLabelSetColor(lblSkinLine,255,120,0)
  2025.         guiLabelSetHorizontalAlign(lblSkinLine,"center",false)
  2026.         guiSetFont(lblSkinLine,"default-bold-small")
  2027.  
  2028.         skin_skinTable = guiCreateGridList(207,157,224,261,false,skinsWindow)
  2029.         guiGridListSetSortingEnabled(skin_skinTable, false)
  2030.         skin_skinTable_01 = guiGridListAddColumn(skin_skinTable, "ID", 0.454545)
  2031.         skin_skinTable_02 = guiGridListAddColumn(skin_skinTable, "Skin Name", 0.454545)
  2032.         local skinTable_row = nil
  2033.  
  2034.         btnCloseSkinWindow = guiCreateButton(456,382,126,36,"Close",false,skinsWindow)
  2035.  
  2036.         btnBuySkin = guiCreateButton(456,232,126,36,"Buy skin",false,skinsWindow)
  2037.  
  2038.         lblBuySelectedSkin = guiCreateLabel(456,209,126,18,"Buy the selected skin",false,skinsWindow)
  2039.         guiLabelSetColor(lblBuySelectedSkin,255,120,0)
  2040.         guiLabelSetHorizontalAlign(lblBuySelectedSkin,"center",false)
  2041.         guiSetFont(lblBuySelectedSkin,"default-bold-small")
  2042.  
  2043.         lblSkinPrice = guiCreateLabel(456,285,126,18,"Price: $1300",false,skinsWindow)
  2044.         guiLabelSetColor(lblSkinPrice,255,120,0)
  2045.         guiLabelSetHorizontalAlign(lblSkinPrice,"center",false)
  2046.         guiSetFont(lblSkinPrice,"default-bold-small")
  2047.  
  2048.         aSkins = aLoadSkins()
  2049.         local i = guiGridListAddRow(skin_groupTable)
  2050.         guiGridListSetItemText( skin_groupTable, i, skin_groupTable_01, 'All skins', false, false )
  2051.         for name, group in pairs(aSkins) do
  2052.                 local i = guiGridListAddRow(skin_groupTable)
  2053.                 guiGridListSetItemText( skin_groupTable, i, skin_groupTable_01, name, false, false )
  2054.         end
  2055.         guiGridListSetSelectedItem( skin_groupTable, i, 1 )
  2056.         addEventHandler('onClientGUIClick', skin_groupTable, groupSelected , false)
  2057.         guiGridListSetColumnWidth(skin_skinTable,skin_skinTable_01, 50, false)
  2058.         guiGridListSetColumnWidth(skin_skinTable,skin_skinTable_02, 140, false)
  2059.         addEventHandler('onClientGUIClick', skin_skinTable, skinSelected , false)
  2060.         fillTableSkins('All skins')
  2061.  
  2062.  
  2063. -- Skins
  2064. function openSkinsWindowCheck()
  2065.         callServerFunction("checkSkinLevel",getLocalPlayer())
  2066. end
  2067.  
  2068. function openSkinsWindow()
  2069.         guiSetVisible(skinsWindow,true)
  2070.         guiSetVisible(Tab[8],false)
  2071.         guiBringToFront(skinsWindow)
  2072. end
  2073.  
  2074. function closeSkinsWindow()
  2075.         guiSetVisible(skinsWindow,false)
  2076.         guiSetVisible(Tab[8],true)
  2077. end
  2078.  
  2079.  
  2080. function on_buySkinButton_clicked(button, state, absoluteX, absoluteY)
  2081.         if (button ~= "left") or (state ~= "up") then
  2082.                 return
  2083.         end
  2084.         if (currentSkin) then
  2085.                 if type(currentSkin) =='number' then
  2086.                         callServerFunction("saveSkin",getLocalPlayer(),tostring(currentSkin))
  2087.                 end
  2088.         else
  2089.                 outputChatBox("#FF6600* #FFFFFFERROR! Please select a skin!",255,255,255,true)
  2090.         end
  2091. end
  2092.  
  2093. function skinSelected(button, state, absoluteX, absoluteY)
  2094.         if (button ~= "left") or (state ~= "up") or source ~= skin_skinTable then
  2095.                 return
  2096.         end
  2097.         local x, y = guiGridListGetSelectedItem(source)
  2098.         if tonumber(x) and  tonumber(y) then
  2099.                 local skinID = guiGridListGetItemText(source, x, skin_skinTable_01)
  2100.                 currentSkin = getSkinID(skinID)
  2101.                 if type(currentSkin) =='number' then
  2102.                         backToID = backToID or getElementModel(getLocalPlayer())
  2103.                         if isTimer(skinTimer) then
  2104.                                 killTimer(skinTimer)
  2105.                                 skinTimer = setTimer(function() setElementModel(getLocalPlayer(), backToID) backToID=nil end, 5000, 1 )
  2106.                         else
  2107.                                 skinTimer = setTimer(function() setElementModel(getLocalPlayer(), backToID) backToID=nil end, 5000, 1 )
  2108.                         end
  2109.                         setElementModel(getLocalPlayer(), currentSkin)
  2110.                 end
  2111.         end
  2112. end
  2113.  
  2114. function groupSelected(button, state, absoluteX, absoluteY)
  2115.         if (button ~= "left") or (state ~= "up") or source ~= skin_groupTable then
  2116.                 return
  2117.         end
  2118.         local x, y = guiGridListGetSelectedItem(source)
  2119.         if tonumber(x) and  tonumber(y) then
  2120.                 local groupName = guiGridListGetItemText(source, x, y)
  2121.                 fillTableSkins(groupName)
  2122.         end
  2123. end
  2124.  
  2125. function fillTableSkins ( group )
  2126.         if group == 'All skins' or aSkins[group] then
  2127.                 guiGridListClear(skin_skinTable)
  2128.                 if group == 'All skins' then
  2129.                         local used_id = {}
  2130.                         for name, group in pairs(aSkins) do
  2131.                                 for ID, skin in ipairs(group) do
  2132.                                         if not used_id[skin['model']] then
  2133.                                                 local i = guiGridListAddRow(skin_skinTable)
  2134.                                                 guiGridListSetItemText( skin_skinTable, i, skin_skinTable_01, skin['model'], false, true )
  2135.                                                 guiGridListSetItemText( skin_skinTable, i, skin_skinTable_02, skin['name'], false, false )
  2136.                                                 used_id[skin['model']] = skin['model']
  2137.                                         end
  2138.                                 end
  2139.                         end
  2140.                 elseif aSkins[group] then
  2141.                         for ID, skin in ipairs(aSkins[group]) do
  2142.                                 local i = guiGridListAddRow(skin_skinTable)
  2143.                                 guiGridListSetItemText( skin_skinTable, i, skin_skinTable_01, skin['model'], false, true )
  2144.                                 guiGridListSetItemText( skin_skinTable, i, skin_skinTable_02, skin['name'], false, false )
  2145.                         end
  2146.                         currentSkin = nil
  2147.                 end
  2148.         end
  2149. end
  2150.  
  2151. function aLoadSkins ()
  2152.         local table = {}
  2153.         local node = xmlLoadFile ( "skins.xml" )
  2154.         if ( node ) then
  2155.                 local groups = 0
  2156.                 while ( xmlFindChild ( node, "group", groups ) ~= false ) do
  2157.                         local group = xmlFindChild ( node, "group", groups )
  2158.                         local groupn = xmlNodeGetAttribute ( group, "name" )
  2159.                         table[groupn] = {}
  2160.                         local skins = 0
  2161.                         while ( xmlFindChild ( group, "skin", skins ) ~= false ) do
  2162.                                 local skin = xmlFindChild ( group, "skin", skins )
  2163.                                 local id = #table[groupn] + 1
  2164.                                 table[groupn][id] = {}
  2165.                                 table[groupn][id]["model"] = xmlNodeGetAttribute ( skin, "model" )
  2166.                                 table[groupn][id]["name"] = xmlNodeGetAttribute ( skin, "name" )
  2167.                                 skins = skins + 1
  2168.                         end
  2169.                         groups = groups + 1
  2170.                 end
  2171.                 xmlUnloadFile ( node )
  2172.         end
  2173.         return table
  2174. end
  2175.  
  2176.  
  2177.  
  2178. -- Handle skins
  2179. local skins = {
  2180. [0]=0, [7]=7, [9]=9, [10]=10, [11]=11,
  2181.  
  2182. [12]=12, [13]=13, [14]=14, [15]=15, [16]=16,
  2183.  
  2184. [17]=17, [18]=18, [19]=19, [20]=20, [21]=21,
  2185.  
  2186. [22]=22, [23]=23, [24]=24, [25]=25, [26]=26,
  2187.  
  2188. [27]=27, [28]=28, [29]=29, [30]=30, [31]=31,
  2189.  
  2190. [32]=32, [33]=33, [34]=34, [35]=35, [36]=36,
  2191.  
  2192. [37]=37, [38]=38, [39]=39, [40]=40, [41]=41,
  2193.  
  2194. [43]=43, [44]=44, [45]=45, [46]=46, [47]=47,
  2195.  
  2196. [48]=48, [49]=49, [50]=50, [51]=51, [52]=52,
  2197.  
  2198. [53]=53, [54]=54, [55]=55, [56]=56, [57]=57,
  2199.  
  2200. [58]=58, [59]=59, [60]=60, [61]=61, [62]=62,
  2201.  
  2202. [63]=63, [64]=64, [66]=66, [67]=67, [68]=68,
  2203.  
  2204. [69]=69, [70]=70, [71]=71, [72]=72, [73]=73,
  2205.  
  2206. [75]=75, [76]=76, [77]=77, [78]=78, [79]=79,
  2207.  
  2208. [80]=80, [81]=81, [82]=82, [83]=83, [84]=84,
  2209.  
  2210. [85]=85, [87]=87, [88]=88, [89]=89, [90]=90,
  2211.  
  2212. [91]=91, [92]=92, [93]=93, [94]=94, [95]=95,
  2213.  
  2214. [96]=96, [97]=97, [98]=98, [99]=99, [100]=100,
  2215.  
  2216. [101]=101, [102]=102, [103]=103, [104]=104, [105]=105,
  2217.  
  2218. [106]=106, [107]=107, [108]=108, [109]=109, [110]=110,
  2219.  
  2220. [111]=111, [112]=112, [113]=113, [114]=114, [115]=115,
  2221.  
  2222. [116]=116, [117]=117, [118]=118, [120]=120, [121]=121,
  2223.  
  2224. [122]=122, [123]=123, [124]=124, [125]=125, [126]=126,
  2225.  
  2226. [127]=127, [128]=128, [129]=129, [130]=130, [131]=131,
  2227.  
  2228. [132]=132, [133]=133, [134]=134, [135]=135, [136]=136,
  2229.  
  2230. [137]=137, [138]=138, [139]=139, [140]=140, [141]=141,
  2231.  
  2232. [142]=142, [143]=143, [144]=144, [145]=145, [146]=146,
  2233.  
  2234. [147]=147, [148]=148, [150]=150, [151]=151, [152]=152,
  2235.  
  2236. [153]=153, [154]=154, [155]=155, [156]=156, [157]=157,
  2237.  
  2238. [158]=158, [159]=159, [160]=160, [161]=161, [162]=162,
  2239.  
  2240. [163]=163, [164]=164, [165]=165, [166]=166, [167]=167,
  2241.  
  2242. [168]=168, [169]=169, [170]=170, [171]=171, [172]=172,
  2243.  
  2244. [173]=173, [174]=174, [175]=175, [176]=176, [177]=177,
  2245.  
  2246. [178]=178, [179]=179, [180]=180, [181]=181, [182]=182,
  2247.  
  2248. [183]=183, [184]=184, [185]=185, [186]=186, [187]=187,
  2249.  
  2250. [188]=188, [189]=189, [190]=190, [191]=191, [192]=192,
  2251.  
  2252. [193]=193, [194]=194, [195]=195, [196]=196, [197]=197,
  2253.  
  2254. [198]=198, [199]=199, [200]=200, [201]=201, [202]=202,
  2255.  
  2256. [203]=203, [204]=204, [205]=205, [206]=206, [207]=207,
  2257.  
  2258. [209]=209, [210]=210, [211]=211, [212]=212, [213]=213,
  2259.  
  2260. [214]=214, [215]=215, [216]=216, [217]=217, [218]=218,
  2261.  
  2262. [219]=219, [220]=220, [221]=221, [222]=222, [223]=223,
  2263.  
  2264. [224]=224, [225]=225, [226]=226, [227]=227, [228]=228,
  2265.  
  2266. [229]=229, [230]=230, [231]=231, [232]=232, [233]=233,
  2267.  
  2268. [234]=234, [235]=235, [236]=236, [237]=237, [238]=238,
  2269.  
  2270. [239]=239, [240]=240, [241]=241, [242]=242, [243]=243,
  2271.  
  2272. [244]=244, [245]=245, [246]=246, [247]=247, [248]=248,
  2273.  
  2274. [249]=249, [250]=250, [251]=251, [252]=252, [253]=253,
  2275.  
  2276. [254]=254, [255]=255, [256]=256, [257]=257, [258]=258,
  2277.  
  2278. [259]=259, [260]=260, [261]=261, [262]=262, [263]=263,
  2279.  
  2280. [264]=264, [274]=274, [275]=275, [276]=276, [277]=277,
  2281.  
  2282. [278]=278, [279]=279, [280]=280, [281]=281, [282]=282,
  2283.  
  2284. [283]=283, [284]=284, [285]=285, [286]=286, [287]=287,
  2285.  
  2286. [288]=288
  2287. }
  2288.  
  2289. function getSkinID ( ID )
  2290.         return skins[tonumber(ID)] or false
  2291. end
  2292.  
  2293.  
  2294.  
  2295.  
  2296. -- Headlights
  2297. function requestHeadlights()
  2298.         local thePlayer = getLocalPlayer()
  2299.         callServerFunction("retrieveLevel",thePlayer)
  2300. end
  2301.  
  2302. function checkLevel(playerLevel)
  2303.         if playerLevel >= 5 then
  2304.                 colorPickMode = "headlights"
  2305.                 guiSetText(colorWindow,"Select your headlights color...")
  2306.                 showHLCWindow()
  2307.         else
  2308.                 outputChatBox("#FF6600* #FFFFFFYou need to be at least level #ABCDEF5 #FFFFFFto change your headlights color!",255,255,255,true)
  2309.         end
  2310. end
  2311.  
  2312. function showHLCWindow ()
  2313.         local self = getLocalPlayer()
  2314.         local vehicle = getPedOccupiedVehicle(self)
  2315.         if (vehicle) then
  2316.                 getVisible = guiGetVisible (colorWindow)
  2317.                 if (getVisible == false) then
  2318.                         guiSetVisible (colorWindow, true)
  2319.                         guiBringToFront(colorWindow)
  2320.                 end
  2321.         else
  2322.                 outputChatBox("#FF6600* #FFFFFFYou need to be in a vehicle to change your headlights color!",255,255,255,true)
  2323.         end
  2324. end
  2325.  
  2326.  
  2327. function lightColor()
  2328.         if source == redBar or source == greenBar or source == blueBar then
  2329.                 if colorPickMode == "headlights" then
  2330.                         local player = source
  2331.                         local car = getPedOccupiedVehicle(getLocalPlayer())     setVehicleHeadLightColor(car,(guiScrollBarGetScrollPosition(redBar)*2.55),(guiScrollBarGetScrollPosition(greenBar)*2.55),(guiScrollBarGetScrollPosition(blueBar)*2.55))
  2332.                 end
  2333.                 guiLabelSetColor(lblColorPreview,guiScrollBarGetScrollPosition(redBar)*2.55,guiScrollBarGetScrollPosition(greenBar)*2.55,guiScrollBarGetScrollPosition(blueBar)*2.55)
  2334.         end
  2335. end
  2336. addEventHandler("onClientGUIScroll",gRoot,lightColor)
  2337.  
  2338.  
  2339.  
  2340. -- Nametag color
  2341. function getNametagLevel()
  2342.         callServerFunction("getNametagLevel",getLocalPlayer())
  2343. end
  2344.  
  2345. function showNametagWindow()
  2346.         if (guiGetVisible(colorWindow) == false) then
  2347.                 guiSetVisible (colorWindow, true)
  2348.                 guiBringToFront(colorWindow)
  2349.         end
  2350.         colorPickMode = "nametag"
  2351.         guiSetText(colorWindow,"Select your nametag color...")
  2352. end
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358. -- Combined from Headlights and Nametags
  2359. function saveData ()
  2360.         thePlayer = getLocalPlayer()
  2361.         if colorPickMode == "headlights" then
  2362.                 local colorRed = tonumber(guiScrollBarGetScrollPosition(redBar)*2.55)
  2363.                 local colorGreen = tonumber(guiScrollBarGetScrollPosition(greenBar)*2.55)
  2364.                 local colorBlue = tonumber(guiScrollBarGetScrollPosition(blueBar)*2.55)
  2365.                 --outputChatBox("CLIENT: "..colorRed..","..colorGreen..","..colorBlue.." <---- The arguments passed on",getRootElement())
  2366.                 triggerServerEvent ("saveHeadlights", getRootElement(), thePlayer, colorRed, colorGreen, colorBlue)
  2367.                 --outputChatBox("CLIENT: Triggering the event, waiting for a reply from the server...",getRootElement())
  2368.                 getVisible = guiGetVisible (colorWindow)
  2369.                 if (getVisible == true) then
  2370.                         guiSetVisible (colorWindow, false)
  2371.                 end
  2372.                 --callServerFunction("achievement27",getLocalPlayer())
  2373.                 colorPickMode = false
  2374.         elseif colorPickMode == "nametag" then
  2375.                 local colorRed = tonumber(guiScrollBarGetScrollPosition(redBar)*2.55)
  2376.                 local colorGreen = tonumber(guiScrollBarGetScrollPosition(greenBar)*2.55)
  2377.                 local colorBlue = tonumber(guiScrollBarGetScrollPosition(blueBar)*2.55)
  2378.                 callServerFunction("saveNametagColor",thePlayer,colorRed,colorGreen,colorBlue)
  2379.                 getVisible = guiGetVisible (colorWindow)
  2380.                 if (getVisible == true) then
  2381.                         guiSetVisible (colorWindow, false)
  2382.                 end
  2383.                 colorPickMode = false
  2384.         end
  2385. end
  2386.  
  2387. function closeColorSelectionWindow()
  2388.         if guiGetVisible(colorWindow) == true then
  2389.                 guiSetVisible(colorWindow,false)
  2390.         end
  2391.         colorPickMode = false
  2392. end
  2393.  
  2394.  
  2395.  
  2396. -- Horns
  2397. function updateHornsOnStart()
  2398.         callServerFunction("getPurchasedHorns",getLocalPlayer())
  2399.         callServerFunction("getLastSetHorn",getLocalPlayer())
  2400. end
  2401. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),updateHornsOnStart)
  2402.  
  2403. function updateHorns(thePlayer,h1,h2,h3,h4,h5,h6,h7)
  2404.         guiGridListSetItemColor(gridHorns,0,1,100,255,60,255)
  2405.         guiGridListSetItemColor(gridHorns,0,2,100,255,60,255)
  2406.  
  2407.         if h1 == 1 then
  2408.                 guiGridListSetItemColor(gridHorns,1,1,100,255,60,255)
  2409.                 guiGridListSetItemColor(gridHorns,1,2,100,255,60,255)
  2410.         end
  2411.  
  2412.         if h2 == 1 then
  2413.                 guiGridListSetItemColor(gridHorns,2,1,100,255,60,255)
  2414.                 guiGridListSetItemColor(gridHorns,2,2,100,255,60,255)
  2415.         end
  2416.  
  2417.         if h3 == 1 then
  2418.                 guiGridListSetItemColor(gridHorns,3,1,100,255,60,255)
  2419.                 guiGridListSetItemColor(gridHorns,3,2,100,255,60,255)
  2420.         end
  2421.  
  2422.         if h4 == 1 then
  2423.                 guiGridListSetItemColor(gridHorns,4,1,100,255,60,255)
  2424.                 guiGridListSetItemColor(gridHorns,4,2,100,255,60,255)
  2425.         end
  2426.  
  2427.         if h5 == 1 then
  2428.                 guiGridListSetItemColor(gridHorns,5,1,100,255,60,255)
  2429.                 guiGridListSetItemColor(gridHorns,5,2,100,255,60,255)
  2430.         end
  2431.  
  2432.         if h6 == 1 then
  2433.                 guiGridListSetItemColor(gridHorns,6,1,100,255,60,255)
  2434.                 guiGridListSetItemColor(gridHorns,6,2,100,255,60,255)
  2435.         end
  2436.  
  2437.         if h7 == 1 then
  2438.                 guiGridListSetItemColor(gridHorns,7,1,100,255,60,255)
  2439.                 guiGridListSetItemColor(gridHorns,7,2,100,255,60,255)
  2440.         end
  2441. end
  2442.  
  2443. function setLastUsedHorn(horn)
  2444.         if not (horn == 0) then
  2445.                 setHornSound = horn
  2446.                 toggleControl("horn",false)
  2447.                 guiSetText(lblCurrentHorn,"Current horn: "..hornName[horn+1])
  2448.         else
  2449.                 toggleControl("horn",true)
  2450.                 guiSetText(lblCurrentHorn,"Current horn: Default GTA horn")
  2451.         end
  2452.         bindKey ("h", "down", playCustomHorn)
  2453. end
  2454.  
  2455.  
  2456. function hornPreview()
  2457.         local selectedHorn = guiGridListGetSelectedItem(gridHorns)
  2458.         if selectedHorn <= 0 then
  2459.                 return
  2460.         end
  2461.         if selectedHorn == 6 then
  2462.                 local previewHorn = playSound(hornSound[selectedHorn])
  2463.                 setSoundVolume(previewHorn,0.6)
  2464.         else
  2465.                 local previewHorn = playSound(hornSound[selectedHorn])
  2466.                 setSoundVolume(previewHorn,0.8)
  2467.         end
  2468. end
  2469.  
  2470.  
  2471. function buyHorn()
  2472.         local selectedHorn = guiGridListGetSelectedItem(gridHorns)
  2473.         if selectedHorn == -1 then
  2474.                 outputChatBox("#FF6600* #FFFFFFERROR! Please select a horn to buy!",255,255,255,true)
  2475.                 return
  2476.         end
  2477.         if selectedHorn == 0 then
  2478.                 outputChatBox("#FF6600* #FFFFFFERROR! You already own this horn!",255,255,255,true)
  2479.                 return
  2480.         end
  2481.         callServerFunction("purchaseHorn",getLocalPlayer(),selectedHorn,hornName[selectedHorn+1])
  2482. end
  2483.  
  2484.  
  2485. function setHornCheck()
  2486.         local selectedHorn = guiGridListGetSelectedItem(gridHorns)
  2487.         if selectedHorn == -1 then
  2488.                 outputChatBox("#FF6600* #FFFFFFERROR! Please select a horn!",255,255,255,true)
  2489.                 return
  2490.         end
  2491.         if selectedHorn == 0 then
  2492.                 outputChatBox("#FF6600* #FFFFFFHorn sound has been set to: #ABCDEF"..hornName[selectedHorn+1],255,255,255,true)
  2493.                 callServerFunction("setLastSetHorn",getLocalPlayer(),selectedHorn)
  2494.                 setHornSound = 0
  2495.                 toggleControl("horn",true)
  2496.                 guiSetText(lblCurrentHorn,"Current horn: Default GTA horn")
  2497.                 return
  2498.         end
  2499.         callServerFunction("checkForPurchasedHorn",getLocalPlayer(),selectedHorn)
  2500. end
  2501.  
  2502. function setHorn(horn)
  2503.         outputChatBox("#FF6600* #FFFFFFHorn sound has been set to: #ABCDEF"..hornName[horn+1],255,255,255,true)
  2504.         callServerFunction("setLastSetHorn",getLocalPlayer(),horn)
  2505.         toggleControl("horn",false)
  2506.         setHornSound = horn
  2507.         guiSetText(lblCurrentHorn,"Current horn: "..hornName[horn+1])
  2508. end
  2509.  
  2510. function updateHornPriceLabel()
  2511.         local row = guiGridListGetSelectedItem(gridHorns)
  2512.         if (row > 0) then
  2513.                 local price = guiGridListGetItemText(gridHorns,row,2)
  2514.                 guiSetText(lblHornPrice,"$"..string.gsub(price," ",""))
  2515.         else
  2516.                 guiSetText(lblHornPrice,"N/A")
  2517.         end
  2518. end
  2519.  
  2520.  
  2521.  
  2522.  
  2523. -- Play the actual horn sound
  2524. function playCustomHorn()
  2525.         if isControlEnabled("horn") == false then
  2526.                 if getElementData(getLocalPlayer(),"state") == "alive" then
  2527.                         if hornNum == 0 then
  2528.                                 callServerFunction("playHornForAllClients",getLocalPlayer(),tostring(hornSound[setHornSound]),setHornSound)
  2529.                         end
  2530.                 end
  2531.         elseif setHornSound ~= 0 then
  2532.                 toggleControl("horn",false)
  2533.                 playCustomHorn()
  2534.         end
  2535. end
  2536.  
  2537.  
  2538. function playHornSound(horningPlayer,hornSoundPath,cSetHornSound)
  2539.         local numItems = 0
  2540.         for k,v in pairs(customHorn) do
  2541.                 numItems = numItems + 1
  2542.         end
  2543.         if (cSetHornSound ~= 0) then
  2544.  
  2545.                 customHorn[numItems+1] = playSound3D(hornSoundPath,0,0,0)
  2546.  
  2547.                 if horningPlayer == getLocalPlayer() then
  2548.                         hornNum = numItems+1
  2549.                 else
  2550.                         hornNum = 0
  2551.                 end
  2552.  
  2553.                 setSoundMaxDistance(customHorn[numItems+1],60)
  2554.                 if (cSetHornSound == 6) then
  2555.                         setSoundVolume(customHorn[numItems+1],0.32)
  2556.                 elseif (cSetHornSound == 5) then
  2557.                         setSoundVolume(customHorn[numItems+1],0.6)
  2558.                 elseif (cSetHornSound == 7) then
  2559.                         setSoundVolume(customHorn[numItems+1],0.73)
  2560.                 elseif (cSetHornSound == 4) then
  2561.                         setSoundVolume(customHorn[numItems+1],0.5)
  2562.                 elseif (cSetHornSound == 1) then
  2563.                         setSoundVolume(customHorn[numItems+1],0.82)
  2564.                 else
  2565.                         setSoundVolume(customHorn[numItems+1],0.6)
  2566.                 end
  2567.  
  2568.                 attachElements(customHorn[numItems+1],horningPlayer,0,0,0.5)
  2569.  
  2570.                 local length = getSoundLength(customHorn[numItems+1])
  2571.                 detachTimer = setTimer(
  2572.                         function()
  2573.                                 if (customHorn[numItems+1]) then
  2574.                                         if isElementAttached(customHorn[numItems+1]) == true then
  2575.                                                 detachElements(customHorn[numItems+1])
  2576.                                         end
  2577.                                         stopSound(customHorn[numItems+1])
  2578.                                 end
  2579.                                 customHorn[numItems+1] = nil
  2580.                                 hornNum = 0
  2581.                         end,length-100,1)
  2582.         end
  2583. end
  2584. addEvent("onRecieveHorn",true)
  2585. addEventHandler("onRecieveHorn",gRoot,playHornSound)
  2586.  
  2587.  
  2588.  
  2589.  
  2590.  
  2591. -- Buy water color and time
  2592. function buyChangeWaterColor()
  2593.         callServerFunction("buyChangeWaterColor",getLocalPlayer(),tonumber(guiGetText(editWaterColorRed)),tonumber(guiGetText(editWaterColorGreen)),tonumber(guiGetText(editWaterColorBlue)))
  2594. end
  2595.  
  2596. function cSetWaterColor(r,g,b)
  2597.         setWaterColor(r,g,b)
  2598. end
  2599.  
  2600.  
  2601. function buyChangeTime()
  2602.         callServerFunction("buyChangeTime",getLocalPlayer(),tonumber(guiGetText(editTimeHours)),tonumber(guiGetText(editTimeMinutes)))
  2603. end