[code]-- This is the menus! --
--[ERROR] gamemodes/testgm/gamemode/cl_menu.lua:132: attempt to index global 'askdo' (a nil value)
-- This function opens the player's inventory.
function OpenInventory()
local ply = LocalPlayer();
ply.invPanel = vgui.Create( "DPanel" )
if !ply.invPanel then return end
ply.invPanel:SetSize( ScrW(), ScrH() )
ply.invPanel:Center()
ply.invPanel:MakePopup()
ply.invPanel.Paint = function()
surface.SetDrawColor( Color( 0, 0, 0, 120 ))
surface.DrawRect( 0, 0, ply.invPanel:GetWide(), ply.invPanel:GetTall() )
end
local deco = vgui.Create( "DPanel", ply.invPanel )
deco:SetSize( ScrW(), 500 )
deco:SetPos( 0, 60 )
deco.Paint = function()
surface.SetDrawColor( Color( 0, 0, 0, 200 ))
surface.DrawRect( 0, 0, deco:GetWide(), deco:GetTall() )
end
local invLabel = vgui.Create( "DLabel", ply.invPanel )
invLabel:SetText( "You don't have any inventory at the moment." )
invLabel:SetFont( "HudHintTextLarge" );
invLabel:SetPos( 110, 70 )
invLabel:SetSize( 300, 20 )
-- If we have an inventory, show it.
if ply.inventory then
invLabel:SetText( ply:Nick() .. "'s inventory." )
local itemW = 140
local itemH = 100
local itemPadding = 1
local itemPerRow = 5
if #ply.inventory > 20 then
itemPerRow = 8
end
-- Calculations, don't touch.
local itemPanelW = itemPerRow * ( itemW + itemPadding ) + itemPadding
local itemPanelH = math.ceil( #ply.inventory / itemPerRow ) * ( itemH + itemPadding ) + itemPadding
-- Resize if there is an inventory.
//ply.invPanel:SetSize( itemPanelW + 40, itemPanelH + 100 )
ply.invPanel:Center()
local invWrapper = vgui.Create( "DPanel", ply.invPanel )
invWrapper:SetSize( itemPanelW, itemPanelH )
invWrapper:SetPos( 100, 100 );
//invWrapper:Center();
invWrapper.Paint = function()
surface.SetDrawColor( Color( 50, 50, 50, 255 ))
surface.DrawRect( 0, 0, invWrapper:GetWide(), invWrapper:GetTall() )
end
-- For each item, draw an icon.
for k,v in pairs(ply.inventory ) do
if k != "weapon" and k != "melee" then
local x = ( k-1 ) % itemPerRow
local y = math.floor( (k - 1) / itemPerRow )
-- Holder panel.
local itemHolder = vgui.Create( "DPanel", invWrapper )
itemHolder:SetSize( itemW, itemH )
itemHolder:SetPos( x * ( itemW + itemPadding ) + itemPadding, y * ( itemH + itemPadding ) + itemPadding )
itemHolder.Paint = function()
-- Draw a little something if we "hover".
surface.SetDrawColor( Color( 30, 30, 30, 255 ))
surface.DrawRect( 0, 0, itemHolder:GetWide(), itemHolder:GetTall() )
end
if v.item != "none" then
-- This will draw our 3D image.
local itemImage = vgui.Create( "DModelPanel", itemHolder )
itemImage:SetModel( items[v.item].model )
itemImage:SetSize( itemW, itemH - 20 )
itemImage:SetPos( 0, 0 )
itemImage:SetCamPos( Vector( 12, 12, 5 ) )
itemImage:SetLookAt( Vector( 0, 0, 0 ) )
-- This is the button.
local itemBtn = vgui.Create( "DButton", itemHolder )
itemBtn:SetPos( 0, 0 )
itemBtn:SetSize( itemW, itemH )
itemBtn:SetText( "" )
itemBtn.DoClick = function()
-- Do actions on success.
local menu = DermaMenu(itemBtn)
-- Add an option to the menu.
local txt = "Use"
if items[v.item].category == "weapons" then
txt = "Equip/Holster"
end
menu:AddOption( txt, function()
local t = {}
local it = v.item
local ic = v.count
t.success = function()
if (items[it].removeOnUse and ic == 1) or items[it].isAmmo then
itemImage:Remove()
itemBtn:Remove()
elseif items[it].removeOnUse and ic > 1 then
v.count = ic - 1
end
end
-- Ask to use item.
askdo.AskUseItem( k, t )
end )
----------------
menu:AddSpacer()
----------------
menu:AddOption( "Drop All", function()
-- Delete item on drop.
local t = {}
t.success = function()
itemImage:Remove()
itemBtn:Remove()
end
-- Ask to drop.
askdo.AskDropItem( {id = k, count = v.count}, t )
end )
menu:AddOption( "Drop Amount...", function()
DropItemAmount( v, k )
end)
if LocalPlayer():InSafezone() then
if items[v.item].salvage then
----------------
menu:AddSpacer()
----------------
menu:AddOption( "Salvage one item for " .. items[v.item].points .. "$ (Safezone - Permanent)", function()
AskSalvage( k );
if v.count > 1 then
v.count = v.count - 1;
else
itemImage:Remove();
itemBtn:Remove();
end
end)
end
----------------
menu:AddSpacer()
----------------
menu:AddOption( "Move to Bank", function()
AskMoveToBank( k );
itemImage:Remove();
itemBtn:Remove();
end)
end
-- Open the menu.
menu:Open()
end
itemBtn.DoRightClick = itemBtn.DoClick
itemBtn.Paint = function()
if v.item == "none" then return end
if items[v.item].category == "weapons" then
surface.SetDrawColor( Color( 50, 55, 60, 255 ) )
else
surface.SetDrawColor( Color( 50, 50, 50, 255 ) )
end
surface.DrawRect( 0, itemBtn:GetTall() - 20, itemBtn:GetWide(), 20 )
draw.SimpleText( items[v.item].name, "HudHintTextLarge", 4, itemBtn:GetTall() - 10, Color( 150, 150, 150, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
draw.SimpleText( v.count, "Trebuchet24", itemBtn:GetWide() - 8, 12, Color( 200, 200, 200, 255 ), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER )
end
end
end
end
end
end
hook.Add( "OnSpawnMenuOpen", "OpenInventory_", OpenInventory )
hook.Add( "OnSpawnMenuClose", "CloseInventory_", function()
if LocalPlayer().invPanel then
LocalPlayer().invPanel:Remove()
end
end )
-- This function opens a given ID inventory...
function OpenOtherInventory( id )
if !inv then return end
if !inv[id] then return end
local otherPanel = vgui.Create( "DPanel" )
otherPanel:MakePopup()
otherPanel.Paint = function ()
surface.SetDrawColor( Color( 0, 0, 0, 200 ))
surface.DrawRect( 0, 0, otherPanel:GetWide(), otherPanel:GetTall() )
end
if inv[id] then
local itemW = 140
local itemH = 100
local itemPadding = 1
local itemPerRow = 5
if #inv[id] > 20 then
itemPerRow = 8
end
-- Calculations, don't touch.
local itemPanelW = itemPerRow * ( itemW + itemPadding ) + itemPadding
local itemPanelH = math.ceil( #inv[id] / itemPerRow ) * ( itemH + itemPadding ) + itemPadding
-- Resize if there is an inventory.
otherPanel:SetSize( ScrW(), itemPanelH + 100 )
otherPanel:Center()
local invWrapper = vgui.Create( "DPanel", otherPanel )
invWrapper:SetSize( itemPanelW, itemPanelH )
invWrapper:SetPos( 100, 100 );
invWrapper:Center();
invWrapper.Paint = function()
surface.SetDrawColor( Color( 50, 50, 50, 255 ))
surface.DrawRect( 0, 0, invWrapper:GetWide(), invWrapper:GetTall() )
end
-- For each item, draw an icon.
for k,v in pairs(inv[id]) do
if k != "weapon" and k != "melee" then
local x = ( k-1 ) % itemPerRow
local y = math.floor( (k - 1) / itemPerRow )
-- Holder panel.
local itemHolder = vgui.Create( "DPanel", invWrapper )
itemHolder:SetSize( itemW, itemH )
itemHolder:SetPos( x * ( itemW + itemPadding ) + itemPadding, y * ( itemH + itemPadding ) + itemPadding )
itemHolder.Paint = function()
-- Draw a little something if we "hover".
surface.SetDrawColo
That means askdo hasn't been defined anywhere in this code. Are there any additonal files which come with it?
Its only this.
[QUOTE=Mr Ibizza;44477815]Its only this.[/QUOTE]
You're missing something, askdo isn't a standard gmod table or library, it's defined somewhere, and it's definitely not defined in this script.
I dont know how you obtained this since its straight from TPS GmodZ server. But Askdo is the addon that Crashlemon made for the gamemode. if you dont have that in your addons folder then you will always get this error. So either find that or remove it from the code and do an alternative for the inventory to work.
[QUOTE=BluBillz;44484138]I dont know how you obtained this since its straight from TPS GmodZ server. But Askdo is the addon that Crashlemon made for the gamemode. if you dont have that in your addons folder then you will always get this error. So either find that or remove it from the code and do an alternative for the inventory to work.[/QUOTE]
If it's private code; report the post for warez. People have been using a gui tool to extract all client code recently. A lot of people have been stealing stuff this way.
Sorry, you need to Log In to post a reply to this thread.