SA-MP Forums Archive
auto gates help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: auto gates help (/showthread.php?tid=286100)



auto gates help - scottygraham1990 - 26.09.2011

can any one help me as im making auto gates but the gates don't move can any one tell me what i have done wrong

here are the gates

GATE-1
Open:

985, 2296.25, 622.98, 10.62, 0.00, 0.00, 0.00
986, 2278.56, 623.00, 10.62, 0.00, 0.00, 0.00

Closed:
985, 2290.88, 623.08, 10.62, 0.00, 0.00, 0.00
986, 2282.93, 623.07, 10.62, 0.00, 0.00, 0.00

GATE-2
Open:

985,2242.30,439.95,5.51, 0.00, 0.00, 179.86
986,2259.99,439.94,5.51, 0.00, 0.00, 179.86

Closed:

985,2247.22,439.92,5.51, 0.00, 0.00, 179.86
986,2255.15,439.88,5.51, 0.00, 0.00, 179.86


MiscObject[0] = CreateObject(976,-1643.446,694.249,6.662,0.0,0.0,270.000); // SFPD West
MiscObject[1] = CreateObject(3092,-1572.638,657.451,7.727,190.795,0.0,-180.000); // Corpse
MiscObject[2] = CreateObject(976,1539.658,-1622.827,12.545,0.0,0.0,90.000); // LSPD1NorthSpare
MiscObject[3] = CreateObject(976,1539.658,-1640.456,12.545,0.0,0.0,90.000); // LSPD1SouthSpare
MiscObject[4] = CreateObject(985, 2296.25, 622.98, 10.62, 0.00, 0.00, 0.00);//Gate-1
MiscObject[5] = CreateObject(986, 2278.56, 623.00, 10.62, 0.00, 0.00, 0.00);//Gate-1

// ######################## ADD TO THESE ##########################
// MakeGate(ObjectID, StartX, StarY, StartZ, FinishX, FinishY, FinishZ, CenterX, CenterY, CenterZ, Rotation, GateNumber);
MakeGate(976, -1571.597,665.725,6.349, -1571.597,656.572,6.349, -1571.5579,661.2339,7.1875, -90.0, 0); // SFPD East
MakeGate(976, -1643.446,676.774,6.662, -1643.446,685.551,6.662, -1643.4032,682.6055,7.4930, 90.0, 1); // SFPD West
MakeGate(976, 2236.992,2448.932,9.848, 2236.992,2457.979,9.848, 2236.992,2453.1646,10.7047, 90.0, 2); // Las Venturas
MakeGate(976, 1539.658,-1631.631,12.545, 1539.658,-1624.255,12.545, 1539.658,-1628.0244,13.3828, 90.0, 3); //Los Santos
MakeGate(985, 2296.25, 622.98, 10.62, 2290.88, 623.08, 10.62, 0,0,0, 0, 4);//Gate-1
MakeGate(986, 2278.56, 623.00, 10.62, 2282.93, 623.07, 10.62, 0,0,0, 0, 5);//Gate-1
// ################################################## ##############


Re: auto gates help - Kostas' - 26.09.2011

First of all make these on your top of your gamemode.
pawn Code:
new Gate1,Gate2;

new GateData;
Then on OnGamemodeInit put these
pawn Code:
public OnGamemodeInit()
{

    GateData = 0;
   
    Gate1 = CreateObject(985,3064.23437500,-577.76251221,6.40274763,0.00000000,0.00000000,94.03747559); //gate 1
    Gate2 = CreateObject(986,3064.80151367,-585.69366455,6.42100000,0.00000000,0.00000000,94.13995361); //gate 2
    return 1;
}
At the end, make a command, like
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
 if (strcmp("/gate", cmdtext, true, 10) == 0)
        {      
        if(GateData == 0)
        {
        SendClientMessage(playerid,messagecolor,"Island Gates Now Open!");
        MoveObject(Gate1, 3063.86181641,-571.97137451,6.40274763, 2.00);
        MoveObject(Gate2, 3065.2329101563,-591.55322265625,6.42100000, 2.00);
        GateData = 1;
        }
        else
        {
        SendClientMessage(playerid,messagecolor,"Island Gates Now Closed!");
        MoveObject(Gate1, 3064.23437500,-577.76251221,6.40274763, 2.00);
        MoveObject(Gate2, 3064.80151367,-585.69366455,6.42100000, 2.00);
        GateData = 0;
        }
    return 1;
}



