funcion CountTillEvento1(playerid)
{
CountEvento1--;
if(CountEvento1 == 0)
{
TogglePlayerControllable(playerid, 1);
SendClientMessage(playerid, COLOR_MSG, "|-INFO-| Ya no puedes unirte al evento, tiempo agotado");
KillTimer(CountTimerEvento1);
return 1;
}
new str[128];
format(str, sizeof(str), "|-INFO-| Tiempo restante para que comience: %d segundos", CountEvento1);
SendClientMessageToAll(AMARILLO, str);
return 1;
}
funcion IniciarEv1(playerid)
{
if(IniciarE == 1)
{
if(CountPlayersEv1 < 2)
{
SendClientMessageToAll(COLOR_MSG, "|-INFOEVENTO-| Evento 1 cancelado, razуn: players insuficientes (Mнnimo: 2)");
EventoIniciado[playerid] = 0;
IniciarE = 0;
KillTimer(Ev1Timer);
}
}
IniciarE = 0;
KillTimer(Ev1Timer);
return 1;
}
case DIALOGO_EVENTOS:
{
if(response)
{
switch(listitem)
{
case 0:
{
if(EventoIniciado[playerid] == 1)
return SendClientMessage(playerid, COLOR_MSG, "|-ERROR-| Evento 1 ya iniciado");
EventoIniciado[playerid] = 1;
SendClientMessage(playerid, NARANJA, "|-EVENTO-| Un administrador activу el Evento 1 e iniciarб en 30 segundos");
IniciarE = 1;
Ev1Timer = SetTimer("IniciarEv1", 30000, 0);
CountTimerEvento1 = SetTimer("CountTillEvento1", 1000, 1);
}
}
}
}
funcion CountTillEvento1(playerid)
{
CountEvento1--; // En la primera hara su trabajo bien, pero cuando lo vuelvas a usar, CountEvento1 habra quedado en 0 de la ultima cuenta regresiva, y esta linea le restara 1, quedando en -1, y repitiendose el timer hasta el infinito ya que la siguiente condicion jamas se va a cumplir
if(CountEvento1 == 0)
{
TogglePlayerControllable(playerid, 1);
SendClientMessage(playerid, COLOR_MSG, "|-INFO-| Ya no puedes unirte al evento, tiempo agotado");
CountEvento1 = 30; // Antes de matar el timer seteamos CountEvento1 a 30 para que la proxima vez que se ejecute esta variable no valga 0 y se produzca lo anterior.
KillTimer(CountTimerEvento1);
return 1;
}
new str[128];
format(str, sizeof(str), "|-INFO-| Tiempo restante para que comience: %d segundos", CountEvento1);
SendClientMessageToAll(AMARILLO, str);
return 1;
}
|
relee el codigo...
en la funcion CountTillEvento1 le restas a CountEvento1. si es 0 matas el timer y haces el resto. pero en ningun momento veo que reinicies "CountEvento1". dentro del if(CountEvento1 == 0) agrega una linea para reiniciar la variable a su valor por defecto. por ejemplo: CountEvento1 = 30; entonces cuando vuelvas a usar el comando y el timer se active, CountEvento1 no va a quedar en 0 de la ultima vez y no se va a restar y quedar en negativo hasta el infinito. Код:
funcion CountTillEvento1(playerid)
{
CountEvento1--; // En la primera hara su trabajo bien, pero cuando lo vuelvas a usar, CountEvento1 habra quedado en 0 de la ultima cuenta regresiva, y esta linea le restara 1, quedando en -1, y repitiendose el timer hasta el infinito ya que la siguiente condicion jamas se va a cumplir
if(CountEvento1 == 0)
{
TogglePlayerControllable(playerid, 1);
SendClientMessage(playerid, COLOR_MSG, "|-INFO-| Ya no puedes unirte al evento, tiempo agotado");
CountEvento1 = 30; // Antes de matar el timer seteamos CountEvento1 a 30 para que la proxima vez que se ejecute esta variable no valga 0 y se produzca lo anterior.
KillTimer(CountTimerEvento1);
return 1;
}
new str[128];
format(str, sizeof(str), "|-INFO-| Tiempo restante para que comience: %d segundos", CountEvento1);
SendClientMessageToAll(AMARILLO, str);
return 1;
}
|