Author Topic: Make the server aware of an add-on modification?  (Read 760 times)

Just need to know the 2 getModPath commands that do this is all

Used tab and typed getMod

Edit: still don't really understand how to use them
« Last Edit: September 19, 2012, 03:10:32 PM by Conservative »

setModPaths(getModPaths());

this is only neccesary if you update the mod inside of a zip.

suggestion: unzip the mod and put it into a folder named the same as the zip and put that in your add-ons
then just change stuff at will and it'll work

discoverFile("filepath..."); but

unzip the mod and put it into a folder named the same as the zip and put that in your add-ons
then just change stuff at will and it'll work

setModPaths(getModPaths());
discoverFile("filepath..."); but
Either of these work, the only difference being discoverFile only checks the file you pass, while setModPaths(getModPaths()); does everything.
That's the only difference I know of.
So I guess it's really a choice of whether you want the server to lag for a very short amount of time, or if you want to type more.

Either of these work, the only difference being discoverFile only checks the file you pass, while setModPaths(getModPaths()); does everything.
That's the only difference I know of.
So I guess it's really a choice of whether you want the server to lag for a very short amount of time, or if you want to type more.

The performance difference is epsilon. setModPaths takes less than 10 MS to execute in average.


Entire thread is bullstuff, setModPaths(getModPaths()) etc just refreshes the resource manager's cached file list and re-scans all the directories for files.

discoverFile is just a way to manually add to the cache without having to entirely re-scan the filesystem.

This is so things like findNextFile will pick up the file you added. Torque doesn't cache the content of files too.

If you update a file in a zip, then attempt to execute said file, it'll forget up

This is due to the resource manager caching where the files are in the zip, if the length changes it will read the wrong section of the zip and get an incomplete file, hence why this is necessary when working out of a zip

Code: [Select]
function _r(%name,%mode)
{
   if(%name $= "")
      %name = getWord($r_last,0);
   if(%mode $= "")
      %mode = getWord($r_last,1);
   else %mode = strReplace(%mode," ","");
   %path = "Add-Ons/" @ %name;
   if(isFile(%path @ ".zip"))
   {
      discoverFile(%path @ ".zip");
   }
   if(striPos(%mode,"c") != -1 && isFile(%path @ "/client.cs"))
      exec(%path @ "/client.cs");
   if(striPos(%mode,"s") != -1 && isFile(%path @ "/server.cs"))
      exec(%path @ "/server.cs");
   $r_last = %name SPC %mode;
}
$r_last = "Weapon_Gun s";
$ _r("Weapon_stuffAddOn","s");
$ _r();