need help with automatic gates!
#2

I think, all is wrong, for Automatic Gates i use this code;

1. Put this in your GameMode/filterscript.
pawn Код:
new gate;
new OpenGate[MAX_PLAYERS];
2. Put this in your GameModeInit or OnFilterScripts.
pawn Код:
gate = CreateObject(ID,X,Y,Z,RX, RY, RZ);
SetTimer("TimerGate", 500, true);
3. Put this in anywhere.
pawn Код:
forward TimerGate();
public TimerGate()
{
  for(new i = 0; i < MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected( i ))
    {
      if(PlayerToPoint(15.0, i,COORDINATES) && OpenGate[i] == 0)
      {
        OpenGate[i] = 1;
        MoveObject(gate, COORDINATES, SPEED);
      }
      else if(!PlayerToPoint(15.0, i,1COORDINATES) && OpenGate[i] == 1)
      {
        OpenGate[i] = 0;
        MoveObject(gated,COORDINATES, SPEED);
      }
    }
  }
}
4. Replace the fuction playertopoint for this.
pawn Код:
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
   public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
   {
   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;
}
Good Luck!
Reply


Messages In This Thread
need help with automatic gates! - by BMGP - 24.08.2009, 07:52
Re: need help with automatic gates! - by Energyzer - 24.08.2009, 09:02
Re: need help with automatic gates! - by BMGP - 24.08.2009, 11:30

Forum Jump:


Users browsing this thread: 2 Guest(s)