Rouzbeh Posted January 12, 2016 Share Posted January 12, 2016 Hi, im working on a rpg server. i want when a player do handbrake then players can't Push that vehicle (just players, not other vehicles), i have vehicle system include handbrake and etc , just need an idea for how to make this 'Anti Vehicle Pushing'? i did tried freeze vehicle, but this is not good idea and socks for RPG... Link to comment
Addlibs Posted January 12, 2016 Share Posted January 12, 2016 I'm not sure if that is possible, I'm afraid. You could try to mess around with the vehicle handling, though I never got any decent successes. Link to comment
Rouzbeh Posted January 12, 2016 Author Share Posted January 12, 2016 I'm not sure if that is possible, I'm afraid. You could try to mess around with the vehicle handling, though I never got any decent successes. i saw that in a MTA RP Server! and was very cool system i already tried increase mass of vehicle but not work.... Link to comment
Addlibs Posted January 12, 2016 Share Posted January 12, 2016 In that case you can try to ask the developers of that server or wait for someone else with a better suggestion as I really don't know what would be a good way. Link to comment
killeryoyo Posted January 12, 2016 Share Posted January 12, 2016 maybe we can use this setElementFrozen ? when the player presses the hand brake. the element gets frozen and no one can push? . 1 Link to comment
Addlibs Posted January 12, 2016 Share Posted January 12, 2016 maybe we can use this setElementFrozen ? i did tried freeze vehicle, but this is not good idea and socks for RPG... Link to comment
ViRuZGamiing Posted January 12, 2016 Share Posted January 12, 2016 It's a bit of an weird way to do it, but I guess you could get the position and set it everytime it changes but it'll be too server or client intensive I guess. Link to comment
Rouzbeh Posted January 12, 2016 Author Share Posted January 12, 2016 It's a bit of an weird way to do it, but I guess you could get the position and set it everytime it changes but it'll be too server or client intensive I guess. hmm, this way have problems like when an another car hit or accident to the car will not move.... and maybe more bugs happend... as i know that rp server did'nt freeze car... server name was: Owl-Gaming Link to comment
Tails Posted January 12, 2016 Share Posted January 12, 2016 (edited) What if you set the vehicle's mass to an extremely high value? I haven't tested if it makes you like a tank so you'll have to see for yourself. https://wiki.multitheftauto.com/wiki/SetVehicleHandling Here's some code I've written a while back, changed it a bit for you. (it's not perfect) function resetHandling() if isPedInVehicle(player) then local veh = getPedOccupiedVehicle(player) if veh then local model = getElementModel(veh) local propTable = getOriginalHandling(model) for k,v in pairs(propTable) do setVehicleHandling(veh,k,v) end end end end function changeHandling(player) if isPedInVehicle(player) then local veh = getPedOccupiedVehicle(player) if veh then local model = getElementModel(veh) local propTable = getOriginalHandling(model) local prop = "mass" local value = propTable[prop] setVehicleHandling(veh,prop,value+70000) end end end function bindKeys(source) bindKey(source,"lshift","down",changeHandling) bindKey(source,"lshift","up",resetHandling) end addEventHandler("onVehicleEnter",root,bindKeys) Edited February 5, 2016 by Guest Link to comment
Noki Posted January 12, 2016 Share Posted January 12, 2016 You could use a timer and set velocity to 0, 0, 0. But like ViRuZ said about setting the position, it might be too intensive. Link to comment
Sasu Posted January 12, 2016 Share Posted January 12, 2016 You could use a timer and set velocity to 0, 0, 0. But like ViRuZ said about setting the position, it might be too intensive. Maybe using with onClientVehicleCollision. Link to comment
Mr_Moose Posted January 13, 2016 Share Posted January 13, 2016 It's not sure that onClientVehicleCollision will trigger when a player tries to push the vehicle as it's the player colliding to the vehicle and not the opposite, it's worth a try however. And once it triggers, the controls of the player may toggle temporary to force the player to stop using: SetControlState and ToggleControl. I've been using these for players with high latency for a while with good results so it might be a useful combination if implemented right. Good luck. Link to comment
Syntrax# Posted January 14, 2016 Share Posted January 14, 2016 Why you ain't using setElementFrozen Here is the script from the wiki. -- Serverside -- -- This function freezes the specified player's vehicle, if he's in one function toggleFreezeStatus ( thePlayer ) -- if he is in a vehicle, if getPedOccupiedVehicle ( thePlayer ) then -- get the vehicle element local playerVehicle = getPlayerOccupiedVehicle ( thePlayer ) -- get the current freeze status local currentFreezeStatus = isElementFrozen ( playerVehicle ) -- get the new freeze status (the opposite of the previous state) local newFreezeStatus = not currentFreezeStatus -- set the new freeze status setElementFrozen ( playerVehicle, newFreezeStatus ) end end -- now bind a key to this function for all players. -- first get a list of all players local connectedPlayers = getElementsByType ( "player" ) -- then, for each player, for i, aPlayer in ipairs(connectedPlayers) do -- bind the player's "p" key to the toggleFreezeStatus function bindKey ( aPlayer, "p", "down", "Toggle freeze status", toggleFreezeStatus ) end Link to comment
Addlibs Posted January 14, 2016 Share Posted January 14, 2016 Freezing a vehicle is not the same as having a handbrake applied. He's aiming for realism rather than mechanics, hence i did tried freeze vehicle, but this is not good idea and socks for RPG... Link to comment
ViRuZGamiing Posted January 14, 2016 Share Posted January 14, 2016 Maybe this works? setControlState(source, "handbrake", true) Regards Billy Link to comment
Addlibs Posted January 14, 2016 Share Posted January 14, 2016 You can't set control state of a vehicle. There's one possible solution, placing a ped inside the vehicle while no one's there and making him apply the handbrake constantly, but then it'd be impossible to re-enter the car (can't jack peds, can't enter while they're inside). The only way to fix that second problem would be deleting the ped when the player enters, but the player won't enter at that instance therefore one will need to press F/Enter twice to re-enter a car. Link to comment
ViRuZGamiing Posted January 14, 2016 Share Posted January 14, 2016 Maybe too advanced but can't you get a vehicle in your line of sight instead of the ped thing? Also not sure if it's secure. Link to comment
Olle Risk Posted January 14, 2016 Share Posted January 14, 2016 You can't set control state of a vehicle. There's one possible solution, placing a ped inside the vehicle while no one's there and making him apply the handbrake constantly, but then it'd be impossible to re-enter the car (can't jack peds, can't enter while they're inside). The only way to fix that second problem would be deleting the ped when the player enters, but the player won't enter at that instance therefore one will need to press F/Enter twice to re-enter a car. I think you can force the player to enter the car again afterwards, or maybe that only works on peds? Link to comment
tosfera Posted January 15, 2016 Share Posted January 15, 2016 Freezing a vehicle/element would be a terrible thing to do.. a simple BMX could stop a freaking rhino with the handbrake applied to it. You can do a few things which indeed have been said in previous comments; 1. Whenever the vehicle gets streamed in, add a ped in there which applies the handbrake every now and then. This is however quite heavy for your server if you have let's say.. 50 people running around in a garage at different locations. 2. Increase the mass of the vehicle, since that didn't work for you early you might want to try and set it to the maximum value of 100000.0 which should actually work. Even though, a player with a higher ping has always been stronger than a person with a normal ping in MTA. 3. Resetting the vehicle's position would be a really bad idea too. It'll make it look like a shocking thing if it's done in a wrong way and your server won't like it. If you however do want to do it this way, make sure you're resetting it with an onClientRender. But then again, it will be really intensive for your server.. 4. If changing the mass doesn't work, you might have to try these handlings: fDragMult (dragCoeff), nPercentSubmerged (percentSubmerged, a ped can't be heavier nor push more than 99999kg I guess.. ). 5. A last thing you could do, which is actually more of a thing that can be done in RPGs but not in RP scripts; disable the collision for the vehicles. They'll be unable to be pushed or standing on top of them and things like that, yet they can still be used to get in and things like that. Link to comment
Dealman Posted January 15, 2016 Share Posted January 15, 2016 Changing the mass is also a bad idea since mass is included in vehicle damage calculations. Also drag is air resistance, pretty sure it would not be of any help. Best workaround I can think of is to spawn a ped and warp the ped into the driver seat. Make the ped invisible using setElementAlpha. Then use setControlState to make the ped apply the GTA handbrake. Link to comment
tosfera Posted January 15, 2016 Share Posted January 15, 2016 @Dealman, putting the pet in there and making him use the handbrake will make it unable to get in the vehicle since the event isn't being fired. The people in previous comments said so, can't confirm this though. Never saw anyone able to hijack a ped. To actually get this working you should bind a custom function to your F ( or enter_vehicle key ) and check if there is a ped in the closest vehicle, check the distance, remove the ped and force the user to get into that vehicle by executing the enter function again. Won't be so much trouble after all, if it works. Link to comment
Rouzbeh Posted January 24, 2016 Author Share Posted January 24, 2016 yes i did tried dealman's way and i have an idea: i have a car alert system and i can add and put ped in vehicle when player lock his/her vehicle from outside and remove when unlock... so players can't push personal vehicles when that vehicle locked ... i think this is best way... Link to comment
Tails Posted February 5, 2016 Share Posted February 5, 2016 i already tried increase mass of vehicle but not work.... It does work. Make sure you set them to the max values. Read my other post, you'll see how I did it. Link to comment
MRThinker Posted June 4, 2018 Share Posted June 4, 2018 @Rouzbeh Whats your server address? Link to comment
salh Posted June 4, 2018 Share Posted June 4, 2018 16 minutes ago, MRThinker said: @Rouzbeh Whats your server address? No 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