Help doors
#1

Hello, i am trying to make a command /toggdoor that will open/close the door (MoveObject)
So when i am standing next to a door it automaticly gets the door id (ObjectID) and open/close it...
The command is a toggle so when i type /toggdoor if door is closed, it will open and if it is opened it will close with the same command.
The doors i want to open/close: http://prntscr.com/47xkai
Here someone made it simmilar: https://www.youtube.com/watch?v=LidJh0_EN8c
Reply
#2

I don't know on what level of pawn skills you are at, so I will just tell you what to do and if you don't know how to do any of the below, you ask.

First, declare variables that will hold the ID of the door objects that will be created. Just name it anything, for example:
Код:
new door_pd_1;
Under OnGameModeInit(), create the objects and assign the previous variables to them. When the function used for creation of objects is called, it returns the ID of the created object and we want that ID because we will need it to move the door. Right? So...
Код:
door_pd_1 = CreateObject(modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, Float:DrawDistance);
Haven't got a clue what command system you are using, but you can change the code in adequate places. When you use the command, you want to check which door the player is next to. Use the proximity detector function as a condition:
Код:
if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
    // rest of code
Obviously, the coordinates that you put into the above function have to be the object coordinates. If the 'if' condition is satisfied, you can move onto the actual moving. So you just move the object using the function you mentioned and the ID we stored in the door_pd_1 variable...

Код:
MoveObject(pd_door_1, x, y, z, speed);
Reply
#3

but how is it going to know the coordinates xyz in if(IsPlayerInRangeOfPoint...
Reply
#4

You input the coordinates of the object, the same ones as you created the doors with. Because the function compares the distance between you and a given set of coordinates.

So to check whether the player is close enough to the door, in IsPlayerInRangeOfPoint you input the object coordinates.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)