Author Topic: Menu Error  (Read 2362 times)

0 Members and 1 Guest are viewing this topic.

s0ber

  • Guest
Menu Error
« on: October 24, 2006, 04:39:53 PM »
Running ULX2.1, Ulib1.1, Wanted to have Music mod in this menu also. AND is it normal for the "Changelevel" and "Misc ULX" menus to be in the "q menu"?

Lua Error: Line 40: attempt to call global 'ULX_CONCOMMAND' (a nil value)
LUA: Errors when running script 'ulx/menus.lua'


s0ber

  • Guest
Re: Menu Error
« Reply #1 on: October 24, 2006, 04:41:38 PM »
This is my menu script

Code: [Select]
-------------
--Main Menu--
-------------
ID_CLIENTMENU = 1
ID_ADMINMENU = 2
ID_MAPSMENU = 3
ID_WEAPONSMENU = 4

function cc_ulxMenu( userid, args )
beginMenu( userid, "ULX Main Menu", cc_ulxMenuFinal )
addOption( userid, "Client Menu", ID_CLIENTMENU, ACCESS_SLAY )
addOption( userid, "Admin Menu", ID_ADMINMENU, ACCESS_CVAR )
addOption( userid, "Maps Menu", ID_MAPSMENU, ACCESS_MAP )
addOption( userid, "Weapons Menu", ID_WEAPONSMENU, ACCESS_KICK )
addOption( userid, "Client Limits", ID_CLIENTLIMITS, ACCESS_CVAR )
addOption( userid, "Other", ID_OTHER, ACCESS_CVAR )
endMenu( userid )
end

function cc_ulxMenuFinal( userid, choice, seconds )
if choice == ID_EXIT then
return
elseif choice == ID_CLIENTMENU then
cc_ulxClientMenu( userid )
elseif choice == ID_ADMINMENU then
cc_ulxAdminMenu( userid )
elseif choice == ID_MAPSMENU then
cc_ulxMapsMenu( userid )
elseif choice == ID_WEAPONSMENU then
cc_ulxWeaponsMenu( userid )
elseif choice == ID_CLIENTLIMITS then
cc_ulxClientLimits( userid )
elseif choice == ID_OTHER then
cc_ulxOther( userid )
end
end

[b]ULX_CONCOMMAND( "ulx_menu", cc_ulxMenu, _, "- Shows the ULX main menu", 0, "menu", false )[/b]


--------------
--Admin Menu--
--------------
function cc_ulxAdminMenu( userid, args )
beginMenu( userid, "ULX Admin Menu", cc_ulxAdminMenuFinal )


--Add

_EntEmitSound(userid,"ambient/alarms/klaxon1.wav")

--End add

if _GetConVar_Bool( "sv_cheats" ) then
addOption( userid, "Cheats Off", "sv_cheats 0", ACCESS_CVAR )
else
addOption( userid, "Cheats On", "sv_cheats 1", ACCESS_CVAR )
end

if _GetConVar_Bool( "gm_sv_playerdamage" ) then
addOption( userid, "Player Damage Off", "gm_sv_playerdamage 0", ACCESS_CVAR )
else
addOption( userid, "Player Damage On", "gm_sv_playerdamage 1", ACCESS_CVAR )
end

if _GetConVar_Bool( "gm_sv_pvpdamage" ) then
addOption( userid, "PvP Damage Off", "gm_sv_pvpdamage 0", ACCESS_CVAR )
else
addOption( userid, "PvP Damage On", "gm_sv_pvpdamage 1", ACCESS_CVAR )
end

if _GetConVar_Bool( "gm_sv_teamdamage" ) then
addOption( userid, "Team Damage Off", "gm_sv_teamdamage 0", ACCESS_CVAR )
else
addOption( userid, "Team Damage On", "gm_sv_teamdamage 1", ACCESS_CVAR )
end

if _GetConVar_Bool( "gm_sv_allowspawning" ) then
addOption( userid, "Disallow Spawning", "gm_sv_allowspawning 0", ACCESS_CVAR )
else
addOption( userid, "Allow Spawning", "gm_sv_allowspawning 1", ACCESS_CVAR )
end

if _GetConVar_Bool( "gm_sv_allowmultigun" ) then
addOption( userid, "Disallow Multigun", "gm_sv_allowmultigun 0", ACCESS_CVAR )
else
addOption( userid, "Allow Multigun", "gm_sv_allowmultigun 1", ACCESS_CVAR )
end

