Timer only works for ID 0 - 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: Timer only works for ID 0 (
/showthread.php?tid=71297)
Timer only works for ID 0 -
loleteviejo - 31.03.2009
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?
Re: Timer only works for ID 0 -
Norn - 31.03.2009
Use SetTimerEx.
Re: Timer only works for ID 0 -
loleteviejo - 31.03.2009
Код:
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.
Re: Timer only works for ID 0 -
ICECOLDKILLAK8 - 31.03.2009
Then use a loop
Re: Timer only works for ID 0 -
Norn - 31.03.2009
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);
}