10.04.2011, 18:59
(
Последний раз редактировалось BizzyD; 17.06.2011 в 14:10.
)
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:
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.
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:
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:
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.
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.
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:
This will forward your timer. Now goto anywhere of your script, and add this:
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:
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:
And it will count it out.
Now lets add a Animation when you open the door.
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:
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
Well, We are going to create a door in the LSPD interior.
First, Put this on top of your script:
Код:
new pddoor1;
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
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
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.
pawn Код:
if(newkeys & 16)
Now add this to your code:
pawn Код:
if(newkeys & 16)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, YOUR CORDINATES))
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)
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);
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);
pawn Код:
public doorclose1(playerid)
{
MoveObject(pddoor,CORDS,SPEED);
return 1;
}
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);
Код:
10 seconds in milliseconds
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);
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);
}
}
}
[ame]http://www.youtube.com/watch?v=sxf3iEIObAA[/ame]
Please reply what you think about my first tutorial