Re: auto gates help - scottygraham1990 - 26.09.2011

Quote:
Originally Posted by Kostas'
View Post
First of all make these on your top of your gamemode.
[/pawn]
its a auto gate fs
pawn Code:
#include <a_samp>
#define FILTERSCRIPT
#if defined FILTERSCRIPT

forward GateTimer();
new Timer; //allows killtimer

// ######################## EDIT THESE ##########################
#define TOLERANCE 20
#define OPENSPEED 2
#define CLOSESPEED 2
#define TIMERSPEED 1500 //(MILLISeconds, eg 1000 = 1, 2000 = 2, 1500 = 1.5)
const GateNum = 8; //number of gates present (defines other arrays)
// ##############################################################
const MiscObjNum = 10;
const GateNum = 8;
new Float:GateInfo[GateNum][9]; //stores all gate c-ords (Start, Fnish, Center)
new GateState[GateNum]; //Whether the gate is open closed (not currently in use)
new OpenGate[GateNum]; //Whether or not to open the gate when the loop finishes
new GateObject[GateNum]; //stores gate object ID's
new MiscObject[MiscObjNum];//stores misc object ID's
new Float:Tempx, Float:Tempy, Float:Tempz; //Holds player position during loops
new Float:xtol1, Float:xtol2, Float:ytol1, Float:ytol2; //Holds area bounds during loops

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print("      AutoGates by Thomas_Conroy");
    print("--------------------------------------\n");

    SendClientMessageToAll(0xFF00FFAA, "AutoGates Activated!");

    Timer = SetTimer("GateTimer", TIMERSPEED, true);

    MiscObject[0] = CreateObject(976,-1643.446,694.249,6.662,0.0,0.0,270.000); // SFPD West
    MiscObject[1] = CreateObject(3092,-1572.638,657.451,7.727,190.795,0.0,-180.000); // Corpse
    MiscObject[2] = CreateObject(976,1539.658,-1622.827,12.545,0.0,0.0,90.000); // LSPD1NorthSpare
    MiscObject[3] = CreateObject(976,1539.658,-1640.456,12.545,0.0,0.0,90.000); // LSPD1SouthSpare
    MiscObject[4] = CreateObject(985, 2296.25, 622.98, 10.62, 0.00, 0.00, 0.00);//Gate-1
    MiscObject[5] = CreateObject(986, 2278.56, 623.00, 10.62, 0.00, 0.00, 0.00);//Gate-1

// ######################## ADD TO THESE ##########################
//  MakeGate(ObjectID, StartX, StarY, StartZ,  FinishX, FinishY, FinishZ,  CenterX, CenterY, CenterZ, Rotation, GateNumber);
    MakeGate(976, -1571.597,665.725,6.349, -1571.597,656.572,6.349, -1571.5579,661.2339,7.1875, -90.0, 0); // SFPD East
    MakeGate(976, -1643.446,676.774,6.662, -1643.446,685.551,6.662, -1643.4032,682.6055,7.4930, 90.0, 1); // SFPD West
    MakeGate(976, 2236.992,2448.932,9.848, 2236.992,2457.979,9.848, 2236.992,2453.1646,10.7047, 90.0, 2); // Las Venturas
    MakeGate(976, 1539.658,-1631.631,12.545, 1539.658,-1624.255,12.545, 1539.658,-1628.0244,13.3828, 90.0, 3); //Los Santos
    MakeGate(985, 2296.25, 622.98, 10.62, 2290.88, 623.08, 10.62, 0,0,0, 0, 4);//Gate-1
    MakeGate(986, 2278.56, 623.00, 10.62, 2282.93, 623.07, 10.62, 0,0,0, 0, 5);//Gate-1
