Timer only works for ID 0
#1

I have a Problem.
In my Gamemode, I have a Engine System that Freezes the player when he enter to the vehicle, and unfreeze the player when he starts the engine. But.. if a player is in a stopped vehicle and other player steal his vehicle, the first player will be freezed out of the car.

I have a timer, that monitors if a player is out of a car and if he is freezed, unfreeze he <--- This only works for ID 0 player.

Код:
new EngineStop[MAX_PLAYERS];
Код:
if(newstate == PLAYER_STATE_DRIVER)
{
  if (Engine[newcar] == 0)
  {
    if(PoliceCar(newcar))
    {
	  GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~r~Engine: Stopped", 6000, 5);
	  EngineStop[playerid] = 1;
      TogglePlayerControllable(playerid, 0);
    }
  }
}
Код:
public OnGameModeInit()
{
  SetTimer("EngineStopped",1500,true);
}
Код:
public EngineStopped(playerid)
{
  if(EngineStop[playerid] == 1 && !IsPlayerInAnyVehicle(playerid))
  {
	TogglePlayerControllable(playerid, 1);
	EngineStop[playerid] = 0;
  }
}
return 1;
How can I solve this?
Reply
#2

Use SetTimerEx.
Reply
#3

Код:
public OnGameModeInit()
{
  SetTimerEx("EngineStopped",1500,0,"i",playerid);
}
Cannot use "playerid" inside OnGameModeInit function

Код:
C:\Documents and Settings\John\gamemodes\testing.pwn(7825) : error 017: undefined symbol "playerid"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

1 Error.
Reply
#4

Then use a loop
Reply
#5

Quote:
Originally Posted by loleteviejo
Код:
public OnGameModeInit()
{
  SetTimerEx("EngineStopped",1500,0,"i",playerid);
}
Cannot use "playerid" inside OnGameModeInit function

Код:
C:\Documents and Settings\John\gamemodes\testing.pwn(7825) : error 017: undefined symbol "playerid"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

1 Error.
pawn Код:
public OnPlayerConnect(playerid)
{
  SetTimerEx("EngineStopped",1500,0,"i",playerid);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)