-- key 7 doesn't work
if _GetConVar_Bool( "say 7" ) then
addOption( userid, "Key 7 doesnt work", "say 7", ACCESS_CVAR )
else
addOption( userid, "Key 7 doesnt work", "say key 7 is not working in Gmod+!", ACCESS_CVAR )
end
-- key 7 doesn't work

if _GetConVar_Bool( "gm_sv_allowphysgun" ) then
addOption( userid, "Disallow Physgun", "gm_sv_allowphysgun 0", ACCESS_CVAR )
else
addOption( userid, "Allow Physgun", "gm_sv_allowphysgun 1", ACCESS_CVAR )
end

if _GetConVar_Bool( "gm_sv_allweapons" ) then
addOption( userid, "All Weapons Off", "gm_sv_allweapons 0", ACCESS_CVAR )
else
addOption( userid, "All Weapons On", "gm_sv_allweapons 1", ACCESS_CVAR )
end

if _GetConVar_Bool( "gm_sv_allowignite" ) then
addOption( userid, "Disallow Ignite", "gm_sv_allowignite 0", ACCESS_CVAR )
else
addOption( userid, "Allow Ignite", "gm_sv_allowignite 1", ACCESS_CVAR )
end

if _GetConVar_Bool( "gm_sv_noclip" ) then
addOption( userid, "Disallow Noclip", "gm_sv_noclip 0", ACCESS_CVAR )
else
addOption( userid, "Allow Noclip", "gm_sv_noclip 1", ACCESS_CVAR )
end

if _GetConVar_Bool( "gm_sv_allownpc" ) then
addOption( userid, "Disallow NPC Spawning", "gm_sv_allownpc 0", ACCESS_CVAR )
else
addOption( userid, "Allow NPC Spawning", "gm_sv_allownpc 1", ACCESS_CVAR )
end

if _GetConVar_Bool( "gm_sv_allowlamps" ) then
addOption( userid, "Disallow Lamps", "gm_sv_allowlamps 0", ACCESS_CVAR )
else

addOption( userid, "Allow Lamps", "gm_sv_allowlamps 1", ACCESS_CVAR )
end

-- key 7 doesn't work
if _GetConVar_Bool( "say 7" ) then
addOption( userid, "Key 7 doesnt work", "say 7", ACCESS_CVAR )
else
addOption( userid, "Key 7 doesnt work", "say key 7 is not working in Gmod+!", ACCESS_CVAR )
end
-- key 7 doesn't work

if _GetConVar_Bool( "sv_gravity" ) then
addOption( userid, "Disallow Lamps", "gm_sv_allowlamps 0", ACCESS_CVAR )
else
addOption( userid, "Allow Lamps", "gm_sv_allowlamps 1", ACCESS_CVAR )
end

endMenu( userid )
end

function cc_ulxAdminMenuFinal( userid, choice, seconds )
if choice == ID_EXIT then
return
else
_ServerCommand( choice .. ";gm_sv_setrules\n" )
end

AddTimer( 0.25, 1, cc_ulxAdminMenu, userid ) -- Give the server some time to register the command before rebuilding menu
end

ULX_CONCOMMAND( "ulx_adminmenu", cc_ulxAdminMenu, ACCESS_CVAR, "- Shows the ULX admin menu", 0, "adminmenu", false )


---------------
--Client Menu--
---------------
user_choice = {}
ID_SLAP = 1
ID_SLAY = 2
ID_SSLAY = 3
ID_FREEZE = 4
ID_UNFREEZE = 5
ID_GOD = 6
ID_EMPTY = 7
ID_UNGOD = 8
ID_IGNITE = 9
ID_KICK = 10
ID_KICKBAN = 11
ID_TEAM_RED = 12
ID_TEAM_GREEN = 13
ID_TEAM_BLUE = 14
ID_TEAM_YELLOW = 15
ID_GIMP = 16
ID_UNGIMP = 17

function cc_ulxClientMenu( userid, args )
menu_sendPlayersMenu( userid, cc_ulxClientMenuPart2 )
end

function cc_ulxClientMenuPart2( userid, target, seconds )
if target == ID_EXIT then
return
end

