Game is spewing out multiple derma menus and other issues.
12 replies, posted
I am trying to code something, that ask for the users input when they press use on the entity. Whenever I use the entity though, it makes like 50 copies of the menu on my screen.
Here is the code:
[code]function ENT:Use( activator, caller )
if ( activator:IsPlayer() ) then
if SERVER then
umsg.Start( "opendatgame", activator )
umsg.End()
end
end
end
if CLIENT then
function opendatgame()
local base = vgui.Create( "DFrame" )
base:SetSize( 500,500 )
base:Center()
base:SetSizable( true )
base:SetVisible( true )
base:SetTitle( "Picture" )
base:SetDraggable( true )
base:ShowCloseButton( true )
base:MakePopup()
base.Paint = function()
draw.RoundedBox( 8, 0, 0, base:GetWide(), base:GetTall(), Color(35,35,35,200))
draw.DrawText( "Please enter the URL", "TargetID", base:GetWide()/2, 50, Color( 255,255,255,255 ), TEXT_ALIGN_CENTER )
end
local DermaText = vgui.Create( "DTextEntry", base )
DermaText:SetPos( 20,25 )
DermaText:SetTall( 20 )
DermaText:SetWide( 450 )
DermaText:SetEnterAllowed( true )
DermaText.OnEnter = function()
url=DermaText:GetValue()
base:Close()
base:SetVisible( false )
end
end
usermessage.Hook( "opendatgame", opendatgame )
end[/code]
I am thinking that it is because I am hosting the serer on my computer, but It has never done that before when I have coded stuff this way.
Issue 2:
The ent I am working on keeps spewing out these errors:
[code]
[ERROR] addons/test small/lua/entities/picture.lua:164: attempt to index global 'vgui' (a nil value)
1. unknown - addons/test small/lua/entities/picture.lua:164
addons/test small/lua/entities/picture.lua:178: bad argument #1 to 'SetMaterial' (IMaterial expected, got no value)addons/test small/lua/entities/picture.lua:178: bad argument #1 to 'SetMaterial' (IMaterial expected, got no value)
[/code]
I looked at the first error and was like, "Oh I should just put that in a client if statement since you can't runt hat stuff on the server side.". Well as soon as I did that it shoots out this massive amount of spam on my console:
[code] il value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser' (a nil value)addons/test
[LUA] if not IsFirstTimePredicted () then return end [/LUA] ?
[QUOTE=Koolaidmini;42807610][lua] ENT:SetUseType(SIMPLE_USE) [/lua]
Merry christmas.[/QUOTE]
Thanks now just to fix the other issue.
The other issue is that you are trying to create the panels on server, which is impossible. Use "if CLIENT then /*createpanels*/ end" construction.
[QUOTE=Robotboy655;42817425]The other issue is that you are trying to create the panels on server, which is impossible. Use "if CLIENT then /*createpanels*/ end" construction.[/QUOTE]
I did try that, I mentioned me doing that in the original post. That is why I am confuzzled with the error I am getting.
After I add the if client statement, it spams this:
[code]
(a nil value)addons/test small/lua/entities/picture.lua:178: attempt to index global 'browser'
[/code]
The thing is browser is a local function not global.
Also I have noticed that it does not change depending on the user, it keeps the same image for every user whenever someone changes it.
Post whole code.
[QUOTE=Robotboy655;42827232]Post whole code.[/QUOTE]
[lua]
AddCSLuaFile()
local BounceSound = Sound( "garrysmod/balloon_pop_cute.wav" )
DEFINE_BASECLASS( "base_anim" )
ENT.PrintName = "Picture"
ENT.Author = "Digihax"
ENT.Information = "A frame to post pictures in"
ENT.Category = "****"
ENT.Editable = true
ENT.Spawnable = true
ENT.AdminOnly = false
ENT.RenderGroup = RENDERGROUP_TRANSLUCENT
local url = "www.google.com"
-- This is the spawn function. It's called when a client calls the entity to be spawned.
-- If you want to make your SENT spawnable you need one of these functions to properly create the entity
--
-- ply is the name of the player that is spawning it
-- tr is the trace from the player's eyes
--
function ENT:SpawnFunction( ply, tr, ClassName )
if ( !tr.Hit ) then return end
local size = math.random( 16, 48 )
local SpawnPos = tr.HitPos + tr.HitNormal * size
local ent = ents.Create( ClassName )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
local width = 1024
local height = 768
return ent
end
--[[---------------------------------------------------------
Name: Initialize
-----------------------------------------------------------]]
function ENT:Initialize()
if ( SERVER ) then
self.Entity:SetModel( "models/props_c17/Frame002a.mdl")
self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
self.Entity:SetSolid(SOLID_VPHYSICS)
self.Entity:SetUseType(SIMPLE_USE)
self.Entity:SetSolid(SOLID_VPHYSICS)
local phys = self.Entity:GetPhysicsObject()
if(phys:IsValid()) then phys:Wake() end
//
local width = 1024
local height = 768
local url = "www.google.com"
end
end
if ( CLIENT ) then
local matBall = Material( "sprites/sent_ball" )
end
--[[---------------------------------------------------------
Name: OnTakeDamage
-----------------------------------------------------------]]
function ENT:OnTakeDamage( dmginfo )
end
--[[---------------------------------------------------------
Name: Use
-----------------------------------------------------------]]
function ENT:Use( activator, caller )
if ( activator:IsPlayer() ) then
if SERVER then
umsg.Start( "opendatgame", activator )
umsg.End()
end
end
end
local width = 1024
local height = 768
local bwidth = 1400
local bheight = 1029
local scale = 0.125
//local url = "www.google.com"
if g_3DHTML and g_3DHTML:IsValid() then g_3DHTML:Remove() end
if CLIENT then
local browser = vgui.Create("HTML")
g_3DHTML = browser
browser:SetPaintedManually(true)
browser:SetSize(bwidth, bheight)
browser:SetMouseInputEnabled(true)
browser:OpenURL(url)
end
local function DrawSign()
-- Draw a background
surface.SetDrawColor(255, 255, 255, 0)
surface.DrawRect(0, 0, 500, 500)
-- Draw the screen
browser:UpdateHTMLTexture()
render.SetMaterial(browser:GetHTMLMaterial())
render.DrawQuad(Vector(0, 0, 0),
Vector(width, 0, 0),
Vector(width, height, 0),
Vector(0, height, 0))
end
function ENT:Draw()
self.Entity:DrawModel()
//cam.Start3D(EyePos(), EyeAngles())
cam.Start3D2D(self.Entity:GetPos() + Vector( 20, -75, 50), self.Entity:GetAngles() + Angle(0,90,90), scale)
local status, err = pcall(DrawSign)
cam.End3D2D()
if not status then Error(err) end
end
if CLIENT then
usermessage.Hook("opendatgame", function ( activator)
//function opendatgame()
local base = vgui.Create( "DFrame" )
local DermaText = vgui.Create( "DTextEntry", base )
local NumSliderThingy = vgui.Create( "DNumSlider", base )
local NumSliderThingy2 = vgui.Create( "DNumSlider", base )
base:SetSize( 500,150 )
base:Center()
base:SetSizable( false )
base:SetVisible( true )
base:SetTitle( "Picture" )
base:SetDraggable( true )
base:ShowCloseButton( true )
base:MakePopup()
base.Paint = function()
draw.RoundedBox( 8, 0, 0, base:GetWide(), base:GetTall(), Color(100,100,100,255))
draw.DrawText( "Please enter the picture URL", "TargetID", base:GetWide()/2, 50, Color( 255,255,255,255 ), TEXT_ALIGN_CENTER )
end
//local DermaText = vgui.Create( "DTextEntry", base )
DermaText:SetPos( 20,25 )
DermaText:SetTall( 20 )
DermaText:SetWide( 450 )
DermaText:SetEnterAllowed( true )
DermaText.OnEnter = function()
local url = DermaText:GetValue()
Msg("You entered -"..DermaText:GetValue().."-!" ) -- What happens when you press enter
//local check = string.Explode(".", url)
local check = (string.find(url, ".png"))
local check2 = (string.find(url, ".jpg"))
local check3 = (string.find(url, ".gif"))
local check4 = (string.find(url, ".swf"))
local pcheck = (string.find(url, "dick"))
local pcheck2 = (string.find(url, "penis"))
local pcheck3 = (string.find(url, "bluewaffle"))
local pcheck4 = (string.find(url, "vagina"))
local pcheck5 = (string.find(url, "goatsee"))
if check == nil and check2 == nil and check3 == nil and check4 == nil then return false end
if pcheck != nil and pcheck2 != nil and pcheck3 != nil and pcheck4 != nil and pcheck5 != nil then return false end
browser:UpdateHTMLTexture()
browser:OpenURL(url)
base:Close()
base:SetVisible( false )
end
NumSliderThingy:SetPos( 100, 90 )
NumSliderThingy:SetWide( 100 )
NumSliderThingy:SetMin( 0 )
NumSliderThingy:SetMax( 2000 )
NumSliderThingy:SetValue( 1 )
NumSliderThingy:SetDecimals( 0 )
NumSliderThingy:SetText( "Width" )
NumSliderThingy.OnValueChanged = function( panel, value )
print( tostring( value ) )
bwidth = value
browser:SetSize(bwidth, bheight)
end
NumSliderThingy2:SetPos( 300, 90 )
NumSliderThingy2:SetWide( 100 )
NumSliderThingy2:SetMin( 0 )
NumSliderThingy2:SetMax( 2000 )
NumSliderThingy2:SetValue( 1 )
NumSliderThingy2:SetDecimals( 0 )
NumSliderThingy2:SetText( "Width" )
NumSliderThingy2.OnValueChanged = function( panel, value )
print( tostring( value ) )
bheight = value
browser:SetSize(bwidth, bheight)
end
end)
//usermessage.Hook( "opendatgame", opendatgame )
end
[/lua]
I was experimenting a lot in this, so sorry if that gets confusing. My code is normally more organized then that and has a ton of comments in it.
What line errors?
Before the function drawsign (), if I put a if client statement there it will spaz out and keep generating a error until it crashes my game. The error it produces says it is on line 178.
The vgui element HTML does not exist. Use DHTML.
[QUOTE=dingusnin;42831779]The vgui element HTML does not exist. Use DHTML.[/QUOTE]
Thanks that solved one issue.
It seems like every time I try and finish this some error arises.
I was trying to make it change the picture depending on the entity, but if one person changes the picture it changes every single picture on the map.
I moved my variables to the initialize area to make it dependent on the entity but that did not fix anything.
Assing your variables to ENT table like ENT.url = "test" and self.url="test" inside ENT:Whatever function.
Sorry, you need to Log In to post a reply to this thread.