SA-MP Forums Archive
Automatic gates question ! - 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: Automatic gates question ! (/showthread.php?tid=136576)



Automatic gates question ! - Kirchhoff - 25.03.2010

How can i make my FS with automatic gates automaticly close after 3 seconds ? This is my pawno code :


Code:
#include <a_samp>
new gate;


#define COLOR_YELLOW 0xFFFF00AA
public OnFilterScriptInit ()
{
  gate = CreateObject(986,2560.146,-2227.251,13.071,0.0,0.0,90.000);
  return 1;
}

public OnPlayerCommandText (playerid, cmdtext[])
{
  if (strcmp(cmdtext, "/vipopen", true) == 0)
  {
    MoveObject(gate, 2560.146,-2235.245,13.071,3);
    SendClientMessage(playerid, COLOR_YELLOW,"Welcome to V.I.P base.");
    return 1;
  }
  if (strcmp(cmdtext, "/vipclose", true) == 0)
  {
    MoveObject(gate, 2560.146,-2227.251,13.071,3);
    SendClientMessage(playerid, COLOR_YELLOW,"Come back later.");
    return 1;
  }
  return 0; 
}



Re: Automatic gates question ! - cssbart - 25.03.2010

how do you want it on a cmd for open and close after 3 seconds
or
open when you go up to it


Re: Automatic gates question ! - Kirchhoff - 26.03.2010

yes i want it to open and close after 3 seconds !


Re: Automatic gates question ! - [cA]Unforseen - 26.03.2010

yes you can

you need to use SetTimer
https://sampwiki.blast.hk/wiki/SetTimer


Re: Automatic gates question ! - Kirchhoff - 26.03.2010

Can you make it like an example for me please ? I am a noob in pawno and i can't make it out by myself !


Re: Automatic gates question ! - [cA]Unforseen - 26.03.2010

here:

Code:
forward GateClose();
public GateClose()
{
  MoveObject(gate, 2560.146,-2227.251,13.071,3);
}
replace your command with this

Code:
  if (strcmp(cmdtext, "/vipopen", true) == 0)
  {
    MoveObject(gate, 2560.146,-2235.245,13.071,3);
    SendClientMessage(playerid, COLOR_YELLOW,"Welcome to V.I.P base.");
    SetTimer("GateClose", 3000, false);
    return 1;
  }



Re: Automatic gates question ! - Kirchhoff - 26.03.2010

And where to put this :
Code:
forward GateClose();
public GateClose()
{
  MoveObject(gate, 2560.146,-2227.251,13.071,3);
}



Re: Automatic gates question ! - jamesbond007 - 26.03.2010

Quote:
Originally Posted by Kirchhoff
And where to put this :
Code:
forward GateClose();
public GateClose()
{
  MoveObject(gate, 2560.146,-2227.251,13.071,3);
}
anywhere in the script


Re: Automatic gates question ! - Oxside - 26.03.2010

the forward must be under the includes so at the top of the script.
The function can be anywhere in the script


Re: Automatic gates question ! - [MK]Soprano - 26.03.2010

Just make timer GateClose