[HELP] Anybody help with automatic gates
#1

Can anybody tell me how to make automatic gates when i come near the gate?
Reply
#2

anybody
Reply
#3

Try using this Funaction:
PlayerToPoint(Float, playerid, Float:X, Float:Y, Float:Z);
Float - Distance
the rest i think you unederstand
and here is something you need to add so it will work:
pawn Код:
//Forward Line
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);

//The Callback public
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
  if(IsPlayerConnected(playerid))
    {
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        tempposx = (oldposx -x);
        tempposy = (oldposy -y);
        tempposz = (oldposz -z);
        if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
        {
            return 1;
        }
    }
    return 0;
}
so the cmd should look like:
pawn Код:
forward MoveObject();
new objectid, objectidstatus = 1;

public MoveObject()
{
    if(objectidstatus == 0)
    {
    MoveObject(objectid, Float:X, Float:Y, Float:Z);
    objectidstatus = 1;
    }
    return 1;
}

    if(PlayerToPoint(5, playerid, Float:X, Float:Y, Float:Z))
    {
        if(objectidstatus == 1)
        {
        MoveObject(objectid, Float:X, Float:Y, Float:Z);
        objectidstatus = 0;
        SetTimer("MoveObject", 5000, false);
        }
        return 1;
    }
   
public OnGameModeInit()
{
    objectid = CreateObject(objectid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ);
    return 1;
}
meaning it will open teh gate if he is near it by 5 and will close it after 5 seconds
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)