[HELP] Anybody help with automatic gates - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Anybody help with automatic gates (
/showthread.php?tid=69254)
[HELP] Anybody help with automatic gates -
RyDeR` - 16.03.2009
Can anybody
tell me how to make automatic gates when i come near the gate?
Re: [HELP] Anybody help with automatic gates -
RyDeR` - 16.03.2009
anybody
Re: [HELP] Anybody help with automatic gates -
Castle - 16.03.2009
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