Gate Problem
#1

Hello everybody.I got problem with automaticli gate I don`t see problem but they won`t open...

pawn Код:
forward CheckGate(playerid);
SetTimer("CheckGate",1000,true);
public CheckGate(playerid)
{
    if(GetPlayerTeam(playerid) == 1)
    {
        new mygate_status;
        if(IsPlayerInRangeOfPoint(playerid,10.0,1578.8043,-1751.2802,4.3760))mygate_status = 1;
        if(mygate_status == 1)
        {
            MoveObject(civilgate1, 1578.91369629,-1751.37561035,1.58261597,2.0);
            MoveObject(civilgate2, 1578.91308594,-1751.37500000,11.43260574,2.0);
        }
        if(mygate_status == 0)
        {
            MoveObject(civilgate1, 1578.91369629,-1751.37561035,5.13261700,2.0);
            MoveObject(civilgate2, 1578.91308594,-1751.37500000,8.70762062,2.0);
        }
    }
    return 1;
}
Reply
#2

Anyone??
Reply
#3

pawn Код:
public CheckGate()
{
  for(new playerid=0; playerid<MAX_PLAYERS; playerid++)
  {
    if(!IsPlayerConnected(playerid)) continue;
    if(GetPlayerTeam(playerid) == 1)
    {
        new mygate_status;
        if(IsPlayerInRangeOfPoint(playerid,10.0,1578.8043,-1751.2802,4.3760))mygate_status = 1;
        if(mygate_status == 1)
        {
            MoveObject(civilgate1, 1578.91369629,-1751.37561035,1.58261597,2.0);
            MoveObject(civilgate2, 1578.91308594,-1751.37500000,11.43260574,2.0);
        }
        if(mygate_status == 0)
        {
            MoveObject(civilgate1, 1578.91369629,-1751.37561035,5.13261700,2.0);
            MoveObject(civilgate2, 1578.91308594,-1751.37500000,8.70762062,2.0);
        }
    }
  }
  return 1;
}
or use SetTimerEx
Reply
#4

pawn Код:
new bool:GateOpen;
public OnGameModeInit() //Or OnFilterScriptInit() if you're using a filterscript
{
    SetTimer("GateCheck", 1000, true);
    civilgate1 = CreateObject... //etc. etc.
    civilgate2 = CreateObject... //etc. etc.
    return 1;
}

forward GateCheck();
public GateCheck()
{
    for(new i = 0; i < MAX_PLAYERS; i++) //Foreach is recommended
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInRangeOfPoint(i, 10.0, 1578.8043, -1751.2802, 4.3760))
            {
                if(GetPlayerTeam(i) == 1)
                {
                    if(GateOpen == false)
                    {
                        MoveObject(civilgate1, 1578.91369629,-1751.37561035,5.13261700,2.0);
                        MoveObject(civilgate2, 1578.91308594,-1751.37500000,8.70762062,2.0);
                        GateOpen = true;
                    }
                }
            }
            else
            {
                if(GateOpen == true)
                {
                    MoveObject(civilgate1, 1578.91369629,-1751.37561035,1.58261597,2.0);
                    MoveObject(civilgate2, 1578.91308594,-1751.37500000,11.43260574,2.0);
                    GateOpen = false;
                }
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)