hey folks,
Right now I am using this code:
function PANEL:DoRightClick()
local menu = DermaMenu()
menu.Player = self:GetPlayer()
local close = hook.Call( "TTTScoreboardMenu", nil, menu )
if close then menu:Remove() return end
menu:Open()
local ply = self.Player
if LocalPlayer():IsAdmin() or LocalPlayer():IsSuperAdmin() then
surface.PlaySound("buttons/button9.wav")
local options = DermaMenu()
options:AddOption("Copy Name", function() SetClipboardText(ply:Nick()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/user_edit.png")
options:AddOption("Copy SteamID", function() SetClipboardText(ply:SteamID()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/tag_blue.png")
options:AddSpacer()
options:AddOption("Open Profile", function() ply:ShowProfile() surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/world.png")
options:AddSpacer()
if IsValid(ply) then
local adminop,subimg = options:AddSubMenu("Admin")
subimg:SetImage("icon16/lorry.png")
adminop:AddOption("Slay Next Round", function() RunConsoleCommand("ulx","slaynr",ply:Nick()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/cross.png")
adminop:AddOption("Slay Now", function() RunConsoleCommand("ulx","slay",ply:Nick()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/cut_red.png")
adminop:AddOption("Kick", function() RunConsoleCommand("ulx","kick",ply:Nick(),"You were kicked") surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/door_out.png")
adminop:AddOption("Ban", function() RunConsoleCommand("ulx","ban",ply:Nick(),120,"You were banned") surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/delete.png")
adminop:AddSpacer()
adminop:AddOption("Mute", function() RunConsoleCommand("ulx","mute",ply:Nick()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/asterisk_yellow.png")
adminop:AddOption("Gag", function() RunConsoleCommand("ulx","gag",ply:Nick()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/asterisk_orange.png")
adminop:AddSpacer()
adminop:AddOption("Spectate", function() RunConsoleCommand("ulx","spectate",ply:Nick()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/zoom.png")
adminop:AddSpacer()
options:Open()
end
end
end
to add a feature for my admins to allow them to rightklick on the scoreboard in TTT and use some command, like copy name, open steamprofile(so we can easily detect ghoster). But i also want that my normal players can use this. But only until the "Admin" drop down menu opens. So i tried this:
function PANEL:DoRightClick()
local menu = DermaMenu()
menu.Player = self:GetPlayer()
local close = hook.Call( "TTTScoreboardMenu", nil, menu )
if close then menu:Remove() return end
menu:Open()
local ply = self.Player
if LocalPlayer():IsUser() then
surface.PlaySound("buttons/button9.wav")
local options = DermaMenu()
options:AddOption("Copy Name", function() SetClipboardText(ply:Nick()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/user_edit.png")
options:AddOption("Copy SteamID", function() SetClipboardText(ply:SteamID()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/tag_blue.png")
options:AddSpacer()
options:AddOption("Open Profile", function() ply:ShowProfile() surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/world.png")
options:AddSpacer()
if LocalPlayer():IsAdmin() or LocalPlayer():IsSuperAdmin() then
surface.PlaySound("buttons/button9.wav")
if IsValid(ply) then
local adminop,subimg = options:AddSubMenu("Admin")
subimg:SetImage("icon16/lorry.png")
adminop:AddOption("Slay Next Round", function() RunConsoleCommand("ulx","slaynr",ply:Nick()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/cross.png")
adminop:AddOption("Slay Now", function() RunConsoleCommand("ulx","slay",ply:Nick()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/cut_red.png")
adminop:AddOption("Kick", function() RunConsoleCommand("ulx","kick",ply:Nick(),"You were kicked") surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/door_out.png")
adminop:AddOption("Ban", function() RunConsoleCommand("ulx","ban",ply:Nick(),120,"You were banned") surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/delete.png")
adminop:AddSpacer()
adminop:AddOption("Mute", function() RunConsoleCommand("ulx","mute",ply:Nick()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/asterisk_yellow.png")
adminop:AddOption("Gag", function() RunConsoleCommand("ulx","gag",ply:Nick()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/asterisk_orange.png")
adminop:AddSpacer()
adminop:AddOption("Spectate", function() RunConsoleCommand("ulx","spectate",ply:Nick()) surface.PlaySound("buttons/button9.wav") end):SetImage("icon16/zoom.png")
adminop:AddSpacer()
options:Open()
end
end
end end
In the line where it checks the group I changed Admin and Superadmin into User and added the check for admin before the admin drop down code. But then i get this error in the consol on join.
[ERROR] gamemodes/terrortown/gamemode/vgui/sb_row.lua:296: attempt to call method 'IsUser' (a nil value)
1. DoRightClick - gamemodes/terrortown/gamemode/vgui/sb_row.lua:296
2. unknown - lua/cl_spectator_deathmatch.lua:161
Yeah I am pretty much a newbie to lua.
Best regards,
Lolomat.