When i press F1 for opening my Menu i recieve error like this
Warning: Unhandled usermessage 'Menu'
cl_init.lua
[lua]
include("shared.lua")
function Menu()
local Window=vgui.Create("DFrame")
local Sheet=vgui.Create("DPropertySheet", Window)
local Windowx=700
local Windowy=450
Window:SetPos(1000-Windowx,900-Windowy)
Window:SetSize(Windowx, Windowy)
Window:SetTitle(mod.Name .. " Menu")
Window:MakePopup
Window.Paint=function()
draw.RoundedBox(3, 0, 0, Window:GetWide(), Window:GetTall(), Color(0, 0, 0, 200))
Sheet:SetPos(10, 30)
Sheet:SetSize(Windowx-20, Windowy-75)
end end
usermessage.Hook("Menu", Menu)[/lua]
init.lua
[lua]
AddCSLuaFile("shared.lua")
AddCSLuaFile("cl_init.lua")
include("shared.lua")
function GM:PlayerLoadout(ply)
ply:StripWeapons()
if ply:Team()==1 then
ply:Give("weapon_crowbar")
elseif ply:Team()==2 then
ply:Give("weapon_pistol")
elseif ply:Team()==3 then
ply:Give("weapon_physgun")
end
end
function team_1(ply)
ply:SetTeam(1)
ply:Spawn()
end
function team_2(ply)
ply:SetTeam(2)
ply:Spawn()
end
function team_3(ply)
ply:SetTeam(3)
ply:Spawn()
end
function GM:ShowHelp(ply)
umsg.Start("Menu", ply)
umsg.End()
end
concommand.Add("team_1", team_1)
concommand.Add("team_2", team_2)
concommand.Add("team_3", team_3)
[/lua]
You should use [noparse][lua] and [/lua][/noparse] tags it will make the code easier to read. It looks like you have an error in your client side file. That is why it can not see the usermessage.Hook. I think you miss placed an end, maybe.
Check the console and see if it shows an error in orange writing.
try this
[lua]
include("shared.lua")
function Menu()
local Window = vgui.Create("DFrame")
local Sheet = vgui.Create("DPropertySheet", Window)
local Windowx=700
local Windowy=450
Window:SetPos(1000-Windowx,900-Windowy)
Window:SetSize(Windowx, Windowy)
Window:SetTitle(mod.Name .. " Menu")
Window:MakePopup
Window.Paint = function()
draw.RoundedBox(3, 0, 0, Window:GetWide(), Window:GetTall(), Color(0, 0, 0, 200))
end
Sheet:SetPos(10, 30)
Sheet:SetSize(Windowx-20, Windowy-75)
end
usermessage.Hook("Menu", Menu)
[/lua]
I know this error comes from cl._nit.lua too, i placed ends but maybe i wrongly placed can you show the proper way ? Also im using lua tags but it shows my code broken.
[editline]29th April 2011[/editline]
[QUOTE=Fantym420;29500522]You should use [noparse][lua] and [/lua][/noparse] tags it will make the code easier to read. It looks like you have an error in your client side file. That is why it can not see the usermessage.Hook. I think you miss placed an end, maybe.
Check the console and see if it shows an error in orange writing.
try this
[lua]
include("shared.lua")
function Menu()
local Window = vgui.Create("DFrame")
local Sheet = vgui.Create("DPropertySheet", Window)
local Windowx=700
local Windowy=450
Window:SetPos(1000-Windowx,900-Windowy)
Window:SetSize(Windowx, Windowy)
Window:SetTitle(mod.Name .. " Menu")
Window:MakePopup
Window.Paint = function()
draw.RoundedBox(3, 0, 0, Window:GetWide(), Window:GetTall(), Color(0, 0, 0, 200))
end
Sheet:SetPos(10, 30)
Sheet:SetSize(Windowx-20, Windowy-75)
end
usermessage.Hook("Menu", Menu)
[/lua][/QUOTE]
[gamemodes\cake\gamemode\cl_init.lua:14] function arguments expected near 'Window'
[cpp]
There was a problem opening the gamemode file 'cake/gamemode/cl_init.lua'
Warning: Unhandled usermessage 'Menu'
you need () after Window:MakePopup on line 13
so
[lua]Window:MakePopup()[/lua]
[QUOTE=Fantym420;29500957]you need () after Window:MakePopup on line 13
so
[lua]Window:MakePopup()[/lua][/QUOTE]
YOU SIR A GENIUS THANK YOU VERY MUCH. Im looking the code for 3 hours or something to find the error and i cant believe how im dumb.
Well it's not being dumb, it just being too close to the problem, always remember to check for errors, and the error will usually tell you what is wrong or at least be near what is wrong. After MakePopup it was expecting () because of using the : after Window, and it looked for it till it found more code and so the error showed for the next line number. Always glad to help when/if I can.
Sorry, you need to Log In to post a reply to this thread.