movable object in range of something?
#1

Hello am kinda newbie scripter, and I dont know how to code that one hehe..

How can I create a let's say gate which raises if i use a cmd or press a button near it?
like if i am in range of this gate and i will hit y or n it will raise up?

thanks in advance.

EDIT: is the anything to create textdraws like a program or a website?
and how can i make a textdraw clickable or show information?
Reply
#2

Hey,

If you would like to press a button near it, you will need to use OnPlayerKeyStateChange
Here you will need to check if the player presses the key you want to use, and if it is pressed check if player is near the gate. You can easily do this by using the IsPlayerInRangeOfPoint function. You'll also have to create an object for the gate. You'll need to use this in functions later so you'll need to assign it to a variable (for example: gate = CreateObject/CreateDynamicObject).

You should take a look at the following function to move the object (close/open the gate): MoveObject (if you use streamer, use MoveDynamicObject.

Before moving the object you need to get it's current position to see whether the gate should be closed or opened. You can simply check if the object ID's position is not equal to open XYZ for instance, if not move it to the open XYZ, if else move it back to closed XYZ.

There are probably countless tutorials on the forums on how to do this but this is hopefully helpful as well.
Reply
#3

Quote:
Originally Posted by CXdur
Посмотреть сообщение
Hey,

If you would like to press a button near it, you will need to use OnPlayerKeyStateChange
Here you will need to check if the player presses the key you want to use, and if it is pressed check if player is near the gate. You can easily do this by using the IsPlayerInRangeOfPoint function. You'll also have to create an object for the gate. You'll need to use this in functions later so you'll need to assign it to a variable (for example: gate = CreateObject/CreateDynamicObject).

You should take a look at the following function to move the object (close/open the gate): MoveObject (if you use streamer, use MoveDynamicObject.

Before moving the object you need to get it's current position to see whether the gate should be closed or opened. You can simply check if the object ID's position is not equal to open XYZ for instance, if not move it to the open XYZ, if else move it back to closed XYZ.

There are probably countless tutorials on the forums on how to do this but this is hopefully helpful as well.
thanks alot! and is there anything for the textdraws?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)