Guest User

Untitled

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