How to create a door with a keypads -
BizzyD - 10.04.2011
Hello, Well this is my first tutorial. And i will try to make it as good as possible
.
Well, We are going to create a door in the LSPD interior.
First, Put this on top of your script:
That is the name of your door. And will be used later.
Then you need to create your object. Put this OnGameModeInit:
Код:
pddoor1 = CreateObject(OBJECTID, X,Y,Z,RX,RY,RZ,DRAWDISTANCE); //Your probably wondering what RX,RY,RZ. Its the rotation coordinates for your object
Then goto your script and search for:
OnPlayerKeyStateChange. If you cant find it. Then you dont have it in your script. But thats alright. Add this to the bottom of your script.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
Well, Now you need to go ingame. And go into your interior where you placed the door. And do /save to get your coordinates. After you have done that. Goto My Documents>Gta San andreas user files>SAMP>Savedpositions.txt and get your cordinates.
Example:
Код:
AddPlayerClass(0,1485.8622,-1565.8378,23.5469,273.8373,0,0,0,0,0,0); // The numbers marked with colour black is your coordinates.
Well now open your script, and add this to your OnPlayerKeyStateChange code:
This is the key ENTER or F. Its the key to enter vehicles. This is the key that will open your door.
Now add this to your code:
pawn Код:
if(newkeys & 16)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, YOUR CORDINATES))
The
IsPlayerInRangeOfPoint part shows if you are near the door. The
2.0 numbers are how long you can be from the keypad. I would
recommend 2.0. Its close enough.
Now when that part is done. You would normally only want police officers to open it. So now lets add this to your command. This is the most used function in the scripts. And i think every RP script uses it.
pawn Код:
if(newkeys & 16)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, YOUR CORDINATES))
{
if (PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pMember] == 1)
This check if you are a member or the leader of LSPD. And it will only be openable if you are in LSPD.
Now lets continue with the command.
We are now going to make the door movable.
pawn Код:
if(newkeys & 16)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, YOUR CORDINATES))
{
if (PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pMember] == 1)
{
MoveObject(pddoor1,CORDS,SPEED);
Alright, Now add your coordinates at the
CORDS place.
The speed is how fast you want the door to move. I would recommend
2.0 again.
Now you got the door moving, But now you want it closed right?
Well lets use a timer for that.
First go to the top of your script. And add:
Код:
forward doorclose1(playerid);
This will forward your timer. Now goto anywhere of your script, and add this:
pawn Код:
public doorclose1(playerid)
{
MoveObject(pddoor,CORDS,SPEED);
return 1;
}
This is the timer that will close your gate. Well now go back to
OnPlayerKeyStateChange. Just hit CTRL + F and search for it.
Now add this to your code:
pawn Код:
if(newkeys & 16)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, YOUR CORDINATES))
{
if (PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pMember] == 1)
{
MoveObject(pddoor1,CORDS,SPEED);
SetTimerEx("doorclose1", 5000, false, "i", playerid);
SetTimerEx will add the timer to your command. So when you open it. It will automaticly close. In 5 seconds. The seconds are in milliseconds. To count that out, just goto ****** and type for an example:
Код:
10 seconds in milliseconds
And it will count it out.
Now lets add a Animation when you open the door.
pawn Код:
if(newkeys & 16)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, YOUR CORDINATES))
{
if (PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pMember] == 1)
{
MoveObject(pddoor1,CORDS,SPEED);
SetTimerEx("doorclose1", 5000, false, "i", playerid);
ApplyAnimation(playerid, "HEIST9", "Use_SwipeCard", 10.0, 0, 0, 0, 0, 0);
This will make it look like you are swiping a card when you press ENTER / F.
Now we are almost done.
We just need to close the command. Just add three closing brackets to the end. Like this:
pawn Код:
if(newkeys & 16)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, YOUR CORDINATES))
{
if (PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pMember] == 1)
{
MoveObject(pddoor1,CORDS,SPEED);
SetTimerEx("doorclose1", 5000, false, "i", playerid);
ApplyAnimation(playerid, "HEIST9", "Use_SwipeCard", 10.0, 0, 0, 0, 0, 0);
}
}
}
And now we are finished! Congratulations!. This is how it should look:
[ame]http://www.youtube.com/watch?v=sxf3iEIObAA[/ame]
Please reply what you think about my first tutorial
Re: How to create a door with a keypads -
BizzyD - 10.04.2011
Thank you
Re: How to create a door with a keypads -
ToPhrESH - 10.04.2011
LOl easy, but nice tutorial for the newbies out there needing miscellanous things like this.
Re: How to create a door with a keypads -
BizzyD - 10.04.2011
Quote:
Originally Posted by ToPhrESH
LOl easy, but nice tutorial for the newbies out there needing miscellanous things like this.
|
Haha yea i know its easy. I just made it for fun :P
Thanks
Re: How to create a door with a keypads -
[BKR]LUCAGRABACR - 10.04.2011
Good tutorial Alex, well yeah, as most RP servers use/based on GF GM this will be so useful for many people hhaha.
Re: How to create a door with a keypads -
BizzyD - 10.04.2011
Quote:
Originally Posted by [BKR]LUCAGRABACR
Good tutorial Alex, well yeah, as most RP servers use/based on GF GM this will be so useful for many people hhaha.
|
Thanks
haha yea i know :P
Re: How to create a door with a keypads -
Adam420 - 11.04.2011
Do i add this stuff on my actual GM or in a new pwn file?
Re: How to create a door with a keypads - Unknown123 - 12.04.2011
Quote:
Originally Posted by Adam420
Do i add this stuff on my actual GM or in a new pwn file?
|
You can add it as a FilterScript or you can add it to your GameMode.. your choose
Re: How to create a door with a keypads -
DarrenReeder - 15.04.2011
Does anyone know what the animation is called where your character presses the button? IT would be nice to have the animation in on this.
EDIT:
ApplyAnimation(playerid, "HEIST9", "Use_SwipeCard", 10.0, 0, 0, 0, 0, 0);
Re: How to create a door with a keypads -
admantis - 15.04.2011
I don't have these variables, you would have them if your script was a GF edit
Re: How to create a door with a keypads -
alpha500delta - 15.04.2011
Quote:
new pddoor1;
That is the name of your door. And will be used later.
Then you need to create your object. Put this OnGameModeInit:
Code:
pdoor1 = CreateObject(OBJECTID, X,Y,Z,RX,RY,RZ,DRAWDISTANCE); //Your probably wondering what RX,RY,RZ. Its
|
Do you see the problem?
Re: How to create a door with a keypads -
BizzyD - 16.04.2011
What is the problem lol
EDIT: Oh! Now i see it
haha thanks
EDIT2: Fixed it :P Thank you xD
Re: How to create a door with a keypads -
alpha500delta - 16.04.2011
No problem xd. Next time check you're code before posting.
Re: How to create a door with a keypads -
iJumbo - 16.04.2011
nice
Re : How to create a door with a keypads -
Naruto_Emilio - 16.04.2011
Thanks man it's a great tutorial
Re: How to create a door with a keypads -
BizzyD - 16.04.2011
Thank you
EDIT:
Quote:
Originally Posted by alpha500delta
No problem xd. Next time check you're code before posting.
|
Haha
Yea, but it was a such small mistake. Couldnt even notice it lol :P
Re: How to create a door with a keypads -
Anteino - 19.04.2011
Lol that's awesome I might use it on my server
Re: How to create a door with a keypads -
blackwave - 19.04.2011
really nice ;>D
Keypads -
[MF]FACE - 30.04.2011
Pls I need the ObjectID or the name of these keypads.
would be nice if someone will post them
Re: Keypads -
BizzyD - 30.04.2011
Quote:
Originally Posted by [MF]FACE
Pls I need the ObjectID or the name of these keypads.
would be nice if someone will post them
|
The object id is:
2886
Thanks everyone for your comments