Small problem
#1

I created this automatic gate, but it only closes, it dont open, when the GM is loaded, it sets the gate to the open position and when i go near the gate, it closes, but when i walk back, it dont open.

pawn Код:
public Gate()
{
    for(new i;i<MAX_PLAYERS;i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(IsPlayerInRangeOfPoint(i,5.0,-505.5048828125, 2593.0556640625, 55.983978271484))State = 1;
    }
    if(State)MoveObject(hgate, -505.5048828125, 2593.0556640625, 55.983978271484,3.0);
    else MoveObject(hgate, -505.65878295898, 2601.5754394531, 55.89282989502,5.0);
}
Reply
#2

Please help.
Reply
#3

pawn Код:
public Gate()
{
    for(new i;i<MAX_PLAYERS;i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(IsPlayerInRangeOfPoint(i,5.0,-505.5048828125, 2593.0556640625, 55.983978271484))State = 1;
        else State = 0;
    }
    if(State)MoveObject(hgate, -505.5048828125, 2593.0556640625, 55.983978271484,3.0);
    else MoveObject(hgate, -505.65878295898, 2601.5754394531, 55.89282989502,5.0);
}
Reply
#4

Thanks it worked.
Reply
#5

It worked but it only work with a player who is not id 0 who to fix that?
Reply
#6

MovePlayerObject(playerid...);
https://sampwiki.blast.hk/wiki/MovePlayerObject
For all ID's
pawn Код:
public Gate()
{
    for(new i;i<MAX_PLAYERS;i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(IsPlayerInRangeOfPoint(i,5.0,-505.5048828125, 2593.0556640625, 55.983978271484))State = 1;
        else State = 0;
    }
    if(State)MovePlayerObject(playerid, hgate, -505.5048828125, 2593.0556640625, 55.983978271484,3.0);
    else MovePlayerObject(playerid, hgate, -505.65878295898, 2601.5754394531, 55.89282989502,5.0);
}
let me know if it worked
Reply
#7

pawn Код:
public Gate()
{
    State = 0;
    for(new i;i<MAX_PLAYERS;i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(IsPlayerInRangeOfPoint(i,5.0,-505.5048828125, 2593.0556640625, 55.983978271484))State = 1;
    }
    if(State)MoveObject(hgate, -505.5048828125, 2593.0556640625, 55.983978271484,3.0);
    else MoveObject(hgate, -505.65878295898, 2601.5754394531, 55.89282989502,5.0);
}
Reply
#8

@ Mean, yours did not work.
@ MadeMan, Thanks it worked.

In SAMP, is 5.0 distance like 1 meter? because when i use 5.0 as the distance, i was close to the gate for it to open.
Reply
#9

You can increase the 5.0 to 10.0 or 15.0 in IsPlayerInRangeOfPoint.
Reply
#10

Thanks. <3
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)