Making a gate for a certain username only?
#1

Hello I was wondering is it possible to make an automatic gate that only works for a certain person? I have the cords for an open and closed gate if you can help me I would appreciate it.

Closed gate
Код:
(CreateObject(980,2061.5000000,2437.5000000,11.1000000,0.0000000,0.0000000,0.0000000); //object(airportgate) (1));


Open Gate
Код:
CreateObject(980,2061.5000000,2437.5000000,7.1000000,0.0000000,0.0000000,0.0000000); //object(airportgate) (1)
Reply
#2

Something like this?

pawn Код:
airportg = CreateObject(980,2061.5000000,2437.5000000,11.1000000,0.0000000,0.0000000,0.0000000); //Closed

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if ((newkeys & KEY_YES) && !(oldkeys & KEY_YES)) // OPENING DOORS OR GATES *************************************************
    {
        if(IsPlayerInRangeOfPoint(playerid, 10.0,2061.5000000,2437.5000000,11.1000000)) //lspd garage door
        {
            if(AirportGateOwner[playerid] == 1)
            {
                MoveDynamicObject(airportg, 2061.5000000,2437.5000000,7.1000000, 2.00); //lspd garage door
            }
        }
    }
    if ((newkeys & KEY_NO) && !(oldkeys & KEY_NO)) // CLOSING DOORS OR GATES **************************************************
    {
        if(IsPlayerInRangeOfPoint(playerid, 10.0,2061.5000000,2437.5000000,7.1000000)) //lspd garage door
        {
            if(AirportGateOwner[playerid] == 1)
            {
                MoveDynamicObject(airportg, 2061.5000000,2437.5000000,11.1000000, 2.00); //lspd garage door
            }
        }
    }
    return 1;
}
EDIT: Do you want a command to make some one the owner of the gate aswell?
Reply
#3

Quote:
Originally Posted by Phil_Cutcliffe
Посмотреть сообщение
Something like this?

pawn Код:
airportg = CreateObject(980,2061.5000000,2437.5000000,11.1000000,0.0000000,0.0000000,0.0000000); //Closed

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if ((newkeys & KEY_YES) && !(oldkeys & KEY_YES)) // OPENING DOORS OR GATES *************************************************
    {
        if(IsPlayerInRangeOfPoint(playerid, 10.0,2061.5000000,2437.5000000,11.1000000)) //lspd garage door
        {
            if(AirportGateOwner[playerid] == 1)
            {
                MoveDynamicObject(airportg, 2061.5000000,2437.5000000,7.1000000, 2.00); //lspd garage door
            }
        }
    }
    if ((newkeys & KEY_NO) && !(oldkeys & KEY_NO)) // CLOSING DOORS OR GATES **************************************************
    {
        if(IsPlayerInRangeOfPoint(playerid, 10.0,2061.5000000,2437.5000000,7.1000000)) //lspd garage door
        {
            if(AirportGateOwner[playerid] == 1)
            {
                MoveDynamicObject(airportg, 2061.5000000,2437.5000000,11.1000000, 2.00); //lspd garage door
            }
        }
    }
    return 1;
}
EDIT: Do you want a command to make some one the owner of the gate aswell?
can I make it open for a certain username only for example it only opens for coolmark1995 when he drives up
Reply
#4

pawn Код:
#include <a_samp>
#include <streamer>

new GateArea, GateObject, bool:GateOpen;
//Place these at the top of your script, these are global variables.

public OnGameModeInit() //Or OnFilterScriptInit() if you're using a filterscript
{
    GateOpen = false;
    GateObject = CreateObject(980, 2061.5, 2437.5, 11.1, 0.0, 0.0, 0.0); //Create closed gate.
    GateArea = CreateDynamicCircle(2061.5, 2437.5, 5.0); //Create area.
    AttachDynamicAreaToObject(GateArea, GateObject); //Attach area to gate.
    return 1;
}

public OnPlayerEnterDynamicArea(playerid, areaid)
{
    if(areaid == GateArea)
    {
        if(IsPlayerInRangeOfPoint(playerid, 5.0, 2061.5000000, 2437.5000000, 11.1000000))
        {
            new name[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name, sizeof(name));
            if(strcmp(name, "coolmark1995", false) != 0) return 1;
            //Replace 'coolmark1995' with your own name.
            //NOTE: You must include capital letters. It must be EXACT.
            if(!GateOpen)
            {
                MoveObject(GateObject, 2061.5, 2437.5, 7.1, 2, 0.0, 0.0, 0.0);
                GateOpen = true;
            }
        }
    }
    return 1;
}

public OnPlayerLeaveDynamicArea(playerid, areaid)
{
    if(areaid == GateArea)
    {
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        if(strcmp(name, "coolmark1995", false) != 0) return 1;
        if(GateOpen)
        {
            MoveObject(GateObject, 2061.5, 2437.5, 11.1, 2, 0.0, 0.0, 0.0);
            GateOpen = false;
        }
    }
    return 1;
}
NOTE: You need the 'streamer' plugin and include for this code. Download it by clicking HERE.
Reply
#5

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
pawn Код:
#include <a_samp>
#include <streamer>

new GateArea, GateObject, bool:GateOpen;
//Place these at the top of your script, these are global variables.

public OnGameModeInit() //Or OnFilterScriptInit() if you're using a filterscript
{
    GateOpen = false;
    GateObject = CreateObject(980, 2061.5, 2437.5, 11.1, 0.0, 0.0, 0.0); //Create closed gate.
    GateArea = CreateDynamicCircle(2061.5, 2437.5, 5.0); //Create area.
    AttachDynamicAreaToObject(GateArea, GateObject); //Attach area to gate.
    return 1;
}

