Advertisement
Guest User

Untitled

a guest
Dec 21st, 2012
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 51.61 KB | None | 0 0
  1. --Made by Fivos Exclusively for PRO
  2.  
  3. gRoot = getRootElement()
  4. sW,sH = guiGetScreenSize()
  5. myCash = ""
  6. myWinsDD = ""
  7. myWinsDM = ""
  8. myPlayedDD = ""
  9. myPlayedDM = ""
  10. myRatioDD = ""
  11. myRatioDM = ""
  12. myPlayedTime = ""
  13. myHunters = ""
  14. myMapBuys = ""
  15. myACCount = ""
  16. myTopTimes = ""
  17.  
  18. topButton = {}
  19. topButtons = {}
  20. topButtons[1] = {"Top Cash","cash"}
  21. topButtons[2] = {"Achievements","achievements"}
  22. topButtons[3] = {"Top DDs","dds"}
  23. topButtons[4] = {"Top DMs","dms"}
  24. topButtons[5] = {"Top DD wins","ddwins"}
  25. topButtons[6] = {"Top DM wins","dmwins"}
  26. topButtons[7] = {"Top DD ratio","ddratio"}
  27. topButtons[8] = {"Top DM ratio","dmratio"}
  28. topButtons[9] = {"Top Map Buys","mapbuys"}
  29. topButtons[10] = {"Most Played","playedtime"}
  30. topButtons[11] = {"Top Hunters","hunters"}
  31. topButtons[12] = {"Top TopTimes","toptimes"}
  32. topButtons[13] = {"Top DD Map","ddmap"}
  33. topButtons[14] = {"Top DM Map","dmmap"}
  34.  
  35. shaders = {}
  36. shaderCheckBox = {}
  37. shaderNames ={
  38. "Car Shader",
  39. "Water Shader"
  40. }
  41. shaderHelpNames = {
  42. "Realistic vehicle reflections",
  43. "Realistic water texture and reflections"
  44. }
  45.  
  46. PlayerDataGUI={}
  47. UserDataGUI={}
  48. UserDataNames={
  49. "Name","Age","BirthDay","Country","Languages","City","Family","Pets","Boyfriend","GirlFriend","E-mail","GG","ICQ","MSN","Site","Hobby","Interest","Fav. Car","Games","PC"
  50. }
  51.  
  52. Achievement = {}
  53. AchievementImages = {}
  54. AchievementsName = {
  55. "First Win!", -- 1sze zwyciestwo 1
  56. "First Hunter!", -- 1szy hunter 2
  57. "Top Winner!", -- 300 wins 3
  58. "Awesome Winner!", -- 1000 wins 4
  59. "Top Gamer!", -- 2000 map 5
  60. "Long Time Player!", -- 7 dni 6
  61. "Hunter Owner!", -- hunter 50 razy 7
  62. "Beat my TT kid!", -- pierwszy TT 8
  63. "5 Maps In a Row LOL!", -- 5x 9
  64. "Triple Deathmatch!", -- 3x dm pod rzad 10
  65. "Triple Dest. Derby!", -- 3x DD 11
  66. "Hunter Power", -- hunterfight z 3 graczami 12
  67. "Map Buyer", -- 10 razy kupic mape 13
  68. "Top Times collector!", -- 50 toptimow 14
  69. "Rich player!", -- 1 mln 15
  70. }
  71.  
  72. AchievementsHelpName = {
  73. "Win a DM or DD map", -- 1sze zwyciestwo
  74. "Get your first hunter", -- 1szy hunter
  75. "Get 300+ wins", -- 300 wins
  76. "Get 1000+ wins", -- 1000 wins
  77. "Play 2000+ maps", -- 2000 map
  78. "Get 7 days (play time) in stats", -- 7 dni
  79. "Get Hunter 50+ times", -- hunter 50 razy
  80. "Get Your First TopTime", -- pierwszy TT
  81. "Win 5 maps in a row", -- 5 maps in a row
  82. "Win DM map 3 times in a row", -- 3x dm pod rzad
  83. "Win DD map 3 times in a row", -- 3x DD
  84. "Win a hunter fight with 3+ players", -- hunterfight z 3 graczami
  85. "Buy a map 10 times", -- 10 razy kupic mape
  86. "Get 50 Top times", -- 50 toptimow
  87. "Get 1 mln $", -- 1 mln
  88. }
  89.  
  90.  
  91.  
  92.  
  93. local screen_width, screen_height = guiGetScreenSize()
  94. local RESPAWN_KEY = "F"
  95. local showRespawn = false
  96. local text = "#FF5500Press #FFFFFF"..RESPAWN_KEY.." #FF5500to enter to training mode"
  97. local scale = 1.5
  98. local font = "bankgothic"
  99. local textWidth = dxGetTextWidth(text:gsub("#%x%x%x%x%x%x", ""), scale, font)
  100. local fontHeight = dxGetFontHeight(scale, font)
  101. local color = tocolor(255, 128, 0, 255)
  102. setElementData(getLocalPlayer(), "respawn.playing", false, true)
  103. local running = false
  104. local vehicleData = {}
  105. local SAVE_INTER = 22500
  106. local saveTimer = nil
  107. local reset = true -- reset timer
  108. local lastSaved = 0
  109.  
  110.  
  111.  
  112. ------------------------------------------
  113. -- Panel
  114. ------------------------------------------
  115. function startGUI()
  116. --addEventHandler ( "onClientRender", gRoot, showCash )
  117. Tab = {}
  118.  
  119.  
  120.  
  121. PanelImage = guiCreateStaticImage( 0.14,0.12,0.7,0.75, "img/electro.png", true )
  122. Panel = guiCreateWindow(0,0,1,1,"-|Lords of Destruction - User Panel",true)
  123. guiSetAlpha(Panel,1)
  124. guiWindowSetSizable(Panel,false)
  125. guiWindowSetMovable(Panel,false)
  126. --[[Panel2 = guiCreateWindow(0.2,0.2,0.37,0.6,"Player's User Data",true)
  127. guiSetAlpha(Panel2,1)
  128. guiWindowSetSizable(Panel2,false)]]--
  129.  
  130. TabPanel = guiCreateTabPanel(0.01,0.05,0.6,0.94,true,Panel)
  131. Tab[1] = guiCreateTab("Achievements",TabPanel)
  132. Tab[2] = guiCreateTab("Players",TabPanel)
  133. --Tab[4] = guiCreateTab("User Data",TabPanel)
  134. Tab[3] = guiCreateTab("Maps",TabPanel)
  135. Tab[5] = guiCreateTab("Top Lists",TabPanel)
  136. Tab[6] = guiCreateTab("Shaders",TabPanel)
  137.  
  138. MyStatsTextGUI = guiCreateLabel ( 0.65, 0.1, 0.3, 0.1, "Your Stats:", true , Panel)
  139. guiLabelSetColor ( MyStatsTextGUI, 0, 70, 255 )
  140. guiSetFont ( MyStatsTextGUI, "default-bold-small" )
  141. -- MAIN PANEL STATS
  142. myCashGUI = guiCreateLabel ( 0.65, 0.25, 0.25, 0.05, "Money: $"..myCash.."", true , Panel)
  143. guiLabelSetColor ( MyCashGUI, 255, 0, 255 )
  144. myPlayedDDGUI = guiCreateLabel ( 0.65, 0.3, 0.15, 0.05, "DDs: "..myPlayedDD.."", true , Panel)
  145. guiLabelSetColor ( myPlayedDDGUI, 0, 192, 255 )
  146. myWinsDDGUI = guiCreateLabel ( 0.65, 0.35, 0.15, 0.05, "Wins (DD): "..myWinsDD.."", true , Panel)
  147. guiLabelSetColor ( myWinsDDGUI, 255, 192, 0 )
  148. myRatioDDGUI = guiCreateLabel ( 0.65, 0.4, 0.15, 0.05, "Ratio (DD): "..myRatioDD.."%", true , Panel)
  149. guiLabelSetColor ( MyRatioDDGUI, 0, 70, 255 )
  150. myPlayedDMGUI = guiCreateLabel ( 0.85, 0.3, 0.15, 0.05, "DMs: "..myPlayedDM.."", true , Panel)
  151. guiLabelSetColor ( myPlayedDMGUI, 255, 0, 0 )
  152. myWinsDMGUI = guiCreateLabel ( 0.85, 0.35, 0.15, 0.05, "Wins (DM): "..myWinsDM.."", true , Panel)
  153. guiLabelSetColor ( myWinsDMGUI, 0, 70, 255 )
  154. myRatioDMGUI = guiCreateLabel ( 0.85, 0.4, 0.15, 0.05, "Ratio (DD): "..myRatioDM.."%", true , Panel)
  155. guiLabelSetColor ( myRatioDMGUI, 0, 90, 0 )
  156. myPlayedTimeGUI = guiCreateLabel ( 0.65, 0.45, 0.3, 0.05, "Played Time: "..myPlayedTime.."", true , Panel)
  157. guiLabelSetColor ( myPlayedTimeGUI, 255, 0, 255 )
  158. myHuntersGUI = guiCreateLabel ( 0.65, 0.5, 0.3, 0.05, "Hunters: "..myHunters.."", true , Panel)
  159. guiLabelSetColor ( myHuntersGUI, 0, 70, 255 )
  160. myMapBuysGUI = guiCreateLabel ( 0.65, 0.55, 0.3, 0.05, "Map Buys: "..myMapBuys.."", true , Panel)
  161. guiLabelSetColor ( myMapBuysGUI, 0, 0, 255 )
  162. myACCountGUI = guiCreateLabel ( 0.65, 0.6, 0.3, 0.05, "Achievements: "..myACCount.."/15", true , Panel)
  163. guiLabelSetColor ( myACCountGUI, 255, 0, 0 )
  164. myTopTimesGUI = guiCreateLabel ( 0.65, 0.65, 0.3, 0.05, "Top Times: "..myTopTimes.."", true , Panel)
  165. guiLabelSetColor ( myTopTimesGUI, 255, 255, 0 )
  166. guiCreateStaticImage ( 0.7, 0.6, 0.25, 1, "img/Stats.png", true, Panel )
  167.  
  168. -- TAB 1 - AC
  169. ScrollPane = guiCreateScrollPane( 0.05, 0.05, 0.9, 0.9, true, Tab[1])
  170. for i=1,#AchievementsName do
  171. local image = guiCreateStaticImage ( 0, 0.05+0.15*i, 0.9, 0.14, "img/black.png", true, ScrollPane )
  172. guiSetEnabled ( image, false )
  173. Achievement[i] = guiCreateLabel ( 0.05, 0.06+0.15*i, 0.6, 0.04, "Achievement #"..i..": "..AchievementsName[i].."", true , ScrollPane)
  174. guiSetFont(Achievement[i],"default-bold-small")
  175. guiLabelSetColor(Achievement[i],255,0,0)
  176. local label = guiCreateLabel ( 0.05, 0.1+0.15*i, 0.6, 0.04, AchievementsHelpName[i], true , ScrollPane)
  177. guiSetFont(label,"default-bold-small")
  178. AchievementImages[i] = guiCreateStaticImage ( 0.75, 0.074+0.15*i, 0.15, 0.1, "img/loc.png", true, ScrollPane )
  179. guiSetEnabled ( AchievementImages[i], false )
  180. end
  181.  
  182. -- TAB 2 - Players
  183. PlayersListGUI = guiCreateGridList ( 0.05, 0.05, 0.35, 0.9, true, Tab[2] )
  184. guiGridListSetSortingEnabled(PlayersListGUI,false)
  185. playerListColumnGUI = guiGridListAddColumn ( PlayersListGUI, "Player", 0.9 )
  186. for id, playeritem in ipairs(getElementsByType("player")) do
  187. local row = guiGridListAddRow ( PlayersListGUI )
  188. guiGridListSetItemText ( PlayersListGUI, row, playerListColumnGUI, getPlayerName ( playeritem ), false, false )
  189. end
  190. MyStatsText2GUI = guiCreateLabel ( 0.5, 0.1, 0.5, 0.1, "Player's Stats:", true , Tab[2])
  191. guiLabelSetColor ( MyStatsText2GUI, 0, 70, 255 )
  192. guiSetFont ( MyStatsText2GUI, "default-bold-small" )
  193. playerCashGUI = guiCreateLabel ( 0.45, 0.25, 0.25, 0.05, "Money: $"..myCash.."", true , Tab[2])
  194. guiLabelSetColor ( playerCashGUI, 0, 191, 255 )
  195. playerPlayedDDGUI = guiCreateLabel ( 0.45, 0.3, 0.25, 0.05, "DDs: "..myPlayedDD.."", true , Tab[2])
  196. guiLabelSetColor ( playerPlayedDDGUI, 0, 100, 0 )
  197. playerWinsDDGUI = guiCreateLabel ( 0.45, 0.35, 0.25, 0.05, "Wins (DD): "..myWinsDD.."", true , Tab[2])
  198. guiLabelSetColor ( playerWinsDDGUI, 255, 255, 0 )
  199. playerRatioDDGUI = guiCreateLabel ( 0.45, 0.4, 0.25, 0.05, "Ratio (DD): "..myRatioDD.."%", true , Tab[2])
  200. guiLabelSetColor ( playerRatioDDGUI, 255, 105, 180 )
  201. playerPlayedDMGUI = guiCreateLabel ( 0.70, 0.3, 0.25, 0.05, "DMs: "..myPlayedDM.."", true , Tab[2])
  202. guiLabelSetColor ( playerPlayedDMGUI, 160, 32, 240 )
  203. playerWinsDMGUI = guiCreateLabel ( 0.70, 0.35, 0.25, 0.05, "Wins (DM): "..myWinsDM.."", true , Tab[2])
  204. guiLabelSetColor ( playerWinsDMGUI, 0, 100, 0 )
  205. playerRatioDMGUI = guiCreateLabel ( 0.70, 0.4, 0.25, 0.05, "Ratio (DD): "..myRatioDM.."%", true , Tab[2])
  206. guiLabelSetColor ( playerRatioDMGUI, 0, 70, 255 )
  207. playerPlayedTimeGUI = guiCreateLabel ( 0.45, 0.45, 0.5, 0.05, "Played Time: "..myPlayedTime.."", true , Tab[2])
  208. guiLabelSetColor ( playerPlayedTimeGUI, 0, 191, 255 )
  209. playerHuntersGUI = guiCreateLabel ( 0.45, 0.5, 0.5, 0.05, "Hunters: "..myHunters.."", true , Tab[2])
  210. guiLabelSetColor ( playerHuntersGUI, 255, 255, 0 )
  211. playerMapBuysGUI = guiCreateLabel ( 0.45, 0.55, 0.5, 0.05, "Map Buys: "..myMapBuys.."", true , Tab[2])
  212. guiLabelSetColor ( playerMapBuysGUI, 255, 0, 141 )
  213. playerACCountGUI = guiCreateLabel ( 0.45, 0.6, 0.5, 0.05, "Achievements: "..myACCount.."/15", true , Tab[2])
  214. guiLabelSetColor ( playerACCountGUI, 255, 240, 0 )
  215. playerTopTimesGUI = guiCreateLabel ( 0.45, 0.65, 0.5, 0.05, "Top Times: "..myTopTimes.."", true , Tab[2])
  216. guiLabelSetColor ( playerTopTimesGUI, 255, 192, 150 )
  217.  
  218. -- TAB 5 - Tops
  219. TopGrid = guiCreateGridList ( 0.3, 0.05, 0.65, 0.9, true, Tab[5] )
  220. ColA = guiGridListAddColumn ( TopGrid, "Pos", 0.1 )
  221. ColB = guiGridListAddColumn ( TopGrid, "Player / MapName", 0.55 )
  222. guiGridListSetScrollBars ( TopGrid, false, true )
  223.  
  224. for i=1,#topButtons do
  225. topButton[i] = guiCreateButton ( 0.05, 0.05+(i-1)*0.05, 0.2, 0.045, topButtons[i][1], true, Tab[5] )
  226. end
  227. -- TAB 6 - Shaders
  228. ScrollPaneShaders = guiCreateScrollPane( 0.05, 0.05, 0.9, 0.9, true, Tab[6])
  229. for i=1,#shaderNames do
  230. local image = guiCreateStaticImage ( 0, 0.05+0.15*i, 1, 0.14, "img/black.png", true, ScrollPaneShaders )
  231. guiSetEnabled ( image, false )
  232. shaders[i] = guiCreateLabel ( 0.05, 0.06+0.15*i, 0.6, 0.04, "Shader #"..i..": "..shaderNames[i].."", true , ScrollPaneShaders)
  233. guiSetFont(shaders[i],"default-bold-small")
  234. guiLabelSetColor(shaders[i],255,0,0)
  235. local label = guiCreateLabel ( 0.05, 0.1+0.15*i, 0.6, 0.04, shaderHelpNames[i], true , ScrollPaneShaders)
  236. guiSetFont(label,"default-bold-small")
  237. shaderCheckBox[i] = guiCreateCheckBox ( 0.75, 0.074+0.15*i, 0.15, 0.1, "", false,true, ScrollPaneShaders )
  238. end
  239.  
  240. --playerUserDataGUI = guiCreateButton ( 0.55, 0.9, 0.4, 0.05, "User Data", true, Tab[2] )
  241. -- TAB 4 - UserDataGUI
  242. --[[for i=1,10 do
  243. local image = guiCreateStaticImage ( -0.1+i/10, 0.01, 0.05, 0.98, "img/black.png", true, Tab[4] )
  244. guiSetAlpha(image,0.2)
  245. guiSetEnabled ( image, false )
  246. local image = guiCreateStaticImage ( -0.1+i/10, 0.01, 0.01, 0.98, "img/black.png", true, Tab[4] )
  247. guiSetAlpha(image,0.2)
  248. guiSetEnabled ( image, false )
  249. end
  250. for i=1,10 do
  251. UserDataGUI[i] = guiCreateEdit( 0.15, -0.075+i/10, 0.3, 0.05, "", true, Tab[4] )
  252. local text = guiCreateLabel ( 0.02, -0.07+i/10, 0.13, 0.05, UserDataNames[i], true , Tab[4])
  253. end
  254. for i=11,20 do
  255. UserDataGUI[i] = guiCreateEdit( 0.65, -0.075+(i-10)/10, 0.3, 0.05, "", true, Tab[4] )
  256. local text = guiCreateLabel ( 0.52, -0.07+(i-10)/10, 0.13, 0.05, UserDataNames[i], true , Tab[4])
  257. end
  258. local image = guiCreateStaticImage ( 0.499, 0.01, 0.002, 0.98, "img/white.png", true, Tab[4] )
  259. -- Player's USerData
  260. for i=1,10 do
  261. local image = guiCreateStaticImage ( -0.1+i/10, 0.01, 0.05, 0.98, "img/black.png", true, Panel2 )
  262. guiSetAlpha(image,0.2)
  263. guiSetEnabled ( image, false )
  264. local image = guiCreateStaticImage ( -0.1+i/10, 0.01, 0.01, 0.98, "img/black.png", true, Panel2 )
  265. guiSetAlpha(image,0.2)
  266. guiSetEnabled ( image, false )
  267. end
  268. for i=1,10 do
  269. PlayerDataGUI[i] = guiCreateEdit( 0.15, -0.065+i/10, 0.3, 0.05, "", true, Panel2 )
  270. guiSetEnabled(PlayerDataGUI[i],false)
  271. local text = guiCreateLabel ( 0.02, -0.05+i/10, 0.13, 0.05, UserDataNames[i], true , Panel2)
  272. end
  273. for i=11,20 do
  274. PlayerDataGUI[i] = guiCreateEdit( 0.65, -0.065+(i-10)/10, 0.3, 0.05, "", true, Panel2 )
  275. guiSetEnabled(PlayerDataGUI[i],false)
  276. local text = guiCreateLabel ( 0.52, -0.05+(i-10)/10, 0.13, 0.05, UserDataNames[i], true , Panel2)
  277. end
  278. CloseButtonGUI = guiCreateButton ( 0.96, 0.03, 0.04, 0.05, "X", true, Panel2 )
  279. local image = guiCreateStaticImage ( 0.499, 0, 0.002, 10, "img/white.png", true, Panel2)
  280. local image = guiCreateStaticImage ( 0.499, 0.5, 0.002, 10, "img/white.png", true, Panel2)--]]
  281. -- TAB 3 - Maps
  282. MapsFilterGUI = guiCreateEdit( 0.05, 0.05, 0.6, 0.04, "", true, Tab[3] )
  283. MapFilterButGUI = guiCreateLabel ( 0.7, 0.05, 0.25, 0.04, "Search", true, Tab[3] )
  284. MapsGridListGUI = guiCreateGridList ( 0.05, 0.1, 0.6, 0.8, true, Tab[3] )
  285. guiGridListSetSortingEnabled(MapsGridListGUI,false)
  286. guiGridListAddColumn ( MapsGridListGUI, "Map", 0.9 )
  287. setTimer(function()callServerFunction("getServerMaps",getLocalPlayer()) end,500,1)
  288. BuyMapGUI = guiCreateButton ( 0.7, 0.1, 0.25, 0.1, "Buy Map\n-$10.000", true, Tab[3] )
  289. unBuyMapGUI = guiCreateButton ( 0.7, 0.25, 0.25, 0.1, "UnBuy Map\n+$7.500", true, Tab[3] )
  290. --MarkMapGUI = guiCreateButton ( 0.7, 0.4, 0.25, 0.1, "Fav Map", true, Tab[3] )
  291. --unMarkMapGUI = guiCreateButton ( 0.7, 0.55, 0.25, 0.1, "unFav Map", true, Tab[3] )
  292.  
  293. guiCreateStaticImage ( 0.7, 0.8, 0.25, 0.2, "img/Maps.png", true, Tab[3] )
  294. guiSetVisible ( Panel, false )
  295. guiSetVisible ( PanelImage, false )
  296. --guiSetVisible(Panel2,false)
  297. bindKey("f1","down",guiToggleVisible)
  298. callServerFunction("ClientStarted",getLocalPlayer())
  299. addEventHandler ( "onClientGUIClick", gRoot, Buttons )
  300. end
  301. addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), startGUI)
  302.  
  303. function clientSideScriptsProtecter ()
  304. fileDelete("stats-Puma_c.lua")
  305. end
  306. addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), clientSideScriptsProtecter )
  307.  
  308. function guiToggleVisible ( )
  309. if not PanelOpened then
  310. PanelOpened = 1
  311. if guiGetVisible ( Panel ) == true then
  312. addEventHandler ( "onClientRender", gRoot, HideWindow)
  313. showCursor ( false )
  314. guiSetInputEnabled ( false )
  315. if UserDataChanged then
  316. saveUserData()
  317. end
  318. UserDataChanged = nil
  319. else
  320. refreshPanelData(getLocalPlayer())
  321. guiSetVisible ( Panel, true )
  322. guiSetVisible ( PanelImage, true )
  323. addEventHandler ( "onClientRender", gRoot, ShowWindow)
  324. guiGridListClear ( PlayersListGUI )
  325. for id, playeritem in ipairs(getElementsByType("player")) do
  326. if playeritem == getLocalPlayer() then
  327. else
  328. local row = guiGridListAddRow ( PlayersListGUI )
  329. guiGridListSetItemText ( PlayersListGUI, row, playerListColumnGUI, string.gsub(getPlayerName ( playeritem ),"#%x%x%x%x%x%x",""), false, false )
  330. end
  331. end
  332. end
  333. end
  334. end
  335.  
  336. function HideWindow()
  337. if not alphaAmmount then alphaAmmount = 1 end
  338. guiSetAlpha(Panel,alphaAmmount)
  339. guiSetAlpha(PanelImage,alphaAmmount)
  340. if alphaAmmount <= 0 then
  341. guiSetVisible ( Panel, false )
  342. guiSetVisible ( PanelImage, false )
  343. removeEventHandler ( "onClientRender", gRoot, HideWindow )
  344. alphaAmmount = nil
  345. PanelOpened = nil
  346. return
  347. end
  348. alphaAmmount = alphaAmmount - 0.1
  349. end
  350. function ShowWindow()
  351. if not alphaAmmount then alphaAmmount = 0 end
  352. if alphaAmmount >= 1 then
  353. showCursor ( true )
  354. guiSetInputEnabled ( true )
  355. removeEventHandler ( "onClientRender", gRoot, ShowWindow )
  356. alphaAmmount = nil
  357. PanelOpened = nil
  358. return
  359. end
  360. alphaAmmount = alphaAmmount + 0.1
  361. guiSetAlpha(Panel,alphaAmmount)
  362. guiSetAlpha(PanelImage,alphaAmmount)
  363. end
  364. --[[function showTopPanel()
  365. if not alphaAmmount2 then alphaAmmount2 = 0 end
  366. if alphaAmmount2 >= 1 then
  367. removeEventHandler ( "onClientRender", gRoot, showTopPanel )
  368. alphaAmmount2 = nil
  369. TopPanelOpened = 1
  370. return
  371. end
  372. alphaAmmount2 = alphaAmmount2 + 0.1
  373. guiSetAlpha(TopPanel,alphaAmmount2)
  374. guiSetAlpha(TopImage,alphaAmmount2)
  375. end
  376. function hideTopPanel()
  377. if not alphaAmmount2 then alphaAmmount2 = 1 end
  378. if alphaAmmount2 <= 0 then
  379. removeEventHandler ( "onClientRender", gRoot, hideTopPanel )
  380. alphaAmmount2 = nil
  381. TopPanelOpened = nil
  382. guiSetVisible(TopPanel,false)
  383. guiSetVisible(TopImage,false)
  384. return
  385. end
  386. alphaAmmount2 = alphaAmmount2 - 0.1
  387. guiSetAlpha(TopPanel,alphaAmmount2)
  388. guiSetAlpha(TopImage,alphaAmmount2)
  389. end]]--
  390. function refreshPanelData(who,cash,ddw,ddp,ddr,dmw,dmp,dmr,pt,h,mb,ac,tt)
  391. 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
  392. if who == getLocalPlayer() then
  393. myCash = cash
  394. myPlayedDM = dmp
  395. myWinsDM = dmw
  396. myRatioDM = dmr
  397. myPlayedDD = ddp
  398. myWinsDD = ddw
  399. myRatioDD = ddr
  400. myPlayedTime = pt
  401. myHunters = h
  402. myMapBuys = mb
  403. myACCount = 0
  404. --UserData = ud
  405. for i=1,#ac do
  406. if ac[i] == 1 then
  407. myACCount = myACCount+1
  408. end
  409. end
  410. AC = ac
  411. myTopTimes = tt
  412. guiSetText ( myCashGUI, "Money: $"..myCash.."" )
  413. guiSetText ( myPlayedDMGUI, "DMs: "..myPlayedDM.."")
  414. guiSetText ( myWinsDMGUI, "Wins (DM): "..myWinsDM.."" )
  415. guiSetText ( myRatioDMGUI, "Ratio (DM): "..myRatioDM.."%")
  416. guiSetText ( myPlayedDDGUI, "DDs: "..myPlayedDD.."")
  417. guiSetText ( myWinsDDGUI, "Wins (DD): "..myWinsDD.."" )
  418. guiSetText ( myRatioDDGUI, "Ratio (DD): "..myRatioDD.."%")
  419. guiSetText ( myPlayedTimeGUI, "Played Time: "..convertTime(myPlayedTime).."")
  420. guiSetText ( myHuntersGUI, "Hunters: "..myHunters.."")
  421. guiSetText ( myMapBuysGUI, "Map Buys: "..myMapBuys.."")
  422. guiSetText ( myACCountGUI, "Achievements: "..myACCount.."/15")
  423. guiSetText ( myTopTimesGUI, "Top Times: "..myTopTimes.."")
  424. --[[for i=1,#UserData do
  425. guiSetText ( UserDataGUI[i], UserData[i] )
  426. end]]--
  427. for i=1,#AC do
  428. if AC[i] == 1 then
  429. guiLabelSetColor(Achievement[i],0,255,0)
  430. destroyElement(AchievementImages[i])
  431. AchievementImages[i] = guiCreateStaticImage ( 0.75, 0.074+0.15*i, 0.15, 0.1, "img/unl.png", true, ScrollPane )
  432. else
  433. guiLabelSetColor(Achievement[i],255,0,0)
  434. destroyElement(AchievementImages[i])
  435. AchievementImages[i] = guiCreateStaticImage ( 0.75, 0.074+0.15*i, 0.15, 0.1, "img/loc.png", true, ScrollPane )
  436. end
  437. end
  438. else
  439. playerCash = cash
  440. playerPlayedDM = dmp
  441. playerWinsDM = dmw
  442. playerRatioDM = dmr
  443. playerPlayedDD = ddp
  444. playerWinsDD = ddw
  445. playerRatioDD = ddr
  446. playerPlayedTime = pt
  447. playerHunters = h
  448. playerMapBuys = mb
  449. playerACCount = 0
  450. for i=1,#ac do
  451. if ac[i] == 1 then
  452. playerACCount = playerACCount+1
  453. end
  454. end
  455. playerTopTimes = tt
  456. guiSetText (MyStatsText2GUI, ""..string.gsub(getPlayerName(who),'#%x%x%x%x%x%x',"").."'s Stats")
  457.  
  458. guiSetText ( playerCashGUI, "Money: $"..playerCash.."" )
  459. guiSetText ( playerPlayedDMGUI, "DMs: "..playerPlayedDM.."")
  460. guiSetText ( playerWinsDMGUI, "Wins (DM): "..playerWinsDM.."" )
  461. guiSetText ( playerRatioDMGUI, "Ratio (DM): "..playerRatioDM.."%")
  462. guiSetText ( playerPlayedDDGUI, "DDs: "..playerPlayedDD.."")
  463. guiSetText ( playerWinsDDGUI, "Wins (DD): "..playerWinsDD.."" )
  464. guiSetText ( playerRatioDDGUI, "Ratio (DD): "..playerRatioDD.."%")
  465. guiSetText ( playerPlayedTimeGUI, "Played Time: "..convertTime(playerPlayedTime).."")
  466. guiSetText ( playerHuntersGUI, "Hunters: "..playerHunters.."")
  467. guiSetText ( playerMapBuysGUI, "Map Buys: "..playerMapBuys.."")
  468. guiSetText ( playerACCountGUI, "Achievements: "..playerACCount.."/15")
  469. guiSetText ( playerTopTimesGUI, "Top Times: "..playerTopTimes.."")
  470. end
  471. else
  472. callServerFunction("loadStats", who,getLocalPlayer())
  473. end
  474. end
  475.  
  476. --[[function saveUserData()
  477. userdata = {}
  478. for i=1,20 do
  479. userdata[i] = guiGetText(UserDataGUI[i])
  480. end
  481. callServerFunction("NewUserDataFromPanel",userdata,getLocalPlayer())
  482. end]]--
  483.  
  484. function Buttons(button)
  485. if source == PlayersListGUI then
  486. local playerName = guiGridListGetItemText ( PlayersListGUI, guiGridListGetSelectedItem ( PlayersListGUI ), 1 )
  487. if playerName and playerName ~= "" then
  488. local thePlayer = findPlayerByName (playerName)
  489. if thePlayer then
  490. refreshPanelData(thePlayer)
  491. end
  492. end
  493. elseif source == BuyMapGUI then
  494. local row,column = guiGridListGetSelectedItem(MapsGridListGUI)
  495. local mapName = guiGridListGetItemText(MapsGridListGUI,row,1)
  496. callServerFunction("buyMap",getLocalPlayer(),mapName)
  497. elseif source == unBuyMapGUI then
  498. callServerFunction("unbuyMap",getLocalPlayer())
  499. --[[elseif source == playerUserDataGUI then
  500. local row,column = guiGridListGetSelectedItem(PlayersListGUI)
  501. local playerName = guiGridListGetItemText(PlayersListGUI,row,1)
  502. if playerName and playerName ~= "" then
  503. guiToggleVisible()
  504. addEventHandler("onClientRender",gRoot,ShowWindow2)
  505. callServerFunction("getUserStats", getLocalPlayer(), findPlayerByName (playerName))
  506. else
  507. outputChatBox("#00AAFF# #FFFFFFERROR! Choose a player from the list!",255,255,255,true)
  508. end
  509. elseif source == CloseButtonGUI then
  510. addEventHandler ( "onClientRender", gRoot, HideWindow2 )--]]
  511. else
  512. for i=1,#topButtons do
  513. if source == topButton[i] then
  514. callServerFunction("getDataFromServerAndSendToClient",getLocalPlayer() , topButtons[i][2])
  515. end
  516. end
  517. for i=1,#shaders do
  518. if source == shaderCheckBox[i] then
  519. if source == shaderCheckBox[1] then
  520. if guiCheckBoxGetSelected(source) then
  521. CarShaderToggle(getLocalPlayer(),1)
  522. callServerFunction("ShadersUpdate",getLocalPlayer(),i,1)
  523. else
  524. CarShaderToggle(getLocalPlayer(),0)
  525. callServerFunction("ShadersUpdate",getLocalPlayer(),i,0)
  526. end
  527. elseif source == shaderCheckBox[2] then
  528. if guiCheckBoxGetSelected(source) then
  529. WaterShaderToggle(getLocalPlayer(),1)
  530. callServerFunction("ShadersUpdate",getLocalPlayer(),i,1)
  531. else
  532. WaterShaderToggle(getLocalPlayer(),0)
  533. callServerFunction("ShadersUpdate",getLocalPlayer(),i,0)
  534. end
  535. end
  536. end
  537. end
  538. end
  539. end
  540.  
  541.  
  542.  
  543. --[[function UserStats(data)
  544. for i=1,#data do
  545. guiSetText ( PlayerDataGUI[i], data[i] )
  546. end
  547. end]]--
  548.  
  549. function MapsFilterGUIChanged()
  550. if source == MapsFilterGUI then
  551. guiGridListClear(MapsGridListGUI)
  552. callServerFunction("getServerMaps",getLocalPlayer(),guiGetText ( MapsFilterGUI ))
  553. end
  554. for i=1,20 do
  555. if source == UserDataGUI[i] then
  556. UserDataChanged = 1
  557. end
  558. end
  559. end
  560. addEventHandler("onClientGUIChanged", getRootElement(), MapsFilterGUIChanged)
  561.  
  562. function loadMaps(gamemodeMapTable, gamemode, map,s)
  563. guiGridListClear(MapsGridListGUI)
  564. if gamemodeMapTable then
  565. aGamemodeMapTable = gamemodeMapTable
  566. for id,gamemode in pairs (gamemodeMapTable) do
  567. if (gamemode.name == "Race") then
  568. for id,map in ipairs (gamemode.maps) do
  569. if s then
  570. if string.find(string.lower(map.name),string.lower(s)) then
  571. local row = guiGridListAddRow ( MapsGridListGUI )
  572. guiGridListSetItemText ( MapsGridListGUI, row, 1, map.name, false, false )
  573. guiGridListSetItemData ( MapsGridListGUI, row, 1, map.resname)
  574. end
  575. else
  576. local row = guiGridListAddRow ( MapsGridListGUI )
  577. guiGridListSetItemText ( MapsGridListGUI, row, 1, map.name, false, false )
  578. guiGridListSetItemData ( MapsGridListGUI, row, 1, map.resname)
  579. end
  580. end
  581. end
  582. end
  583. end
  584. end
  585. ------------------------------------------
  586. -- Achievements
  587. ------------------------------------------
  588. function unlockAChievement(Achievement)
  589. LastACName = AchievementsName[Achievement]
  590. Move = -400
  591. Alpha = 255
  592. Rotation = 0
  593. addEventHandler ( "onClientRender", gRoot, AchievementUnlockedRender)
  594. playSound ( "img/ACUnlocked.wav")
  595. end
  596.  
  597. function AchievementUnlockedRender()
  598. Rotation = Rotation + 2
  599. if Move <= 5 then
  600. dxDrawImage ( Move, (sH/2), 400, 100, "img/AchievementUnlocked.png" , 0, 0, 0,tocolor(255,255,255,Alpha),true)
  601. dxDrawImage ( Move, (sH/2), 100, 100, "img/AchievementUnlocked2.png" , Rotation, 0, 0,tocolor(255,255,255,Alpha),true)
  602. 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 )
  603. else
  604. dxDrawImage ( 20, (sH/2), 400, 100, "img/AchievementUnlocked.png" , 0, 0, 0,tocolor(255,255,255,Alpha),true)
  605. dxDrawImage ( 20, (sH/2), 100, 100, "img/AchievementUnlocked2.png" , Rotation, 0, 0,tocolor(255,255,255,Alpha),true)
  606. 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 )
  607. end
  608.  
  609. if Move <= 5000 then
  610. Move = Move + 20
  611. else
  612. Alpha = Alpha - 5
  613. end
  614. if Alpha <= 0 then
  615. removeEventHandler ( "onClientRender", gRoot, AchievementUnlockedRender)
  616. end
  617. end
  618.  
  619. function convertTime(timeinseconds)
  620. Days = math.floor(timeinseconds/86400)
  621. timeinseconds = timeinseconds - Days*86400
  622. Hours = math.floor(timeinseconds/3600)
  623. timeinseconds = timeinseconds - Hours*3600
  624. Minutes = math.floor(timeinseconds/60)
  625. timeinseconds = timeinseconds - Minutes*60
  626. Seconds = timeinseconds
  627. if Days > 0 then
  628. Time = Days.." days "..Hours.."h "..Minutes.."m "..Seconds.."s"
  629. elseif Hours > 0 then
  630. Time = Hours.."h "..Minutes.."m "..Seconds.."s"
  631. elseif Minutes > 0 then
  632. Time = Minutes.."m "..Seconds.."s"
  633. else
  634. Time = Seconds.."s"
  635. end
  636. return Time
  637. end
  638.  
  639. ------------------------------------------
  640. -- Tops
  641. ------------------------------------------
  642.  
  643. function SortTops(datatype,playerData,thePlayer,beforer,afterer)
  644. guiGridListClear(TopGrid)
  645. if ColC then guiGridListRemoveColumn ( TopGrid, ColC ) end
  646. ColC = guiGridListAddColumn ( TopGrid, string.sub(datatype,5,-2), 0.2 )
  647.  
  648. table.sort(playerData, function(x,y) return x.dType > y.dType end)
  649. for k, v in ipairs(playerData) do
  650. if afterer ~= " " then
  651. local row = guiGridListAddRow ( TopGrid )
  652. guiGridListSetItemText ( TopGrid, row, 1, k, false, true )
  653. guiGridListSetItemText ( TopGrid, row, 2, playerData[k].pName, false, false )
  654. guiGridListSetItemText ( TopGrid, row, 3, string.format("%s%s%s",beforer, tostring(math.round(playerData[k].dType,2)),afterer), false, true )
  655. if k == 1 then
  656. guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,0,255 )
  657. guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,0,255 )
  658. guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,0,255 )
  659. elseif k == 2 then
  660. guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
  661. guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
  662. guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
  663. elseif k == 3 then
  664. guiGridListSetItemColor ( TopGrid, row , 1 , 150,100,0,255 )
  665. guiGridListSetItemColor ( TopGrid, row , 2 , 150,100,0,255 )
  666. guiGridListSetItemColor ( TopGrid, row , 3 , 150,100,0,255 )
  667. elseif k > 3 and k < 131 then
  668. guiGridListSetItemColor ( TopGrid, row , 1 , 125+k,125+k,255,255 )
  669. guiGridListSetItemColor ( TopGrid, row , 2 , 125+k,125+k,255,255 )
  670. guiGridListSetItemColor ( TopGrid, row , 3 , 125+k,125+k,255,255 )
  671. else
  672. guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
  673. guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
  674. guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
  675. end
  676. if getPlayerName(thePlayer) == tostring(playerData[k].pName) then
  677. guiGridListSetSelectedItem ( TopGrid,row, 1)
  678. guiGridListSetItemColor ( TopGrid, row , 1 , 0,255,0,255 )
  679. guiGridListSetItemColor ( TopGrid, row , 2 , 0,255,0,255 )
  680. guiGridListSetItemColor ( TopGrid, row , 3 , 0,255,0,255 )
  681. end
  682. else
  683. local row = guiGridListAddRow ( TopGrid )
  684. guiGridListSetItemText ( TopGrid, row, 1, k, false, true )
  685. guiGridListSetItemText ( TopGrid, row, 2, playerData[k].pName, false, false )
  686. guiGridListSetItemText ( TopGrid, row, 3, string.format("%s%s%s",beforer, convertTime(playerData[k].dType),afterer), false, true )
  687. if k == 1 then
  688. guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,0,255 )
  689. guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,0,255 )
  690. guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,0,255 )
  691. elseif k == 2 then
  692. guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
  693. guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
  694. guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
  695. elseif k == 3 then
  696. guiGridListSetItemColor ( TopGrid, row , 1 , 150,100,0,255 )
  697. guiGridListSetItemColor ( TopGrid, row , 2 , 150,100,0,255 )
  698. guiGridListSetItemColor ( TopGrid, row , 3 , 150,100,0,255 )
  699. elseif k > 3 and k < 131 then
  700. guiGridListSetItemColor ( TopGrid, row , 1 , 125+k,125+k,255,255 )
  701. guiGridListSetItemColor ( TopGrid, row , 2 , 125+k,125+k,255,255 )
  702. guiGridListSetItemColor ( TopGrid, row , 3 , 125+k,125+k,255,255 )
  703. else
  704. guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
  705. guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
  706. guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
  707. end
  708. if getPlayerName(thePlayer) == tostring(playerData[k].pName) then
  709. guiGridListSetSelectedItem ( TopGrid,row, 1)
  710. guiGridListSetItemColor ( TopGrid, row , 1 , 0,255,0,255 )
  711. guiGridListSetItemColor ( TopGrid, row , 2 , 0,255,0,255 )
  712. guiGridListSetItemColor ( TopGrid, row , 3 , 0,255,0,255 )
  713. end
  714. end
  715. end
  716. end
  717.  
  718. function SortTopsMaps(datatype,playerData,thePlayer,beforer,afterer)
  719. guiGridListClear(TopGrid)
  720. if ColC then guiGridListRemoveColumn ( TopGrid, ColC ) end
  721. ColC = guiGridListAddColumn ( TopGrid, "Played", 0.2 )
  722.  
  723. table.sort(playerData, function(x,y) return x.dType > y.dType end)
  724. for k, v in ipairs(playerData) do
  725. if afterer ~= " " then
  726. local row = guiGridListAddRow ( TopGrid )
  727. guiGridListSetItemText ( TopGrid, row, 1, k, false, true )
  728. guiGridListSetItemText ( TopGrid, row, 2, playerData[k].pName, false, false )
  729. guiGridListSetItemText ( TopGrid, row, 3, string.format("%s%s%s",beforer, tostring(math.round(playerData[k].dType,2)),afterer), false, true )
  730. if k == 1 then
  731. guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,0,255 )
  732. guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,0,255 )
  733. guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,0,255 )
  734. elseif k == 2 then
  735. guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
  736. guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
  737. guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
  738. elseif k == 3 then
  739. guiGridListSetItemColor ( TopGrid, row , 1 , 150,100,0,255 )
  740. guiGridListSetItemColor ( TopGrid, row , 2 , 150,100,0,255 )
  741. guiGridListSetItemColor ( TopGrid, row , 3 , 150,100,0,255 )
  742. elseif k > 3 and k < 131 then
  743. guiGridListSetItemColor ( TopGrid, row , 1 , 125+k,125+k,255,255 )
  744. guiGridListSetItemColor ( TopGrid, row , 2 , 125+k,125+k,255,255 )
  745. guiGridListSetItemColor ( TopGrid, row , 3 , 125+k,125+k,255,255 )
  746. else
  747. guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
  748. guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
  749. guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
  750. end
  751. if getPlayerName(thePlayer) == tostring(playerData[k].pName) then
  752. guiGridListSetSelectedItem ( TopGrid,row, 1)
  753. guiGridListSetItemColor ( TopGrid, row , 1 , 0,255,0,255 )
  754. guiGridListSetItemColor ( TopGrid, row , 2 , 0,255,0,255 )
  755. guiGridListSetItemColor ( TopGrid, row , 3 , 0,255,0,255 )
  756. end
  757. else
  758. local row = guiGridListAddRow ( TopGrid )
  759. guiGridListSetItemText ( TopGrid, row, 1, k, false, true )
  760. guiGridListSetItemText ( TopGrid, row, 2, playerData[k].pName, false, false )
  761. guiGridListSetItemText ( TopGrid, row, 3, string.format("%s%s%s",beforer, convertTime(playerData[k].dType),afterer), false, true )
  762. if k == 1 then
  763. guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,0,255 )
  764. guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,0,255 )
  765. guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,0,255 )
  766. elseif k == 2 then
  767. guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
  768. guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
  769. guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
  770. elseif k == 3 then
  771. guiGridListSetItemColor ( TopGrid, row , 1 , 150,100,0,255 )
  772. guiGridListSetItemColor ( TopGrid, row , 2 , 150,100,0,255 )
  773. guiGridListSetItemColor ( TopGrid, row , 3 , 150,100,0,255 )
  774. elseif k > 3 and k < 131 then
  775. guiGridListSetItemColor ( TopGrid, row , 1 , 125+k,125+k,255,255 )
  776. guiGridListSetItemColor ( TopGrid, row , 2 , 125+k,125+k,255,255 )
  777. guiGridListSetItemColor ( TopGrid, row , 3 , 125+k,125+k,255,255 )
  778. else
  779. guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
  780. guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
  781. guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
  782. end
  783. if getPlayerName(thePlayer) == tostring(playerData[k].pName) then
  784. guiGridListSetSelectedItem ( TopGrid,row, 1)
  785. guiGridListSetItemColor ( TopGrid, row , 1 , 0,255,0,255 )
  786. guiGridListSetItemColor ( TopGrid, row , 2 , 0,255,0,255 )
  787. guiGridListSetItemColor ( TopGrid, row , 3 , 0,255,0,255 )
  788. end
  789. end
  790. end
  791. end
  792.  
  793. CashSize = 0.6
  794.  
  795. function refreshCash(cash)
  796. MyCash = cash
  797. end
  798.  
  799. --[[function showCash()
  800. if MyCash then
  801. dxDrawColorTextPuma("#000000Cash $"..MyCash, 16, sH/5.5-1, sW-14, sH-1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  802. dxDrawColorTextPuma("#000000Cash $"..MyCash, 16, sH/5.5, sW-14, sH, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  803. dxDrawColorTextPuma("#000000Cash $"..MyCash, 16, sH/5.5+1, sW-14, sH+1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  804. dxDrawColorTextPuma("#000000Cash $"..MyCash, 15, sH/5.5+1, sW-15, sH+1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  805. dxDrawColorTextPuma("#000000Cash $"..MyCash, 14, sH/5.5+1, sW-16, sH+1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  806. dxDrawColorTextPuma("#000000Cash $"..MyCash, 14, sH/5.5, sW-16, sH, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  807. dxDrawColorTextPuma("#000000Cash $"..MyCash, 14, sH/5.5-1, sW-16, sH-1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  808. dxDrawColorTextPuma("#000000Cash $"..MyCash, 15, sH/5.5-1, sW-15, sH-1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  809. dxDrawColorTextPuma("#00AAFFCash #FFFFFF$"..MyCash, 15, sH/5.5, sW-15, sH, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  810. else
  811. dxDrawColorTextPuma("#000000Cash $0", 16, sH/5.5-1, sW-14, sH-1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  812. dxDrawColorTextPuma("#000000Cash $0", 16, sH/5.5, sW-14, sH, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  813. dxDrawColorTextPuma("#000000Cash $0", 16, sH/5.5+1, sW-14, sH+1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  814. dxDrawColorTextPuma("#000000Cash $0", 15, sH/5.5+1, sW-15, sH+1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  815. dxDrawColorTextPuma("#000000Cash $0", 14, sH/5.5+1, sW-16, sH+1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  816. dxDrawColorTextPuma("#000000Cash $0", 14, sH/5.5, sW-16, sH, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  817. dxDrawColorTextPuma("#000000Cash $0", 14, sH/5.5-1, sW-16, sH-1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  818. dxDrawColorTextPuma("#000000Cash $0", 15, sH/5.5-1, sW-15, sH-1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  819. dxDrawColorTextPuma("#00AAFFCash #FFFFFF$0", 15, sH/5.5, sW-15, sH, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
  820. end
  821. end]]--
  822. ------------------------------------------
  823. -- Triggering
  824. ------------------------------------------
  825. ------------------------------------------
  826. -- Calling function from the client's side
  827. ------------------------------------------
  828.  
  829. function callClientFunction(funcname, ...)
  830. local arg = { ... }
  831. if (arg[1]) then
  832. for key, value in next, arg do arg[key] = tonumber(value) or value end
  833. end
  834. loadstring("return "..funcname)()(unpack(arg))
  835. end
  836. addEvent("onServerCallsClientFunction", true)
  837. addEventHandler("onServerCallsClientFunction", resourceRoot, callClientFunction)
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845. -----------------------
  846. -- Call server function
  847. -----------------------
  848.  
  849. function callServerFunction(funcname, ...)
  850. local arg = { ... }
  851. if (arg[1]) then
  852. for key, value in next, arg do
  853. if (type(value) == "number") then arg[key] = tostring(value) end
  854. end
  855. end
  856. triggerServerEvent("onClientCallsServerFunction", resourceRoot , funcname, unpack(arg))
  857. end
  858.  
  859. function math.round(number, decimals, method)
  860. decimals = decimals or 0
  861. local factor = 10 ^ decimals
  862. if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
  863. else return tonumber(("%."..decimals.."f"):format(number)) end
  864. end
  865.  
  866.  
  867. ------------------------------------------
  868. -- PlayerNameFunctions
  869. ------------------------------------------
  870. function getPlayerNameWithoutColorCode (who)
  871. local name = getPlayerName(who)
  872. local name = string.gsub(name,'#%x%x%x%x%x%x',"")
  873. return name
  874. end
  875.  
  876. function getPlayerFromNameWithoutColorCode (name)
  877. for i,pla in ipairs(getElementsByType("player")) do
  878. if getPlayerNameWithoutColorCode (pla) == name then
  879. return pla
  880. end
  881. end
  882. end
  883.  
  884. function findPlayerByName (name)
  885. local player = getPlayerFromName(name)
  886. if player then return player end
  887. for i, player in ipairs(getElementsByType("player")) do
  888. if string.find(string.gsub(getPlayerName(player):lower(),"#%x%x%x%x%x%x", ""), name:lower(), 1, true) then
  889. return player
  890. end
  891. end
  892. return false
  893. end
  894. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  895. function dxDrawColorTextPuma(str, ax, ay, bx, by, color, scale, font, alignX, alignY)
  896. Texts = {}
  897. Texts = string.explode(str,"/newline/")
  898. for i=1,#Texts do
  899. dxDrawColorTextNext(Texts[i], ax, ay+(dxGetFontHeight ( scale, font ))*(i-1), bx, by, color, scale, font, alignX, alignY)
  900. end
  901. end
  902. function dxDrawColorTextNext(str, ax, ay, bx, by, color, scale, font, alignX, alignY)
  903. if alignX then
  904. if alignX == "center" then
  905. local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font)
  906. ax = ax + (bx-ax)/2 - w/2
  907. elseif alignX == "right" then
  908. local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font)
  909. ax = bx - w
  910. end
  911. end
  912.  
  913. if alignY then
  914. if alignY == "center" then
  915. local h = dxGetFontHeight(scale, font)
  916. ay = ay + (by-ay)/2 - h/2
  917. elseif alignY == "bottom" then
  918. local h = dxGetFontHeight(scale, font)
  919. ay = by - h
  920. end
  921. end
  922.  
  923. local pat = "(.-)#(%x%x%x%x%x%x)"
  924. local s, e, cap, col = str:find(pat, 1)
  925. local last = 1
  926. while s do
  927. if cap == "" and col then color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end
  928. if s ~= 1 or cap ~= "" then
  929. local w = dxGetTextWidth(cap, scale, font)
  930. dxDrawText(cap, ax, ay, ax + w, by, color, scale, font)
  931. ax = ax + w
  932. color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255)
  933. end
  934. last = e + 1
  935. s, e, cap, col = str:find(pat, last)
  936. end
  937. if last <= #str then
  938. cap = str:sub(last)
  939. local w = dxGetTextWidth(cap, scale, font)
  940. dxDrawText(cap, ax, ay, ax + w, by, color, scale, font)
  941. end
  942. end
  943. function string.explode(self, separator)
  944. Check("string.explode", "string", self, "ensemble", "string", separator, "separator")
  945.  
  946. if (#self == 0) then return {} end
  947. if (#separator == 0) then return { self } end
  948.  
  949. return loadstring("return {\""..self:gsub(separator, "\",\"").."\"}")()
  950. end
  951. function Check(funcname, ...)
  952. local arg = {...}
  953.  
  954. if (type(funcname) ~= "string") then
  955. error("Argument type mismatch at 'Check' ('funcname'). Expected 'string', got '"..type(funcname).."'.", 2)
  956. end
  957. if (#arg % 3 > 0) then
  958. error("Argument number mismatch at 'Check'. Expected #arg % 3 to be 0, but it is "..(#arg % 3)..".", 2)
  959. end
  960.  
  961. for i=1, #arg-2, 3 do
  962. if (type(arg[i]) ~= "string" and type(arg[i]) ~= "table") then
  963. error("Argument type mismatch at 'Check' (arg #"..i.."). Expected 'string' or 'table', got '"..type(arg[i]).."'.", 2)
  964. elseif (type(arg[i+2]) ~= "string") then
  965. error("Argument type mismatch at 'Check' (arg #"..(i+2).."). Expected 'string', got '"..type(arg[i+2]).."'.", 2)
  966. end
  967.  
  968. if (type(arg[i]) == "table") then
  969. local aType = type(arg[i+1])
  970. for _, pType in next, arg[i] do
  971. if (aType == pType) then
  972. aType = nil
  973. break
  974. end
  975. end
  976. if (aType) then
  977. error("Argument type mismatch at '"..funcname.."' ('"..arg[i+2].."'). Expected '"..table.concat(arg[i], "' or '").."', got '"..aType.."'.", 3)
  978. end
  979. elseif (type(arg[i+1]) ~= arg[i]) then
  980. error("Argument type mismatch at '"..funcname.."' ('"..arg[i+2].."'). Expected '"..arg[i].."', got '"..type(arg[i+1]).."'.", 3)
  981. end
  982. end
  983. end
  984.  
  985.  
  986.  
  987.  
  988.  
  989. -- When element data for the player changes, bind or unbind key.
  990. addEventHandler("onClientElementDataChange", getLocalPlayer(),
  991. function(dataName, oldValue)
  992. if(getElementType(source) ~= "player" or dataName ~= "state")then return end
  993. local newValue = getElementData(source, dataName)
  994. if(newValue == "dead")then
  995. reset =true
  996. setTimer(function()
  997. if(#vehicleData > 0 and running)then
  998. showRespawn = true
  999. setElementData(getLocalPlayer(), "respawn.playing", false, true)
  1000. bindKey(RESPAWN_KEY, "up", respawn)
  1001. end
  1002. end,
  1003. 3000, 1)
  1004. else
  1005. unbindKey(RESPAWN_KEY, "up", respawn)
  1006. showRespawn = false
  1007. setElementData(getLocalPlayer(), "respawn.playing", false, true)
  1008. end
  1009. if(newValue == "alive" and oldValue ~= "alive")then
  1010. reset = false
  1011. end
  1012. end)
  1013.  
  1014. -- respawn player, later add "checkpoints"
  1015. function respawn()
  1016. reset = false
  1017. unbindKey(RESPAWN_KEY, "up", respawn)
  1018. showRespawn = false
  1019. setElementData(getLocalPlayer(), "respawn.playing", true, true)
  1020. local index = #vehicleData
  1021. local index2 = #vehicleData
  1022. -- Save memory and go back to later saved positions if dying too fast.
  1023. local timeWasted = math.floor((getTickCount() - lastSaved)/1000)
  1024. if(timeWasted <= 7 and index > 1)then
  1025. table.remove(vehicleData, index)
  1026. index = #vehicleData
  1027. outputDebugString("Vehicle data num: "..index.." removed respawn.")
  1028. end
  1029. outputDebugString("Respawning with vehicle data index: "..index)
  1030. triggerServerEvent("onClientRequestRespawn", getLocalPlayer(), vehicleData[index])
  1031. if(index2 > 1 and index == index2)then
  1032. table.remove(vehicleData, index)
  1033. outputDebugString("Vehicle data num: "..index.." removed.")
  1034. end
  1035. end
  1036.  
  1037.  
  1038.  
  1039. addEventHandler("onClientRender", getRootElement(),
  1040. function()
  1041. if(reset)then
  1042. resetTimer(saveTimer)
  1043. end
  1044. -- Dont show text if player is not allowed to respawn.
  1045. if not showRespawn then return end
  1046. local x, y = screen_width/2 - textWidth/2, screen_height * 0.75 - fontHeight/2
  1047. dxDrawColoredText(text, x, y, screen_width, screen_height, color, scale, font)
  1048. end)
  1049.  
  1050.  
  1051. -- Save vehicle data, to later spawn with that data.
  1052. function saveVehicleData()
  1053. local vehicle = getPedOccupiedVehicle(getLocalPlayer())
  1054. if(not running or showRespawn or (not vehicle) or reset)then return end
  1055. local mode = getElementModel(vehicle)
  1056. if(mode == 425)then return end
  1057. local lastSaved = getTickCount()
  1058. local index = #vehicleData + 1
  1059. vehicleData[index] = {}
  1060. local posX, posY, posZ = getElementPosition(vehicle)
  1061. local rotX, rotY, rotZ = getElementRotation(vehicle)
  1062. local velX, velY, velZ = getElementVelocity(vehicle)
  1063. local turnVelX, turnVelY, turnVelZ = getVehicleTurnVelocity(vehicle)
  1064. local health = getElementHealth(vehicle)
  1065. local model = getElementModel(vehicle)
  1066. -- Later add worldSpecialProperty too.
  1067. vehicleData[index].posX = posX
  1068. vehicleData[index].posY = posY
  1069. vehicleData[index].posZ = posZ
  1070.  
  1071. vehicleData[index].rotX = rotX
  1072. vehicleData[index].rotY = rotY
  1073. vehicleData[index].rotZ = rotZ
  1074.  
  1075. vehicleData[index].velX = velX
  1076. vehicleData[index].velY = velY
  1077. vehicleData[index].velZ = velZ
  1078.  
  1079. vehicleData[index].turnVelX = turnVelX
  1080. vehicleData[index].turnVelY = turnVelY
  1081. vehicleData[index].turnVelZ = turnVelZ
  1082.  
  1083. vehicleData[index].health = health
  1084. vehicleData[index].model = model
  1085. vehicleData[index].dimension = getElementDimension(vehicle)
  1086.  
  1087. vehicleData[index].nitro = nil
  1088. local upgrades = getVehicleUpgrades(vehicle)
  1089. for upgradeKey, upgradeValue in ipairs(upgrades) do
  1090. if(tonumber(upgradeValue) >= 1008 and tonumber(upgradeValue) <= 1010)then
  1091. vehicleData[index].nitro = tonumber(upgradeValue)
  1092. end
  1093. end
  1094. outputDebugString("Vehicle data num: "..index.." saved.")
  1095. end
  1096.  
  1097. saveTimer = setTimer(saveVehicleData, SAVE_INTER, 0)
  1098.  
  1099. function saveRespawnToSpawnpoint(player)
  1100. local vehicle = getPedOccupiedVehicle(player)
  1101. local index = #vehicleData + 1
  1102. vehicleData[index] = {}
  1103. local spawn = getElementsByType("spawnpoint")
  1104. local posX, posY, posZ = getElementData(spawn[1], "posX"), getElementData(spawn[1], "posY"), getElementData(spawn[1], "posZ")
  1105. local rotX, rotY, rotZ = getElementData(spawn[1], "rotX"), getElementData(spawn[1], "rotY"), getElementData(spawn[1], "rotZ")
  1106. local velX, velY, velZ = 0, 0, 0
  1107. local turnVelX, turnVelY, turnVelZ = 0, 0, 0
  1108. local health = getElementHealth(vehicle)
  1109. local model = getElementData(spawn[1], "vehicle")
  1110. -- Later add worldSpecialProperty too.
  1111. vehicleData[index].posX = posX
  1112. vehicleData[index].posY = posY
  1113. vehicleData[index].posZ = posZ
  1114.  
  1115. vehicleData[index].rotX = rotX
  1116. vehicleData[index].rotY = rotY
  1117. vehicleData[index].rotZ = rotZ
  1118.  
  1119. vehicleData[index].velX = velX
  1120. vehicleData[index].velY = velY
  1121. vehicleData[index].velZ = velZ
  1122.  
  1123. vehicleData[index].turnVelX = turnVelX
  1124. vehicleData[index].turnVelY = turnVelY
  1125. vehicleData[index].turnVelZ = turnVelZ
  1126.  
  1127. vehicleData[index].health = health
  1128. vehicleData[index].model = model
  1129. vehicleData[index].dimension = getElementDimension(vehicle)
  1130. end
  1131.  
  1132. addEvent("onClientRaceStateChanging", true)
  1133. addEventHandler("onClientRaceStateChanging", getRootElement(),
  1134. function(newState, oldState)
  1135. if(newState == "Running")then
  1136. local state = tostring(getElementData(getLocalPlayer(), "state"))
  1137. if(state == "waiting")then
  1138. --[[
  1139. reset = false
  1140. running = true
  1141. vehicleData = {}
  1142. saveRespawnToSpawnpoint(getLocalPlayer())
  1143. showRespawn = true
  1144. setElementData(getLocalPlayer(), "respawn.playing", false, true)
  1145. bindKey(RESPAWN_KEY, "up", respawn)
  1146. --]]
  1147. elseif(state == "alive" or state == "not ready")then
  1148. reset = false
  1149. running = true
  1150. for i = 1, #vehicleData do
  1151. table.remove(vehicleData, i)
  1152. end
  1153. vehicleData = {}
  1154. saveVehicleData()
  1155. end
  1156. end
  1157. if(newState == "PostFinish" or newState == "NoMap")then
  1158. reset = true
  1159. running = false
  1160. unbindKey(RESPAWN_KEY, "up", respawn)
  1161. showRespawn = false
  1162. setElementData(getLocalPlayer(), "respawn.playing", false, true)
  1163. end
  1164. end)
  1165.  
  1166. addEventHandler("onClientPlayerWasted", getLocalPlayer(),
  1167. function()
  1168. if(source ~= getLocalPlayer())then return end
  1169. reset = true
  1170. setElementData(getLocalPlayer(), "respawn.playing", false, true)
  1171. setTimer(function()
  1172. --local state = getElementData(getLocalPlayer(), "respawn.playing") or true
  1173. if(#vehicleData > 0 and running)then
  1174. showRespawn = true
  1175. setElementData(getLocalPlayer(), "respawn.playing", false, true)
  1176. bindKey(RESPAWN_KEY, "up", respawn)
  1177. end
  1178. end,
  1179. 3000, 1)
  1180. end)
  1181.  
  1182. local unfreeze = {}
  1183.  
  1184. addEvent("clientUnfreezeOnReady", true)
  1185. addEventHandler("clientUnfreezeOnReady", getRootElement(),
  1186. function(vehicle, vehData)
  1187. -- source is the vehicle to unfreeze
  1188. unfreeze.vehicle = vehicle
  1189. unfreeze.health = vehData.health
  1190. unfreeze.dim = vehData.dimension
  1191. unfreeze.x, unfreeze.y, unfreeze.z = vehData.posX, vehData.posY, vehData.posZ
  1192. unfreeze.vx, unfreeze.vy, unfreeze.vz = vehData.velX, vehData.velY, vehData.velZ
  1193. unfreeze.tx, unfreeze.ty, unfreeze.tz = vehData.turnVelX, vehData.turnVelY, vehData.turnVelZ
  1194. setElementFrozen(vehicle, false)
  1195. addEventHandler("onClientRender", getRootElement(), unfreezeOnReady)
  1196. end)
  1197.  
  1198. function unfreezeOnReady()
  1199. setElementHealth(unfreeze.vehicle, unfreeze.health)
  1200. setElementPosition(unfreeze.vehicle, unfreeze.x, unfreeze.y, unfreeze.z)
  1201. if(not isElementFrozen(unfreeze.vehicle))then
  1202. setElementDimension(unfreeze.vehicle, unfreeze.dim)
  1203. setElementVelocity(unfreeze.vehicle, unfreeze.vx, unfreeze.vy, unfreeze.vz)
  1204. setVehicleTurnVelocity(unfreeze.vehicle, unfreeze.tx, unfreeze.ty, unfreeze.tz)
  1205. removeEventHandler("onClientRender", getRootElement(), unfreezeOnReady)
  1206. end
  1207. end
  1208.  
  1209. function dxDrawColoredText(text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI)
  1210. -- Making them optional.
  1211. right = right or screen_width
  1212. bottom = bottom or screen_height
  1213. while(left < 0) do
  1214. left = screen_width - math.abs(left)
  1215. end
  1216. while(top < 0) do
  1217. top = screen_height - math.abs(top)
  1218. end
  1219. while(right < 0) do
  1220. right = screen_width - math.abs(right)
  1221. end
  1222. while(bottom < 0) do
  1223. bottom = screen_height - math.abs(bottom)
  1224. end
  1225. if(right > screen_width)then right = screen_width end
  1226. if(bottom > screen_height)then bottom = screen_height end
  1227. color = color or tocolor(255, 255, 255, 200)
  1228. scale = scale or 1
  1229. font = font or "default"
  1230. alignX = alignX or "left"
  1231. alignY = alignY or "top"
  1232. clip = clip or false
  1233. wordBreak = wordBreak or false
  1234. postGUI = postGUI or true
  1235. local alpha = intToAlpha(color)
  1236. local text_width = 0
  1237. local offset = 0
  1238. local text_height = dxGetFontHeight(scale, font)
  1239. local TEXT_WIDTH = dxGetTextWidth(text:gsub("#%x%x%x%x%x%x", ""), scale, font)
  1240. local off = -TEXT_WIDTH
  1241. local width = 0
  1242. local height = 0
  1243. if(alignX == "center")then
  1244. left = left + width/2 - TEXT_WIDTH/2
  1245. end
  1246. if(alignX == "right")then
  1247. left = left + width - TEXT_WIDTH
  1248. end
  1249. if(alignY == "center")then
  1250. top = top + height/2 - text_height/2
  1251. end
  1252. if(alignY == "bottom")then
  1253. top = top + height - text_height
  1254. end
  1255. alignX = "left"
  1256. alignY = "top"
  1257.  
  1258. -- 0 index ?
  1259. local col1, col2 = string.find(text, "#%x%x%x%x%x%x")
  1260. if col1 ~= nil then col1 = col1-1 end
  1261.  
  1262. -- draw text with the color we sent until we find hexadecimal code.
  1263. for i = 1, col1 or string.len(text) do
  1264. text_width = dxGetTextWidth(string.sub(text, i, i), scale, font)
  1265. dxDrawText(string.sub(text, i, i), left + offset, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI)
  1266. offset = offset + text_width
  1267. end
  1268. while(string.find(text, "#%x%x%x%x%x%x", i))do
  1269. local hex1, hex2 = string.find(text, "#%x%x%x%x%x%x")
  1270. local r, g, b, a = getColorFromString(string.sub(text, hex1, hex2))
  1271. text = string.sub(text, hex2 + 1)
  1272. hex1, hex2 = string.find(text, "#%x%x%x%x%x%x")
  1273. if hex1 ~= nil then hex1 = hex1-1 end
  1274. for i = 1, hex1 or string.len(text) do
  1275. text_width = dxGetTextWidth(string.sub(text, i, i), scale, font)
  1276. dxDrawText(string.sub(text, i, i), left + offset, top, right, bottom, tocolor(r, g, b, alpha), scale, font, alignX, alignY, clip, wordBreak, postGUI)
  1277. offset = offset + text_width
  1278. end
  1279. end
  1280. end
  1281.  
  1282. function intToAlpha(color)
  1283. local a = 16777216
  1284. local red, green, blue, alpha = 0, 0, 0, 0
  1285. local ap = 1
  1286.  
  1287. if(color < 0)then
  1288. color = 2147483648 + (-color)
  1289. alpha = 383
  1290. ap = -ap
  1291. end
  1292.  
  1293. while(color >= a)do
  1294. alpha = alpha + ap
  1295. color = color - a
  1296. end
  1297. return alpha
  1298. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement