Reloading a script.

Hey. :wink:

Was wondering if it is at all possible to reload a serverside script while in-game and not causing the game to load again (I only need to reload one simple script)

It’s a simple script that gives players X suit armor once every X sec. The values can be changed with convars, but after changing them I need to reload in order for it to be “updated” so is there a way to update just one script?

Put in console on the server:


lua_openscript myFile.lua

Can also go down in sub directorys, into swep folders, specific gamemode folders etc etc

Nice, thanks alot. Where does it “start”? If you know what I mean? :confused:

Oh just tried it, It will even search for the things. :wink:

Its root directory is the Lua folder.

Basically everywhere.

lua_openscript sandbox/ Will start at directory garrysmod/gamemodes/sandbox
lua_openscript effects/ Starts at garrysmod/lua/effects
lua_openscript myFile.lua Opens file myFile located at garrysmod/lua/myFile.lua
lua_openscript weapons/ Starts at garrysmod/lua/weapons

You can keep going down in directories.

Yeah, I was a little to fast before and didn’t really check what the name of the script i loaded was. Got the wrong one and thought I’d gotten the one from inside the other folders… :S Nevermind. I fixed my problem, thanks alot. :wink:

Notice the garrysmod/lua, so you disagreed with me without reason. The gamemodes one is the only exception which I didn’t know of.

You can also load scripts within addons.
Example:

lua_openscript myAddon/lua/autorun/init.lua will open garrysmod/Addons/myAddon/lua/autorun/init.lua

Oh, never mind then.