[Tutorial] How to make multiple moveable gates.
#1

Hello guys today i decided to make a tutorial about movin multiple gates.
So now you need to make a new pawn project in pawno.
If you don't have pawno download the server package from sa-mp.com.
For this tutorial you will also need the streamer plugin which you can download from here.
Now when you have everything setted up lets get started.


Step #1: Include the streamer:
pawn Code:
#include <streamer>
you must put this under #include <a_samp>.

Step #2: When you create the new project delete all unnecessarily callbacks till you have only public OnFilterScriptInit() and public OnPlayerCommandText.
pawn Code:
#include <a_samp>
#include <streamer>

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Multiple Gates ");
    print("--------------------------------------\n");
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    return 0;
}
Step #3: Create array that is going to hold the multiple gates in this tutorial i will make array named gate.

Step #4: Now you need to define how much parameters the gate array is going to have. In this this tutorial i will have only 2. So in the [] put 2.

Step #5: Now lets move on to the gates. For this tutorial you must already have the gates code. First define each gate with in the array. And now in order to make the objects dynamic add an extra "Dynamic" to the CreateObject the code should look like this below. Also the those must be the gate "closed object". You need to do this ar the OnFilterScriptInit
pawn Code:
#include <a_samp>
#include <streamer>

new gate[2];

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Multiple Gates ");
    print("--------------------------------------\n");
    gate[0] = CreateDynamicObject(987,1496.59997559,-699.75000000,93.80000305,0.00000000,0.00000000,0.00000000);
    gate[1] = CreateDynamicObject(987,1484.59997559,-699.75000000,93.80000305,0.00000000,0.00000000,0.00000000);
        return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    return 0;
}
Step 6 and 7 are at writed at OnPlayerCommandText callback.

Step #6: Now it's time to make the commad for opening the gates. First you need your gate "opened object".
pawn Code:
if(!strcmp(cmdtext, "/open"))
     {
     MoveDynamicObject(gate[0], 1496.59997559,-699.75000000,86.80000305, 1);
     MoveDynamicObject(gate[1], 1484.59997559,-699.75000000,86.80000305, 1);
     return 1;
     }
The code above will open the gate [0] and [1] with the low speed of 1.

Step #7: Now it's time to make the commad for closing the gates. First you need your gate "closed object".
pawn Code:
if(!strcmp(cmdtext, "/close", true))
     {
     MoveDynamicObject(agate[0], 1496.59997559,-699.75000000,93.40000153, 1);
     MoveDynamicObject(agate[1], 1484.59997559,-699.75000000,93.40000153, 1);
     return 1;
     }
The code above will close gate [o] and [1] with the low speed of 1.

Now here is how your code should look like in the end.
pawn Code:
#include <a_samp>
#include <streamer>

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Multiple Gates ");
    print("--------------------------------------\n");
    gate[0] = CreateDynamicObject(987,1496.59997559,-699.75000000,93.80000305,0.00000000,0.00000000,0.00000000);
    gate[1] = CreateDynamicObject(987,1484.59997559,-699.75000000,93.80000305,0.00000000,0.00000000,0.00000000);
        return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/open"))
     {
     MoveDynamicObject(gate[0], 1496.59997559,-699.75000000,86.80000305, 1);
     MoveDynamicObject(gate[1], 1484.59997559,-699.75000000,86.80000305, 1);
     return 1;
     }

if(!strcmp(cmdtext, "/close"))
     {
     MoveDynamicObject(gate[0], 1496.59997559,-699.75000000,86.80000305, 1);
     MoveDynamicObject(gate[1], 1484.59997559,-699.75000000,86.80000305, 1);
     return 1;
     }
}
Reply
#2

You should explain it more.Like MoveDynamicObject(GateID, X,Y,Z,Speed);
Reply
#3

Quote:
Originally Posted by Infinity90
View Post
You should explain it more.Like MoveDynamicObject(GateID, X,Y,Z,Speed);
Yeah thanks ill take that in mind next time i do a tutorial.
Reply
#4

Quote:
Originally Posted by Rg-Gaming.Info
View Post
Yeah thanks ill take that in mind next time i do a tutorial.
you can always edit this one!

and why not use pawn tags?

you should also show how to open each gate with a different command,
and maybe offer a command processor example.

What you dont cover also is how to get the cords for the gates..
And without that part this tutorial is useless.
Reply
#5

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/open"))
     {
     MoveDynamicObject(gate[0], 1496.59997559,-699.75000000,86.80000305, 1);
     MoveDynamicObject(gate[1], 1484.59997559,-699.75000000,86.80000305, 1);
     return 1;
     }

 {
     MoveDynamicObject(agate[0], 1496.59997559,-699.75000000,93.40000153, 1);
     MoveDynamicObject(agate[1], 1484.59997559,-699.75000000,93.40000153, 1);
     return 1;
     }
    return 0;
}
You didn't forget something ?
Reply
#6

Quote:
Originally Posted by Jonny5
View Post
you can always edit this one!

and why not use pawn tags?

you should also show how to open each gate with a different command,
and maybe offer a command processor example.

What you dont cover also is how to get the cords for the gates..
And without that part this tutorial is useless.
Edited it.
Is i said you must already have mapped the gates .....

Quote:
Originally Posted by Vukilore
View Post
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/open"))
     {
     MoveDynamicObject(gate[0], 1496.59997559,-699.75000000,86.80000305, 1);
     MoveDynamicObject(gate[1], 1484.59997559,-699.75000000,86.80000305, 1);
     return 1;
     }

 {
     MoveDynamicObject(agate[0], 1496.59997559,-699.75000000,93.40000153, 1);
     MoveDynamicObject(agate[1], 1484.59997559,-699.75000000,93.40000153, 1);
     return 1;
     }
    return 0;
}
You didn't forget something ?
Edited thank you.
Reply
#7

Cool.
Reply
#8

Nice job man 10/10
Reply
#9

Quote:
Originally Posted by necrobg3
View Post
Cool.
Quote:
Originally Posted by kalata981
View Post
Nice job man 10/10
Thank you both.
Reply
#10

pawn Code:
if(!strcmp(cmdtext, "/close", true))
{
     MoveDynamicObject(agate[0], 1496.59997559,-699.75000000,93.40000153, 1);
     MoveDynamicObject(agate[1], 1484.59997559,-699.75000000,93.40000153, 1);
     return 1;
}
You forgot to edit on this one too. "agate"

pawn Code:
if(!strcmp(cmdtext, "/close", true))
{
     MoveDynamicObject(gate[0], 1496.59997559,-699.75000000,93.40000153, 1);
     MoveDynamicObject(gate[1], 1484.59997559,-699.75000000,93.40000153, 1);
     return 1;
}
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)