[Ajuda] Bug contado
#1

BUG CONTADO

Olб pessoal, hoje eu estou aqui para resolver um bug muito estranho, eu nгo sei por quer ele ta acontecendo. O bug й o contado sempre pula 1 segundo tipo 1 2 4 5 6 7 8 9 10 й com todos os nъmeros nгo sei oque й se alguйm pode ajudar o cуdigo estб aн em baixo.

CODE

Код:
forward updateTime(playerid);

new gMinutes, gSeconds;



public updateTime(playerid)
{
	new Time2, timestamp;
	new tmp[10];
	timestamp = GetTickCount();
	if (gRaceStart != 0)
		Time2 = timestamp - gRaceStart;
	else
		Time2=5;

	new MSeconds;
	timeconvert(Time2, gMinutes, gSeconds, MSeconds);
	gindex=0;
	while (gSeconds > 9)
	{
		gSeconds-=10;
		gindex++;
	}

 	format(tmp,10,"%d:%d%d",gMinutes,gindex,gSeconds);
	TextDrawSetString(Ttime, tmp);

}

createTextDraws()
{
	Ttime = TextDrawCreate(563.0, 376.0, "0");
	TextDrawLetterSize(Ttime, 0.6, 3);
	TextDrawColor(Ttime,0xffffffff);
	TextDrawSetShadow(Ttime,1);
}

public OnPlayerConnect(playerid)
{

TextDrawShowForPlayer(playerid, Ttime);

return 1;
}
Reply
#2

UP;;;;
Reply
#3

Parei de ler quando me deparei com isso:

Код:
	gindex=0;
	while (gSeconds > 9)
	{
		gSeconds-=10;
		gindex++;
	}

 	format(tmp,10,"%d:%d%d",gMinutes,gindex,gSeconds);
	TextDrawSetString(Ttime, tmp);
A lуgica й de cada um, mas isso foi completamente desotimizado!

Segue o modo otimizado:
Код:
public updateTime(playerid)
{
	new Time2, timestamp;
	new tmp[10];
	
	timestamp = GetTickCount();
	if (gRaceStart != 0)
		Time2 = timestamp - gRaceStart;
	else
		Time2=5;

	new MSeconds;
	timeconvert(Time2, gMinutes, gSeconds, MSeconds);
	
 	format(tmp,10,"%2d:%2d",gMinutes,gSeconds);
	
	TextDrawSetString(Ttime, tmp);
}
P.S.: Isso provavelmente nгo irб corrigir este problema, mas vai dar up nesta callback!
Reply
#4

vlw mano melhorou muito o sistema sу que nгo resolveu eu acho que й isso olhar.

public OnGameModeInit()
{
SetTimer("updateTime",1000,1);
return 1;
}
Reply
#5

Quote:
Originally Posted by F1N4L
Посмотреть сообщение
Parei de ler quando me deparei com isso:

Код:
	gindex=0;
	while (gSeconds > 9)
	{
		gSeconds-=10;
		gindex++;
	}

 	format(tmp,10,"%d:%d%d",gMinutes,gindex,gSeconds);
	TextDrawSetString(Ttime, tmp);
A lуgica й de cada um, mas isso foi completamente desotimizado!

Segue o modo otimizado:
Код:
public updateTime(playerid)
{
	new Time2, timestamp;
	new tmp[10];
	
	timestamp = GetTickCount();
	if (gRaceStart != 0)
		Time2 = timestamp - gRaceStart;
	else
		Time2=5;

	new MSeconds;
	timeconvert(Time2, gMinutes, gSeconds, MSeconds);
	
 	format(tmp,10,"%2d:%2d",gMinutes,gSeconds);
	
	TextDrawSetString(Ttime, tmp);
}
P.S.: Isso provavelmente nгo irб corrigir este problema, mas vai dar up nesta callback!
Quote:
Originally Posted by Marllun
Посмотреть сообщение
vlw mano melhorou muito o sistema sу que nгo resolveu eu acho que й isso olhar.

public OnGameModeInit()
{
SetTimer("updateTime",1000,1);
return 1;
}
Parei de ler quando vн a palavra "otimizado" seguidamente da funзгo GetTickCount.





--


Por favor, poste a funзгo timeconvert .
Reply
#6

timeconvert(Time, &Minutes, &Seconds, &MSeconds)
{
new Float:fTime = floatdiv(Time, 60000);
Minutes = floatround(fTime, floatround_tozero);
Seconds = floatround(floatmul(fTime - Minutes, 60), floatround_tozero);
MSeconds = floatround(floatmul(floatmul(fTime - Minutes, 60) - Seconds, 1000), floatround_tozero);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)