public OnPlayerEnterDynamicArea(playerid, areaid)
{
    if(areaid == GateArea)
    {
        if(IsPlayerInRangeOfPoint(playerid, 5.0, 2061.5000000, 2437.5000000, 11.1000000))
        {
            new name[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name, sizeof(name));
            if(strcmp(name, "coolmark1995", false) != 0) return 1;
            //Replace 'coolmark1995' with your own name.
            //NOTE: You must include capital letters. It must be EXACT.
            if(!GateOpen)
            {
                MoveObject(GateObject, 2061.5, 2437.5, 7.1, 2, 0.0, 0.0, 0.0);
                GateOpen = true;
            }
        }
    }
    return 1;
}

public OnPlayerLeaveDynamicArea(playerid, areaid)
{
    if(areaid == GateArea)
    {
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        if(strcmp(name, "coolmark1995", false) != 0) return 1;
        if(GateOpen)
        {
            MoveObject(GateObject, 2061.5, 2437.5, 11.1, 2, 0.0, 0.0, 0.0);
            GateOpen = false;
        }
    }
    return 1;
}
NOTE: You need the 'streamer' plugin and include for this code. Download it by clicking HERE.
the gate dosent open I am not sure why
Reply
#6

Is your name 'coolmark1995' ?? (No capitals, it must match that name)

Read this part of the code:

if(strcmp(name, "coolmark1995", false) != 0) return 1;
//Replace 'coolmark1995' with your own name.
//NOTE: You must include capital letters. It must be EXACT.
Reply
#7

Actually, now that I think about it, dynamic areas might not work with regular objects. Change CreateObject to CreateDynamicObject.

EDIT:
pawn Код:
new GateArea, GateObject, bool:GateOpen;
//Place these at the top of your script, these are global variables.

public OnGameModeInit() //Or OnFilterScriptInit() if you're using a filterscript
{
    GateOpen = false;
    GateObject = CreateDynamicObject(980, 2061.5, 2437.5, 11.1, 0.0, 0.0, 0.0); //Create closed gate.
    GateArea = CreateDynamicCircle(2061.5, 2437.5, 5.0); //Create area.
    AttachDynamicAreaToObject(GateArea, GateObject); //Attach area to gate.
    return 1;
}

public OnPlayerEnterDynamicArea(playerid, areaid)
{
    if(areaid == GateArea)
    {
        if(IsPlayerInRangeOfPoint(playerid, 5.0, 2061.5000000, 2437.5000000, 11.1000000))
        {
            new name[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name, sizeof(name));
            if(strcmp(name, "coolmark1995", false) != 0) return 1;
            //Replace 'coolmark1995' with your own name.
            //NOTE: You must include capital letters. It must be EXACT.
            if(!GateOpen)
            {
                MoveObject(GateObject, 2061.5, 2437.5, 7.1, 2, 0.0, 0.0, 0.0);
                GateOpen = true;
            }
        }
    }
    return 1;
}

public OnPlayerLeaveDynamicArea(playerid, areaid)
{
    if(areaid == GateArea)
    {
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        if(strcmp(name, "coolmark1995", false) != 0) return 1;
        if(GateOpen)
        {
            MoveObject(GateObject, 2061.5, 2437.5, 11.1, 2, 0.0, 0.0, 0.0);
            GateOpen = false;
        }
    }
    return 1;
}
Reply
#8

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
Actually, now that I think about it, dynamic areas might not work with regular objects. Change CreateObject to CreateDynamicObject.

EDIT:
pawn Код:
new GateArea, GateObject, bool:GateOpen;
//Place these at the top of your script, these are global variables.

public OnGameModeInit() //Or OnFilterScriptInit() if you're using a filterscript
{
    GateOpen = false;
    GateObject = CreateDynamicObject(980, 2061.5, 2437.5, 11.1, 0.0, 0.0, 0.0); //Create closed gate.
    GateArea = CreateDynamicCircle(2061.5, 2437.5, 5.0); //Create area.
    AttachDynamicAreaToObject(GateArea, GateObject); //Attach area to gate.
    return 1;
}

public OnPlayerEnterDynamicArea(playerid, areaid)
{
    if(areaid == GateArea)
    {
        if(IsPlayerInRangeOfPoint(playerid, 5.0, 2061.5000000, 2437.5000000, 11.1000000))
        {
            new name[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name, sizeof(name));
            if(strcmp(name, "coolmark1995", false) != 0) return 1;
            //Replace 'coolmark1995' with your own name.
            //NOTE: You must include capital letters. It must be EXACT.
            if(!GateOpen)
            {
                MoveObject(GateObject, 2061.5, 2437.5, 7.1, 2, 0.0, 0.0, 0.0);
                GateOpen = true;
            }
        }
    }
    return 1;
}

public OnPlayerLeaveDynamicArea(playerid, areaid)
{
    if(areaid == GateArea)
    {
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        if(strcmp(name, "coolmark1995", false) != 0) return 1;
        if(GateOpen)
        {
            MoveObject(GateObject, 2061.5, 2437.5, 11.1, 2, 0.0, 0.0, 0.0);
            GateOpen = false;
        }
    }
    return 1;
}
now its moving the wrong object its not moving 980 its moving
Код:
CreateObject(7749,2000.6000000,2419.9000000,12.8000000,0.0000000,0.0000000,270.0000000); //object(vgsnotxrefhse02) (1)
Reply
#9

Did you add this?

Quote:

GateObject = CreateObject(980,2061.5000000,2437.5000000,11.1000 000,0.0000000,0.0000000,0.0000000);

Reply
#10

Quote:
Originally Posted by FaZeRs
Посмотреть сообщение
Did you add this?
when I was given the code above it didnt require it ive used both createobject and createdynamic object dosent work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)