Author Topic: [Solved] Change maxWheelSpeed of vehicle for a gamemode  (Read 807 times)

Without editing the vehicle script, is it possible to set a different maxWheelSpeed for a vehicle only when a certain gamemode runs?

If that isn't possible, maybe I could remove the vehicle add-on from the gamemode.txt so it isn't required and then put the custom version of the vehicle add-on inside the gamemode folder to be executed.
« Last Edit: June 23, 2016, 03:08:00 AM by Farad »

Have you tried use console to do it? I use console for tweaks on my vehicle Wildcat
Here a console command. you can change "vehicleDB" to different vehicle datablocks and for speed just change "x" to any number
Code: [Select]
vehicleDB.maxWheelSpeed = x;
Here a example:
Code: [Select]
WildcatVehicle.maxWheelSpeed = 99;

That's fine in singleplayer, but when you change a value in the datablock while a server is running, it'll get weird and desynchronized. The vehicle moves at its new speed on the server, but players' clients expect it to move at a different speed, so it jumps around constantly on their screens. You would have to transmit datablocks every time it's changed.

I would just use a different version of the vehicle.
« Last Edit: June 22, 2016, 03:58:49 AM by Teneksi »

Without editing the vehicle script, is it possible to set a different maxWheelSpeed for a vehicle only when a certain gamemode runs?

If that isn't possible, maybe I could remove the vehicle add-on from the gamemode.txt so it isn't required and then put the custom version of the vehicle add-on inside the gamemode folder to be executed.
Edit the server.cs of whatever gamemode you may be editting, type in the change in wheel speed at the bottom, much like master king deaddude did, and type right below it transmitdatablocks();

This changes the value for the gamemode specifically and make sure it doesn't spaz out chronically.
You would have to transmit datablocks every time it's changed.
I think the idea here is that it's only changed once.

I think the idea here is that it's only changed once.
In which case the transmitDatablocks(); is unnecessary.

What's really important is that you use loadRequiredAddOn(%name); before attempting to change the speed, so you can be sure you can reference the datablock. If you've built your gamemode to double as a script when loaded in a custom gamemode, compare the return value of that function to $Error::AddOn_Disabled, and skip the change if it is. As long as you do it in a script that gets loaded when the game is started, you can change all the datablocks you want with no real consequence.

In which case the transmitDatablocks(); is unnecessary.
Just for clarification here, I thought the transmitDatablocks(); was necessary if the host is hosting the gamemode outside of a dedicated as they need to get the datablock information themselves.
-snip-
Couldn't the same thing be accomplished by moving the Gamemode_[file] to the bottom of the
ADDON [ADDON]
ADDON [ADDON]
ADDON Gamemode_[file]

part in the gamemode.txt since it's basically an execution order?

Just for clarification here, I thought the transmitDatablocks(); was necessary if the host is hosting the gamemode outside of a dedicated as they need to get the datablock information themselves.
Nope. All add-ons load before localClientConnection actually "connects" to the server and loads their own datablocks. Even if they didn't, the local client usually remains sync'd when a datablock changes.

Never looked in to why that is. I want to say because the client side and the server side are using the same datablock objects, but then I'd have no idea what's going on when it's supposedly loading datablocks from a local server. So I'm just guessing there's some special handling for local clients when datablocks change, maybe for the sake of singleplayer torque games that might want to do that easily.

Couldn't the same thing be accomplished by moving the Gamemode_[file] to the bottom of the
ADDON [ADDON]
ADDON [ADDON]
ADDON Gamemode_[file]

part in the gamemode.txt since it's basically an execution order?
Yeah you're right. I wasn't aware that it also loaded add-ons in the order given. Since it does, that would work just fine if you don't want the gamemode to work as a stand-alone script.