Help with a moving gate
#8

pawn Код:
#include <a_samp>

//****** Add these just under your includes. (#include) ******
new gate1, gate2;
new bool:Gate1Open;
new bool:Gate2Open;
//************************************************************

public OnFilterScriptInit() //Or OnGameModeInit() if you're using a gamemode.
{
    gate1 = CreateObject(980, 2097.51, 1720.01, 12.64, 0.00, 0.00, 63.00);
    gate2 = CreateObject(980, 2088.80, 1645.47, 12.43, 0.00, 0.00, 90.00);
    Gate1Open = false;
    Gate2Open = false;
    SetTimer("Gate1Check", 1000, true);
    SetTimer("Gate2Check", 1000, true);
    return 1;
}

//Add these public functions at the bottom of your script.
forward Gate1Check();
public Gate1Check()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInRangeOfPoint(i, 5, 2097.51, 1720.01, 12.64))
            {
                new GateName[MAX_PLAYER_NAME];
                GetPlayerName(i, GateName, MAX_PLAYER_NAME);
                if(strcmp(GateName, "Zach7", false) == 0)
                {
                    if(Gate1Open == false)
                    {
                        MoveObject(gate1, 2097.51, 1720.01, 6, 4, 0, 0, 63);
                        Gate1Open = true;
                    }
                }
            }
            else
            {
                if(Gate1Open == true)
                {
                MoveObject(gate1, 2097.51, 1720.01, 12.64, 4, 0, 0, 63);
                Gate1Open = false;
                }
            }
        }
    }
    return 1;
}

forward Gate2Check();
public Gate2Check()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInRangeOfPoint(i, 5, 2088.80, 1645.47, 12.43))
            {
                new GateName[MAX_PLAYER_NAME];
                GetPlayerName(i, GateName, MAX_PLAYER_NAME);
                if(strcmp(GateName, "Zach7", false) == 0)
                {
                    if(Gate2Open == false)
                    {
                        MoveObject(gate2, 2088.80, 1645.47, 6, 4, 0, 0, 90);
                        Gate2Open = true;
                    }
                }
            }
            else
            {
                if(Gate2Open == true)
                {
                    MoveObject(gate2, 2088.80, 1645.47, 12.43, 4, 0, 0, 90);
                    Gate2Open = false;
                }
            }
        }
    }
    return 1;
}
Enjoy.
Reply


Messages In This Thread
Help with a moving gate - by Zach7 - 12.07.2012, 00:56
Re: Help with a moving gate - by CmZxC - 12.07.2012, 00:58
Re: Help with a moving gate - by Zach7 - 12.07.2012, 01:04
Re: Help with a moving gate - by CmZxC - 12.07.2012, 01:20
Re: Help with a moving gate - by Zach7 - 12.07.2012, 01:33
Re: Help with a moving gate - by CmZxC - 12.07.2012, 01:34
Re: Help with a moving gate - by Zach7 - 12.07.2012, 01:36
Re: Help with a moving gate - by clarencecuzz - 12.07.2012, 12:13

Forum Jump:


Users browsing this thread: 6 Guest(s)