Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Client-sided setVehicleHandling for local entities (aka client-sided vehicles) #192
The following includes some basic tests of the features implemented.
Basically, implemented setVehicleHandling client-side allowing it only to work with local entities so as to avoid having to sync the changes (if you need to sync them, you can do it serverside, since it means you your vehicle is serverside).
When resetting vehicleHandling, it can only be resetted to original value. (there's no setModelHandling client-side, which means that you should use the following syntax).
setVehicleHandling(veh, nil) -- resets all to gta default
Tested programatically as it will be shown below (can't get inside client-sided vehicles to test-drive)
Please code review and tell me if there's something I can do to improve.
I have tried to have a HandlingDefs function like server-side (so that it would serversided guidelines), and I got to a dead end (probably due to my lack of knowledge).
Also, the signature of the handling methods use a CClientVehicle instead of a CVehicle checking if it's a localEntity. I'm not sure if they implement any interface, in which case we could think about sharing the code.
Finally, resetting got the boolean parameter removed, although the code is still very similar.
What do you suggest I could do to improve it?
Should I try to implement it shared?
Yes please! Not everything has to implemented shared but the more, the better.
I think the trick here is to wrap the initial declaration in an
#ifdef MTA_CLIENT CClientVehicle* pVeh = getVehicle(); #else CVehicle* pVeh = getVehicle(); #endif // Now you can use common methods pVeh->something();
It's probable that the only suitable thing to implement shared is
I think a good way forward would to actually keep the boolean feature of setVehicleHandling, except just disable
That way both functions (server and client side) function exactly the same, except on the client the model handling would throw an error. (This would make it easier to document and easier to remember.)
Thank you for your contribution!