Include file from different directory

Hi all,

I need to use some functions from another file in my gmod server directory. The problem is I don’t know how to navigate to it from that file.

This is where my functions are ( which I want to include ):


This is where I want to include it in:


I have tried many paths using the include function but none of them work.


PS: I basically want to use functions from the first file I mentioned in the second file I mentioned. If there is a better/easier way please tell me. Thanks once again

Take a look at, I think this should help

There is no reason why you should need to include a ULX function within the directory. Placing them in autorun should work perfectly fine if you’ve done everything correctly. Can’t you call the ulx functions? The ULX table should be global, you should be able to use it wherever.


Here’s the function I’m editing in ULX:

function ulx.adduser( calling_ply, target_ply, group_name )
	local userInfo = ULib.ucl.authed[ target_ply:UniqueID() ]

	local id = ULib.ucl.getUserRegisteredID( target_ply )
	if not id then id = target_ply:SteamID() end

	ULib.ucl.addUser( id, userInfo.allow, userInfo.deny, group_name )

	SaveULXRank( target_ply )

	ulx.fancyLogAdmin( calling_ply, "#A added #T to group #s", target_ply, group_name )
local adduser = ulx.command( CATEGORY_NAME, "ulx adduser", ulx.adduser )
adduser:addParam{ type=ULib.cmds.PlayerArg }
adduser:addParam{ type=ULib.cmds.StringArg, completes=ulx.group_names_no_user, hint="group", error="invalid group \"%s\" specified", ULib.cmds.restrictToCompletes }
adduser:defaultAccess( ULib.ACCESS_SUPERADMIN )
adduser:help( "Add a user to specified group." )

SaveULXRank is the function I’m trying to get working

and heres that function in the autorun folder:

function SaveULXRank(ply)
	local usergroup = "user"
	if ply:IsUserGroup( "superadmin" ) then
		usergroup = "superadmin"
	elseif ply:IsUserGroup( "admin" ) then
		usergroup = "admin"
	elseif ply:IsUserGroup( "moderator" ) then
		usergroup = "moderator"
	elseif ply:IsUserGroup( "vip" ) then
		usergroup = "vip"
	elseif ply:IsUserGroup( "vip+" ) then
		usergroup = "vip+"
	elseif ply:IsUserGroup( "community" ) then
		usergroup = "community"
		usergroup = "user"
	local steamid = ply:SteamID()
	local InsertQ = DB:query("INSERT INTO `rankinfo` (`steam`, `groups`) VALUES ('" .. usergroup .."', '" .. ply:SteamID() .. "')")
	InsertQ.onError = DBError
		InsertQ.onSuccess = function(q)
		if checkQuery(q) then
			print ("That Database Stuff Happened Yay")

Have I missed something?

I wouldn’t recommend this method. ULX calls a hook after every command has been translated:
This is how I hooked in “synchronization”
function db:onConnected()

MsgN( "[Sync] Connected successfully to "..ip..":"..port.." with the username "..user.."

" )

hook.Add( "ULibPostTranslatedCommand", "UpdateOnPromotion", function( ply, command, args ) 

	if ( command ~= "ulx adduserid" and command ~= "ulx adduser" ) then return end

	local id = command == "ulx adduser" and args[2]:SteamID() or command == "ulx adduserid" and args[2] or nil // grabs the steamid from the arguments
	local group = args[3] // grabs the ULX group from the arguments

	MsgN( "[Sync] Traced a promotion successfully - attempting update query...

" )

	if db:status() ~= mysqloo.DATABASE_CONNECTED then

		MsgN( "[Sync] Server has lost connection to database - will reconnect and try again in 5 seconds...")


		timer.Simple( 5, function() updateUser( id, group ) end ) // wait for the database to connect


	updateUser( id, group ) // I'd make this your function with the update query

end )

Maybe you can learn from it. Remember to check the database status before querying to reconnect if necessary, otherwise the query will be lost.