04.11.2010, 13:14
(
Last edited by knackworst; 07/12/2010 at 06:57 PM.
)
Hello everyone, since alot of people helped me out with the moving objects I want to make a little tutorial...
I know there are already alot of tutorials for it, but who carezzz?
For this tutorial I will use a little cage...
Save this map and put it in your server,
If you don't know how to put maps in your server, watch this: [ame]http://www.youtube.com/watch?v=7N4qd3HGi_U[/ame]
OK, the next thing you are going to do is making the door, to do that , simply make add the door in its Closed State ! on your cage, and remove everything but the door:
Ok, now save the map with the closed door too, (for example, save it as: cagecloseddoor)
Now comes the scripting:
Open your gamemode and on the beginning of the script you write this: new cagecloseddoor;
Like this:
I'm not going to show you the entire beginning of my gamemode, because it's huge, so...
Make sure you write it under: include,pragma,forward, define and static. Not somewhere in between those things !
Ok now we will need the cagedoor object, to get the object go into your MTA file, then click server -> mods -> deathmatch and finally resources, then find the file: cagecloseddoor, and convert the .map file as shown in the "adding maps" tutorial...
After you converted it you will get something like: CreatObject(...)
Now, you copy the entire "CreateObject(coords)" and you write in pawno, under OnGameModeInit:
"cagecloseddoor = the CreatObject (coords) that you just copied."
Like this:
Ok, now we are going to make the commands, for that go to OnPlayerCommandText
**The coords you see after : (cagecloseddoor, ) are the coords of the Opengate...
To get those coords you go back In MTA, now instead of the closed door state you simple set it open, now double click on the open state gate, and copy the x,y and z coordinates, and paste them behind:
(cagecloseddoor, x here, y here, z here , Speed)
You also see the 2.0 after the coordinates, this is the speed value, I like speed value 2, but if you want it faster just make it 2.00001 or more, for slower: 1.99999 or less...
Now we made a command to open the door, to close the door you copy everything from the open command, and paste it under the open command. like this:
But now you have to change the command from open to close, and change the coordinates, you have to change the coordinates after moveobject blahblah, into the coordinates of the opend gate, to get those coords, you just go back to: ongamemodeinit, and copy the coords. so you would have this:
now , you simply compile, and go ingame and test it![Smiley](images/smilies/smile.png)
NOTE: If you want the gate to close with a timer check out this tutorial:
http://forum.sa-mp.com/showthread.ph...ht=move+object
I hope it helped, if you have any further questions, feel free to post them here, or send me a PM![Smiley](images/smilies/smile.png)
BTW: this is my very first scripting tutorial :P
I know there are already alot of tutorials for it, but who carezzz?
For this tutorial I will use a little cage...
First of all we are going to make the map in MTA:
![](/imageshack/img6/6712/moveobjecttutcage.jpg)
As you can see we have the cage WHITOUT THE DOOR ! !![](/imageshack/img6/6712/moveobjecttutcage.jpg)
Save this map and put it in your server,
If you don't know how to put maps in your server, watch this: [ame]http://www.youtube.com/watch?v=7N4qd3HGi_U[/ame]
OK, the next thing you are going to do is making the door, to do that , simply make add the door in its Closed State ! on your cage, and remove everything but the door:
![](/imageshack/img100/7985/moveobjecttutcagedoor.jpg)
Now comes the scripting:
Open your gamemode and on the beginning of the script you write this: new cagecloseddoor;
Like this:
pawn Code:
new cagecloseddoor;
Make sure you write it under: include,pragma,forward, define and static. Not somewhere in between those things !
Ok now we will need the cagedoor object, to get the object go into your MTA file, then click server -> mods -> deathmatch and finally resources, then find the file: cagecloseddoor, and convert the .map file as shown in the "adding maps" tutorial...
After you converted it you will get something like: CreatObject(...)
Now, you copy the entire "CreateObject(coords)" and you write in pawno, under OnGameModeInit:
"cagecloseddoor = the CreatObject (coords) that you just copied."
Like this:
pawn Code:
public OnGameModeInit()
{
cagecloseddor = CreateObject(blahblah)
pawn Code:
if(strcmp("/opengate1", cmdtext, true) == 0) //We make the command
{
MoveObject(cagecloseddoor, 2897.8764648438, -2059.2080078125, 5.4179458618164, 2.0);
//THE moveobject function
SendClientMessage(playerid, 0xFF8000FF, "The gate is open close it right after you enterd!.");
}
return 1;
}
To get those coords you go back In MTA, now instead of the closed door state you simple set it open, now double click on the open state gate, and copy the x,y and z coordinates, and paste them behind:
(cagecloseddoor, x here, y here, z here , Speed)
You also see the 2.0 after the coordinates, this is the speed value, I like speed value 2, but if you want it faster just make it 2.00001 or more, for slower: 1.99999 or less...
Now we made a command to open the door, to close the door you copy everything from the open command, and paste it under the open command. like this:
pawn Code:
if(strcmp("/opengate1", cmdtext, true) == 0)
{
MoveObject(gateone, 2897.8764648438, -2059.2080078125, 5.4179458618164, 2.0);
SendClientMessage(playerid, 0xFF8000FF, "The gate is open close it right after you enterd!.");
}
return 1;
}
if(strcmp("/opengate1", cmdtext, true) == 0)
{
MoveObject(gateone, 2897.8764648438, -2059.2080078125, 5.4179458618164, 2.0);
SendClientMessage(playerid, 0xFF8000FF, "The gate is open close it right after you enterd!.");
}
return 1;
}
if(strcmp("/closegate1", cmdtext, true) == 0)
{
pawn Code:
if(strcmp("/opengate1", cmdtext, true) == 0)
{
MoveObject(gateone, 2897.8764648438, -2059.2080078125, 5.4179458618164, 2.0);
SendClientMessage(playerid, 0xFF8000FF, "The gate is open close it right after you enterd!.");
}
return 1;
}
if(strcmp("/closegate1", cmdtext, true) == 0)
{
MoveObject(gateone, 2897.9375, -2051.705078125, 5.4179458618164, 4.0);
SendClientMessage(playerid, 0xFF8000FF, "The gate is closed.");
}
return 1;
}
now , you simply compile, and go ingame and test it
![Smiley](images/smilies/smile.png)
NOTE: If you want the gate to close with a timer check out this tutorial:
http://forum.sa-mp.com/showthread.ph...ht=move+object
I hope it helped, if you have any further questions, feel free to post them here, or send me a PM
![Smiley](images/smilies/smile.png)
BTW: this is my very first scripting tutorial :P