I'm making some slight modifications to ULX, namely, adding my own module.
When the map changes, console looks like:
[code]
---- Host_Changelevel ----
Error loading cfg/trusted_keys_base.txt
Error loading cfg/pure_server_minimal.txt
///////////////////////////////
// Ulysses Library //
///////////////////////////////
// Loading... //
// shared/defines.lua //
// shared/misc.lua //
// shared/util.lua //
// shared/hook.lua //
// shared/table.lua //
// shared/player.lua //
// server/player.lua //
// shared/messages.lua //
// shared/commands.lua //
// server/concommand.lua //
// server/util.lua //
// shared/sh_ucl.lua //
// server/ucl.lua //
// server/phys.lua //
// server/player_ext.lua //
// server/entity_ext.lua //
// Load Complete! //
///////////////////////////////
[ULIB] Loading SHARED module: ulx_init.lua
///////////////////////////////
// ULX Admin Mod //
///////////////////////////////
// Loading... //
// sh_defines.lua //
// lib.lua //
// base.lua //
// sh_base.lua //
// log.lua //
// MODULE: slots.lua //
// MODULE: uteam.lua //
// MODULE: votemap.lua //
// MODULE: xgui_server.lua //
///////////////////////////////
// ULX GUI -- by Stickly Man //
///////////////////////////////
// Adding Main Modules.. //
// bans.lua //
// commands.lua //
// groups.lua //
// maps.lua //
// settings.lua //
// Adding Setting Modules.. //
// client.lua //
// server.lua //
// Adding Gamemode Modules.. //
// sandbox.lua //
// Loading Server Modules.. //
// sv_bans.lua //
// sv_groups.lua //
// sv_maps.lua //
// sv_sandbox.lua //
// sv_settings.lua //
// XGUI modules added! //
///////////////////////////////
// MODULE: chat.lua //
// MODULE: fun.lua //
// MODULE: menus.lua //
// MODULE: rcon.lua //
// MODULE: teleport.lua //
// MODULE: user.lua //
// MODULE: userhelp.lua //
// MODULE: util.lua //
// MODULE: vote.lua //
// end.lua //
// Load Complete! //
///////////////////////////////
[AddCSLuaFile] Couldn't find 'effects/ulx_firework/init.lua' (<nowhere>)
[AddCSLuaFile] Couldn't find 'effects/ulx_fireworkstem/init.lua' (<nowhere>)
Executing dedicated server config file server.cfg
Nav File is wrong or something (4)
[/code]
Which is ULX's init.lua loading all the modules and the like. However for some reason, when I originally open srcds.exe, none of this happens. The modules don't load and my changes don't work properly. Can anyone explain this to me so I can find a workaround or force ULX to run all this at startup?
Problem number 2:
I'm trying to do 2 things in the init.lua of ULX. Both are adding hooks.
[code]
hook.Add("PlayerInitialSpawn", "lol_PlayerConnect", function(ply) -- Adds ULX group to players when they join based on data read from a webserver elsewhere
local rank = getRank(ply:SteamID())
print("Player's rank: " .. rank)
local group = "user"
if rank == "Officer" then
group = "officer"
elseif rank == "Representative" then
group = "reps"
elseif rank == "Advisor" then
group = "advisor"
elseif rank == "Council" then
group = "superadmin"
elseif rank == "Operator" then
group = "operator"
elseif rank == "Admin" then
group = "admin"
end
if rank ~= "error" then
print("Rank is not error")
ucl.addUser(ply:SteamID(), {}, {}, group)
end
end)
hook.Add("PlayerSpawn", "lol_PlayerSpawn", function(ply) -- Kicks players who spawn with clan tag on that aren't in the clan
print("Player spawned!")
local nick = ply:Nick()
local i,j = string.find(nick, "[tag]")
local rank = getRank(ply:SteamID())
if i then
print("Player has [tag] in name!")
print("Rank: " .. rank)
if rank == "user" then
print("Player is user!")
ULib.kick(ply, "You are not a member, don't wear the tag!")
end
end
end)
[/code]
For some reason, when these are used together, if a non-member wearing the tags joins, they get kicked but srcds.exe crashes. A dump file is generated with error:
[code]
The thread tried to read from or write to a virtual address for which it does not have the appropriate access.
[/code]
Probably because the user doesn't have an assigned rank yet.
What do you mean? All players are assigned "user" by default.
[QUOTE=RealDope;45414406][code][AddCSLuaFile] Couldn't find 'effects/ulx_firework/init.lua' (<nowhere>)
[AddCSLuaFile] Couldn't find 'effects/ulx_fireworkstem/init.lua' (<nowhere>)[/code][/QUOTE]
Are you running the latest ULX from [url=https://github.com/Nayruden/Ulysses]our GitHub page[/url]? These errors make me suspect you're on an older version, and I'd recommend keeping as up-to-date as possible.
[QUOTE=RealDope;45414406]For some reason, when these are used together, if a non-member wearing the tags joins, they get kicked but srcds.exe crashes.[/QUOTE]
The crash is likely due to [url=http://facepunch.com/showthread.php?t=1374457&p=45394628&viewfull=1#post45394628]an issue I posted about here[/url]. Essentially, kicking a player on a hook tends to cause a crash if it gets back to the engine code, or .. something odd. You might be able to fix it by adding a return false right after your ULib.kick line- that should stop the hook right there and hopefully prevent the crash.
I updated to 3.62, the latest (not on the ulysses website). I was running 3.61. Apparently 3.62 fixes an error where kicking yourself via chat command crashes the server (2 days ago).
Unfortunately this did not solve my problem, non-members wearing the tags are still kicked, and the server still crashes. Returning false after the kick does not solve my problem either :/
Any word on ULX not including all the lua files at server launch?
Also, for what it's worth, confirmed that the kick is causing the crash. With the kick line commented and nothing else changed, the crash does not happen.
When I try to change a player's group, I get the following:
[code]
[ERROR] addons/ulx/lua/ulx/init.lua:75: attempt to index global 'ucl' (a nil value)
1. fn - addons/ulx/lua/ulx/init.lua:75
2. unknown - addons/ulib/lua/ulib/shared/hook.lua:183
[/code]
Am I changing the group wrong?
[editline]17th July 2014[/editline]
UPDATE: Fixed it, just added a one second timer and kicked in that. Gives the hook time to finish properly.
UPDATE: Scrapped trying to use ucl, just run a console command to do it. Still looking for a way to force ULX to include all modules on server start.
edit: Oops, assumed this would just edit onto other post, sorry for double.
[QUOTE=RealDope;45414826]Unfortunately this did not solve my problem, non-members wearing the tags are still kicked, and the server still crashes. Returning false after the kick does not solve my problem either :/
UPDATE: Fixed it, just added a one second timer and kicked in that. Gives the hook time to finish properly.
[/QUOTE]
The returning false seems to not work all the time, seems to be dependent on the other functions on the same hooks for some reason. But yes, using a timer is probably the best (although rather hacky) way to do it for now, and I may go change ULX to do that as well.
[QUOTE=RealDope;45414826]
When I try to change a player's group, I get the following:
[/QUOTE]
You need to use "ULib.ucl.addUser", the ULib files use a namespace that doesn't require us to add "ULib" to the beginning. But just running the console command works, too, and also runs through all the checks to do logging, etc.
[QUOTE=RealDope;45414826]
Any word on ULX not including all the lua files at server launch?
[/QUOTE]
Make sure your script is in the correct location- ULX and ULib both have folders that can autorun scripts without needing to change the default code, and ensures that ULX/ULib is fully loaded before running the script.
For ULib, it's:
/lua/ulib/server/ (server)
/lua/ulib/modules/ (shared)
/lua/ulib/client/ (client)
For ULX, it's:
/lua/ulx/modules/ (server)
/lua/ulx/modules/sh/ (shared)
/lua/ulx/modules/cl/ (client)
[QUOTE=Stickly Man!;45419800]The returning false seems to not work all the time, seems to be dependent on the other functions on the same hooks for some reason. But yes, using a timer is probably the best (although rather hacky) way to do it for now, and I may go change ULX to do that as well.
You need to use "ULib.ucl.addUser", the ULib files use a namespace that doesn't require us to add "ULib" to the beginning. But just running the console command works, too, and also runs through all the checks to do logging, etc.
Make sure your script is in the correct location- ULX and ULib both have folders that can autorun scripts without needing to change the default code, and ensures that ULX/ULib is fully loaded before running the script.
For ULib, it's:
/lua/ulib/server/ (server)
/lua/ulib/modules/ (shared)
/lua/ulib/client/ (client)
For ULX, it's:
/lua/ulx/modules/ (server)
/lua/ulx/modules/sh/ (shared)
/lua/ulx/modules/cl/ (client)[/QUOTE]
Thanks for all the help man.
My script loads just fine, but only after a map change. When the server initially launches, I don't see any of the typical ULX loading stuff print in console, and when functions of mine are called, they throw errors because things that we're supposed to get setup in the initialization of my script never got called.
EDIT:
Seemingly of the same origin; if I have a syntax error in my modification of init.lua, I don't see any errors, ulx just doesn't load, and typing "ulx" prompts the "Unknown command" error. However, after a map change, I see ulx print all it's usual loading messages up to the point where I put an error, and then it tells me exactly what the error is.
It's really strange, it seems like starting the server and changing the map have very different ways of loading.
Ok; so ulx's init.lua is not even running on the initial startup, but loads fine after one map change.
How can I force init.lua to run on the initial startup? I really need this.
Bumping..
With a fresh install of srcds and ULib/ULX 3.61 or 3.62, modules do NOT load on initial server startup, and init.lua is not run at all.
Sorry for the delay in responding- had a busy weekend. If you're still having troubles, feel free to [url=http://steamcommunity.com/id/Stickly_Man/]add me as a friend[/url] and send me a message. If/when I'm available, that should be the fastest way for me to help you. :P
Sorry, you need to Log In to post a reply to this thread.