user_choice[ userid ] = target
beginMenu( userid, "ULX Command", cc_ulxClientMenuFinal )
addOption( userid, "Slap Player", ID_SLAP, ACCESS_SLAY )
addOption( userid, "Slay Player", ID_SLAY, ACCESS_SLAY )
addOption( userid, "SSlay Player", ID_SSLAY, ACCESS_SLAY )
addOption( userid, "Kick Player", ID_KICK, ACCESS_KICK )
addOption( userid, "Kickban Player", ID_KICKBAN, ACCESS_BAN )
addOption( userid, "Key 7 doesnt work", ID_EMPTY, ACCESS_SLAY )
addOption( userid, "Give Godmode", ID_GOD, ACCESS_SLAY )
addOption( userid, "Remove Godmode", ID_UNGOD, ACCESS_SLAY )
addOption( userid, "Freeze Player", ID_FREEZE, ACCESS_SLAY )
addOption( userid, "Unfreeze Player", ID_UNFREEZE, ACCESS_SLAY )
addOption( userid, "Ignite Player", ID_IGNITE, ACCESS_SLAY )
addOption( userid, "Force Team Red", ID_TEAM_RED, ACCESS_SLAY )
addOption( userid, "Force Team Blue", ID_TEAM_BLUE, ACCESS_SLAY )
addOption( userid, "Force Team Green", ID_TEAM_GREEN, ACCESS_SLAY )
addOption( userid, "Force Team Yellow", ID_TEAM_YELLOW, ACCESS_SLAY )
addOption( userid, "Gimp", ID_GIMP, ACCESS_SLAY )
addOption( userid, "Ungimp", ID_UNGIMP, ACCESS_SLAY )
endMenu( userid )
end

function cc_ulxClientMenuFinal( userid, choice, seconds )
local target = user_choice[ userid ]
if target == nil or _PlayerInfo( target, "connected" ) == false then
return
end

if choice == ID_EXIT then -- This is a global for when they hit the exit button, just take them back
cc_ulxClientMenu( userid, _ )
return
elseif choice == ID_SLAP then
ulx_slap( target, 0, 1000 )
elseif choice == ID_SLAY then
_PlayerKill( target )
elseif choice == ID_SSLAY then
_PlayerSilentKill( target, 3, true )
elseif choice == ID_GOD then
_PlayerGod( target, true )
elseif choice == ID_EMPTY then
_Screentext(0, 'Key 7 doenst work in Gmod+!', -1, -1, 255, 0, 0, 60, 2, 2, 10, 0, 0)
elseif choice == ID_UNGOD then
_PlayerGod( target, false )
elseif choice == ID_FREEZE then
_PlayerFreeze( target, true )
elseif choice == ID_UNFREEZE then
_PlayerFreeze( target, false )
elseif choice == ID_IGNITE then
_PlayerSetHealth( target, 139 ) -- This is so the person doesn't keep dying in the next spawn
_EntFire( target, "ignite", 1, 0 )
elseif choice == ID_KICK then
_ServerCommand( "kickid " .. _PlayerInfo( target, "networkid" ) .. "\n" )
elseif choice == ID_KICKBAN then
_ServerCommand( "banid 0 " .. _PlayerInfo( target, "networkid" ) .. " kick\n" )
elseif choice == ID_TEAM_RED then
_PlayerChangeTeam( target, TEAM_RED )
_PlayerRespawn( target )
elseif choice == ID_TEAM_GREEN then
_PlayerChangeTeam( target, TEAM_GREEN )
_PlayerRespawn( target )
elseif choice == ID_TEAM_BLUE then
_PlayerChangeTeam( target, TEAM_BLUE )
_PlayerRespawn( target )
elseif choice == ID_TEAM_YELLOW then
_PlayerChangeTeam( target, TEAM_YELLOW )
_PlayerRespawn( target )
elseif choice == ID_GIMP then
ulx_gimp( _PlayerInfo( target, "networkid" ) )
elseif choice == ID_UNGIMP then
ulx_ungimp( _PlayerInfo( target, "networkid" ) )
end

end

function testCallBack( userid, unique_num, seconds )
ulx_tsay_all( _PlayerInfo( userid, "name" ) .. " choose menu ID #" .. unique_num .. "!" )
end

ULX_CONCOMMAND( "ulx_clientmenu", cc_ulxClientMenu, ACCESS_SLAY, "- Shows the client admin menu", 0, "clientmenu", false )

-------------
--Maps Menu--
-------------

function cc_ulxMapsMenu( userid, args )
local maps = getFilesFromDir( "maps/" )

