Author Topic: Making Agenda re-sizable ( Question )  (Read 1588 times)

0 Members and 1 Guest are viewing this topic.

Offline Schiaffino

  • Jr. Member
  • **
  • Posts: 88
  • Karma: 1
Making Agenda re-sizable ( Question )
« on: September 26, 2014, 08:42:51 AM »
Hello guys, well i've been looking for this feature for a while, and i did get something that help me with a "base", i've found ( Laws on HUD re-sizable depending of the amount of laws you insert ).

Let me explain myself better ( and forgive my spelling ).

When you write your agenda, you usually do:

/agenda I'm writing whatever just to make a random // agenda to check how it looks like

ok, the idea basically is that when you insert or you make a new line the

draw.RoundedBox( HEIGHT ... ) get bigger for each "line",

I've found this before ( this is not for agendas of course )

Code: [Select]

-- These are the default laws, they're unchangeable in-game.
local Laws = {
"Do not attack other citizens except in self-defence.",
"Do not steal or break in to peoples homes.",
"Money printers/drugs are illegal.",
}

function DrawLaws()

local X = ScrW()-500
local Y = 0
local W = 500
local H = 290

surface.SetDrawColor( 0, 0, 0, 200 )
surface.DrawRect( X, Y, W, 35+(#Laws*20) )

draw.RoundedBox( 4, X, Y, W, 30, Color( 0, 0, 100, 200 ) )
draw.DrawText("LAWS OF THE LAND", "TargetID", X+W/2, Y+7, Color( 255, 0, 0, 200 ), TEXT_ALIGN_CENTER )

local y = 35
for i, law in pairs( Laws ) do

draw.DrawText( i .. ": " .. law, "TargetID", X+5, y, Color( 255, 255, 255, 200 ) )

y = y + 20

end

end
hook.Add("HUDPaint", "DrawLaws", DrawLaws)


local function AddLaw( um )

print("Catched by Lawshud")
table.insert( Laws, um:ReadString() )

end
usermessage.Hook("DRP_AddLaw", AddLaw )

local function RemoveLaw( um )

table.remove( Laws, um:ReadChar() )

end
usermessage.Hook("DRP_RemoveLaw", RemoveLaw )

And the actual agenda code of darkrp is.

Code: [Select]
local agendaText
local function Agenda()
local shouldDraw = hook.Call("HUDShouldDraw", GAMEMODE, "DarkRP_Agenda")
if shouldDraw == false then return end

local agenda = localplayer:getAgendaTable()
if not agenda then return end
agendaText = agendaText or DarkRP.textWrap((localplayer:getDarkRPVar("agenda") or ""):gsub("//", "\n"):gsub("\\n", "\n"), "DarkRPHUD1", 440)

draw.RoundedBox(10, 10, 10, 460, 110, colors.gray1)

draw.RoundedBox(10, 12, 12, 456, 106, colors.gray2) -- TRYING TO ADD TO THE 456 HEIGHT ( OFC WHEN I GET THE CORRECT FUNCTION ITS GOING TO BE LIKE 50 OR LESS... BUT TO ADD EACH LINE EXTRA SPACE TO THIS AREA )
draw.RoundedBox(10, 12, 12, 456, 20, colors.darkred)

draw.DrawNonParsedText(agenda.Title, "DarkRPHUD1", 30, 12, colors.red, 0)
draw.DrawNonParsedText(agendaText, "DarkRPHUD1", 30, 35, colors.white, 0)
end

Is there a way to detect the spaces you make on the Agenda somehow ? becuase i've tried #agenda , since local = agenda gets the table but didn't work :B

Any help ?

Thanks !