Rouzbeh Posted February 20, 2015 Share Posted February 20, 2015 hello , how i can Avoid vehicle pushing ,so when a player push an empty car , can't move that car and car will stay there i saw this in a rp server! Link to comment
TAPL Posted February 20, 2015 Share Posted February 20, 2015 Freeze the vehicle. setElementFrozen Link to comment
Rouzbeh Posted February 20, 2015 Author Share Posted February 20, 2015 Freeze the vehicle. setElementFrozen yes but with this way if a vehicle hit that frozen vehicle it will not move ? Link to comment
crismar Posted February 20, 2015 Share Posted February 20, 2015 Yes, when you freeze an element it cannot be moved unless you change it's state. function toggleFreezeState(thePlayer, theSeat) if(theSeat == 0) if(isElementFrozen(source)) then setElementFrozen(source, false) else setElementFrozen(source, true) end end end addEventHandler("onVehicleExit", root, toggleFreezeState) addEventHandler("onVehicleEnter", root, toggleFreezeState) Link to comment
Rouzbeh Posted February 20, 2015 Author Share Posted February 20, 2015 Yes, when you freeze an element it cannot be moved unless you change it's state.yes but i want just avoid players(on-foot) pushing vehicles , and vehicle can move from another things happend like hit by car Link to comment
GERgta Posted February 21, 2015 Share Posted February 21, 2015 You could try freezing the cars client-side for players that are on foot. Link to comment
Rouzbeh Posted February 21, 2015 Author Share Posted February 21, 2015 You could try freezing the cars client-side for players that are on foot. can you give me an example plz? Link to comment
Mr_Moose Posted February 21, 2015 Share Posted February 21, 2015 You could try freezing the cars client-side for players that are on foot. That's not possible, unless a client side freeze only applies to the client it's triggered for, haven't tested that tho and you would still have the issue that you can't see the difference wherever the his player is on foot or in a vehicle. I've also seen some disadvantages with implementations like this such as players who use a packer truck to rise a frozen vehicle up in the air, then it just hangs there which would look really strange on a roleplay server. Solution Something you could try is to use the code by crismar and then add a clientside part which triggers on the event: onClientVehicleCollision. Now, as you can see this has a hitelement which you basically pass to the server side, if the hit element is a vehicle then set the vehicle unfrozen, otherwise ignore. Client: addEventHandler("onClientVehicleCollision", root, function(collider,force, bodyPart, x, y, z, nx, ny, nz) if collider and isElement(collider) and getElementType(collider) == "vehicle" then triggerServerEvent("disableFrozenState", localPlayer, collider) end end) Server: function disableFrozen( theElement ) setElementFrozen(theElement, false) end addEvent("disableFrozenState", true ) addEventHandler("disableFrozenState", resourceRoot, disableFrozen) Link to comment
3B00DG4MER Posted February 21, 2015 Share Posted February 21, 2015 You don't have to trigger the Event that function is shared (client and Server Sides) Link to comment
Addlibs Posted February 21, 2015 Share Posted February 21, 2015 You could manipulate handling so that all vehicles are too heavy for on-foot people to push. Since all cars would have increased mass, one vehicle would be able to push another just like previously, while peds/players would be unable to push it. I have done this in my server. Note that this solution will require you to completely change vehicle handling since higher mass = more momentum, thus braking deceleration, engine inertia, engine acceleration, and possibly braking bias would need to be changed in order to compensate for higher mass. You should also increase drag by the same multiplier as mass, so your car will decelerate at normal speed when accelerator button is released. You don't have to trigger the Event that function is shared (client and Server Sides) Clientside setElementFrozen would change the state only on the current client - what if another client was syncing the car? It would't move on the server... Link to comment
3B00DG4MER Posted February 21, 2015 Share Posted February 21, 2015 like that the crash will be latent cuz triggering an Event take time you could do a loop for all players Link to comment
Rouzbeh Posted February 21, 2015 Author Share Posted February 21, 2015 You could manipulate handling so that all vehicles are too heavy for on-foot people to push. Since all cars would have increased mass, one vehicle would be able to push another just like previously, while peds/players would be unable to push it. I have done this in my server. Note that this solution will require you to completely change vehicle handling since higher mass = more momentum, thus braking deceleration, engine inertia, engine acceleration, and possibly braking bias would need to be changed in order to compensate for higher mass. You should also increase drag by the same multiplier as mass, so your car will decelerate at normal speed when accelerator button is released. i did try your method and changed mass, braking deceleration, engine inertia, engine acceleration and ... but now cars seems a bit unnormally Link to comment
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