ULX

Author Topic: A command for ban history, slays, gags, mutes, kicks, and hours played?  (Read 2769 times)

0 Members and 1 Guest are viewing this topic.

Offline Spectral

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
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?

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: A command for ban history, slays, gags, mutes, kicks, and hours played?
« Reply #1 on: September 10, 2014, 11:25:30 PM »
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
Out of the Garry's Mod business.

Offline Spectral

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: A command for ban history, slays, gags, mutes, kicks, and hours played?
« Reply #2 on: September 13, 2014, 05:26:43 PM »
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,

Code: [Select]
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
Code: [Select]
--[[ 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
Code: [Select]
--[[ 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.
« Last Edit: September 13, 2014, 05:54:37 PM by Spectral »