[Ajuda] Erro com SetTimer - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Non-English (
https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (
https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (
https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Erro com SetTimer (
/showthread.php?tid=469007)
Erro com SetTimer -
bruxo00 - 11.10.2013
Nгo estou a perceber este erro:
PHP код:
error 076: syntax error in the expression, or invalid function call
Eu criei um timer que actualiza de segundo a segundo, mas quando quero colocar a funзгo para acabar com o timer (KillTimer), dб esse erro.
Como comeзo o timer:
pawn Код:
SetTimer("RespawnCarros", 1000, true);
Onde estб o KillTimer:
pawn Код:
public RespawnCarros()
{
new string[3];
if(CounterCountdown != 0)
{
CounterCountdown--;
format(string, sizeof(string), "%i", CounterCountdown);
GameTextForAll(string, 999, 4);
printf("1");
}
else if(CounterCountdown == 0)
{
KillTimer(RespawnCarros); // AQUI!!!!!!!!!!!!!!!!!!
printf("2");
new bool:vehicle[MAX_VEHICLES];
for(new j = 1; GetVehicleModel(j); ++j)
{
printf("3");
vehicle[j] = false;
for(new i, p = GetMaxPlayers(); i < p; ++i)
{
printf("4");
if(!IsPlayerInAnyVehicle(i) || !IsPlayerConnected(i)) continue;
if(IsPlayerInVehicle(i, j))
{
printf("5");
vehicle[j] = true;
break;
}
}
if(!vehicle[j]) SetVehicleToRespawn(j);
printf("6");
}
GameTextForAll("~g~RESPAWN!!!", 5000, 0);
printf("7");
}
return 1;
}
Alguйm sabe como fixar?
Re: Erro com SetTimer -
Schocc - 11.10.2013
Tem que usar um
identificador.
pawn Код:
new Timer;
public OnPlayerConnect(playerid)
{
Timer = SetTimerEx("FuncaoA_Chamar", 1000, true, "i", playerid);
return 1;
}
public FuncaoA_Chamar(playerid)
{
//something
return 1;
}
CMD:stoptimer(p)
{
KillTimer(Timer);
return 1;
}
Referencia:
SetTimerEx
KillTimer
Se precisar de ajuda pra adaptar a seu cуdigo sу pedir.
Re: Erro com SetTimer -
PT - 11.10.2013
tira o KillTimer
Re: Erro com SetTimer -
iDreak - 11.10.2013
pawn Код:
new RP = SetTimerEx("RespawnCarros", 1000, true, "i", playerid);
Public RespawnCarros()
Re: Erro com SetTimer -
bruxo00 - 11.10.2013
@Schocc
Muito obrigado, estava esquecido disso!
@PT
O timer ali й fundamental