[Tutorial] How to put your map in your server + creating gates with 2 commands
#1

Introduction

Hello guys. I will show you tutorial on how to put your map, after converting in your server + how to create gates with two commands [/open and /close]. I know there is many tutorials like this but i will try to explain it a little better because i am new at scripting so i know what were my mistakes and probably of most new scripters.
So let's get started...

Starting

Ok so first of all enter pawno and select "New". Right lick now and press on "Select all" and then delete it. Now put this at top of script:
pawn Код:
#include a_samp
You can also put it like this:
pawn Код:
#include  <a_samp>
It doesn't really matter.

Now if you are creating gates put this below:
pawn Код:
new gate; //replace "gate" with some other name if you want but then you will have to replace it in few other locations
Now if you are creating more gates it should look like this:
pawn Код:
new gate;
new gate2;
new gate3;
Never put same name for two gates or objects because it will return this error:
pawn Код:
error 021: symbol already defined: "gate"

Adding objects to map

So now we are creating objects you converted.

Below
pawn Код:
new gate;
put this:
pawn Код:
public OnFilterScriptInit()
{
So below that you put codes. I will put part of code from one of my maps. It should like like this:
pawn Код:
public OnFilterScriptInit()
{
CreateObject(8172,2055.8000000,3606.3999000,7.2000000,0.0000000,0.0000000,0.0000000);
CreateObject(8172,2095.6001000,3606.5000000,7.2000000,0.0000000,0.0000000,0.0000000);
CreateObject(8172,2135.4004000,3606.6006000,7.2000000,0.0000000,0.0000000,0.0000000);
CreateObject(8172,2175.3000000,3606.7000000,7.2000000,0.0000000,0.0000000,0.0000000);
If you are creating gates don't put it in codes above.
Create it like this:
pawn Код:
gate = CreateObject(987,2116.7000000,3526.0000000,7.2000000,0.0000000,0.0000000,0.0000000);
And just finish it with this:
pawn Код:
return 1;
}
If you are not removing map objects or gates put
pawn Код:
return 0;
}
below.
So now you are done if you are not creating gates. This is how it should look:
pawn Код:
#include a_samp

public OnFilterScriptInit()
{
CreateObject(8172,2055.8000000,3606.3999000,7.2000000,0.0000000,0.0000000,0.0000000);
CreateObject(8172,2095.6001000,3606.5000000,7.2000000,0.0000000,0.0000000,0.0000000);
CreateObject(8172,2135.4004000,3606.6006000,7.2000000,0.0000000,0.0000000,0.0000000);
CreateObject(8172,2175.3000000,3606.7000000,7.2000000,0.0000000,0.0000000,0.0000000);
return 1;
}
return 0;
}
If you are creating gates move on...
Adding gate commands

So you are done with creating objects now let's create command for gates.
First of all you don't put this
pawn Код:
return 0;
}
yet.
First of all under
pawn Код:
return 1;
}
Put this:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
And now let's create command to open gate. Under that ^^^ put this:
pawn Код:
if(strcmp(cmdtext,"/YOURCOMMAND",true)==0)//gatesopen
{
So now we got command. But it doesn't do anything yet. Let's make this command to move gates. Under that ^^^ put this:
pawn Код:
MoveObject(gate, 2116.7000000,3526.0000000,0.0000000, 5.00);
return 1;
}
Now let me explain you. Where you see "gate" there you have to put name of your gates. Name you putted on top after "new". First number (2116.7000000) is X coordinate, second one (3526.0000000) is Y coordinate and third one (0.0000000) is Z coordinate.
Note: This command opens gate so you got to change Z coordinate. Depens do you want gate to go up or down. You can change X or Y if you want gates to go left/right. Which one you have to change depens on your gate's rotation. 4th number (5.00) is speed of gates moving. I use 5 because it isn't too slow or too fast.
Now let's get back to this code for a second:
pawn Код:
gate = CreateObject(987,2116.7000000,3526.0000000,7.2000000,0.0000000,0.0000000,0.0000000);
You got gateid first number, second three numbers are location on map, coordinates. Now last three numbers are rotation of object. While all three numbers are 0.000 you don't have to do anything. But if they have some rotation like these:
pawn Код:
gate = CreateObject(987,2116.7000000,3526.0000000,7.2000000,0.0000000,0.0000000,90.0000000);
That means gate are rotated so you have to change this command from this:
pawn Код:
MoveObject(gate, 2116.7000000,3526.0000000,0.0000000, 5.00);
to this:
pawn Код:
MoveObject(gate, 2116.7000000,3526.0000000,0.0000000, 5.00, 0.0000000,0.0000000,90.0000000);
Note: Rotation coordinates have to be last! It must be like this:
pawn Код:
MoveObject(gateid, X, Y, Z, speed, RotX, RotY, RotZ);
So let's close the gates now. Again, first create the command
pawn Код:
if(strcmp(cmdtext,"/YOURCOMMAND",true)==0)//gatesclosed
{
Then make command move gates:
pawn Код:
MoveObject(gate, 2116.7000000,3526.0000000,7.2000000, 5.00);
return 1;
}
Or if you have rotation like these:
pawn Код:
MoveObject(gate, 2116.7000000,3526.0000000,7.2000000, 5.00, 0.0000000,0.0000000,90.0000000);
Note: Your Z coordinate must be closed gates. Or if you changed X or Y coordinate they must be closed too!
This is how it should look:
pawn Код:
#include a_samp

new gate;

public OnFilterScriptInit()
{
//Your objects here

gate = CreateObject(987,2116.7000000,3526.0000000,7.2000000,0.0000000,0.0000000,0.0000000); //Your coordinates here

return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext,"/YOURCOMMAND",true)==0)//gatesopen
{
MoveObject(gate, 2116.7000000,3526.0000000,0.0000000, 5.00);
return 1;
}
if(strcmp(cmdtext,"/YOURCOMMAND",true)==0)//gatesclosed1
{
MoveObject(gate, 2116.7000000,3526.0000000,7.2000000, 5.00);
return 1;
}
return 0;
}
HOPE YOU LIKE IT AND YOU CAN UNDERSTAND EVERYTHING
If you don't understand something or need any help ask me, it will be my pleasure to help!
Reply
#2

This helped me a lot, but I have one question, how do I make a private gate?
I mean, only some people can open it.
I want to put the allowed nicks in the script but I can't find how to..
Reply
#3

Quote:
Originally Posted by danuub
Посмотреть сообщение
This helped me a lot, but I have one question, how do I make a private gate?
I mean, only some people can open it.
I want to put the allowed nicks in the script but I can't find how to..
Check this out, it'll allow you to set a password to access the gate, only people with the password can enter.

https://sampforum.blast.hk/showthread.php?tid=497223
Reply
#4

Quote:
Originally Posted by TakeiT
Посмотреть сообщение
Check this out, it'll allow you to set a password to access the gate, only people with the password can enter.
Well if you are using my tutorial only people with password can open it too.
Reply
#5

You could add a very simple thing to check if the player is in range of any gate and then it'll compare the gate's 'owner' with the player's name and return a message.

OT:Nice job.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)