Cronoss Posted February 28, 2022 Posted February 28, 2022 (edited) I made a function for my "carshop system", basically the function spawns the car that the player select and then, if the player select another car from the list, the script delete the car and starts again. But I know that creating and deleting this element in client-side everytime the player clicks on a row from the gridlist would be bad for my server, so I want to know how could I optimize this as much as it's possible Client-Side function vehicleVisible() local row = guiGridListGetSelectedItem(list) ---------get the row from the gui gridlist iprint("1") if row~=-1 then -----------if row is not -1 destroyVehicleVisible() ----another function that destroys the element "vehicleVisibleForPlayer" local id = guiGridListGetItemText(list, row, 1) iprint("2") if id then iddef = getVehicleModelFromName(id) ----------get the vehicle id from the name iprint("ID: "..iddef) vehicleVisibleForPlayer = createVehicle(iddef, 2123.560546875,-1129.4521484375,25.453437805176) ----spawns the car iprint("Llego hasta acá") local rot = setElementRotation(vehicleVisibleForPlayer, -0, 0, 331.40734863281) end end end Edited February 28, 2022 by Cronoss
Spakye Posted March 2, 2022 Posted March 2, 2022 Hello, maybe just add a button to confirm the vehicle creation ? you could also add a timer to disable it for a while after its been used. Though dont forget vehicles created client side cant be driven so you will need to trigger the server at some point. 1
Moderators IIYAMA Posted March 2, 2022 Moderators Posted March 2, 2022 Here is a useful function to add a rate limit (to user input): https://wiki.multitheftauto.com/wiki/CheckPassiveTimer 1
Cronoss Posted March 2, 2022 Author Posted March 2, 2022 Quote Hello, maybe just add a button to confirm the vehicle creation ? you could also add a timer to disable it for a while after its been used. Though dont forget vehicles created client side cant be driven so you will need to trigger the server at some point. Answering this, the system I'm showing this time it's not for the vehicle "definitive" creation, it's just my method to show the player what vehicle it's selecting, confirm the creation doesn't work for me, because I need to show the player the vehicle at the moment he selects the row in the "carshop" panel Quote Here is a useful function to add a rate limit (to user input): https://wiki.multitheftauto.com/wiki/CheckPassiveTimer In my opinion, limiting the player's time to select the next vehicle wouldn't look too good. I guess there is no way to optimize a system like this because i've been searching for something similar and nothing. I think that I need a new method to show the player the vehicle he is selecting but I can't figure out how to make it better
Moderators IIYAMA Posted March 2, 2022 Moderators Posted March 2, 2022 2 hours ago, Cronoss said: next vehicle wouldn't look too good Then do the selection 100% clientside, that way you eliminate the connection delay and also not wasting network for other players. In your code I do not see serverside btw. 1
Cronoss Posted March 2, 2022 Author Posted March 2, 2022 Thank you so much, I though that Client-side also could affect the other's player in some way, appreciate your time 1
Moderators IIYAMA Posted March 2, 2022 Moderators Posted March 2, 2022 6 minutes ago, Cronoss said: I though that Client-side also could affect the other's player in some way In most cases not. (with an important exception: on clientside setElementData used on an element which is created by serverside) 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now