[Help] Creating timer
#1

Код:
public OnPlayerExitVehicle(playerid)
   {
   SendClientMessage(playerid,0xFF0000AA,"YOU EXITED A VEHICLE:");
   GameTextForPlayer(playerid," ~w~ Vehicle Is Being ~h~ Destroyed./carmenu for new car", 2000, 6);
   {
   print("Starting timer...");
	SetTimer("message",5000,false);
  }
print("5 seconds had passed.");
  SendClientMessage(playerid,0xFF0000AA,"YOU EXITED A VEHICLE::::it will be destroyed now use /carmenu ");
    DestroyVehicle(vd);
  return 1;
    }
what is wrong with this code
As soon as i exits the car it gets destroyed but i want to be destroyed it after 5 secs please help and it should also tell after each sec 1 sec has passed
2 secs had passed
3----
4-----
5---------
After 5 secs
your vehicle had been destroyed now
Reply
#2

Quote:
Originally Posted by mannu
Код:
public OnPlayerExitVehicle(playerid)
  {
  SendClientMessage(playerid,0xFF0000AA,"YOU EXITED A VEHICLE:");
  GameTextForPlayer(playerid," ~w~ Vehicle Is Being ~h~ Destroyed./carmenu for new car", 2000, 6);
  {
  print("Starting timer...");
	SetTimer("message",5000,false);
  }
print("5 seconds had passed.");
 SendClientMessage(playerid,0xFF0000AA,"YOU EXITED A VEHICLE::::it will be destroyed now use /carmenu ");
   DestroyVehicle(vd);
  return 1;
   }
what is wrong with this code
As soon as i exits the car it gets destroyed but i want to be destroyed it after 5 secs please help and it should also tell after each sec 1 sec has passed
2 secs had passed
3----
4-----
5---------
After 5 secs
your vehicle had been destroyed now
Код:
new messagetimer;
new messagetime;
forward message();

public OnPlayerExitVehicle(playerid)
   {
   SendClientMessage(playerid,0xFF0000AA,"YOU EXITED A VEHICLE:");
   GameTextForPlayer(playerid," ~w~ Vehicle Is Being ~h~ Destroyed./carmenu for new car", 2000, 6);
   {
   print("Starting timer...");
	messagetimer = SetTimer("message",1000,true);
    messagetime = 0;
  }
  return 1;
}

public message()
{
  messagetime++;
  if(messagetime >= 5)
  {
  SendClientMessage(playerid,0xFF0000AA,"YOU EXITED A VEHICLE::::it will be destroyed now use /carmenu ");
    DestroyVehicle(vd);
  DestroyTimer(messagetimer);
  messagetime = 0;
  }
  return 1;
}
Reply
#3

Код:
F:\GTA SAN ANDREAS\GTA SA\GTA-SanAndreas\samp02Xserver.win32\filterscripts\allcars.pwn(2397) : warning 225: unreachable code
F:\GTA SAN ANDREAS\GTA SA\GTA-SanAndreas\samp02Xserver.win32\filterscripts\allcars.pwn(2397) : error 029: invalid expression, assumed zero
F:\GTA SAN ANDREAS\GTA SA\GTA-SanAndreas\samp02Xserver.win32\filterscripts\allcars.pwn(2397) : error 004: function "OnPlayerExitVehicle" is not implemented
F:\GTA SAN ANDREAS\GTA SA\GTA-SanAndreas\samp02Xserver.win32\filterscripts\allcars.pwn(2409) : warning 225: unreachable code
F:\GTA SAN ANDREAS\GTA SA\GTA-SanAndreas\samp02Xserver.win32\filterscripts\allcars.pwn(2409) : error 029: invalid expression, assumed zero
F:\GTA SAN ANDREAS\GTA SA\GTA-SanAndreas\samp02Xserver.win32\filterscripts\allcars.pwn(2409) : error 004: function "message" is not implemented
F:\GTA SAN ANDREAS\GTA SA\GTA-SanAndreas\samp02Xserver.win32\filterscripts\allcars.pwn(2416) : error 017: undefined symbol "DestroyTimer"
F:\GTA SAN ANDREAS\GTA SA\GTA-SanAndreas\samp02Xserver.win32\filterscripts\allcars.pwn(2425) : warning 225: unreachable code
F:\GTA SAN ANDREAS\GTA SA\GTA-SanAndreas\samp02Xserver.win32\filterscripts\allcars.pwn(2425) : error 029: invalid expression, assumed zero
F:\GTA SAN ANDREAS\GTA SA\GTA-SanAndreas\samp02Xserver.win32\filterscripts\allcars.pwn(2425) : error 004: function "OnPlayerExitedMenu" is not implemented
F:\GTA SAN ANDREAS\GTA SA\GTA-SanAndreas\samp02Xserver.win32\filterscripts\allcars.pwn(2435) : error 029: invalid expression, assumed zero
F:\GTA SAN ANDREAS\GTA SA\GTA-SanAndreas\samp02Xserver.win32\filterscripts\allcars.pwn(2435) : error 004: function "OnPlayerSpawn" is not implemented
F:\GTA SAN ANDREAS\GTA SA\GTA-SanAndreas\samp02Xserver.win32\filterscripts\allcars.pwn(2445) : error 030: compound statement not closed at the end of file (started at line 2379)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


10 Errors.
errors
Reply
#4

First of all, giving people plain codes don't make them learn, so please refrain from that

Secondly, the name of the timer is function's name. A function needs to be apart from any other function in the gamemode(basicly means you may not script it inside any bracket).

Thirdly, as far as I can see I think you forgot a bracket somewhere, the amount of opened brackets also needs to be closed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)