Error: (Fixed!
[CODE]
GmodAirsoft\gamemode\cl_weaponmenu.lua:120: 'end' expected (to close 'if' at line 59) near 'else'
[/CODE]
[lua]local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( DermaPanel )
DermaButton:SetText( "Click to redeem this gun" )
DermaButton:SetPos( 100, 290 )
DermaButton:SetSize( 230, 30 )
DermaButton.DoClick = function ()
if CboxRIFLE:GetSelectedItems() and CboxRIFLE:GetSelectedItems()[1] then
if CboxRIFLE:GetSelectedItems()[1]:GetValue() == "Ak47" then
RunConsoleCommand( "airsoft_weapons", "ak", ply )
DermaPanel:Close()
else if CboxRIFLE:GetSelectedItems()[1]:GetValue() == "M4a1" then
RunConsoleCommand( "airsoft_weapons", "m4", ply )
DermaPanel:Close()
else if CboxRIFLE:GetSelectedItems()[1]:GetValue() == "Galil" then
RunConsoleCommand( "airsoft_weapons", "galil", ply )
DermaPanel:Close()
else if CboxRIFLE:GetSelectedItems()[1]:GetValue() == "Famas" then
RunConsoleCommand( "airsoft_weapons", "famas", ply )
DermaPanel:Close()
else if CboxRIFLE:GetSelectedItems()[1]:GetValue() == "Sig552" then
RunConsoleCommand( "airsoft_weapons", "sig552", ply )
DermaPanel:Close()
else if CboxRIFLE:GetSelectedItems()[1]:GetValue() == "SteyrAUG" then
RunConsoleCommand( "airsoft_weapons", "aug", ply )
DermaPanel:Close()
end
end
end
end
end
end
else if CboxSMG:GetSelectedItems() and CboxSMG:GetSelectedItems()[1] then
if CboxSMG:GetSelectedItems()[1]:GetValue() == "Mp7" then
RunConsoleCommand( "airsoft_weapons", "tmp", ply )
DermaPanel:Close()
else if CboxSMG:GetSelectedItems()[1]:GetValue() == "Uzi" then
RunConsoleCommand( "airsoft_weapons", "mac10", ply )
DermaPanel:Close()
else if CboxSMG:GetSelectedItems()[1]:GetValue() == "Mp5" then
RunConsoleCommand( "airsoft_weapons", "mp5", ply )
DermaPanel:Close()
else if CboxSMG:GetSelectedItems()[1]:GetValue() == "P90" then
RunConsoleCommand( "airsoft_weapons", "p90", ply )
DermaPanel:Close()
else if CboxSMG:GetSelectedItems()[1]:GetValue() == "M1a1" then
RunConsoleCommand( "airsoft_weapons", "ump45", ply )
DermaPanel:Close()
end
end
end
end
end
else if CboxSHOT:GetSelectedItems() and CboxSHOT:GetSelectedItems()[1] then
if CboxSHOT:GetSelectedItems()[1]:GetValue() == "M3Super" then
RunConsoleCommand( "airsoft_weapons", "m3", ply )
DermaPanel:Close()
else if CboxSHOT:GetSelectedItems()[1]:GetValue() == "Spas12" then
RunConsoleCommand( "airsoft_weapons", "xm1014", ply )
DermaPanel:Close()
else if CboxSHOT:GetSelectedItems()[1]:GetValue() == "Spas12-Hl2" then
RunConsoleCommand( "airsoft_weapons", "shotgun", ply )
DermaPanel:Close()
end
end
end
end
end
else if CboxSNIPER:GetSelectedItems() and CboxSNIPER:GetSelectedItems()[1] then
if CboxSNIPER:GetSelectedItems()[1]:GetValue() == "FN-Fal" then
RunConsoleCommand( "airsoft_weapons", "g3", ply )
DermaPanel:Close()
else if CboxSNIPER:GetSelectedItems()[1]:GetValue() == "M14" then
RunConsoleCommand( "airsoft_weapons", "sg550", ply )
DermaPanel:Close()
end
end
end
end
end
else if CboxMG:GetSelectedItems() and CboxMG:GetSelectedItems()[1] then
if CboxMG:GetSelectedItems()[1]:GetValue() == "M249" then
RunConsoleCommand( "airsoft_weapons", "m249", ply )
DermaPanel:Close()
end
end
end
end
end
end
end
[/lua]
I used to be able to fix this one, but now, If I had one end, it tell me to add another, I add it, it tell me I need to end the file at this line. It was working before I add the Snipers and the MG.
[B]Also :
How would I do a command that would keep in memory the last weapon the player picked up from my menu, and give it to him back when he respawn? If the commands is set to 1.
And again:
Is there a way to toggle secondary fire, and disable primary fire while it's toggled?[/B]
Stop it right there. Don't post a word until you've gotten Notepad++ and pasted your code in it (with lua syntax highlighting).
This is literally the most sickening piece of code I have ever encountered, what were you even trying to do with that fucked up indentation and amount of extra ends?!
Also elseif is one word.
[lua]local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( DermaPanel )
DermaButton:SetText( "Click to redeem this gun" )
DermaButton:SetPos( 100, 290 )
DermaButton:SetSize( 230, 30 )
DermaButton.DoClick = function ()
--Start of the main if
if CboxRIFLE:GetSelectedItems() and CboxRIFLE:GetSelectedItems()[1] then
if CboxRIFLE:GetSelectedItems()[1]:GetValue() == "Ak47" then
RunConsoleCommand( "airsoft_weapons", "ak", ply )
DermaPanel:Close()
elseif CboxRIFLE:GetSelectedItems()[1]:GetValue() == "M4a1" then
RunConsoleCommand( "airsoft_weapons", "m4", ply )
DermaPanel:Close()
elseif CboxRIFLE:GetSelectedItems()[1]:GetValue() == "Galil" then
RunConsoleCommand( "airsoft_weapons", "galil", ply )
DermaPanel:Close()
elseif CboxRIFLE:GetSelectedItems()[1]:GetValue() == "Famas" then
RunConsoleCommand( "airsoft_weapons", "famas", ply )
DermaPanel:Close()
elseif CboxRIFLE:GetSelectedItems()[1]:GetValue() == "Sig552" then
RunConsoleCommand( "airsoft_weapons", "sig552", ply )
DermaPanel:Close()
elseif CboxRIFLE:GetSelectedItems()[1]:GetValue() == "SteyrAUG" then
RunConsoleCommand( "airsoft_weapons", "aug", ply )
DermaPanel:Close()
end
elseif CboxSMG:GetSelectedItems() and CboxSMG:GetSelectedItems()[1] then
if CboxSMG:GetSelectedItems()[1]:GetValue() == "Mp7" then
RunConsoleCommand( "airsoft_weapons", "tmp", ply )
DermaPanel:Close()
elseif CboxSMG:GetSelectedItems()[1]:GetValue() == "Uzi" then
RunConsoleCommand( "airsoft_weapons", "mac10", ply )
DermaPanel:Close()
elseif CboxSMG:GetSelectedItems()[1]:GetValue() == "Mp5" then
RunConsoleCommand( "airsoft_weapons", "mp5", ply )
DermaPanel:Close()
elseif CboxSMG:GetSelectedItems()[1]:GetValue() == "P90" then
RunConsoleCommand( "airsoft_weapons", "p90", ply )
DermaPanel:Close()
elseif CboxSMG:GetSelectedItems()[1]:GetValue() == "M1a1" then
RunConsoleCommand( "airsoft_weapons", "ump45", ply )
DermaPanel:Close()
end
elseif CboxSHOT:GetSelectedItems() and CboxSHOT:GetSelectedItems()[1] then
if CboxSHOT:GetSelectedItems()[1]:GetValue() == "M3Super" then
RunConsoleCommand( "airsoft_weapons", "m3", ply )
DermaPanel:Close()
elseif CboxSHOT:GetSelectedItems()[1]:GetValue() == "Spas12" then
RunConsoleCommand( "airsoft_weapons", "xm1014", ply )
DermaPanel:Close()
elseif CboxSHOT:GetSelectedItems()[1]:GetValue() == "Spas12-Hl2" then
RunConsoleCommand( "airsoft_weapons", "shotgun", ply )
DermaPanel:Close()
end
elseif CboxSNIPER:GetSelectedItems() and CboxSNIPER:GetSelectedItems()[1] then
if CboxSNIPER:GetSelectedItems()[1]:GetValue() == "FN-Fal" then
RunConsoleCommand( "airsoft_weapons", "g3", ply )
DermaPanel:Close()
elseif CboxSNIPER:GetSelectedItems()[1]:GetValue() == "M14" then
RunConsoleCommand( "airsoft_weapons", "sg550", ply )
DermaPanel:Close()
end
elseif CboxMG:GetSelectedItems() and CboxMG:GetSelectedItems()[1] then
if CboxMG:GetSelectedItems()[1]:GetValue() == "M249" then
RunConsoleCommand( "airsoft_weapons", "m249", ply )
DermaPanel:Close()
end
end -- End of the main if.
end -- End of the function[/lua]
I have Notepad++ I just use both notebad and ++.
This code was working fine at the beginning.
But thanks.
Sorry, you need to Log In to post a reply to this thread.