Automatic gates question !
#1

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; 
}
Reply
#2

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

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

yes you can

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

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 !
Reply
#6

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;
  }
Reply
#7

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

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
Reply
#9

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

Just make timer GateClose
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)