24.08.2009, 09:02
I think, all is wrong, for Automatic Gates i use this code;
1. Put this in your GameMode/filterscript.
2. Put this in your GameModeInit or OnFilterScripts.
3. Put this in anywhere.
4. Replace the fuction playertopoint for this.
Good Luck!
1. Put this in your GameMode/filterscript.
pawn Код:
new gate;
new OpenGate[MAX_PLAYERS];
pawn Код:
gate = CreateObject(ID,X,Y,Z,RX, RY, RZ);
SetTimer("TimerGate", 500, true);
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);
}
}
}
}
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;
}