Ulysses
General => Developers Corner => Topic started by: Spectral on September 10, 2014, 10:14:51 PM
-
I am a bit confused on how I would go about this, as I am not an expert in Lua, but I've seen this around on different Garry's Mod servers, where you would type in a command !stats and it would pop up with a GUI which had your hours played, the amount of slays, gags, mutes, kicks, and your ban history.
Staff were able to target specific players and see there stats, as well if they were offline, they could input their Steam ID and still see their stats.
EX:
!stats "Spectral"
!stats STEAM ID HERE
Anybody mind helping me out with this?
-
Try to learn Lua, otherwise neither I, nor most people here will be able to help.
But if you need the basic idea, it's:
- Store player data with GetPData()
- Make DermaPanel
- Display player data on DermaPanel
-
Try to learn Lua, otherwise neither I, nor most people here will be able to help.
But if you need the basic idea, it's:
- Store player data with GetPData()
- Make DermaPanel
- Display player data on DermaPanel
Alright, I tried a little, and have a quick question before going, I am making it where whenever the commands, !gag, !mute, !kick, and !slaynr (!slay works too), will add it to the PData with SetPData.
I was only able to find where ULX handles the kick command and got this,
local currentKicks = ply:GetPData("timesKicked",0)
currentKicks = currentKicks + 1
ply:SetPData("timesKicked",currentKicks)
I haven't tested it, but here are the files so far I have made.
sv_playerstats
--[[ Player Stats | Server Side ]]--
if SERVER then
AddCSLuaFile()
hook.Add("PlayerSay", "OpenGUI", function(ply, text, public) -- Chat Command to open the GUI
local text = string.lower(text)
if (string.sub(text, 1, 8) == string.lower("!stats")) then
ply:ConCommand("stats")
end
end)
concommand.Add("stats", function(ply) -- Console Command to open the GUI
net.Start("OpenPlayerStats")
net.Send(ply)
end )
end
cl_playerstats
--[[ Player Stats | Client Side ]]--
--[[ PData Name = Description
timesKicked = Times the Player has been Kicked
timesSlain = Times the Player has been Slain
timesGagged = Times the Player has been Gagged
timesMuted = Times the Player has been Muted
--]]
if CLIENT then
local Frame = nil
function OpenPlayerStats()
local ply = LocalPlayer()
local currentKicks = ply:GetPData("timesKicked",0)
local currentSlain = ply:GetPData("timesSlain",0)
local currentGagged = ply:GetPData("timesGagged",0)
local currentMuted = ply:GetPData("timesMuted",0)
-- Creating the GUI
Frame = vgui.Create("DFrame")
Frame:SetPos(700, 400)
Frame:SetSize(500, 300)
Frame:SetTitle("Divinity TTT Player Stats")
Frame:SetVisible(true)
Frame:MakePopup()
end
net.Receive("OpenPlayerStats", function(len, ply)
OpenPlayerStats()
end)
end
Where are the commands, !gag, !mute, and !slaynr (when the player is slain) handled like the !kick command?
Also, I have no idea how I would incorporate the ban history in it.