[FilterScript] Gate System - In Script
#1

There are many scripts around that let you simply do /creategate in game and set up dynamic gates that way. However, if you run a big roleplay server that does custom mapping, it might be a pain to do it that way. I've created an advanced mapping script for my server, but I have decided to release a simplified version to all of you.

When you are near a gate that you have mapped in, you can type /gate and it will prompt you for a code, if the code is correct it will open. This is extremely easy to edit to link gates to open according to a house or faction, as opposed to a code.

How does it work?

You simply paste all of your gates (or even all your mapping) in the desired place in the filterscript. I personally use a more advanced version using streamer and a lot more functions, and use the script for all of my mapping.

To create a gate, map 2 gates in your editor, one open and one closed. Now go into your code and export the parameters of the gates and format them as follows:

Код:
CreateDynamicGate(modelid, Float:closedx, Float:closedy, Float:closedz, Float:closedrx, Float:closedry, Float:closedrz, Float:openx, Float:openy, Float:openz, Float:openrx, Float:openry, Float:openrz, code[]);
Modelid - The IDE of the object that you want to move
Closed, open Floats - The X, Y, Z and rotations for the object in it's closed and open spots.
Code - The password required to open the gate.

Now, if you want to use a streamer for this, you can make the gates create in only a certain virtual world, which I recommend if you are using this for RP purposes in interiors.

The script is short, so I will post it below.
pawn Код:
#include <a_samp>
#include <zcmd>

#undef MAX_OBJECTS
#define MAX_OBJECTS 1000000 //Change this if you want to have a maximum amount of objects in the server

#define MAX_GATES 999 //The maximum amount of gates that will create

enum GateInfo
{
    gmodel,
    gobject,
    Float:gclosedx,
    Float:gclosedy,
    Float:gclosedz,
    Float:gclosedrx,
    Float:gclosedry,
    Float:gclosedrz,
    Float:gopenx,
    Float:gopeny,
    Float:gopenz,
    Float:gopenrx,
    Float:gopenry,
    Float:gopenrz,
    gcode[6],
    gclosed,
    gopening,
   
};


#define DIALOG_CODE 392 //Change 392 if the dialog does not show up



new GInfo[MAX_GATES][GateInfo];
new gatescreated;

public OnFilterScriptInit()
{
    gatescreated = 0;
   
   
    //Insert the gate/mapping codes here
   
   
//=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%
//                              END OF EDIT
//=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%

    for(new i=0; i<MAX_GATES; i++)
    {
        GInfo[i][gobject] = CreateObject(GInfo[i][gmodel], GInfo[i][gclosedx], GInfo[i][gclosedy], GInfo[i][gclosedz], GInfo[i][gclosedrx], GInfo[i][gclosedry], GInfo[i][gclosedrz]);
        GInfo[i][gclosed] = 1;
    }
    return 1;
}

public OnFilterScriptExit()
{
    for(new i = 0; i < MAX_OBJECTS; i++)
    {
        if(IsValidObject(i))
        {
            DestroyObject(i);
        }
    }
}

CMD:gate(playerid)
{
    for(new i=0; i<MAX_GATES; i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 5.0, GInfo[i][gclosedx], GInfo[i][gclosedy], GInfo[i][gclosedz]))
        {
            if(GInfo[i][gclosed] == 1)
            {
                ShowPlayerDialog(playerid, DIALOG_CODE, DIALOG_STYLE_INPUT, "Code", "This door is password protected.\nEnter the code.", "Enter", "");
                GInfo[i][gclosed] = 0;
                GInfo[i][gopening] = 0;
            }
            else
            {
                MoveObject(GInfo[i][gobject], GInfo[i][gclosedx], GInfo[i][gclosedy], GInfo[i][gclosedz], 3.0, GInfo[i][gclosedrx], GInfo[i][gclosedry], GInfo[i][gclosedrz]);
                GInfo[i][gclosed] = 1;
            }
        }
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_CODE)
    {
        if(response)
        {
            for(new i=0; i<MAX_GATES; i++)
            {
                if(strmatch(inputtext, GInfo[i][gcode]))
                {
                    MoveObject(GInfo[i][gobject], GInfo[i][gopenx], GInfo[i][gopeny], GInfo[i][gopenz], 3.0, GInfo[i][gopenrx], GInfo[i][gopenry], GInfo[i][gopenrz]);
                    GInfo[i][gclosed] = 0;
                    GInfo[i][gopening] = 0;
                }
            }
        }
    }
    return 0;
}

CreateDynamicGate(modelid, Float:closedx, Float:closedy, Float:closedz, Float:closedrx, Float:closedry, Float:closedrz, Float:openx, Float:openy, Float:openz, Float:openrx, Float:openry, Float:openrz, code[6])
{
    gatescreated ++;
    new id = gatescreated;
    GInfo[id][gmodel] = modelid;
    GInfo[id][gclosedx] = closedx;
    GInfo[id][gclosedy] = closedy;
    GInfo[id][gclosedz] = closedz;
    GInfo[id][gclosedrx] = closedrx;
    GInfo[id][gclosedry] = closedry;
    GInfo[id][gclosedrz] = closedrz;
    GInfo[id][gopenx] = openx;
    GInfo[id][gopeny] = openy;
    GInfo[id][gopenz] = openz;
    GInfo[id][gopenrx] = openrx;
    GInfo[id][gopenry] = openry;
    GInfo[id][gopenrz] = openrz;
    GInfo[id][gcode] = code;
    return 1;
}

stock strmatch(const String1[], const String2[])//credits to cameltoe
{
    if ((strcmp(String1, String2, true, strlen(String2)) == 0) && (strlen(String2) == strlen(String1)))
    {
        return true;
    }
    else
    {
        return false;
    }
}
Note: This script uses ZCMD. Make sure you have it before trying to compile the script!
Reply
#2

Very kawaii.
Reply
#3

This is the lackest script i've ever seen, what's the point of all this?
Reply
#4

Quote:
Originally Posted by Wi
Посмотреть сообщение
This is the lackest script i've ever seen, what's the point of all this?
The point is that it simplifies the creation of gates and adds a password function. No need to be a dick.
Reply
#5

Quote:
Originally Posted by Wi
Посмотреть сообщение
This is the lackest script i've ever seen, what's the point of all this?
It allows you to create gates within a matter of seconds, and keep it with your mapping code. It's a great mapping system, and in my opinion quicker than making them in game
Reply
#6

Nicely done, thank you!
Reply
#7

Its a great script man!
Well done.
Reply
#8

Quote:
Originally Posted by Ozil
Посмотреть сообщение
Its a great script man!
Well done.
Thanks
Reply
#9

Bump! I've noticed a lot of people are still doing it manually! This is seriously only 1 line of code per gate guys
Reply
#10

I prefer dynamic gate system wich allows you and even your admin personnel to create gates during the game. I don't understand why anyone would use this over a dynamic gate system, other then that it's ok.
Reply
#11

Awesome work nice release
Reply
#12

Capture.PNG

How to solve this?
Reply
#13

Remove the code[12] param at the end, if the gate was going to be passworded, add "code" like that.
Reply
#14

Well done i like it!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)