Hey guys, back at it with the HUD i've been working on, can someone help me figure out how to add a agenda to my hud?
Here's how to get the agenda text:
[code]
local agenda -- Create a variable that will be used later
local function agendaInfo()
local agendaTbl= LocalPlayer():getAgendaTable() -- This will return the players agenda tabl
if not agendaTbl then return end -- If the players jobs doesn't have an agenda/ there was an issue grabbing it, the script will return to prevent script errors.
agenda= agenda or DarkRP.textWrap((LocalPlayer():getDarkRPVar("agenda")):gsub("//", "\n"):gsub("\\n", "\n"), "DermaDefault", 300) -- Set the variable agenda that you created earlier to itself or the new agenda table and wrap it. Set the 300 to whatever you want the max width of each line before it creates another one
if not LocalPlayer():getDarkRPVar("agenda") then return end -- Not sure if this is really needed , but this is just incase the darkrp var isn't set for some reason.
draw.DrawText( agendaTbl.Title, "DermaDefault", 200, 200, color_white, 1 ) -- This will draw the agenda title. Obviously, you can change the positions.
draw.DrawText( agenda, "DermaDefault", 200, 300, color_white) -- This will draw the actual agenda text that we stored above. Again, change the positions.
end
hook.Add("HUDPaint", "nameurshitm8", agendaInfo) -- Hook it to HUDPaint so that it draws, and the agenda will be updated as soon as it changes
[/code]
not sure if this would work, but it should.
I think you meant "if not agentaTbl" on line 3???
[QUOTE=timz9;50892558]I think you meant "if not agentaTbl" on line 3???[/QUOTE]
fixed
[QUOTE=Tupac;50892505]Here's how to get the agenda text:
[code]
local agenda -- Create a variable that will be used later
local function agendaInfo()
local agendaTbl= LocalPlayer():getAgendaTable() -- This will return the players agenda tabl
if not agendaTbl then return end -- If the players jobs doesn't have an agenda/ there was an issue grabbing it, the script will return to prevent script errors.
agenda= agenda or DarkRP.textWrap((LocalPlayer():getDarkRPVar("agenda")):gsub("//", "\n"):gsub("\\n", "\n"), "DermaDefault", 300) -- Set the variable agenda that you created earlier to itself or the new agenda table and wrap it. Set the 300 to whatever you want the max width of each line before it creates another one
if not LocalPlayer():getDarkRPVar("agenda") then return end -- Not sure if this is really needed , but this is just incase the darkrp var isn't set for some reason.
draw.DrawText( agendaTbl.Title, "DermaDefault", 200, 200, color_white, 1 ) -- This will draw the agenda title. Obviously, you can change the positions.
draw.DrawText( agenda, "DermaDefault", 200, 300, color_white) -- This will draw the actual agenda text that we stored above. Again, change the positions.
end
hook.Add("HUDPaint", "nameurshitm8", agendaInfo) -- Hook it to HUDPaint so that it draws, and the agenda will be updated as soon as it changes
[/code]
not sure if this would work, but it should.[/QUOTE]
Sadly this didn't bring any agenda up when you wrote one.
[editline]15th August 2016[/editline]
[QUOTE=Tupac;50892625]fixed[/QUOTE]
Oh didn't see the updated version, let me go check
[editline]15th August 2016[/editline]
[QUOTE=Tupac;50892625]fixed[/QUOTE]
[ERROR] addons/sleekhud/lua/autorun/cl_hud.lua:188: attempt to index a nil value
1. fn - addons/sleekhud/lua/autorun/cl_hud.lua:188
2. unknown - addons/ulib/lua/ulib/shared/hook.lua:110
This is the error that I get in console when I become a job with an agenda
[editline]15th August 2016[/editline]
Fixed! thanks for the help guys
Sorry, you need to Log In to post a reply to this thread.