AUTOGATES
#1

i have a auto gate system on my server when a player goes so close it opens , its in thomas conroys autogates , what i want to no is how i make it so that it has to be opened by command ?
Reply
#2

Uhm, you need to do two diffrent commands, one for /open and for /close or /gates and a timer.
Reply
#3

yes i no that bit but its in a filterscript called thomas conroy gates , it doesnt have commands at moment just autogates

this is what i have at moment

pawn Код:
#include <a_samp>
#define FILTERSCRIPT
#if defined FILTERSCRIPT

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

// ######################## EDIT THESE ##########################
#define TOLERANCE 20
#define OPENSPEED 4
#define CLOSESPEED 3
#define TIMERSPEED 1500 //(MILLISeconds, eg 1000 = 1, 2000 = 2, 1500 = 1.5)
const GateNum = 4; //number of gates present (defines other arrays)
// ##############################################################

const MiscObjNum = 5;
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("      Gates ByThomas_Conroy");
    print("--------------------------------------\n");
   
    SendClientMessageToAll(0xFF00FFAA, "AutoGates Activated! (by: Thomas_Conroy)");

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

// ######################## ADD TO THESE ##########################
//  MakeGate(ObjectID, StartX, StarY, StartZ,  FinishX, FinishY, FinishZ,  CenterX, CenterY, CenterZ, Rotation, GateNumber);

    MakeGate(980, 2783.2734375, 2663.802734375, 12.599925994873, 2783.2734375, 2663.802734375, 7.0249314308167,2782.1326,2662.6736,10.8359,0);//lht base
   
// ################################################################
    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! (by: Thomas_Conroy)");
    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;
}
Reply
#4

Edit the part of the script where it says something like this: "MoveObject"

Copy that line++ and paste it onto your command.

EDIT: since you have posted the code, i could say which line :P

Copy all the lines inside the public function called GateTimer and paste it in a command like /gate
Reply
#5

so like this

pawn Код:
if(!strcmp(cmdtext, "/LHT", true))
    {
        SendClientMessage(playerid, 0x66FF33FF, "Company gate opened");
        return 1;
    }
where would i put the open gate ? part
Reply
#6

pawn Код:
if(!strcmp(cmdtext, "/LHT", true))
    {
        //here
        SendClientMessage(playerid, 0x66FF33FF, "Company gate opened");
        return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)