Why I can set AddNotify properly ?
[code]autorun/AddWeapons.lua:67: attempt to call method 'AddNotify' (a nil value)[/code]
[lua]if CLIENT then
function DermaMenu()
DermaPanel = vgui.Create("DFrame") -- make the frame
makelabel = vgui.Create("DLabel") -- make the label
DermaPanel:SetPos(50,50) -- set the frame's position
DermaPanel:SetSize(190, 290) -- set the frame's size
DermaPanel:SetTitle( "Weapons Menu Configurator" ) -- set the frame's title
DermaPanel:SetVisible( true ) -- make it visible
DermaPanel:MakePopup() -- make it popup
function DermaPanel:Paint()
surface.SetDrawColor( 90, 90, 90, 200 )
surface.DrawRect( 0, 0, DermaPanel:GetWide(), DermaPanel:GetTall() )
end
local DermaListView = vgui.Create("DListView")
DermaListView:SetParent(DermaPanel)
DermaListView:SetPos(15, 35)
DermaListView:SetSize(140, 240)
DermaListView:SetMultiSelect(false)
DermaListView:AddColumn("Name") -- Add column
DermaListView:SetMultiSelect( true )
for k,v in pairs(player.GetAll()) do
DermaListView:AddLine(v:Nick()) -- Add lines
end
DermaListView.OnRowSelected = function(panel , line)
print( "aaa" )
end
RButton = vgui.Create("DSysButton", DermaPanel)
RButton:SetPos(173, 130)
RButton:SetSize(14, 34)
RButton:SetType( "right" )
RButton.DoClick = function( button )
LocalPlayer():ConCommand ("SendNotice1")
end
end
concommand.Add("MainMenu", DermaMenu )
end
if SERVER then
function MSGNotice1()
for k,v in pairs(player.GetAll()) do
GAMEMODE:AddNotify("Obey the rules.", 0, 5);
end
end
concommand.Add("SendNotice1", MSGNotice1 )
end[/lua]
AddNotify is client-side only.
[QUOTE=Entoros;22073060]AddNotify is client-side only.[/QUOTE]
I tried also on CLIENT side and it say the same thing
If you're using a gamemode other than Sandbox, make sure it is derived from Sandbox, otherwise that function won't exist.
Ok it's work, it's weird because I tried without restart gmod but before
but also I use lua_openscript_cl for clientside and lua_openscript for serverside to refresh is that good ?
[lua]if CLIENT then
function DermaMenu()
DermaPanel = vgui.Create("DFrame") -- make the frame
makelabel = vgui.Create("DLabel") -- make the label
DermaPanel:SetPos(50,50) -- set the frame's position
DermaPanel:SetSize(190, 290) -- set the frame's size
DermaPanel:SetTitle( "Weapons Menu Configurator" ) -- set the frame's title
DermaPanel:SetVisible( true ) -- make it visible
DermaPanel:MakePopup() -- make it popup
function DermaPanel:Paint()
surface.SetDrawColor( 90, 90, 90, 200 )
surface.DrawRect( 0, 0, DermaPanel:GetWide(), DermaPanel:GetTall() )
end
local DermaListView = vgui.Create("DListView")
DermaListView:SetParent(DermaPanel)
DermaListView:SetPos(15, 35)
DermaListView:SetSize(140, 240)
DermaListView:SetMultiSelect(false)
DermaListView:AddColumn("Name") -- Add column
DermaListView:SetMultiSelect( true )
for k,v in pairs(player.GetAll()) do
DermaListView:AddLine(v:Nick()) -- Add lines
end
DermaListView.OnRowSelected = function(panel , line)
print( "aaa" )
end
RButton = vgui.Create("DSysButton", DermaPanel)
RButton:SetPos(173, 130)
RButton:SetSize(14, 34)
RButton:SetType( "right" )
RButton.DoClick = function( button )
LocalPlayer():ConCommand ("SendNotice1")
end
end
concommand.Add("MainMenu", DermaMenu )
function MSGNotice1()
for k,v in pairs(player.GetAll()) do
GAMEMODE:AddNotify("Obey the rules.", 0, 5);
end
end
concommand.Add("SendNotice1", MSGNotice1 )
end
if SERVER then
end[/lua]
Sorry, you need to Log In to post a reply to this thread.