// ################################################################
    return 1;
}

public OnFilterScriptExit()
{
    for(new tempgate=0; tempgate<GateNum; tempgate++)
        {
        DestroyObject(GateObject[tempgate]);
        }
    for(new tempgate=0; tempgate<MiscObjNum; tempgate++)
        {
        DestroyObject(MiscObject[tempgate]);
        }
    KillTimer(Timer);
    SendClientMessageToAll(0xFF00FFAA, "AutoGates Deactivated!");
    return 1;
}

#else
#endif

public GateTimer()
{
    for(new tempgate=0; tempgate<GateNum; tempgate++)
        {
        for(new pid=0; pid<MAX_PLAYERS; pid++)
            {
            if(OpenGate[tempgate] == 0/* && IsPlayerAdmin(pid) == 1*/) OpenGate[tempgate] = IsPlayerNearGate(pid, tempgate, TOLERANCE);
            }
        if(OpenGate[tempgate] == 1) MoveObject(GateObject[tempgate], GateInfo[tempgate][3], GateInfo[tempgate][4], GateInfo[tempgate][5], OPENSPEED), GateState[tempgate] = 1;
        else MoveObject(GateObject[tempgate], GateInfo[tempgate][0], GateInfo[tempgate][1], GateInfo[tempgate][2], CLOSESPEED), GateState[tempgate] = 0;
        OpenGate[tempgate] = 0;
        }
}

MakeGate(z, Float:a, Float:b, Float:c, Float:d, Float:e, Float:f, Float:g, Float:h, Float:i, Float:j, k)
{
    GateInfo[k][0] = a, GateInfo[k][1] = b, GateInfo[k][2] = c; //Start
    GateInfo[k][3] = d, GateInfo[k][4] = e, GateInfo[k][5] = f; //Finish
    GateInfo[k][6] = g, GateInfo[k][7] = h, GateInfo[k][8] = i; //Center
    GateState[k] = 0; //Gate Closed
    GateObject[k] = CreateObject(z ,a, b, c, 0.0,0.0,j);
}

stock IsPlayerNearGate(pid, tempgate, tolerance)
{
    GetPlayerPos(pid, Tempx, Tempy, Tempz);
    xtol1 = GateInfo[tempgate][6] + tolerance;
    xtol2 = GateInfo[tempgate][6] - tolerance;
    ytol1 = GateInfo[tempgate][7] + tolerance;
    ytol2 = GateInfo[tempgate][7] - tolerance;
    if(Tempx >= xtol2 && Tempx <= xtol1 && Tempy >= ytol2 && Tempy <= ytol1) return 1;
    return 0;
}



Re : auto gates help - Naruto_Emilio - 26.09.2011

Delet the second
const GateNum = 8;


Re: Re : auto gates help - scottygraham1990 - 26.09.2011

Quote:
Originally Posted by Naruto_Emilio
View Post
Delet the second
const GateNum = 8;
i have dun that ut the gates still dnt move


Re : auto gates help - Naruto_Emilio - 26.09.2011

Then this FS about making auto gates is fucked, i suggest you to make your own one, there are some plenty of them i suggest you to use Varth Tutorial. gtg now good night.


Re: auto gates help - scottygraham1990 - 27.09.2011

Quote:
Originally Posted by Kostas'
View Post
First of all make these on your top of your gamemode.
pawn Code:
new Gate1,Gate2;

