SA-MP Forums Archive
How to move 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: How to move gates? (/showthread.php?tid=112776)



How to move gates? - universe - 10.12.2009

How can y move gates? with commands


Re: How to move gates? - Goobiiify - 10.12.2009

It's easy.

Top of your script:
pawn Код:
new Gate1;
OnGameModeInit()
pawn Код:
Gate1 = CreateObject(ObjectID, X, Y, Z, rX, rY, rZ);
OnPlayerCommandText.
pawn Код:
if (strcmp("/movegate", cmdtext, true) == 0)
{
MoveObject(Gate1, newX, newY, newZ, speed);
return 1;
}

This is just an exemple that I made for like 0.1 seconds


Re: How to move gates? - patchkinson - 10.12.2009

well, thats a good example given but do you want autogates?
Il explain how to do it but PLEASE READ THIS WIKI LINK::https://sampwiki.blast.hk/wiki/Automatic_Gates
oK NOW LET ME EXPLAIN^^:
At the top of your script, under your defines do new gatetomove;
Under OnGameModeInit do gatetomove = CreateObject(id, X, Y, Z, closed_rad_X, closed_rad_Y, closed_rad_Z);
you can get all those coordinates by doing /save ingame then going to your game's folder and open a file called savedpositions
do like /save gate and it will appear in that file a coordinate with //gate as name
then above your main put
new OpenGate[MAX_PLAYERS];
Then under OnGameModeInit do
SetTimer("Gate", 500, true);
You will need to forward gate though, so under your defines add forward ();
at the end of your script add:
public Gate()
{
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(!IsPlayerConnected(i)) continue;
if(PlayerToPoint(10.0, i, X coords when near gate, closed_Y, closed_Z) && OpenGate[i] == 0)
{
MoveObject(c_gate, X open coords, Y open coords, Z open coords);
OpenGate[i] = 1;
}
else if(!PlayerToPoint(10.0, i, when you are not near gate X, Y Z && OpenGate[i] == 1)
{
MoveObject(c_gate, close X positions of gate, closed_Y, closed_Z);
OpenGate[i] = 0;
}
}
}


hope i was usefull but thats pretty much like the wiki, but the wiki is cleaner, im too god damn lazy to add [pawn] tagss!! xD