GDO lua problem

hey guys.
i hope some of you can help me.
when i use the gdo tool and try to save a new iris password it says:
“weapons/weapon_gdo/cl_init.lua:136: attempt to concatenate a nil value”

plzz help me


include('shared.lua')

SWEP.PrintName          = "Stargate GDO"
SWEP.Slot               = 5
SWEP.Slotpos            = 1
SWEP.Drawammo           = false
SWEP.Drawcrosshair      = false
SWEP.WepSelectIcon = surface.GetTextureID("weapons/gdo_inventory")

CreateClientConVar("cl_weapon_gdo_iriscode", 0, true, true)
CreateClientConVar("cl_weapon_gdo_codelist", "", true, true)

function ShowIrisMenu()

	local codesString = LocalPlayer():GetInfo("cl_weapon_gdo_codelist")
	codes = {}
	
	if codeString != "" then
		local tempvar = ""
		for k,v in pairs(string.Explode("|", codesString)) do
			tempvar = string.Explode(",", v)
			codes[tempvar[1]] = tempvar[2]
		end
	end
	
	local panel = vgui.Create("DFrame")
	panel:SetDeleteOnClose()
	panel:ShowCloseButton(false)
	panel:SetTitle("Select the iris code")
	panel:SetSize(350, 215)
	panel:SetPos((ScrW()/2 - 350) / 2, ScrH()/2 - 75)
	panel:MakePopup()
	
	local codeLabel = vgui.Create("DLabel", panel)
	codeLabel:SetPos(10,25)
	codeLabel:SetText("Iris Code")
	
	local descLabel = vgui.Create("DLabel", panel)
	descLabel:SetPos(120,25)
	descLabel:SetText("Description")
	
	local code = vgui.Create( "DTextEntry", panel)
	code:SetPos( 10, 45)
	code:SetSize(100, 20)	
	
	local desc = vgui.Create ("DTextEntry", panel)
	desc:SetPos(120, 45)
	desc:SetSize(100, 20)
	
	for k,v in pairs(codes) do
		if v == LocalPlayer():GetInfo("cl_weapon_gdo_iriscode") then
			code:SetText(v)
			desc:SetText(k)
		end
	end
	
	local addButton = vgui.Create("DButton", panel)
	addButton:SetPos(230, 45)
	addButton:SetSize(20,20)
	addButton:SetText("+")
	
	function addButton:DoClick()
		local found = false
		for k,v in pairs(codes) do
			if v == tonumber(code:GetValue()) or k == desc:GetValue() then
				found = true
			end
		end

		if not found then
			codes[string.gsub(string.gsub(desc:GetValue(), "|", ""), ",", "")] = tonumber(code:GetValue())
			updateCodes()
		end
	end
	
	local remButton = vgui.Create("DButton", panel)
	remButton:SetPos(260, 45)
	remButton:SetSize(20,20)
	remButton:SetText("-")
	
	function remButton:DoClick()
		local found = false
		for k,v in pairs(codes) do
			if v == tonumber(code:GetValue()) or k == desc:GetValue() then
				found = true
				codes[k] = nil
			end
		end
		
		if found then
			updateCodes()
		end
	end
	
	local codeList = vgui.Create( "DListView", panel)
	codeList:SetPos(10, 75)
	codeList:SetSize(330, 100)
	codeList:AddColumn("Code")
	codeList:AddColumn("Description")
	codeList:SortByColumn(1, true)
	
	function updateCodes()
		codeList:Clear()
		for k,v in pairs(codes) do
			codeList:AddLine(v, k)
		end
	end
	
	updateCodes()
	
	function codeList:OnRowSelected(id, selected)
		local codeS = selected:GetColumnText(1)
		local descS = selected:GetColumnText(2)
		code:SetText(codeS)
		desc:SetText(descS)
	end
	
	function codeList:DoDoubleClick(ListView, List)
		saveCodes()
		panel:Close()
	end
	
	local saveClose = vgui.Create("DButton", panel)
	saveClose:SetText("Save and Close")
	saveClose:SetSize(100, 22)
	saveClose:SetPos(10,185)
	
	function saveClose:DoClick()
		saveCodes()
		panel:Close()
	end
	
	function saveCodes()
		addButton:DoClick()
		local codesList = {}
		LocalPlayer():ConCommand("cl_weapon_gdo_iriscode " .. tonumber(code:GetValue()) .. "
")
		for k,v in pairs(codes) do
			table.insert(codesList, k..","..v)
		end
		LocalPlayer():ConCommand("cl_weapon_gdo_codelist " .. string.Implode("|", codesList) .. "
")
	end
	
	local cancelButton = vgui.Create("DButton", panel)
	cancelButton:SetText("Cancel")
	cancelButton:SetPos(120, 185)
	
	function cancelButton:DoClick()
		panel:Close()
	end
end

function gdo_menuhook(um)
	ShowIrisMenu()
end

usermessage.Hook("gdo_openpanel", gdo_menuhook)

How about you post the code.

sry… here it is.


include('shared.lua')

SWEP.PrintName          = "Stargate GDO"
SWEP.Slot               = 5
SWEP.Slotpos            = 1
SWEP.Drawammo           = false
SWEP.Drawcrosshair      = false
SWEP.WepSelectIcon = surface.GetTextureID("weapons/gdo_inventory")

CreateClientConVar("cl_weapon_gdo_iriscode", 0, true, true)
CreateClientConVar("cl_weapon_gdo_codelist", "", true, true)

function ShowIrisMenu()

	local codesString = LocalPlayer():GetInfo("cl_weapon_gdo_codelist")
	codes = {}
	
	if codeString != "" then
		local tempvar = ""
		for k,v in pairs(string.Explode("|", codesString)) do
			tempvar = string.Explode(",", v)
			codes[tempvar[1]] = tempvar[2]
		end
	end
	
	local panel = vgui.Create("DFrame")
	panel:SetDeleteOnClose()
	panel:ShowCloseButton(false)
	panel:SetTitle("Select the iris code")
	panel:SetSize(350, 215)
	panel:SetPos((ScrW()/2 - 350) / 2, ScrH()/2 - 75)
	panel:MakePopup()
	
	local codeLabel = vgui.Create("DLabel", panel)
	codeLabel:SetPos(10,25)
	codeLabel:SetText("Iris Code")
	
	local descLabel = vgui.Create("DLabel", panel)
	descLabel:SetPos(120,25)
	descLabel:SetText("Description")
	
	local code = vgui.Create( "DTextEntry", panel)
	code:SetPos( 10, 45)
	code:SetSize(100, 20)	
	
	local desc = vgui.Create ("DTextEntry", panel)
	desc:SetPos(120, 45)
	desc:SetSize(100, 20)
	
	for k,v in pairs(codes) do
		if v == LocalPlayer():GetInfo("cl_weapon_gdo_iriscode") then
			code:SetText(v)
			desc:SetText(k)
		end
	end
	
	local addButton = vgui.Create("DButton", panel)
	addButton:SetPos(230, 45)
	addButton:SetSize(20,20)
	addButton:SetText("+")
	
	function addButton:DoClick()
		local found = false
		for k,v in pairs(codes) do
			if v == tonumber(code:GetValue()) or k == desc:GetValue() then
				found = true
			end
		end

		if not found then
			codes[string.gsub(string.gsub(desc:GetValue(), "|", ""), ",", "")] = tonumber(code:GetValue())
			updateCodes()
		end
	end
	
	local remButton = vgui.Create("DButton", panel)
	remButton:SetPos(260, 45)
	remButton:SetSize(20,20)
	remButton:SetText("-")
	
	function remButton:DoClick()
		local found = false
		for k,v in pairs(codes) do
			if v == tonumber(code:GetValue()) or k == desc:GetValue() then
				found = true
				codes[k] = nil
			end
		end
		
		if found then
			updateCodes()
		end
	end
	
	local codeList = vgui.Create( "DListView", panel)
	codeList:SetPos(10, 75)
	codeList:SetSize(330, 100)
	codeList:AddColumn("Code")
	codeList:AddColumn("Description")
	codeList:SortByColumn(1, true)
	
	function updateCodes()
		codeList:Clear()
		for k,v in pairs(codes) do
			codeList:AddLine(v, k)
		end
	end
	
	updateCodes()
	
	function codeList:OnRowSelected(id, selected)
		local codeS = selected:GetColumnText(1)
		local descS = selected:GetColumnText(2)
		code:SetText(codeS)
		desc:SetText(descS)
	end
	
	function codeList:DoDoubleClick(ListView, List)
		saveCodes()
		panel:Close()
	end
	
	local saveClose = vgui.Create("DButton", panel)
	saveClose:SetText("Save and Close")
	saveClose:SetSize(100, 22)
	saveClose:SetPos(10,185)
	
	function saveClose:DoClick()
		saveCodes()
		panel:Close()
	end
	
	function saveCodes()
		addButton:DoClick()
		local codesList = {}
		LocalPlayer():ConCommand("cl_weapon_gdo_iriscode " .. tonumber(code:GetValue()) .. "
")
		for k,v in pairs(codes) do
			table.insert(codesList, k..","..v)
		end
		LocalPlayer():ConCommand("cl_weapon_gdo_codelist " .. string.Implode("|", codesList) .. "
")
	end
	
	local cancelButton = vgui.Create("DButton", panel)
	cancelButton:SetText("Cancel")
	cancelButton:SetPos(120, 185)
	
	function cancelButton:DoClick()
		panel:Close()
	end
end

function gdo_menuhook(um)
	ShowIrisMenu()
end

usermessage.Hook("gdo_openpanel", gdo_menuhook)

Put it in code tags

so i have done that… maby you can help me now?:slight_smile:

I don’t spend every minute of my life looking through Facepunch. I’ll look at it in a second.

Edit: What you were trying to do there wasn’t easy to see. I fixed the error anyway.

[lua]include(‘shared.lua’)

SWEP.PrintName = “Stargate GDO”
SWEP.Slot = 5
SWEP.Slotpos = 1
SWEP.Drawammo = false
SWEP.Drawcrosshair = false
SWEP.WepSelectIcon = surface.GetTextureID(“weapons/gdo_inventory”)

CreateClientConVar(“cl_weapon_gdo_iriscode”, 0, true, true)
CreateClientConVar(“cl_weapon_gdo_codelist”, “”, true, true)

function ShowIrisMenu()

local codesString = LocalPlayer():GetInfo("cl_weapon_gdo_codelist")
codes = {}

if codeString != "" then
	local tempvar = ""
	for k,v in pairs(string.Explode("|", codesString)) do
		tempvar = string.Explode(",", v)
		codes[tempvar[1]] = tempvar[2]
	end
end

local panel = vgui.Create("DFrame")
panel:SetDeleteOnClose()
panel:ShowCloseButton(false)
panel:SetTitle("Select the iris code")
panel:SetSize(350, 215)
panel:SetPos((ScrW()/2 - 350) / 2, ScrH()/2 - 75)
panel:MakePopup()

local codeLabel = vgui.Create("DLabel", panel)
codeLabel:SetPos(10,25)
codeLabel:SetText("Iris Code")

local descLabel = vgui.Create("DLabel", panel)
descLabel:SetPos(120,25)
descLabel:SetText("Description")

local code = vgui.Create( "DTextEntry", panel)
code:SetPos( 10, 45)
code:SetSize(100, 20)	

local desc = vgui.Create ("DTextEntry", panel)
desc:SetPos(120, 45)
desc:SetSize(100, 20)

for k,v in pairs(codes) do
	if v == LocalPlayer():GetInfo("cl_weapon_gdo_iriscode") then
		code:SetText(v)
		desc:SetText(k)
	end
end

local addButton = vgui.Create("DButton", panel)
addButton:SetPos(230, 45)
addButton:SetSize(20,20)
addButton:SetText("+")

function addButton:DoClick()
	local found = false
	for k,v in pairs(codes) do
		if v == tonumber(code:GetValue()) or k == desc:GetValue() then
			found = true
		end
	end

	if not found then
		codes[string.gsub(string.gsub(desc:GetValue(), "|", ""), ",", "")] = tonumber(code:GetValue())
		updateCodes()
	end
end

local remButton = vgui.Create("DButton", panel)
remButton:SetPos(260, 45)
remButton:SetSize(20,20)
remButton:SetText("-")

function remButton:DoClick()
	local found = false
	for k,v in pairs(codes) do
		if v == tonumber(code:GetValue()) or k == desc:GetValue() then
			found = true
			codes[k] = nil
		end
	end
	
	if found then
		updateCodes()
	end
end

local codeList = vgui.Create( "DListView", panel)
codeList:SetPos(10, 75)
codeList:SetSize(330, 100)
codeList:AddColumn("Code")
codeList:AddColumn("Description")
codeList:SortByColumn(1, true)

function updateCodes()
	codeList:Clear()
	for k,v in pairs(codes) do
		codeList:AddLine(v, k)
	end
end

updateCodes()

function codeList:OnRowSelected(id, selected)
	local codeS = selected:GetColumnText(1)
	local descS = selected:GetColumnText(2)
	code:SetText(codeS)
	desc:SetText(descS)
end

function codeList:DoDoubleClick(ListView, List)
	saveCodes()
	panel:Close()
end

local saveClose = vgui.Create("DButton", panel)
saveClose:SetText("Save and Close")
saveClose:SetSize(100, 22)
saveClose:SetPos(10,185)

function saveClose:DoClick()
	saveCodes()
	panel:Close()
end

function saveCodes()
	addButton:DoClick()
	local codesList = {}
	if code:GetValue() then
		LocalPlayer():ConCommand("cl_weapon_gdo_iriscode " .. tonumber(code:GetValue()) .. "

“)
end
for k,v in pairs(codes) do
table.insert(codesList, k…”,"…v)
end
LocalPlayer():ConCommand(“cl_weapon_gdo_codelist " … string.Implode(”|", codesList) … "
")
end

local cancelButton = vgui.Create("DButton", panel)
cancelButton:SetText("Cancel")
cancelButton:SetPos(120, 185)

function cancelButton:DoClick()
	panel:Close()
end

end

function gdo_menuhook(um)
ShowIrisMenu()
end

usermessage.Hook(“gdo_openpanel”, gdo_menuhook)[/lua]

thx… but now it just says “weapons/weapon_gdo/cl_init.lua:137: attempt to concatenate a nil value”

Then something is seriously wrong with your script. I checked if the value was nil or not before allowing it to run the command.

Try this anyway:

[lua]include(‘shared.lua’)

SWEP.PrintName = “Stargate GDO”
SWEP.Slot = 5
SWEP.Slotpos = 1
SWEP.Drawammo = false
SWEP.Drawcrosshair = false
SWEP.WepSelectIcon = surface.GetTextureID(“weapons/gdo_inventory”)

CreateClientConVar(“cl_weapon_gdo_iriscode”, 0, true, true)
CreateClientConVar(“cl_weapon_gdo_codelist”, “”, true, true)

function ShowIrisMenu()

local codesString = LocalPlayer():GetInfo("cl_weapon_gdo_codelist")
codes = {}

if codeString != "" then
	local tempvar = ""
	for k,v in pairs(string.Explode("|", codesString)) do
		tempvar = string.Explode(",", v)
		codes[tempvar[1]] = tempvar[2]
	end
end

local panel = vgui.Create("DFrame")
panel:SetDeleteOnClose()
panel:ShowCloseButton(false)
panel:SetTitle("Select the iris code")
panel:SetSize(350, 215)
panel:SetPos((ScrW()/2 - 350) / 2, ScrH()/2 - 75)
panel:MakePopup()

local codeLabel = vgui.Create("DLabel", panel)
codeLabel:SetPos(10,25)
codeLabel:SetText("Iris Code")

local descLabel = vgui.Create("DLabel", panel)
descLabel:SetPos(120,25)
descLabel:SetText("Description")

local code = vgui.Create( "DTextEntry", panel)
code:SetPos( 10, 45)
code:SetSize(100, 20)	

local desc = vgui.Create ("DTextEntry", panel)
desc:SetPos(120, 45)
desc:SetSize(100, 20)

for k,v in pairs(codes) do
	if v == LocalPlayer():GetInfo("cl_weapon_gdo_iriscode") then
		code:SetText(v)
		desc:SetText(k)
	end
end

local addButton = vgui.Create("DButton", panel)
addButton:SetPos(230, 45)
addButton:SetSize(20,20)
addButton:SetText("+")

function addButton:DoClick()
	local found = false
	for k,v in pairs(codes) do
		if v == tonumber(code:GetValue()) or k == desc:GetValue() then
			found = true
		end
	end

	if not found then
		codes[string.gsub(string.gsub(desc:GetValue(), "|", ""), ",", "")] = tonumber(code:GetValue())
		updateCodes()
	end
end

local remButton = vgui.Create("DButton", panel)
remButton:SetPos(260, 45)
remButton:SetSize(20,20)
remButton:SetText("-")

function remButton:DoClick()
	local found = false
	for k,v in pairs(codes) do
		if v == tonumber(code:GetValue()) or k == desc:GetValue() then
			found = true
			codes[k] = nil
		end
	end
	
	if found then
		updateCodes()
	end
end

local codeList = vgui.Create( "DListView", panel)
codeList:SetPos(10, 75)
codeList:SetSize(330, 100)
codeList:AddColumn("Code")
codeList:AddColumn("Description")
codeList:SortByColumn(1, true)

function updateCodes()
	codeList:Clear()
	for k,v in pairs(codes) do
		codeList:AddLine(v, k)
	end
end

updateCodes()

function codeList:OnRowSelected(id, selected)
	local codeS = selected:GetColumnText(1)
	local descS = selected:GetColumnText(2)
	code:SetText(codeS)
	desc:SetText(descS)
end

function codeList:DoDoubleClick(ListView, List)
	saveCodes()
	panel:Close()
end

local saveClose = vgui.Create("DButton", panel)
saveClose:SetText("Save and Close")
saveClose:SetSize(100, 22)
saveClose:SetPos(10,185)

function saveClose:DoClick()
	saveCodes()
	panel:Close()
end

function saveCodes()
	addButton:DoClick()
	local codesList = {}
	if code:GetValue() then
		LocalPlayer():ConCommand("cl_weapon_gdo_iriscode " .. tonumber(code:GetValue()))
	end
	for k,v in pairs(codes) do
		table.insert(codesList, k..","..v)
	end
	LocalPlayer():ConCommand("cl_weapon_gdo_codelist " .. string.Implode("|", codesList))
end

local cancelButton = vgui.Create("DButton", panel)
cancelButton:SetText("Cancel")
cancelButton:SetPos(120, 185)

function cancelButton:DoClick()
	panel:Close()
end

end

function gdo_menuhook(um)
ShowIrisMenu()
end

usermessage.Hook(“gdo_openpanel”, gdo_menuhook)[/lua]

I found the problem. Don’t use
in player:ConCommand.

maby its my computer there is somthing worng with… :frowning:

weapons/weapon_gdo/cl_init.lua:137: attempt to concatenate a nil value

One of your variables has a nil value. You need to make a check to make sure its not nil.

but i cant find uot what… i just downloaded it at http://www.garrysmod.org/downloads/?a=view&id=54647

if (code:GetValue()!=nil) then
LocalPlayer():ConCommand("cl_weapon_gdo_iriscode " … tonumber(code:GetValue()))
end

ít work now… there was a bug on my computer… sry guys…