F4 Menu shop for my gamemode isnt allowing me to buy guns
1 replies, posted
[B]This isnt for darkrp, it is for my custom gamemode "Open World Combat"
Here is the code, the fix I need I think is in the WEAPON Shop area
Im guessing the error has to do with DoClick, because I cant click on the gun at all, I still have the pointer cursor and not the click cursor
[/B][CODE]local Menu
net.Receive("Fmenu",function()
local Menu = vgui.Create("DFrame")
Menu:SetSize(750,500)
Menu:SetPos(ScrW()/2 -325, ScrH()/2 -250)
Menu:SetTitle("Survival Menu")
Menu:SetDraggable(false)
Menu:ShowCloseButton(true)
Menu:SetDeleteOnClose(false)
Menu:MakePopup()
Menu.Paint = function()
surface.SetDrawColor(60, 60, 60, 255)
surface.DrawRect(0, 0, Menu:GetWide(), Menu:GetTall())
surface.SetDrawColor(40, 40, 40, 255)
surface.DrawRect(0, 24,Menu:GetWide(), 1)
end
addButtons(Menu)
end)
function addButtons(Menu)
local playerButton = vgui.Create("DButton")
playerButton:SetParent(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)
local playerPanel = Menu:Add("PlayerPanel")
playerPanel.Paint = function()
surface.SetDrawColor(50, 50, 50, 255)
surface.DrawRect(0, 0, playerPanel:GetWide(), playerPanel:GetTall())
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
end
local shopButton = vgui.Create("DButton")
shopButton:SetParent(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)
shopButton.DoClick = function(playerButton)
local shopPanel = Menu:Add("ShopPanel")
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,100)
weaponCatergory:SetSize(shopPanel:GetWide(), 100)
weaponCatergory:SetLabel("Weapons")
local entityList = vgui.Create("DIconLayout", shopPanel)
entityList:SetPos(0,0)
entityList:SetSize(shopPanel:GetWide(), shopPanel:GetTall())
entityList:SetSpaceY(5)
entityList:SetSpaceX(5)
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)
--WEAPON Shop
local weaponsArr = {}
weaponsArr[1] = {"models/weapons/w_rif_ak47.mdl", "fas2_ak47", "AK-47", "1000"}
for k,v in pairs(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)
LocalPlayer():ConCommmand("buy_gun "..v[2].." "..v[4])
end
end
end
end
end
--Player Panel
PANEL = {}
function PANEL:Init()
self:SetSize(650, 475)
self:SetPos(100,25)
end
function PANEL:Paint(w,h)
draw.RoundedBox(0, 0, 0, w,h,Color(140,140,140,255))
end
vgui.Register("PlayerPanel",PANEL, "Panel")
--End of this
--Shop Panel
PANEL = {}
function PANEL:Init()
self:SetSize(650, 475)
self:SetPos(100,25)
end
function PANEL:Paint(w,h)
draw.RoundedBox(0, 0, 0, w,h,Color(255,255,255,255))
end
vgui.Register("ShopPanel",PANEL, "Panel")
--End of this
[/CODE]
Thanks!
Move the weaponList:Add(icon) after the doclick line
Sorry, you need to Log In to post a reply to this thread.