• Need help with
    2 replies, posted
[B]IK, the name was cut off for some weird reason, so if some mod could rename it to Need help with Gamemode Error, I would be really happy[/B] Yeah, Im coding Open World Combat and this error happened [CODE][ERROR] gamemodes/owc/gamemode/modules/f4menu/cl_f4menu.lua:89: bad argument #2 to 'WriteInt' (number expected, got no value) 1. WriteInt - [C]:-1 2. DoClick - gamemodes/owc/gamemode/modules/f4menu/cl_f4menu.lua:89 3. unknown - lua/vgui/dlabel.lua:218 [ERROR] gamemodes/owc/gamemode/modules/f4menu/cl_f4menu.lua:77: bad argument #2 to 'WriteInt' (number expected, got no value) 1. WriteInt - [C]:-1 2. DoClick - gamemodes/owc/gamemode/modules/f4menu/cl_f4menu.lua:77 3. unknown - lua/vgui/dlabel.lua:218 [/CODE] Here are the two files associated with it cl_f4menu [CODE]local Menu function gameMenu() if (Menu == nil)then Menu = vgui.Create( "DFrame" ) Menu:SetSize(750, 500) Menu:Center() Menu:SetTitle("Survival Menu") Menu:SetDraggable(false) Menu:ShowCloseButton(false) Menu:SetDeleteOnClose(false) Menu.Paint = function() surface.SetDrawColor(48,44,21,200) surface.DrawRect(0,0,Menu:GetWide(),Menu:GetTall()) surface.SetDrawColor(40,40,40,255) surface.DrawRect(0,24,Menu:GetWide(),1) end addButtons(Menu) gui.EnableScreenClicker(true) else if(Menu:IsVisible())then Menu:SetVisible(false) gui.EnableScreenClicker(false) else Menu:SetVisible(true) gui.EnableScreenClicker(true) end end end concommand.Add("open_game_menu",gameMenu) function CreatePlayerPanel() local playerPanel = vgui.Create("PlayerPanel", Menu) playerPanel:Hide() -- add things to player panel return playerPanel end function CreateShopPanel() local shopPanel = vgui.Create("ShopPanel", Menu) local entityCatergory = vgui.Create("DCollapsibleCategory", shopPanel) entityCatergory:SetPos(0,0) entityCatergory:SetSize(shopPanel:GetWide(), 100) entityCatergory:SetLabel("Entities") local weaponCatergory = vgui.Create("DCollapsibleCategory", shopPanel) weaponCatergory:SetPos(0,200) weaponCatergory:SetSize(shopPanel:GetWide(), 100) weaponCatergory:SetLabel("Weapons") local entityList = vgui.Create("DIconLayout", entityCatergory) entityList:SetPos(0,20) entityList:SetSize(entityCatergory:GetWide(), entityCatergory:GetTall()) entityList:SetSpaceY(5) entityList:SetSpaceX(5) local weaponList = vgui.Create("DIconLayout", weaponCatergory) weaponList:SetPos(0,20) weaponList:SetSize(weaponCatergory:GetWide(), weaponCatergory:GetTall()) weaponList:SetSpaceY(5) weaponList:SetSpaceX(5) --ERRORS START HERE for k,v in pairs(OWC.Config.SHOP.entsArr)do local icon = vgui.Create("SpawnIcon", entityList) icon:SetModel(v[1]) icon:SetToolTip(v[3].."\nCost: "..v[4]) entityList:Add(icon) icon.DoClick = function(icon) net.Start("buy_entity") net.WriteInt(k) net.SendToServer() end end for k,v in pairs(OWC.Config.SHOP.weaponsArr)do local icon = vgui.Create("SpawnIcon", weaponList) icon:SetModel(v[1]) icon:SetToolTip(v[3].."\nCost: "..v[4]) weaponList:Add(icon) icon.DoClick = function(icon) net.Start("buy_gun") net.WriteInt(k) net.SendToServer() end end return shopPanel end --ERRORS SHOULD END HERE function addButtons(Menu) local playerPanel = CreatePlayerPanel() playerPanel:Hide() local shopPanel = CreateShopPanel() shopPanel:Hide() local playerButton = vgui.Create( "DButton", Menu ) playerButton:SetText("") playerButton:SetSize(100, 50) playerButton:SetPos(0,25) playerButton.Paint = function() --Color of button surface.SetDrawColor(50, 50, 50, 255) surface.DrawRect(0, 0, playerButton:GetWide(), playerButton:GetTall()) --Draw bottom and right colors surface.SetDrawColor(40, 40, 40, 255) surface.DrawRect(0, 49, playerButton:GetWide(),1) surface.DrawRect(99, 0, 1, playerButton:GetTall()) --Draw Text draw.DrawText("Player Info", "DermaDefaultBold", playerButton:GetWide()/2, 17, Color(255, 255, 255, 255), 1) end playerButton.DoClick = function(playerButton) playerPanel:Show() shopPanel:Hide() end local shopButton = vgui.Create( "DButton", Menu ) shopButton:SetText("") shopButton:SetSize(100, 50) shopButton:SetPos(0,75) shopButton.Paint = function() --Color of button surface.SetDrawColor(50, 50, 50, 255) surface.DrawRect(0, 0, shopButton:GetWide(), shopButton:GetTall()) --Draw bottom and right colors surface.SetDrawColor(40, 40, 40, 255) surface.DrawRect(0, 49, shopButton:GetWide(),1) surface.DrawRect(99, 0, 1, shopButton:GetTall()) --Draw Text draw.DrawText("Shop", "DermaDefaultBold", shopButton:GetWide()/2, 17, Color(255, 255, 255, 255), 1) end shopButton.DoClick = function(playerButton) playerPanel:Hide() shopPanel:Show() end end --Player Panel PANEL = {} function PANEL:Init() self:SetSize(1250, 1250) self:SetPos(100,25) end function PANEL:Paint(w,h) surface.SetDrawColor(50, 50, 50, 255) surface.DrawRect(0, 0, w, h) surface.SetTextColor(255, 255, 255, 255) --Name surface.CreateFont("HeaderFont", {font= "Default", size=25, weight=5000}) surface.SetFont("HeaderFont") surface.SetTextPos(5,0) surface.DrawText(LocalPlayer():GetName()) --xp and lvl local xpToLevel = (LocalPlayer():GetNWInt("playerPanel")*100)*3 surface.SetFont("Default") surface.SetTextPos(8,35) surface.DrawText("Level: "..LocalPlayer():GetNWInt("playerLvl")) surface.DrawText("\tXP: "..LocalPlayer():GetNWInt("playerXp")) --balance surface.SetTextPos(8, 55) surface.DrawText("Balance: "..LocalPlayer():GetNWInt("playerMoney")) end vgui.Register("PlayerPanel",PANEL, "Panel") --End of this --Shop Panel PANEL = {} function PANEL:Init() self:SetSize(1250, 1250) self:SetPos(100,25) end function PANEL:Paint(w,h) draw.RoundedBox(0, 0, 0, w,h,Color(255,255,255,200)) end vgui.Register("ShopPanel",PANEL, "Panel") --End of this[/CODE] config.lua [CODE]OWC.Config.SHOP = OWC.Config.SHOP or {} --ENTITY Shop OWC.Config.SHOP.entsArr = OWC.Config.SHOP.entsArr or {} --entsArr[# in order (ex. [1], then [2], and so on)] = {"model", "weapon's folder name (found in qmenu and copying to clipboard)", "name", "cost"} OWC.Config.SHOP.entsArr[1] = {"models/Items/BoxSRounds.mdl", "cw_ammo_kit_small", "Small Ammo Kit", "250"} OWC.Config.SHOP.entsArr[2] = {"models/Items/BoxSRounds.mdl", "cw_attpack_various", "Various Attachments", "550"} OWC.Config.SHOP.entsArr[3] = {"models/Items/BoxSRounds.mdl", "cw_attpack_sights_cqb", "CQB Sights", "450"} OWC.Config.SHOP.entsArr[4] = {"models/Items/BoxSRounds.mdl", "cw_attpack_sights_midrange", "Mid-Range Sight", "550"} OWC.Config.SHOP.entsArr[5] = {"models/Items/BoxSRounds.mdl", "cw_attpack_sights_longrange", "Long Range Sights", "750"} OWC.Config.SHOP.entsArr[6] = {"models/Items/BoxSRounds.mdl", "cw_attpack_sights_sniper", "Sniper Sights", "250"} OWC.Config.SHOP.entsArr[7] = {"models/Items/BoxSRounds.mdl", "cw_attpack_ammotypes_rifles", "Match Grade and Magnum Ammo", "850"} OWC.Config.SHOP.entsArr[8] = {"models/Items/BoxSRounds.mdl", "cw_attpack_suppressors", "Supressors", "650"} --WEAPON Shop OWC.Config.SHOP.weaponsArr = OWC.Config.SHOP.weaponsArr or {} OWC.Config.SHOP.weaponsArr[1] = {"models/weapons/w_rif_ak47.mdl", "cw_ak74", "AK-74", "1000"} OWC.Config.SHOP.weaponsArr[2] = {"models/weapons/w_pist_deagle.mdl", "cw_deagle", "Deagle", "450"} OWC.Config.SHOP.weaponsArr[3] = {"models/weapons/w_cstm_l96.mdl", "cw_l115", "L115", "1250"} OWC.Config.SHOP.weaponsArr[4] = {"models/weapons/w_smg_mp5.mdl", "cw_mp5", "MP5", "750"} OWC.Config.SHOP.weaponsArr[5] = {"models/weapons/w_snip_g3sg1.mdl", "cw_g3a3", "G3A3", "1125"} OWC.Config.SHOP.weaponsArr[6] = {"models/weapons/w_eq_smokegrenade.mdl", "cw_deagle", "Smoke Grenade", "250"} OWC.Config.SHOP.weaponsArr[7] = {"models/weapons/w_rif_m4a1.mdl", "cw_ar15", "AR-15", "1300"} OWC.Config.SHOP.weaponsArr[8] =
With [url=https://wiki.garrysmod.com/page/net/WriteInt]net.WriteInt[/url] you need to provide the bit count as the second argument, you could just set it to 32 if you're not sure. If you want to avoid doing this, you could try using [url=https://wiki.garrysmod.com/page/net/WriteFloat]net.WriteFloat[/url]
Thanks! It is now fixed!
Sorry, you need to Log In to post a reply to this thread.