I wanted to change up the style for a DarkRP script I had.
I created a panel with a DListView with a button that ran a command.
It runs RunConCommand("say", playername .. playermoney .. playerjob .. usergroup).
I'm running into issues with the certain components of the RunConCommand not getting their required information from the proper player.
playername works fine. The rest; playermoney, playerjob, and their usergroup(ulx group), all come from what I assume is the first player found in ipairs.
Here is the semi-working code.
[code]
concommand.Add("doxmenu", function()
local mainmenu = vgui.Create("DFrame")
mainmenu:SetSize(300, 200)
mainmenu:MakePopup()
mainmenu:SetTitle("RP-Info Menu")
mainmenu:Center()
mainmenu:SetKeyBoardInputEnabled()
local playerlist = vgui.Create("DListView", mainmenu)
playerlist:SetSize(mainmenu:GetWide()-20, mainmenu:GetTall()-80)
playerlist:SetPos(10, 30)
playerlist:AddColumn("Players: " .. #player.GetAll())
for k, v in pairs(player.GetHumans()) do
playerlist:AddLine(v:Nick())
end
local infobutton = vgui.Create("DButton", mainmenu)
infobutton:SetSize(mainmenu:GetWide()-20, 25)
infobutton:SetPos(10, mainmenu:GetTall()-40)
infobutton:SetText("Run")
infobutton.DoClick = function()
if playerlist:GetSelectedLine() != nil then
local selectedplayer = playerlist:GetLine(playerlist:GetSelectedLine()):GetValue(1)
for _,v in ipairs(player.GetHumans()) do
local playermoney = (v.DarkRPVars and v.DarkRPVars.money) or 0
local playerjob = (team.GetName(v:Team())) or nil
RunConsoleCommand("say", "// NAME: " .. selectedplayer .. " CASH: $" .. playermoney .. " JOB: " .. playerjob .. " ULX Status: " .. string.lower(FindMetaTable("Entity").GetNetworkedString(v, "UserGroup")))
end
end
end
end)
[/code]
I tried replacing the v's after the button with selected player, but I then get errors for stuff like the money, and an issue with team.
[code]
[ERROR] external:29: attempt to index a string value with bad key ('DarkRPVars' is not part of the string library)
1. error - [C]:-1
2. __index - lua/includes/extensions/string.lua:297
3. DoClick - external:29
4. unknown - lua/vgui/dlabel.lua:232
[/code]
[code]
[ERROR] external:30: attempt to index a string value with bad key ('Team' is not part of the string library)
1. error - [C]:-1
2. __index - lua/includes/extensions/string.lua:297
3. DoClick - external:30
4. unknown - lua/vgui/dlabel.lua:232
[/code]
"selectedplayer" is a string, not a player object.
[QUOTE=Sean Bean;52406335]"selectedplayer" is a string, not a player object.[/QUOTE]
Wow 10/10 help that fixed everything
[editline]27th June 2017[/editline]
[QUOTE=Heroezzz;52406823]RunConsoleCommand("say", "// NAME: " .. selectedplayer .. " CASH: $" .. playermoney .. " JOB: " .. playerjob .. " ULX Status: " .. string.lower(FindMetaTable("Entity").GetNetworkedString(v, "UserGroup")))
You can use or try :
[CODE]local lp = LocalPlayer()
lp:ChatPrint( "NAME: " .. selectedplayer .. " CASH: $" .. playermoney .. " JOB: " .. playerjob .. " ULX Status: " .. selectedplayer:GetNWString("usergroup") )[/CODE][/QUOTE]
I want to use the say command. Sending it as a message.
That still wont fix the issues with it targeting the wrong people.
Sorry, you need to Log In to post a reply to this thread.