• Help w/ CPanels
    3 replies, posted
So I'm making an stool that displays 3d text with cam3d2d, but I can't figure out how to store text from a cpanel textbox. I assumed that the text entered would be put in "Command", but when I print the variable it comes out as nil. I basically just need help storing the entered text into a value that I can use later. Any help would be appreciated. [B]TOOL.Category = "Tools" TOOL.Name = "Waypoint Creator" TOOL.Tab = "Waypoints" TOOL.Command = nil TOOL.ConfigName = "" wptext = "Ooga Booga" if (CLIENT) then language.Add("Tool.waypoints.name", "Waypoint Creator") language.Add("Tool.waypoints.desc", "Place waypoints") language.Add("Tool.waypoints.0", "") end function TOOL.BuildCPanel( panel ) panel:AddControl("Header", { Text = "Waypoints", Description = "Adjust values and then create your waypoint!" }) panel:AddControl("textbox", { Label = "Waypoint Name", Command = wptext, WaitForEnter = "1" }) function TOOL:LeftClick( trace ) print(wptext) end function TOOL:RightClick( trace ) end end[/B]
please post this in a code tag
Try doing TOOL.wptext = "Ooga Booga" and access it with self.wptext
[QUOTE=MPan1;51668807]Try doing TOOL.wptext = "Ooga Booga" and access it with self.wptext[/QUOTE] I actually just fixed it :D I had to create a clientside convar with TOOL.ClientConVar["string"] = "blablabla" and store it in that, and then reference it with self:GetClientInfo("string") Code ended up looking like this for anyone wondering [B]TOOL.Category = "Tools" TOOL.Name = "Waypoint Creator" TOOL.Tab = "Waypoints" TOOL.Command = nil TOOL.ConfigName = "" TOOL.ClientConVar["usertext"] = "hi" TOOL.ClientConVar["duration"] = 10 if (CLIENT) then language.Add("Tool.waypoints.name", "Waypoint Creator") language.Add("Tool.waypoints.desc", "Place waypoints") language.Add("Tool.waypoints.0", "") end function TOOL.BuildCPanel( panel ) panel:AddControl("Header", { Text = "Waypoints", Description = "Adjust values and then create your waypoint!" }) panel:AddControl("textbox", { Label = "usertext", Command = "waypoints_usertext" }) end function TOOL:LeftClick( trace ) local text = self:GetClientInfo("usertext") print(text) end function TOOL:RightClick( trace ) print("hi") end function TOOL:Think() end[/B]
Sorry, you need to Log In to post a reply to this thread.