new GateData;
Then on OnGamemodeInit put these
pawn Code:
public OnGamemodeInit()
{

    GateData = 0;
   
    Gate1 = CreateObject(985,3064.23437500,-577.76251221,6.40274763,0.00000000,0.00000000,94.03747559); //gate 1
    Gate2 = CreateObject(986,3064.80151367,-585.69366455,6.42100000,0.00000000,0.00000000,94.13995361); //gate 2
    return 1;
}
At the end, make a command, like
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
 if (strcmp("/gate", cmdtext, true, 10) == 0)
        {      
        if(GateData == 0)
        {
        SendClientMessage(playerid,messagecolor,"Island Gates Now Open!");
        MoveObject(Gate1, 3063.86181641,-571.97137451,6.40274763, 2.00);
        MoveObject(Gate2, 3065.2329101563,-591.55322265625,6.42100000, 2.00);
        GateData = 1;
        }
        else
        {
        SendClientMessage(playerid,messagecolor,"Island Gates Now Closed!");
        MoveObject(Gate1, 3064.23437500,-577.76251221,6.40274763, 2.00);
        MoveObject(Gate2, 3064.80151367,-585.69366455,6.42100000, 2.00);
        GateData = 0;
        }
    return 1;
}
hi i use this gate cmd you posted and i get errors
C:\Users\Joe\Desktop\Admin-Vip V.3\Admin-VIP.pwn(88 : error 017: undefined symbol "messagecolor"
C:\Users\Joe\Desktop\Admin-Vip V.3\Admin-VIP.pwn(895) : error 017: undefined symbol "messagecolor"


Re: auto gates help - boyan96 - 27.09.2011

replace messagecolor with 0xFFFFFFAA


Re: auto gates help - Max_Coldheart - 27.09.2011

Quote:
Originally Posted by scottygraham1990
View Post
its a auto gate fs

#include <a_samp>
#define FILTERSCRIPT
#if defined FILTERSCRIPT

forward GateTimer();
new Timer; //allows killtimer

// ######################## EDIT THESE ##########################
#define TOLERANCE 20
#define OPENSPEED 2
#define CLOSESPEED 2
#define TIMERSPEED 1500 //(MILLISeconds, eg 1000 = 1, 2000 = 2, 1500 = 1.5)
const GateNum = 8; //number of gates present (defines other arrays)
// ################################################## ############
const MiscObjNum = 10;
const GateNum = 8;
new Float:GateInfo[GateNum][9]; //stores all gate c-ords (Start, Fnish, Center)
new GateState[GateNum]; //Whether the gate is open closed (not currently in use)
new OpenGate[GateNum]; //Whether or not to open the gate when the loop finishes
new GateObject[GateNum]; //stores gate object ID's
new MiscObject[MiscObjNum];//stores misc object ID's
new Float:Tempx, Float:Tempy, Float:Tempz; //Holds player position during loops
new Floattol1, Floattol2, Float:ytol1, Float:ytol2; //Holds area bounds during loops

public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" AutoGates by Thomas_Conroy");
print("--------------------------------------\n");

SendClientMessageToAll(0xFF00FFAA, "AutoGates Activated!");

Timer = SetTimer("GateTimer", TIMERSPEED, true);

MiscObject[0] = CreateObject(976,-1643.446,694.249,6.662,0.0,0.0,270.000); // SFPD West
MiscObject[1] = CreateObject(3092,-1572.638,657.451,7.727,190.795,0.0,-180.000); // Corpse
MiscObject[2] = CreateObject(976,1539.658,-1622.827,12.545,0.0,0.0,90.000); // LSPD1NorthSpare
MiscObject[3] = CreateObject(976,1539.658,-1640.456,12.545,0.0,0.0,90.000); // LSPD1SouthSpare
MiscObject[4] = CreateObject(985, 2296.25, 622.98, 10.62, 0.00, 0.00, 0.00);//Gate-1
MiscObject[5] = CreateObject(986, 2278.56, 623.00, 10.62, 0.00, 0.00, 0.00);//Gate-1

