Author Topic: Script customizing in-game <Is It Possible? and can you show me how?>  (Read 985 times)

So I wanted to know if it was possible to modify the file of something in-game, for Example If I wanted a jeeps speed to go from 30 ---> 500 I would need to modify the script of the jeep. Iv'e searched online and something about the function below using a script to call the function, but I haven't tried that, because of the fact does it have to be un-compressed or not?

{
   discoverfile("add-ons/FileName.zip"); //Discover it if you made any changes whatsoever
   exec("add-ons/FileName/server.cs"); //Exec it a faster way using the function
}
-----> Function  function reloadMe()

So Iv'e tried a method before which was just using *exec("");* and I get a *Missing File Location, and a File is not in default area* yet I don't know if its because its in a Compressed Folder or if its because I need to use Discover File first. If anyone could help me out on what the problem would be, I would be greatly appreciated
« Last Edit: July 18, 2017, 01:14:47 AM by woof :3 »

you should be able to modify the script ingame if you keep the addon unzipped

it sounds a lot like an xy problem though
it may make more sense to have prefs that are saved and loaded, instead of rewriting the script itself
if you're trying to create an ingame editor, then it may make sense
what is your goal?

when you're building mods you shouldn't have the folder compressed. only when you redistribute should you compress it.

if you want to change the jeep's speed, don't directly modify the jeep add-on. instead, make your own script and in the server.cs do something like

ForceRequiredAddOn("Vehicle_Jeep");
JeepVehicleData.speedorwhatev er = 500;
« Last Edit: July 18, 2017, 08:13:15 AM by PhantOS »

What I do, to edit Add-Ons ingame, I edit it, then I save it to the file (which pops up when i close it) and then ingame, I would type something like this:
Code: [Select]
setmodpaths(getmodpaths());exec("add-ons/YOUR ADDON HERE/server.cs"); in the chat (Since I have eval) and then to make sure that it worked, I do
Code: [Select]
TransmitDatablocks();
Note: If you do edit an addon ingame with players on your server, it may force them to disconnect due to an invalid Packet. They can just reconnect, but I'm telling you since it's happened to me before.

transmitdatablocks() isn't necessary most of the time, only if you're editing certain datablocks like weaponimages or playerdata

Invalid packets are caused when using a new datablock that is not a new model - players can crash if using a new player datablock or a new model is loaded without sending a new manifest. (Just avoid doing this, it's not easy making a workaround if you don't know how to do it)

You should only use transmit datablocks if you seriously need to, try not to get into the habit of this - sometimes transmitting datablocks does not work and you will have to restart the server (such as weapon states)



To make a script that customizes current datablocks have it start with Script_ or Server_, you can also name it something like Extension_ if you even wanted to.
2 ways to change a datablock from an external script:
  Change it inside a function with a schedule OR
  Change it directly without a function

then put the datablock and the variable and set it to whatever you want

example A:
Code: (Extension_VehiclePrefs/server.cs) [Select]
TankVehicle.maxWheelSpeed = 100;example B:
Code: (Extension_VehiclePrefs/server.cs) [Select]
function Ext_ChangeVehiclePrefs()
{
      TankVehicle.maxWheelSpeed = 100;
}
schedule(0, 0, Ext_ChangeVehiclePrefs);
« Last Edit: July 18, 2017, 09:08:17 PM by Kyuande »