Possible to implement custom TTT weapon lua code to a map?

I’ve been wondering about this - There’s an entity that runs Garry’s Mod lua code when triggered, so it could be theoretically possible to use it to add a custom TTT weapon to my map after packing the lua files in my map’s .BSP.
Has anyone tried this out yet?

indeed it is possible, i haven’t tried it but i knows its possible

Hmm, it could be possible via VScript.
But I’m not sure if the GMOD branch supports it.

I know nothing about lua, but from what I know about gmod’s filesystem in theory it could work.

After some messing around with this I’m inclined to say no.

Here is what I tried -

I made a small box in hammer, plopped a weapon_ttt_flaregun entity down and spawned in; it worked fine as expected.

I removed the weapon_ttt_flaregun folder from the server and then packed it into the .bsp under ‘gamemodes/terrortown/entities/weapons/weapon_ttt_flaregun’. It wasn’t recognized by the server.

Lastly I did the same as above, but I placed a lua_run entity which attempted to include the shared.lua of the flaregun, and that didn’t seem to work.

I’m not sure if I did something wrong, but alternatives could be to open files from within the BSP and use runstring, or load lua from a URL (Though people would be sketchy about this since you can load whatever you want on their servers)


I forgot, lua_run is also serverside only, I’m not sure if it could work using AddCSLuaFile / include in there, but if I remember right, AddCSLuaFile can’t be used on the fly to change what is being sent, only works on load.

Try doing weapon_ttt_flaregun2 instead of weapon_ttt_flaregun

The entity names are derived from their folder names. I flat out removed the weapon_ttt_flaregun so it was no longer on the server then packed it into the bsp in an attempt to get it working again, so I could tell if it was being loaded or not.

I can see why this would be intentionally disallowed, if you could automatically run lua files on the server without any lua_run then it would be even easier to exploit and run hidden code on other people’s servers.