Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------- SERVER
- ------------------------------------------------------------------------------------
- -- SCRIPT: COMMUNITY CONTRIBUTION FOR CIT2.NET
- -- FILE: CITquickStats/quickStats.slua
- -- PURPOSE: Server sided information that goes to client for use in GUI
- -- DEVELOPERS: Nuko and Elite
- ------------------------------------------------------------------------------------
- stats = {
- -- Total turfs taken
- ["turfs"] = {
- msg = "Total turfs taken: ",
- guiMsg = "Total Turfs Taken",
- accStat = "turfs_taken",
- command = "/qs turfs"
- },
- -- Total turfs defended
- --[[["defend"] = {
- msg = "Total turfs defended: ",
- guiMsg = "Total Turfs Defended",
- accStat = "turfs_defended",
- command = "/qs defend"
- },
- -- Total life time wanted points
- ["ltwanted"] = {
- msg = "Life time wanted: ",
- guiMsg = "Life Time Wanted",
- accStat = "lifetime_wanted_points",
- command = "/qs ltwanted"
- },
- -- Total arrests
- ["arrests"] = {
- msg = "Total arrests: ",
- guiMsg = "Total Arrests",
- --accStat = ??
- command = "/qs arrests",
- },
- -- Total arrest points
- ["arrestpoints"] = {
- msg = "Total arrest points: ",
- guiMsg = "Total Arrest Points",
- --accStat = ??
- command = "/qs arrestpoints",
- },
- -- Total arrest kills
- ["arrestkills"] = {
- msg = "Total arrest kills: ",
- guiMsg = "Total Arrest Kills",
- --accStat = ??
- command = "/qs arrestkills",
- },
- -- Total races won
- ["races"] = {
- msg = "Total races won: ",
- guiMsg = "Total Races Won",
- accStat = "race_wins",
- command = "/qs races",
- },
- -- Total briefcase deliveries
- ["bc"] = {
- msg = "Total briefcases dropped off: ",
- guiMsg = "Dropped Off Briefcases",
- accStat = "briefcases_dropped_off",
- command = "/qs bc",
- },
- -- Total bank robs
- ["br"] = {
- msg = "Total successful bank robs: ",
- guiMsg = "Total successful bank robs",
- accStat = "successful_bankrob",
- command = "/qs br",
- },
- -- Total hijack deliveries
- ["hijack"] = {
- msg = "Total successful hijack deliveries: ",
- guiMsg = "Successful Hijack Deliveries",
- accStat = "hijack_delivery",
- command = "/qs hijack",
- },
- -- Total pilot flights
- ["flights"] = {
- msg = "Total pilot flights: ",
- guiMsg = "Total Pilot Flights",
- --accStat = ??
- command = "/qs flights",
- },
- -- Total bus stops
- ["busstops"] = {
- msg = "Total bus stops: ",
- guiMsg = "Total Bus Stops",
- --accStat = ??
- command = "/qs busstops",
- },
- -- Total fires put out
- ["fires"] = {
- msg = "Total fires put out: ",
- guiMsg = "Total Fires Put Out",
- accStat = "fires_put_out",
- command = "/qs fires",
- },
- -- Total heal points
- ["heals"] = {
- msg = "Total heal points: ",
- guiMsg = "Total Heal Points",
- --accStat = ??
- command = "/qs heals",
- },
- -- Total trees cut
- ["trees"] = {
- msg = "Total trees cut: ",
- guiMsg = "Total Trees Cut",
- --accStat = ??
- command = "/qs trees",
- },
- -- Life time iron
- ["iron"] = {
- msg = "Lifetime iron collected: ",
- guiMsg = "Lifetime Iron Collected",
- --accStat = ??
- command = "/qs iron",
- },
- -- Total playtime
- ["playtime"] = {
- msg = "Total play time in server: ",
- guiMsg = "Total Play Time In Server",
- --accStat = ??
- command = "/qs playtime",
- },
- -- Total robbers killed
- ["robberskilled"] = {
- msg = "Total robbers killed: ",
- guiMsg = "Total Robbers Killed",
- accStat = "bank_robbers_killed",
- command = "/qs robberskilled",
- },
- -- Total cops killed
- ["copskilled"] = {
- msg = "Total cops killed: ",
- guiMsg = "Total Cops Killed",
- --accStat = ??
- command = "/qs copskilled",
- },
- -- Total farmer bails collected
- ["farmer"] = {
- msg = "Total farmer bails: ",
- guiMsg = "Total Farmer Bails",
- accStat = "farmer_bails",
- command = "/qs farmer",
- },
- -- Total kills made
- ["kills"] = {
- msg = "Total people killed: ",
- guiMsg = "Total People Killed",
- accStat = "total_kills",
- command = "/qs kills",
- },
- -- Total trucker miles
- ["trucker"] = {
- msg = "Total trucker miles made: ",
- guiMsg = "Total Trucker Miles",
- --accStat = ??
- command = "/qs trucker",
- },
- -- Trucker earnings
- ["truckearnings"] = {
- msg = "Total trucker earnings made: $",
- guiMsg = "Total Trucket Earnings",
- accStat = "trucker_earnings",
- command = "/qs truckearnings",
- },
- -- Total fish sales
- ["fish"] = {
- msg = "Total fish sales: ",
- guiMsg = "Total Fish Sales",
- accStat = "fish_sales",
- command = "/qs fish",
- },
- -- Total delivery earnings
- ["deliveries"] = {
- msg = "Total delivery earnings: $",
- guiMsg = "Total Delivery Earnings",
- accStat = "delivery_earning",
- command = "/qs deliveries",
- },
- -- Total pictures taken
- ["pictures"] = {
- msg = "Total pictures taken: ",
- guiMsg = "Total Pictures Taken",
- accStat = "media_picture",
- command = "/qs pictures",
- },
- -- Total taxi drop-offs
- ["taxi"] = {
- msg = "Total taxi drop offs: ",
- guiMsg = "Total Taxi Drop Offs",
- accStat = "taxi_dropoff",
- command = "/qs taxi",
- },
- -- Total meat collected
- ["meat"] = {
- msg = "Total meat hunted: ",
- guiMsg = "Total Meat Hunted",
- --accStat = ??
- command = "/qs meat",
- }, --]]
- }
- function getServerInfo(plr, stat, cmd)
- if (not stats[cmd]) then
- exports.CIThelp:dm("Usage: '/qs <commandHere>'. You can view quick stat keys by doing '/qsk'.", plr, 255, 0, 0)
- return false
- end
- local stat = exports.CITstats:getPlayerAccountStat(plr, stats[cmd].accStat) or 0
- outputChatBox("[Quick Stats] "..stats[cmd].msg..stat, plr, 50, 255, 50)
- end
- addCommandHandler("qs", getServerInfo)
- function retrieveStatsForClient()
- local tempStatsTable = {}
- for k, v in pairs(stats) do
- local stat = exports.CITstats:getPlayerAccountStat(client, stats[k].accStat) or 0
- tempStatsTable[#tempStatsTable + 1] = {msg = v.guiMsg, stat = stat, cmd = v.command}
- end
- triggerClientEvent(client, "CITquickStats.ReturnStats", resourceRoot, tempStatsTable)
- end
- addEvent("CITquickStats.RetrieveStats", true)
- addEventHandler("CITquickStats.RetrieveStats", root, retrieveStatsForClient)
- ------ CLIENT
- ------------------------------------------------------------------------------------
- -- SCRIPT: COMMUNITY CONTRIBUTION FOR CIT2.NET
- -- FILE: CITquickStats/quickStats.lua
- -- PURPOSE: A new upgraded window used for '/qsk'.
- -- DEVELOPERS: Nuko and Elite
- ------------------------------------------------------------------------------------
- local screenWidth, screenHeight = guiGetScreenSize()
- local lastOpenedTick = getTickCount()
- function quickGUI()
- -- Window
- quickWindow = guiCreateWindow((screenWidth / 2) - (575 / 2), (screenHeight / 2) - (427 / 2), 575, 427, "CIT - Quick Stats", false)
- guiWindowSetSizable(quickWindow, false)
- guiWindowSetMovable(quickWindow, true)
- guiSetAlpha(quickWindow, 0.95)
- guiSetVisible(quickWindow, false)
- -- Information
- 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)
- guiSetFont(quickLab1, "clear-normal")
- guiLabelSetHorizontalAlign(quickLab1, "left", true)
- -- Close
- quickClose = guiCreateButton(16, 378, 542, 30, "Close this window", false, quickWindow)
- guiSetFont(quickClose, "clear-normal")
- -- Gridlist
- quickGrid = guiCreateGridList(16, 145, 542, 223, false, quickWindow)
- guiGridListAddColumn(quickGrid, "Available Stats", 0.4)
- guiGridListAddColumn(quickGrid, "Command", 0.3)
- guiGridListAddColumn(quickGrid, "My Score", 0.2)
- -- Event handler
- addEventHandler("onClientGUIClick", quickClose, closeWindow, false)
- end
- addEventHandler("onClientResourceStart", resourceRoot, quickGUI)
- function returnStats(stats)
- guiGridListClear(quickGrid)
- for k, v in ipairs(stats) do
- local row = guiGridListAddRow(quickGrid)
- guiGridListSetItemText(quickGrid, row, 1, v.msg, false, false)
- guiGridListSetItemText(quickGrid, row, 2, v.cmd, false, false)
- guiGridListSetItemText(quickGrid, row, 3, v.stat, false, false)
- end
- guiSetVisible(quickWindow, true)
- showCursor(true)
- end
- addEvent("CITquickStats.ReturnStats", true)
- addEventHandler("CITquickStats.ReturnStats", resourceRoot, returnStats)
- function closeWindow(button)
- if (button ~= "left") then
- return false
- end
- guiSetVisible(quickWindow, false)
- showCursor(false)
- end
- function openWindow()
- if (guiGetVisible(quickWindow)) then
- guiSetVisible(quickWindow, false)
- showCursor(false)
- return false
- end
- if (getTickCount() - lastOpenedTick < 3000) then
- guiSetVisible(quickWindow, true)
- showCursor(true)
- lastOpenedTick = getTickCount()
- return false
- end
- lastOpenedTick = getTickCount()
- triggerServerEvent("CITquickStats.RetrieveStats", localPlayer)
- end
- addCommandHandler("qsk", openWindow)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement