[Ajuda] Loop infinito apуs 2 player logado
#1

Bom, meu problema й o seguinte. Eu to com um problema no meu cуdigo. Ele fica fazendo voltas e voltas e nгo seta a prуxima quantidade de EXP para o prуximo nнvel. E fica dando voltas e voltas, e acrescendo nнvel.

Код:
function::TimerLevel() {
	foreach(new i : Player) {
		if(!IsPlayerConnected(i)) continue;
		if(APlayerData[i][pEXP] >= ObjectiveXP[i] && APlayerData[i][pLogado] == true) {
			APlayerData[i][pEXP] = 0;
			APlayerData[i][pNivel]++;
			ObjectiveXP[i] = ObjectiveXP[i] * APlayerData[i][pNivel] * 2;
			format(tString, sizeof(tString), " Vocк estб no nнvel %02d.", APlayerData[i][pNivel]);
			SendClientMessage(i, COLOR_LIGHTBLUE, tString);
			return 1;
		}
	}
	return 1;
}
Resumindo, fica subindo o level infinitamente.
Reply
#2

return em loop?
Reply
#3

Quote:
Originally Posted by F1N4L
Посмотреть сообщение
return em loop?
Ignora os return ... lembrando que esta funзгo й um Timer.
Reply
#4

Nгo hб necessidade de usar IsPlayerConnect quando se usa foreach.
Reply
#5

Quote:
Originally Posted by Lуs
Посмотреть сообщение
Nгo hб necessidade de usar IsPlayerConnect quando se usa foreach.
Ainda assim, nгo foi resolvido o meu problema. Continua a acrescer nнvel apуs o outro quando tem 2 ou mais players no servidor.
Reply
#6

Quote:
Originally Posted by pWesley
Посмотреть сообщение
Ainda assim, nгo foi resolvido o meu problema. Continua a acrescer nнvel apуs o outro quando tem 2 ou mais players no servidor.
Aonde estas chamando o timer? Mostre a funзгo por inteira.
Reply
#7

Nunca vi algo similar, mas tenta colocar as variбveis per player.

PHP код:
SetTimerEx("TimerLevel"100000true"i"playerid);

function::
TimerLevel(playerid
{
    if(
APlayerData[playerid][pEXP] >= ObjectiveXP[playerid] && APlayerData[playerid][pLogado] == true
    {
        
APlayerData[playerid][pEXP] = 0;
        
APlayerData[playerid][pNivel]++;
        
ObjectiveXP[playerid] = ObjectiveXP[playerid] * APlayerData[playerid][pNivel] * 2;
        
format(tStringsizeof(tString), " Vocк estб no nнvel %02d."APlayerData[playerid][pNivel]);
        
SendClientMessage(playeridCOLOR_LIGHTBLUEtString);
    }
    return 
1;

Reply
#8

Quote:
Originally Posted by ipsLuan
Посмотреть сообщение
Nunca vi algo similar, mas tenta colocar as variбveis per player.

PHP код:
SetTimerEx("TimerLevel"100000true"i"playerid);
function::
TimerLevel(playerid
{
    if(
APlayerData[playerid][pEXP] >= ObjectiveXP[playerid] && APlayerData[playerid][pLogado] == true
    {
        
APlayerData[playerid][pEXP] = 0;
        
APlayerData[playerid][pNivel]++;
        
ObjectiveXP[playerid] = ObjectiveXP[playerid] * APlayerData[playerid][pNivel] * 2;
        
format(tStringsizeof(tString), " Vocк estб no nнvel %02d."APlayerData[playerid][pNivel]);
        
SendClientMessage(playeridCOLOR_LIGHTBLUEtString);
    }
    return 
1;

Continua a mesma coisa. O problema em evidкncia, no entanto, aparece na variбvel ObjectiveXP[playerid]. Ela permanece zerada.

@EDIT. Descobri o problema. Era na repetiзгo da variбvel ObjectiveXP[playerid], mesmo eu tendo a definido como valor padrгo 1000, a callback interpretava como valor igual a 0.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)