// ######################## ADD TO THESE ##########################
// MakeGate(ObjectID, StartX, StarY, StartZ, FinishX, FinishY, FinishZ, CenterX, CenterY, CenterZ, Rotation, GateNumber);
MakeGate(976, -1571.597,665.725,6.349, -1571.597,656.572,6.349, -1571.5579,661.2339,7.1875, -90.0, 0); // SFPD East
MakeGate(976, -1643.446,676.774,6.662, -1643.446,685.551,6.662, -1643.4032,682.6055,7.4930, 90.0, 1); // SFPD West
MakeGate(976, 2236.992,2448.932,9.848, 2236.992,2457.979,9.848, 2236.992,2453.1646,10.7047, 90.0, 2); // Las Venturas
MakeGate(976, 1539.658,-1631.631,12.545, 1539.658,-1624.255,12.545, 1539.658,-1628.0244,13.3828, 90.0, 3); //Los Santos
MakeGate(985, 2296.25, 622.98, 10.62, 2290.88, 623.08, 10.62, 0,0,0, 0, 4);//Gate-1
MakeGate(986, 2278.56, 623.00, 10.62, 2282.93, 623.07, 10.62, 0,0,0, 0, 5);//Gate-1
// ################################################## ##############
return 1;
}

public OnFilterScriptExit()
{
for(new tempgate=0; tempgate<GateNum; tempgate++)
{
DestroyObject(GateObject[tempgate]);
}
for(new tempgate=0; tempgate<MiscObjNum; tempgate++)
{
DestroyObject(MiscObject[tempgate]);
}
KillTimer(Timer);
SendClientMessageToAll(0xFF00FFAA, "AutoGates Deactivated!");
return 1;
}

#else
#endif

public GateTimer()
{
for(new tempgate=0; tempgate<GateNum; tempgate++)
{
for(new pid=0; pid<MAX_PLAYERS; pid++)
{
if(OpenGate[tempgate] == 0/* && IsPlayerAdmin(pid) == 1*/) OpenGate[tempgate] = IsPlayerNearGate(pid, tempgate, TOLERANCE);
}
if(OpenGate[tempgate] == 1) MoveObject(GateObject[tempgate], GateInfo[tempgate][3], GateInfo[tempgate][4], GateInfo[tempgate][5], OPENSPEED), GateState[tempgate] = 1;
else MoveObject(GateObject[tempgate], GateInfo[tempgate][0], GateInfo[tempgate][1], GateInfo[tempgate][2], CLOSESPEED), GateState[tempgate] = 0;
OpenGate[tempgate] = 0;
}
}

MakeGate(z, Float:a, Float:b, Float:c, Float:d, Float:e, Float:f, Float:g, Float:h, Float:i, Float:j, k)
{
GateInfo[k][0] = a, GateInfo[k][1] = b, GateInfo[k][2] = c; //Start
GateInfo[k][3] = d, GateInfo[k][4] = e, GateInfo[k][5] = f; //Finish
GateInfo[k][6] = g, GateInfo[k][7] = h, GateInfo[k][8] = i; //Center
GateState[k] = 0; //Gate Closed
GateObject[k] = CreateObject(z ,a, b, c, 0.0,0.0,j);
}

stock IsPlayerNearGate(pid, tempgate, tolerance)
{
GetPlayerPos(pid, Tempx, Tempy, Tempz);
xtol1 = GateInfo[tempgate][6] + tolerance;
xtol2 = GateInfo[tempgate][6] - tolerance;
ytol1 = GateInfo[tempgate][7] + tolerance;
ytol2 = GateInfo[tempgate][7] - tolerance;
if(Tempx >= xtol2 && Tempx <= xtol1 && Tempy >= ytol2 && Tempy <= ytol1) return 1;
return 0;
}
Please use [ pawn ] and [ /pawn ]