-
-
Notifications
You must be signed in to change notification settings - Fork 415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client-sided setVehicleHandling for local entities (aka client-sided vehicles) #192
Conversation
It looks like some of this code was copied from the server. Have you explored ways to share code? |
Sincerely no. 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! 👍 💖 |
Due to exams I won't be able to work on it till late June/early July. Anybody available to work on it is welcome. Feel free to work on my fork (if you need to get collaborator status send me a message). |
@Renkon I might have a dabble if you can add me as a contributor |
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
setVehicleHandling(veh, property, nil) -- resets property to nil
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.
Thank you,
-ffs-Renkon