Jump to content

Vehicle Freezing at spawn & Toggling on player interaction.


xboxxxxd

Recommended Posts

Hi there person,

I need some help figuring out how to progress and finish up a script (idea to reality), but i can't find a way to do it on my own,

So can sombady help me out,

Here's the code.

CLIENT:

addEventHandler("onClientVehicleEnter", getRootElement(),
	function (thePlayer, seat)
		if thePlayer == getLocalPlayer() then
			triggerServerEvent ("Freeze", resourceRoot)
		end
	end
)

addEventHandler("onClientVehicleExit", getRootElement(),
	function (thePlayer, seat)
		if thePlayer == getLocalPlayer() then
			triggerServerEvent ("Freeze", resourceRoot)
		end
	end
)

SERVER:

function FreezeHandler()

end
addEvent("Freeze", true)
addEventHandler("Freeze", resourceRoot, FreezeHandler)

So my intention is first of all to freeze every vehicle when it respawns/spawns, and for example if 1 does respawn/spawn then only that 1 get's frozen.

And whenever the Event "onClientVehicleEnter" get's triggered, then the vehicle the player is going to unfreeze's,

and for "onClientVehicleExit" it's inverted, so it has to freeze the vehicle again until another player interaction would occur.

 

is anyone willing to help me out on this one, because i can't find it..

 

Gr.xboxxxxd.

Edited by xboxxxxd
Link to comment

One way to do this is to set the vehicle as the source of the event give a boolean value to triggerServerEvent, like this:

triggerServerEvent ("Freeze", source, true) -- true will be passed to setElementFrozen

Then in your freeze handler, you can add an argument and use it to freeze the vehicle:

function handler(frozen)
  setElementFrozen(source, frozen)
end

Server side, you will need to make the Frozen event bind to root, rather than resourceRoot.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...