Automatic Gate / Door problem!
#1

Hey! I used one of the newest tutorials for automatic gate.. I used it for door as well..
Everything worked fine.. till I tried to make that only you're using car for gate or only on foot for door the gate/door will open..
and only if you're a cop it will open..
but! after I did that! the gate or the door doesnt move at all!
anyway.. here's the publics:

pawn Код:
public PDdoorcheck()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(GetPlayerState(i) == PLAYER_STATE_ONFOOT)
        {
            if(IsPlayerInRangeOfPoint(i, 2.0, 1584.3352, -1637.8557, 12.3400))
            {
                if (PlayerInfo[i][pMember] == 1 || PlayerInfo[i][pLeader] == 1)
                {
                    if(pddooropen == false)
                    {
                        MoveObject(pddoor, 1582.6152, -1637.8557, 12.3400, 2.0);
                        pddooropen = true;
                    }
                    if(pddooropen == true)
                    {
                        MoveObject(pddoor, 1584.3352, -1637.8557, 12.3400, 2.0);
                        pddooropen = false;
                    }
                }
                else
                {
                    SendClientMessage(i,COLOR_GREY,"You are not a Cop!, You better leave or be arrested!.");
                }
            }
        }
    }
    return 1;
}

public GateCheck()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInAnyVehicle(i))
        {
            if(IsPlayerInRangeOfPoint(i, 5.0, 1588.5841, -1638.3521, 13.7000))
            {
                if (PlayerInfo[i][pMember] == 1 || PlayerInfo[i][pLeader] == 1)
                {
                    if(gateopen == false)
                    {
                        MoveObject(gate, 1597.4628, -1638.3291, 13.7000, 3.5);
                        gateopen = true;
                    }
                    if(gateopen == true)
                    {
                        MoveObject(gate, 1588.5841, -1638.3521, 13.7000, 3.5);
                        gateopen = false;
                    }
                }
                else
                {
                    SendClientMessage(i,COLOR_GREY,"You are not a Cop!, You better leave or be arrested!.");
                }
            }
        }
    }
    return 1;
}

If someone can help me! THANKS!
Reply
#2

FIX

pawn Код:
public PDdoorcheck()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(GetPlayerState(i) == PLAYER_STATE_ONFOOT)
        {
            if(IsPlayerInRangeOfPoint(i, 2.0, 1584.3352, -1637.8557, 12.3400))
            {
                if (PlayerInfo[i][pMember] == 1 || PlayerInfo[i][pLeader] == 1)
                {
                    if(pddooropen == false)
                    {
                        MoveObject(pddoor, 1582.6152, -1637.8557, 12.3400, 2.0);
                        pddooropen = true;
                        return 1;
                    }
                    if(pddooropen == true)
                    {
                        MoveObject(pddoor, 1584.3352, -1637.8557, 12.3400, 2.0);
                        pddooropen = false;
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(i,COLOR_GREY,"You are not a Cop!, You better leave or be arrested!.");
                }
            }
        }
    }
    return 1;
}

public GateCheck()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInAnyVehicle(i))
        {
            if(IsPlayerInRangeOfPoint(i, 5.0, 1588.5841, -1638.3521, 13.7000))
            {
                if (PlayerInfo[i][pMember] == 1 || PlayerInfo[i][pLeader] == 1)
                {
                    if(gateopen == false)
                    {
                        MoveObject(gate, 1597.4628, -1638.3291, 13.7000, 3.5);
                        gateopen = true;
                        return 1;
                    }
                    if(gateopen == true)
                    {
                        MoveObject(gate, 1588.5841, -1638.3521, 13.7000, 3.5);
                        gateopen = false;
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(i,COLOR_GREY,"You are not a Cop!, You better leave or be arrested!.");
                }
            }
        }
    }
    return 1;
}
You see , the problem is that you check if gateopen == false then it will become true ... but right after it comes to true you check if gateopen == true then it turns it back to false and the door will never open ...
Just add return 1; there as I did
Reply
#3

I Suggest to use it under OnPlayerUpdate
Reply
#4

Elka_Blazer THANKS a lot! I couldnt understand that I need a return!
but.. the one you posted isnt worked well.. it open and closed non stop when I were next to the gate/door and when I left it was stay open..
anyway.. if anyone will need in the future.. here what I did and it fixed it..

pawn Код:
public PDdoorcheck()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(GetPlayerState(i) == PLAYER_STATE_ONFOOT)
        {
            if (PlayerInfo[i][pMember] == 1 || PlayerInfo[i][pLeader] == 1)
            {
                if(IsPlayerInRangeOfPoint(i, 2.0, 1584.3352, -1637.8557, 12.3400))
                {
                    if(pddooropen == false)
                    {
                        MoveObject(pddoor, 1582.6152, -1637.8557, 12.3400, 2.0);
                        pddooropen = true;
                    }
                    return 1;
                }
                if(pddooropen == true)
                {
                    MoveObject(pddoor, 1584.3352, -1637.8557, 12.3400, 2.0);
                    pddooropen = false;
                }
                return 1;
            }
            else
            {
                SendClientMessage(i,COLOR_GREY,"You are not a Cop!, You better leave or be arrested!.");
            }
        }
    }
    return 1;
}

public GateCheck()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInAnyVehicle(i))
        {
            if (PlayerInfo[i][pMember] == 1 || PlayerInfo[i][pLeader] == 1)
            {
                if(IsPlayerInRangeOfPoint(i, 5.0, 1588.5841, -1638.3521, 13.7000))
                {
                    if(gateopen == false)
                    {
                        MoveObject(gate, 1597.4628, -1638.3291, 13.7000, 3.5);
                        gateopen = true;
                    }
                    return 1;
                }
                if(gateopen == true)
                {
                    MoveObject(gate, 1588.5841, -1638.3521, 13.7000, 3.5);
                    gateopen = false;
                }
                return 1;
            }
            else
            {
                SendClientMessage(i,COLOR_GREY,"You are not a Cop!, You better leave or be arrested!.");
            }
        }
    }
    return 1;
}
And thanks a lot!
Reply
#5

Yea I didnt notice it .... but anyways you fixed it by yourself and thats better for you . GOOD LUCK
Reply
#6

Thanks a lot.. right now its working.. but wanted to ask another thing without open a new topic..

If I want that the part of
pawn Код:
SendClientMessage(i,COLOR_GREY,"You are not a Cop!, You better leave or be arrested!.");
The player will get it only 1 time.. and not if he stand there like 10 secs so he'll get every 1 sec this msg..

Hope I was understandable.. Thanks
Reply
#7

Bump..
Still stuck on the last problem...

dont want it to spamm that part of you're not a cop.. bla bla bla
Reply
#8

pawn Код:
else
{
    SendClientMessage(i,COLOR_GREY,"You are not a Cop!, You better leave or be arrested!.");
    break;
}
Reply
#9

Thanks.. but for some reason didnt help.. still spamming the clientmsg..
Reply
#10

LOL Of curse its not gonna work .... u use this function on a timer / onplayerupdate
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)