• Help with Dlabel.
    10 replies, posted
Hello, I need your help, i have a error when i open my help menu . The error is : [@lua\vgui\dcategorycollapse.lua:83] bad argument #1 to 'SetText' (string expected, got nil) The Function is : [code] local function AddText ( Text, Owner ) local CategoryContentOne = vgui.Create("DLabel") CategoryContentOne:SetText( Text ) CategoryContentOne:SizeToContents() Owner:AddItem(CategoryContentOne) end [/code] A example : AddText('Question about the gamemode ?', PanelList1); Thanks.
-snip- Figured it has nothing todo with your function actually, seems like you tried to call SetLabel on the collapsable without passing a string.
Sorry but it worked before the update of gmod :s Edit : A example to fix this please ?
Please post the whole file.
-snip- EDIT: nevermind stupid reply.
[code]local function AddText ( Text, Owner ) local CategoryContentOne = vgui.Create("DLabel") CategoryContentOne:SetText(Text) CategoryContentOne:SizeToContents() Owner:AddItem(CategoryContentOne) end local function AddBar ( Owner, Why ) local bar = vgui.Create('perp_skill_bar', Owner); Owner:AddItem(bar) bar:SetTall(64); bar:SetSkill(Why); end AlphabetWeights = { a = 1, A = 1, b = 2, B = 2, c = 3, C = 3, d = 4, D = 4, e = 5, E = 5, f = 6, F = 6, g = 7, G = 7, h = 8, H = 8, i = 9, I = 9, j = 10, J = 10, k = 11, K = 11, l = 12, L = 12, m = 13, M = 13, n = 14, N = 14, o = 15, O = 15, p = 16, P = 16, q = 17, Q = 17, r = 18, R = 18, s = 19, S = 19, t = 20, T = 20, u = 21, U = 21, v = 22, V = 22, w = 23, W = 23, x = 24, X = 24, y = 25, Y = 25, z = 26, Z = 26 }; function GM.CreateHelpMenu ( ) local W, H = 550, 350; /// local DermaPanel = vgui.Create("DFrame") DermaPanel:SetPos(ScrW() * .5 - W * .5, ScrH() * .5 - H * .5) DermaPanel:SetSize(W, H) DermaPanel:SetTitle("Pulsar Effect RP - Help Menu") DermaPanel:SetVisible(true) DermaPanel:SetDraggable(false) DermaPanel:ShowCloseButton(true) DermaPanel:MakePopup() local PropertySheet = vgui.Create("DPropertySheet", DermaPanel) PropertySheet:StretchToParent(5, 30, 5, 5) local PanelList1 = vgui.Create("DPanelList"); PanelList1:EnableHorizontal(false) PanelList1:EnableVerticalScrollbar(true) PanelList1:SetPadding(5); AddText('Q: Where are all the jobs?!', PanelList1); AddText("A: This gamemode is player driven, meaning players use their skills to create", PanelList1); AddText("jobs of their own by making items other players would need or want, or by becoming", PanelList1); AddText("an outlaw and growing or smuggling drugs, performing 'hits', robberies, etc.", PanelList1); AddText('', PanelList1); AddText('Q: How am I supposed to make money?', PanelList1); AddText("A: There are multiple ways to earn money ranging from selling drugs to making items.", PanelList1); AddText('', PanelList1); AddText('Q: How do I choose my job?', PanelList1); AddText('A: You seek out NPCs scattered around the town to get hired, or start a business.', PanelList1); AddText('', PanelList1); AddText('Q: Where can I find the drug dealer?', PanelList1); AddText("A: He likes to hang around the slums. He doesn't always have everything in stock, though.", PanelList1); AddText('', PanelList1); AddText('Q: Do I have to use a pre-defined job?', PanelList1); AddText('A: Of course not! Players are encouraged to use their skills to make money.', PanelList1); AddText('', PanelList1); AddText('Q: How can I put my gun back in my inventory?', PanelList1); AddText('A: Hit the Q button while holding the weapon you wish to store in your inventory.', PanelList1); AddText('', PanelList1); AddText('Q: How do I form a mixture?', PanelList1); AddText("A: Drop the items and knock them together wtih your gravity cannon.", PanelList1); AddText('', PanelList1); AddText('Q: How do I become the Mayor?', PanelList1); AddText("A: When there is no mayor seek out the County Clerk, and ask to run for office.", PanelList1); AddText('', PanelList1); AddText('Q: How do I give someone money / trade?', PanelList1); AddText("A: Look at them and press F4. This will bring up the trade menu.", PanelList1); AddText('', PanelList1); AddText('Q: How do I sell items?', PanelList1); AddText("A: Put the item you want to sell into a cash register.", PanelList1); local PanelList2 = vgui.Create("DPanelList"); PanelList2:EnableHorizontal(false) PanelList2:EnableVerticalScrollbar(true) PanelList2:SetPadding(5); AddText('1. Do not prop spam / prop push / prop block / prop shield / prop surf / prop kill.', PanelList2); AddText('', PanelList2); AddText('2. Do not, under any circumstances, go under the map.', PanelList2); AddText('', PanelList2); AddText('3. Do not beg other players for loans / money.', PanelList2); AddText('', PanelList2); AddText('4. Do not break laws just to get attention from cops. ', PanelList2); AddText('', PanelList2); AddText('5. Do not kill other players with your cars off the road. If they are walking in the middle of the', PanelList2); AddText('street, then you are allowed to run them down. The local authorities are allowed, however, to', PanelList2); AddText('punish you in any way, shape, or form that they deem necessary.', PanelList2); AddText('', PanelList2); AddText('6. Do not talk in all caps ever. If you wish to yell, use /y.', PanelList2); AddText('', PanelList2); AddText('7. Do not abuse the advertisement system. ( i.e. saying "/advert LOLOL FAIL" )', PanelList2); AddText('', PanelList2); AddText('8. Do not metagame. Metagaming is where you use the knowledge you have gained from an outside', PanelList2); AddText('source other than the RP itself. For example; Seeing pot leaves through walls and getting a', PanelList2); AddText('warrant for whoever owns the house.', PanelList2); AddText('', PanelList2); AddText('9. Do not respond to RP reports that are said in OOC, as that would be metagaming.', PanelList2); AddText('', PanelList2); AddText('10. Do NOT kill another player for no reason but your own entertainment. ( RDM )', PanelList2); AddText('', PanelList2); AddText('11. Do not break the New Life Rule ( NLR ). The NLR comes into affect when your RP character dies', PanelList2); AddText('but you continue to use knowledge gained of the RP from before your death. NLR is 10 mins ', PanelList2); AddText('so you must wait this length of time before returning to your death place, no matter what.', PanelList2); AddText('', PanelList2); AddText("12. Respect the admin's descision. If you disagree with their decisions, post an abuse report or", PanelList2); AddText('a unban request on the Pulsar Effect forums.', PanelList2); AddText('', PanelList2); AddText('13. Do not excessively run around not roleplaying at all. ( Running around on the main roads,', PanelList2); AddText('jumping on cars, hitting random cars with bats, etc. )', PanelList2); AddText('', PanelList2); AddText('14. Do not punch other players excessively without a purpose. ( Punchwhoring )', PanelList2); AddText('', PanelList2); AddText('15. Do not randomly demote someone as a Mayor, or demote someone so your friend can take the new', PanelList2); AddText('job opening. Doing so will get you blacklisted.', PanelList2); AddText('', PanelList2); AddText('16. Do not request a warrant for a reason that you made up or using metagaming resources as an', PanelList2); AddText('Officer.', PanelList2); AddText('', PanelList2); AddText('17. Do not turn your lights / siren on as a government employee just to bypass traffic laws.', PanelList2); AddText('', PanelList2); AddText('18. Only turn your lights / siren on when you receive an emergency call, or another report', PanelList2); AddText('of the like.', PanelList2); AddText('', PanelList2); AddText('19. Do not repeatedly unlock cars just to spam the car alarm noise.', PanelList2); AddText('', PanelList2); AddText('20. Do not sit in the Nexus and spam the NPC for the police, fireman, or paramedic job. When the', PanelList2); AddText('job opens up, you may go to the NPC. Otherwise, it is Career Camping.', PanelList2); AddText('', PanelList2); AddText("21. Do not steal other player's vehicles under any circumstances. You are allowed to borrow their", PanelList2); AddText('cars with their permission, but simple theft is against the rules. ( GTA )', PanelList2); AddText('', PanelList2); AddText('22. Do not text spam or microphone spam.', PanelList2); AddText('', PanelList2); AddText('23. You cannot mess with other players stores. This includes stealing items for sale.', PanelList2); AddText('', PanelList2); AddText('24. Do not purposely run into other cars just to disable them.', PanelList2); AddText('', PanelList2); AddText('25. As a government employee, you must do your job correctly and well, or you will get demoted', PanelList2); AddText('or blacklisted.', PanelList2); AddText('', Pane
CollapsibleCat:SetLabel(v.Name) v.Name is nil, go check for that.
Ok Thanks i test this .
Just a little tip, you can get the "alphabet weight" by doing this string.byte(char:upper())-65
Thanks Flap :D You are a king in lua lol ^^ [editline]10th June 2011[/editline] Ok i have fixed thanks all of the topics . and now i have a error with a lua ^^ The lua is : [code] function ENT:Use ( Activator, Player) if !Player or !Player:IsValid() or !Player:IsPlayer() then return false; end if Player:Team() != TEAM_CITIZEN then Player:Notify('Government official cannot use this machine.'); return false; end if self.Spinning then return false; end if Player:GetCash() < 15 then Player:Notify('Not enough cash.'); return false; end Player:AddProgress(28, 1); Player:TakeCash(15); self.Spinning = true; self.Player = Player; for i = 1, 3 do self.Wheels[i].StopTime = CurTime() + SpinTimes[i]; self.Wheels[i].Outcome = ChancesTable[math.random(1, #ChancesTable)]; self.Wheels[i].StopSpinning = true; end local RP = RecipientFilter(); RP:AddPVS(Player); RP:AddPlayer(Player); umsg.Start('rp_slots_rotate', RP); umsg.Entity(self); for i = 1, 3 do umsg.Short(self.Wheels[i].Outcome); end umsg.End(); function ENT:AnnounceResults ( ) local AmmountWon = 0; if self.Wheels[1].Outcome == self.Wheels[2].Outcome and self.Wheels[1].Outcome == self.Wheels[3].Outcome then AmmountWon = CashWonTable[self.Wheels[1].Outcome]; end if AmmountWon != 0 then self.Player:GiveCash(AmmountWon); end for i = 1, 3 do self.Wheels[i].StopTime = nil; self.Wheels[i].Outcome = nil; self.Wheels[i].StopSpinning = nil; end self.Spinning = nil; self.Player = nil; end function ENT:Think() if self.Spinning then if self.Wheels[3].StopTime and CurTime() >= self.Wheels[3].StopTime then self:AnnounceResults(); end end self:NextThink(CurTime() + .01); return true end [/code] The error is on this : [code] local RP = RecipientFilter(); RP:AddPVS(Player); RP:AddPlayer(Player); [/code]
It helps if you use [noparse][lua][/lua] instead of [code][/code][/noparse] the lua tags add some syntax highlighting and line numbers, it help to identify problems. When you have an error please post the error code too, it helps a lot., I believe Player is a reserved word, try changing all the Player to ply in the ENT:Use function.
Sorry, you need to Log In to post a reply to this thread.