Gate timer
#1

Hey

I need a gate that when you open it, that it closed automatic after 3 sec

here is what I already got:

OnPlayerCommandText
Код:
	if(strcmp("/aopen", cmdtext, true, 7) == 0)
	{
		MoveObject(agate,321.292,-1188.194,71.049,5.0);
		SendClientMessage(playerid, 0xAA3333AA, "Close the gate by typing: '/aclose' or by waiting 3 sec.");
		return 1;
	}
	if(strcmp("/aclose", cmdtext, true, 8) == 0)
	{
		MoveObject(agate,321.292,-1188.194,78.049,5.0);
		SendClientMessage(playerid, 0xAA3333AA, "You have closed the gate");
		return 1;
	}
This works, It closes and opens normal, but now I try to upgrade it so that it closes automatic after 3 sec.

Thanks
Reply
#2

pawn Код:
SetTimer("CloseGate", 3000, 0);

public CloseGate()
{
  MoveObject(gate, ...);
  return 1;
}
Reply
#3

I got no error, but still it doesn't work

Код:
	if(strcmp("/aopen", cmdtext, true, 7) == 0)
	{
		MoveObject(agate,321.292,-1188.194,71.049,5.0);
		SendClientMessage(playerid, 0xAA3333AA, "Close the gate by typing: '/aclose' or by waiting 3 sec.");
		return 1;
	}
	if(strcmp("/aclose", cmdtext, true, 8) == 0)
	{
		MoveObject(agate,321.292,-1188.194,78.049,5.0);
		SendClientMessage(playerid, 0xAA3333AA, "You have closed the gate");
		return 1;
	}
	return 0;
}


public CloseGate()
{
  SetTimer("CloseGate", 3000, 0);
  MoveObject(agate,321.292,-1188.194,78.049,5.0);
  return 1;
}
Reply
#4

please somebody
Reply
#5

The timer should be in your /aopen command.
Reply
#6

//very up
forward CloseGate;

if(strcmp("/aopen", cmdtext, true, 7) == 0)
{
MoveObject(agate,321.292,-1188.194,71.049,5.0);
SendClientMessage(playerid, 0xAA3333AA, "Close the gate by typing: '/aclose' or by waiting 3 sec.");
SetTimer("CloseGate", 3000, 0);
return 1;
}
if(strcmp("/aclose", cmdtext, true, == 0)
{
MoveObject(agate,321.292,-1188.194,78.049,5.0);
SendClientMessage(playerid, 0xAA3333AA, "You have closed the gate");
return 1;
}
return 0;
}


public CloseGate()
{
MoveObject(agate,321.292,-1188.194,78.049,5.0);
SendClientMessage(playerid, 0xAA3333AA, "Gate has closed");
return 1;
}
Reply
#7

now I am getting this

Код:
C:\Users\Decoster Joeri\Desktop\World FreeRoam\filterscripts\sh2.pwn(15) : error 001: expected token: "(", but found "public"
C:\Users\Decoster Joeri\Desktop\World FreeRoam\filterscripts\sh2.pwn(15) : error 001: expected token: ";", but found "-identifier-"
C:\Users\Decoster Joeri\Desktop\World FreeRoam\filterscripts\sh2.pwn(193) : error 017: undefined symbol "playerid"
C:\Users\Decoster Joeri\Desktop\World FreeRoam\filterscripts\sh2.pwn(197) : warning 203: symbol is never used: "OnFilterScriptInit"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
line 15
Код:
public OnFilterScriptInit()
Line 193
Код:
  SendClientMessage(playerid, 0xAA3333AA, "Gate has closed");
Line 197
There is no line 197, it ends at 196, but I guess that it will get fixed after that line 15 is fixed
Reply
#8

make forward CloseGate :
pawn Код:
forward CloseGate();
And just remove the SendClientMessage in the CloseGate callback.
Reply
#9

Quote:
Originally Posted by Swift_
make forward CloseGate :
pawn Код:
forward CloseGate();
And just remove the SendClientMessage in the CloseGate callback.
yeah, no errors, now I will go test it
Reply
#10

Now I got mutiple gates, 4 in total extually,

Iv seen that when I open 1 gate, and wait 1 sec. and open another gate, that the 2nd gate doesn't wait 3 sec to close

I guess that it has something to do with this

Код:
public CloseGate()
{
  MoveObject(bsgate,1245.418,-767.151,93.827,5.0);
  MoveObject(bsgate2,1304.439,-812.133,79.816,5.0);
  MoveObject(dogate,1281.541,-614.808,104.861,5.0);
  MoveObject(agate,321.292,-1188.194,78.049,5.0);
  return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)