[PORQUE?]OnPlayerUpdate -
TiagoPS - 16.08.2010
Bom Gente estou criando um velocimetro que esta ficando show de bola que provavelmente amanha irei posta-lo aqui.
mas estava todo faceiro tstando ele derrepente ele simplesmente sumiu o textdraw que mostra a velocidade eu estou fazendo ele para dar o "update" pelo OnPlayerUpdate onde a velocidade fica exelence nгo mente nгo da lag ou seja mostra a velocidade real de cada carro mas nгo sei a hora que ele puxa umas 10 mil vezes o OnPlayerUpdate ele some o textdraw de mostrar a velocidade eu nгo queria usar SetTimer's porque nгo sao tao ageis e demoram um pouco da a velocidade real e ai pessoal alguma ideia do que fazer
ele some so aquele Textdraw onde ta escrito
Velocidade 142KM/h
O quadro branco e a borda preta fica normal so as letras somem
Uma preview do velocimetro
@EDIT
Esqueci de postar o meu OnPlayerUpdate
em
OnPlayerUpdate
pawn Код:
public OnPlayerUpdate(playerid)
{
ChecarVelocimetro();
return 1;
}
e a public do velocimetro й
pawn Код:
public ChecarVelocimetro()
{ for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
new Float:xa[3];
new string[128];
GetPlayerPos(i, xa[0], xa[1], xa[2]);
if(IsPlayerInRangeOfPoint(i, 100, xa[0], xa[1], xa[2]) && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
TextDrawHideForPlayer(i,Textdraw2);
format(string, sizeof(string), "~g~Velocidade ~r~%dKM/h", VelocidadeKM(i));
Textdraw2 = TextDrawCreate(496.000000,355.000000,string);
TextDrawAlignment(Textdraw2,0);
TextDrawBackgroundColor(Textdraw2,0x000000ff);
TextDrawFont(Textdraw2,1);
TextDrawLetterSize(Textdraw2,0.299999,1.200000);
TextDrawColor(Textdraw2,0xffffffff);
TextDrawSetOutline(Textdraw2,1);
TextDrawSetProportional(Textdraw2,1);
TextDrawSetShadow(Textdraw2,1);
TextDrawShowForPlayer(i,Textdraw2);
}
}
}
}
return 1;
}
Claro que o que esta na print nгo й a versгo final ai so esta a velocidade mas eu ainda vou colocar para mostrar o nome do veiculo, danos, combustivel e nome do piloto se tudo der certo se deus quiser amanha posto ele
Re: [PORQUE?]OnPlayerUpdate -
MrDeath537 - 16.08.2010
Try it:
Change "forward ChecarVelocimetro();" to "forward ChecarVelocimetro(i);"
pawn Код:
public ChecarVelocimetro(i)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
new Float:xa[3];
new string[128];
GetPlayerPos(i, xa[0], xa[1], xa[2]);
if(IsPlayerInRangeOfPoint(i, 100, xa[0], xa[1], xa[2]) && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
TextDrawHideForPlayer(i,Textdraw2);
format(string, sizeof(string), "~g~Velocidade ~r~%dKM/h", VelocidadeKM(i));
Textdraw2 = TextDrawCreate(496.000000,355.000000,string);
TextDrawAlignment(Textdraw2,0);
TextDrawBackgroundColor(Textdraw2,0x000000ff);
TextDrawFont(Textdraw2,1);
TextDrawLetterSize(Textdraw2,0.299999,1.200000);
TextDrawColor(Textdraw2,0xffffffff);
TextDrawSetOutline(Textdraw2,1);
TextDrawSetProportional(Textdraw2,1);
TextDrawSetShadow(Textdraw2,1);
TextDrawShowForPlayer(i,Textdraw2);
}
}
return 1;
}
and in OnPlayerUpdate:
pawn Код:
ChecarVelocimetro(playerid);
Sorry, I don't speak portuguese
Re: [PORQUE?]OnPlayerUpdate -
TiagoPS - 16.08.2010
Quote:
Originally Posted by MrDeath
Try it:
Change "forward ChecarVelocimetro();" to "forward ChecarVelocimetro(playerid);"
pawn Код:
public ChecarVelocimetro(playerid) { if(GetPlayerState(i) == PLAYER_STATE_DRIVER) { new Float:xa[3]; new string[128]; GetPlayerPos(i, xa[0], xa[1], xa[2]); if(IsPlayerInRangeOfPoint(i, 100, xa[0], xa[1], xa[2]) && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER) { TextDrawHideForPlayer(i,Textdraw2); format(string, sizeof(string), "~g~Velocidade ~r~%dKM/h", VelocidadeKM(i)); Textdraw2 = TextDrawCreate(496.000000,355.000000,string); TextDrawAlignment(Textdraw2,0); TextDrawBackgroundColor(Textdraw2,0x000000ff); TextDrawFont(Textdraw2,1); TextDrawLetterSize(Textdraw2,0.299999,1.200000); TextDrawColor(Textdraw2,0xffffffff); TextDrawSetOutline(Textdraw2,1); TextDrawSetProportional(Textdraw2,1); TextDrawSetShadow(Textdraw2,1); TextDrawShowForPlayer(i,Textdraw2); } } return 1; }
and in OnPlayerUpdate:
pawn Код:
ChecarVelocimetro(playerid);
Sorry, I don't speak portuguese
|
MrDeath the TextDraw works perfectly but after about two minutes he disappears and no longer appears so if you restart the server
Re: [PORQUE?]OnPlayerUpdate -
MrDeath537 - 16.08.2010
Sorry, I didn't understand.
Try it:
pawn Код:
new Text:Velocimetro[MAX_PLAYERS];
public OnGameModeInit()
{
// Other stuff...
for(new x = 0; x < MAX_PLAYERS; x ++)
{
Velocimetro[x] = TextDrawCreate(496.000000,355.000000, "");
TextDrawAlignment(Velocimetro[x],0);
TextDrawBackgroundColor(Velocimetro[x],0x000000ff);
TextDrawFont(Velocimetro[x],1);
TextDrawLetterSize(Velocimetro[x],0.299999,1.200000);
TextDrawColor(Velocimetro[x],0xffffffff);
TextDrawSetOutline(Velocimetro[x],1);
TextDrawSetProportional(Velocimetro[x],1);
TextDrawSetShadow(Velocimetro[x],1);
}
}
public ChecarVelocimetro(i)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
new Float:xa[3];
new string[128];
GetPlayerPos(i, xa[0], xa[1], xa[2]);
if(IsPlayerInRangeOfPoint(i, 100, xa[0], xa[1], xa[2]) && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
format(string, sizeof(string), "Velocidade: %i", VelocidadeKM(i));
TextDrawSetString(Velocimetro[i], string);
TextDrawShowForPlayer(i, Velocimetro[i]);
}
}
return 1;
}
Re: [PORQUE?]OnPlayerUpdate -
TiagoPS - 16.08.2010
Quote:
Originally Posted by MrDeath
Sorry, I didn't understand.
Try it:
pawn Код:
new Text:Velocimetro[MAX_PLAYERS];
public OnGameModeInit() { // Other stuff...
for(new x = 0; x < MAX_PLAYERS; x ++) { Velocimetro[x] = TextDrawCreate(496.000000,355.000000, ""); TextDrawAlignment(Velocimetro[x],0); TextDrawBackgroundColor(Velocimetro[x],0x000000ff); TextDrawFont(Velocimetro[x],1); TextDrawLetterSize(Velocimetro[x],0.299999,1.200000); TextDrawColor(Velocimetro[x],0xffffffff); TextDrawSetOutline(Velocimetro[x],1); TextDrawSetProportional(Velocimetro[x],1); TextDrawSetShadow(Velocimetro[x],1); } }
public ChecarVelocimetro(i) { if(GetPlayerState(i) == PLAYER_STATE_DRIVER) { new Float:xa[3]; new string[128]; GetPlayerPos(i, xa[0], xa[1], xa[2]); if(IsPlayerInRangeOfPoint(i, 100, xa[0], xa[1], xa[2]) && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER) { format(string, sizeof(string), "Velocidade: %i", VelocidadeKM(i)); TextDrawSetString(Velocimetro[i], string); TextDrawShowForPlayer(i, Velocimetro[i]); } } return 1; }
|
Did not work this way also the TextDraw works normally but after two minutes or so he disappears and only reappears if restart served, I think it has something to do with OnPlayerUpdate think he only works a certain time after the player connects, I think the way will be to use SetTimer's but I did not want to use because there's a real impression of speed because of the delay to draw the public's
Sorry my bad
English is that I'm
Brazilian
Re: [PORQUE?]OnPlayerUpdate -
Kasura - 16.08.2010
Tipuw desculpe aproveitar seu tуpico.... mas й pra n ficar meio que dois tуpicos iguais...
tenhu uma duvida...
Criei 1 textdraw que mostra o score.... da pra usar onplayerupdate em vez de settimer para meu caso?
Re: [PORQUE?]OnPlayerUpdate -
LeLeTe - 16.08.2010
Cara. O problema й o seu OnPlayerUpdate.
Faзa igual a eu (No novo sistema de concessionбrias vou embutir um sisteminha de velocнmetros e gasolina):
-Crie um timer para a sua funзгo no OnGameModeInit.
Exemplo:
SetTimer("ChecarVelocimetro", 500, 1);
E pronto
Acho que sua velocidade й meio lol, cara.
Seu velocнmetro tб estranho, acho.
Re: [PORQUE?]OnPlayerUpdate -
[VTLS]Victor - 16.08.2010
Eita
ele fala english e й da Argentina?
Re: [PORQUE?]OnPlayerUpdate -
LeLeTe - 16.08.2010
Seguindo a lуgica que o resto do mundo tem, Brasileiro = Mal sabe falar portuguкs. Imagine espanhol. Entгo eles tentam o inglкs que й uma lнngua que 90% do planeta sabe o bбsico.
Re: [PORQUE?]OnPlayerUpdate -
Kasura - 16.08.2010
settimer = lag comprovado ^^
NГO USE SETTIMER PARA AЗХES INSTANTANEAS
descobri que o onplayerupdade funciona bem melhor que o settimer para aзхes instantaneas
mas tipuw cara acho que velocimetr n da pois ele usa d+ o public fica muito rapido...
a maquina do seu host precisa ser muito boa pra aguentar esse processamento...