Advertisement
Guest User

Untitled

a guest
May 20th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.89 KB | None | 0 0
  1. ------- SERVER
  2. ------------------------------------------------------------------------------------
  3. -- SCRIPT: COMMUNITY CONTRIBUTION FOR CIT2.NET
  4. -- FILE: CITquickStats/quickStats.slua
  5. -- PURPOSE: Server sided information that goes to client for use in GUI
  6. -- DEVELOPERS: Nuko and Elite
  7. ------------------------------------------------------------------------------------
  8.  
  9. stats = {
  10. -- Total turfs taken
  11. ["turfs"] = {
  12. msg = "Total turfs taken: ",
  13. guiMsg = "Total Turfs Taken",
  14. accStat = "turfs_taken",
  15. command = "/qs turfs"
  16. },
  17. -- Total turfs defended
  18. --[[["defend"] = {
  19. msg = "Total turfs defended: ",
  20. guiMsg = "Total Turfs Defended",
  21. accStat = "turfs_defended",
  22. command = "/qs defend"
  23. },
  24. -- Total life time wanted points
  25. ["ltwanted"] = {
  26. msg = "Life time wanted: ",
  27. guiMsg = "Life Time Wanted",
  28. accStat = "lifetime_wanted_points",
  29. command = "/qs ltwanted"
  30. },
  31. -- Total arrests
  32. ["arrests"] = {
  33. msg = "Total arrests: ",
  34. guiMsg = "Total Arrests",
  35. --accStat = ??
  36. command = "/qs arrests",
  37. },
  38. -- Total arrest points
  39. ["arrestpoints"] = {
  40. msg = "Total arrest points: ",
  41. guiMsg = "Total Arrest Points",
  42. --accStat = ??
  43. command = "/qs arrestpoints",
  44. },
  45. -- Total arrest kills
  46. ["arrestkills"] = {
  47. msg = "Total arrest kills: ",
  48. guiMsg = "Total Arrest Kills",
  49. --accStat = ??
  50. command = "/qs arrestkills",
  51. },
  52. -- Total races won
  53. ["races"] = {
  54. msg = "Total races won: ",
  55. guiMsg = "Total Races Won",
  56. accStat = "race_wins",
  57. command = "/qs races",
  58. },
  59. -- Total briefcase deliveries
  60. ["bc"] = {
  61. msg = "Total briefcases dropped off: ",
  62. guiMsg = "Dropped Off Briefcases",
  63. accStat = "briefcases_dropped_off",
  64. command = "/qs bc",
  65. },
  66. -- Total bank robs
  67. ["br"] = {
  68. msg = "Total successful bank robs: ",
  69. guiMsg = "Total successful bank robs",
  70. accStat = "successful_bankrob",
  71. command = "/qs br",
  72. },
  73. -- Total hijack deliveries
  74. ["hijack"] = {
  75. msg = "Total successful hijack deliveries: ",
  76. guiMsg = "Successful Hijack Deliveries",
  77. accStat = "hijack_delivery",
  78. command = "/qs hijack",
  79. },
  80. -- Total pilot flights
  81. ["flights"] = {
  82. msg = "Total pilot flights: ",
  83. guiMsg = "Total Pilot Flights",
  84. --accStat = ??
  85. command = "/qs flights",
  86. },
  87. -- Total bus stops
  88. ["busstops"] = {
  89. msg = "Total bus stops: ",
  90. guiMsg = "Total Bus Stops",
  91. --accStat = ??
  92. command = "/qs busstops",
  93. },
  94. -- Total fires put out
  95. ["fires"] = {
  96. msg = "Total fires put out: ",
  97. guiMsg = "Total Fires Put Out",
  98. accStat = "fires_put_out",
  99. command = "/qs fires",
  100. },
  101. -- Total heal points
  102. ["heals"] = {
  103. msg = "Total heal points: ",
  104. guiMsg = "Total Heal Points",
  105. --accStat = ??
  106. command = "/qs heals",
  107. },
  108. -- Total trees cut
  109. ["trees"] = {
  110. msg = "Total trees cut: ",
  111. guiMsg = "Total Trees Cut",
  112. --accStat = ??
  113. command = "/qs trees",
  114. },
  115. -- Life time iron
  116. ["iron"] = {
  117. msg = "Lifetime iron collected: ",
  118. guiMsg = "Lifetime Iron Collected",
  119. --accStat = ??
  120. command = "/qs iron",
  121. },
  122. -- Total playtime
  123. ["playtime"] = {
  124. msg = "Total play time in server: ",
  125. guiMsg = "Total Play Time In Server",
  126. --accStat = ??
  127. command = "/qs playtime",
  128. },
  129. -- Total robbers killed
  130. ["robberskilled"] = {
  131. msg = "Total robbers killed: ",
  132. guiMsg = "Total Robbers Killed",
  133. accStat = "bank_robbers_killed",
  134. command = "/qs robberskilled",
  135. },
  136. -- Total cops killed
  137. ["copskilled"] = {
  138. msg = "Total cops killed: ",
  139. guiMsg = "Total Cops Killed",
  140. --accStat = ??
  141. command = "/qs copskilled",
  142. },
  143. -- Total farmer bails collected
  144. ["farmer"] = {
  145. msg = "Total farmer bails: ",
  146. guiMsg = "Total Farmer Bails",
  147. accStat = "farmer_bails",
  148. command = "/qs farmer",
  149. },
  150. -- Total kills made
  151. ["kills"] = {
  152. msg = "Total people killed: ",
  153. guiMsg = "Total People Killed",
  154. accStat = "total_kills",
  155. command = "/qs kills",
  156. },
  157. -- Total trucker miles
  158. ["trucker"] = {
  159. msg = "Total trucker miles made: ",
  160. guiMsg = "Total Trucker Miles",
  161. --accStat = ??
  162. command = "/qs trucker",
  163. },
  164. -- Trucker earnings
  165. ["truckearnings"] = {
  166. msg = "Total trucker earnings made: $",
  167. guiMsg = "Total Trucket Earnings",
  168. accStat = "trucker_earnings",
  169. command = "/qs truckearnings",
  170. },
  171. -- Total fish sales
  172. ["fish"] = {
  173. msg = "Total fish sales: ",
  174. guiMsg = "Total Fish Sales",
  175. accStat = "fish_sales",
  176. command = "/qs fish",
  177. },
  178. -- Total delivery earnings
  179. ["deliveries"] = {
  180. msg = "Total delivery earnings: $",
  181. guiMsg = "Total Delivery Earnings",
  182. accStat = "delivery_earning",
  183. command = "/qs deliveries",
  184. },
  185. -- Total pictures taken
  186. ["pictures"] = {
  187. msg = "Total pictures taken: ",
  188. guiMsg = "Total Pictures Taken",
  189. accStat = "media_picture",
  190. command = "/qs pictures",
  191. },
  192. -- Total taxi drop-offs
  193. ["taxi"] = {
  194. msg = "Total taxi drop offs: ",
  195. guiMsg = "Total Taxi Drop Offs",
  196. accStat = "taxi_dropoff",
  197. command = "/qs taxi",
  198. },
  199. -- Total meat collected
  200. ["meat"] = {
  201. msg = "Total meat hunted: ",
  202. guiMsg = "Total Meat Hunted",
  203. --accStat = ??
  204. command = "/qs meat",
  205. }, --]]
  206. }
  207.  
  208. function getServerInfo(plr, stat, cmd)
  209. if (not stats[cmd]) then
  210. exports.CIThelp:dm("Usage: '/qs <commandHere>'. You can view quick stat keys by doing '/qsk'.", plr, 255, 0, 0)
  211. return false
  212. end
  213. local stat = exports.CITstats:getPlayerAccountStat(plr, stats[cmd].accStat) or 0
  214. outputChatBox("[Quick Stats] "..stats[cmd].msg..stat, plr, 50, 255, 50)
  215. end
  216. addCommandHandler("qs", getServerInfo)
  217.  
  218. function retrieveStatsForClient()
  219. local tempStatsTable = {}
  220. for k, v in pairs(stats) do
  221. local stat = exports.CITstats:getPlayerAccountStat(client, stats[k].accStat) or 0
  222. tempStatsTable[#tempStatsTable + 1] = {msg = v.guiMsg, stat = stat, cmd = v.command}
  223. end
  224. triggerClientEvent(client, "CITquickStats.ReturnStats", resourceRoot, tempStatsTable)
  225. end
  226. addEvent("CITquickStats.RetrieveStats", true)
  227. addEventHandler("CITquickStats.RetrieveStats", root, retrieveStatsForClient)
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237. ------ CLIENT
  238. ------------------------------------------------------------------------------------
  239. -- SCRIPT: COMMUNITY CONTRIBUTION FOR CIT2.NET
  240. -- FILE: CITquickStats/quickStats.lua
  241. -- PURPOSE: A new upgraded window used for '/qsk'.
  242. -- DEVELOPERS: Nuko and Elite
  243. ------------------------------------------------------------------------------------
  244.  
  245. local screenWidth, screenHeight = guiGetScreenSize()
  246. local lastOpenedTick = getTickCount()
  247.  
  248. function quickGUI()
  249. -- Window
  250. quickWindow = guiCreateWindow((screenWidth / 2) - (575 / 2), (screenHeight / 2) - (427 / 2), 575, 427, "CIT - Quick Stats", false)
  251. guiWindowSetSizable(quickWindow, false)
  252. guiWindowSetMovable(quickWindow, true)
  253. guiSetAlpha(quickWindow, 0.95)
  254. guiSetVisible(quickWindow, false)
  255.  
  256. -- Information
  257. quickLab1 = guiCreateLabel(16, 29, 542, 112, "This window can be used to see your current quick stats. You can also see quick stats without viewing this window by doing '/qs <command>'. \n\nExample given: '/qs kills'. This would output your current kills on the server.\n\nExample of how to bind: '/bind key <key> qs <command>. Example given: bind k qs kills.", false, quickWindow)
  258. guiSetFont(quickLab1, "clear-normal")
  259. guiLabelSetHorizontalAlign(quickLab1, "left", true)
  260.  
  261. -- Close
  262. quickClose = guiCreateButton(16, 378, 542, 30, "Close this window", false, quickWindow)
  263. guiSetFont(quickClose, "clear-normal")
  264.  
  265. -- Gridlist
  266. quickGrid = guiCreateGridList(16, 145, 542, 223, false, quickWindow)
  267. guiGridListAddColumn(quickGrid, "Available Stats", 0.4)
  268. guiGridListAddColumn(quickGrid, "Command", 0.3)
  269. guiGridListAddColumn(quickGrid, "My Score", 0.2)
  270.  
  271. -- Event handler
  272. addEventHandler("onClientGUIClick", quickClose, closeWindow, false)
  273. end
  274. addEventHandler("onClientResourceStart", resourceRoot, quickGUI)
  275.  
  276. function returnStats(stats)
  277. guiGridListClear(quickGrid)
  278. for k, v in ipairs(stats) do
  279. local row = guiGridListAddRow(quickGrid)
  280. guiGridListSetItemText(quickGrid, row, 1, v.msg, false, false)
  281. guiGridListSetItemText(quickGrid, row, 2, v.cmd, false, false)
  282. guiGridListSetItemText(quickGrid, row, 3, v.stat, false, false)
  283. end
  284. guiSetVisible(quickWindow, true)
  285. showCursor(true)
  286. end
  287. addEvent("CITquickStats.ReturnStats", true)
  288. addEventHandler("CITquickStats.ReturnStats", resourceRoot, returnStats)
  289.  
  290. function closeWindow(button)
  291. if (button ~= "left") then
  292. return false
  293. end
  294. guiSetVisible(quickWindow, false)
  295. showCursor(false)
  296. end
  297.  
  298. function openWindow()
  299. if (guiGetVisible(quickWindow)) then
  300. guiSetVisible(quickWindow, false)
  301. showCursor(false)
  302. return false
  303. end
  304. if (getTickCount() - lastOpenedTick < 3000) then
  305. guiSetVisible(quickWindow, true)
  306. showCursor(true)
  307. lastOpenedTick = getTickCount()
  308. return false
  309. end
  310. lastOpenedTick = getTickCount()
  311. triggerServerEvent("CITquickStats.RetrieveStats", localPlayer)
  312. end
  313. addCommandHandler("qsk", openWindow)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement