Isplayerinrangeofpoint
#1

Hi,is it possible that isplayerinrangeofpoint then the gate automaticly open and it giveplayermoney -$15?
Reply
#2

Of course it is
Reply
#3

Cool.thanks for the help
Reply
#4

How can i make it?
Reply
#5

Quote:
Originally Posted by LegendNissanGTR
Посмотреть сообщение
How can i make it?
pawn Код:
public OnPlayerStateChange(playerid, oldstate, newstate)
{
   if(IsPlayerInRangeOfPoint(playerid, distance, x, y, z)) // distance from x,y,z
   {
         MoveObject(objectid, x, y, z); // x, y, z  where the gate will be moved to
         GivePlayerMoney(playerid, -115);
   }
   return 1;
}
Reply
#6

Quote:
Originally Posted by blackwave
Посмотреть сообщение
pawn Код:
public OnPlayerStateChange(playerid, oldstate, newstate)
{
   if(IsPlayerInRangeOfPoint(playerid, distance, x, y, z)) // distance from x,y,z
   {
         MoveObject(objectid, x, y, z); // x, y, z  where the gate will be moved to
         GivePlayerMoney(playerid, -115);
   }
   return 1;
}
Wrong.

Your state doesn't change while driving (as far as I'm concerned). You would be better off using a timer to open/close the gate automatically when a player is in a certain range of it. Something like this would be appropriate:

pawn Код:
public OnGameModeInit()
{
    SetTimer("AutoGate", 3000, 1);
    return 1;
}

forward AutoGate();
public AutoGate()
{
    foreach(Player, i) // Using "foreach" we're going to loop through the online players.
    {
        if(IsPlayerInRangeOfPoint(i, 20.0, GateX, GateY, GateZ)) // We need to check if the any of the players are in-range of the gate.
        {
            MoveObject(OBJECT_ID, GateOpenX, GateOpenY, GateOpenZ, 2.0); // If they are in-range, let's open it.
            SetTimer("AutoGateClose", 3000, 1);
            break; // Stop the loop - we found the player.
        }
    }
    return 1;
}

forward AutoGateClose();
public AutoGateClose()
{
    MoveObject(OBJECT_ID, GateCloseX, GateCloseY, GateCloseZ, 2.0);
    return 1;
}
Reply
#7

Cool thanks guys =) =) =) <3
Reply
#8

RealCop228 so i dont need to CreateObject(987,bla,bla,bla under ongamemodeinit? for the gate to be build closed?
Reply
#9

@LegendNissanGTR, if you want gate, you need to create it. Isn't it obvious?
Reply
#10

oh yah lol thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)