beginMenu( userid, "Maps Menu", cc_ulxMapsMenuCallback )
for i=1, table.getn( maps ) do
if string.sub( maps[ i ], -4 ) == ".bsp" and string.sub( maps[ i ], 1, 10 ) ~= "background" and string.sub( maps[ i ], 1, 5 ) ~= "test_" then -- Ignore background maps
addOption( userid, stripExt( maps[ i ] ), stripExt( maps[ i ] ), ACCESS_MAP )
end
end
endMenu( userid )
end

function cc_ulxMapsMenuCallback( userid, map )
if map == ID_EXIT then
return
end

ulx_tsay_all( "CHANGELEVEL: " .. map )
AddTimer( 5, 1, _ServerCommand, "changelevel " .. map .. "\n" )
end

ULX_CONCOMMAND( "ulx_mapmenu", cc_ulxMapsMenu, ACCESS_MAP, "- Shows the map menu", 0, "mapmenu", false )

----------------
--Weapons Menu--
----------------

gIgnoreWeapons = {}
user_choice = {}

function cc_ulxWeaponsMenu( userid, args )
local weapons = getFilesFromDirRecursive( "lua/weapons" )

beginMenu( userid, "Weapons Menu", cc_ulxWeaponsMenuCallback )
for i=1, table.getn( weapons ) do
weapons[ i ] = string.sub( weapons[ i ], 5 ) -- The sub removes 'lua/'
if string.sub( weapons[ i ], -4 ) == ".lua" and gIgnoreWeapons[ weapons[ i ] ] == nil then
local weapon = getWeaponInfo( weapons[ i ] )
if weapon ~= nil and weapon.printName ~= nil then
addOption( userid, weapon.printName, weapons[ i ], ACCESS_KICK )
end
end
end
endMenu( userid )
end

function cc_ulxWeaponsMenuCallback( userid, weapon )
if weapon == ID_EXIT then
return
end

user_choice[ userid ] = weapon
menu_sendPlayersMenu( userid, cc_ulxWeaponsMenuFinal, _, "Give to:", true )
end

function cc_ulxWeaponsMenuFinal( userid, target )
if target == ID_EXIT then
return
end

if target == 0 then
for i=1, _MaxPlayers() do
debug( target .. " " .. i )
if _PlayerInfo( i, "connected" ) == true then
_PlayerGiveSWEP( i, user_choice[ userid ] )
end
end
else
_PlayerGiveSWEP( target, user_choice[ userid ] )
end
end

function addWeaponIgnore( weapon )
gIgnoreWeapons[ weapon ] = true
end

function getWeaponInfo( weapon ) -- TODO: Finish this function
if _file.Exists( "lua/" .. weapon ) == false or _file.IsDir( "lua/" .. weapon ) == true then
error_msg( "loadWeaponInfo given an invalid file!" )
return
end

_OpenScript( weapon )

local info = {}

info.printName = getPrintName()
info.classname = getClassName()
info.swapHands = getWeaponSwapHands()
info.fov = getWeaponFOV()
info.weaponSlot = getWeaponSlot()
info.weaponSlotPos = getWeaponSlotPos()
info.firesUnderwater = getFiresUnderwater()
info.reloadsSingly = getReloadsSingly()
info.damage = getDamage()
info.primaryShotDelay = getPrimaryShotDelay()
info.secondaryShotDelay = getSecondaryShotDelay()
info.primaryIsAutomatic = getPrimaryIsAutomatic()

return info
end

-- This ignore list in part is taken from andyvincent's weapon menu, you can check it out at http://forums.facepunchstudios.com/showthread.php?t=67193
addWeaponIgnore( "weapons/base.lua" )
addWeaponIgnore( "weapons/build/weapon_cratemaker.lua" )
addWeaponIgnore( "weapons/build/weapon_propmaker.lua" )
addWeaponIgnore( "weapons/build/weapon_freeze.lua" )
addWeaponIgnore( "weapons/build/weapon_remover.lua" )
addWeaponIgnore( "weapons/build/weapon_spawn.lua" )
addWeaponIgnore( "weapons/football/weapon_phys.lua" )
addWeaponIgnore( "weapons/hideandseek/weapon_catcher.lua" )

ULX_CONCOMMAND( "ulx_weaponmenu", cc_ulxWeaponsMenu, ACCESS_KICK, "- Shows the weapons menu", 0, "weaponmenu", false )

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Menu Error
« Reply #2 on: October 24, 2006, 09:15:32 PM »
That menu was made for ULX v1.1, sorry. Yes it's normal to have those things in your prop menu.
Experiencing God's grace one day at a time.