Velocнmetro nгo funciona -
bruxo00 - 06.08.2014
PHP код:
public ActualizarCarro(playerid)
{
new vehicle, Float:speed_x, Float:speed_y, Float:speed_z, speedstring[256];
GetPlayerVehicleID(vehicle);
GetVehicleVelocity(vehicle, speed_x, speed_y, speed_z);
Velocidade[playerid] = floatmul(floatsqroot(floatadd(floatpower(speed_x, 2), floatadd(floatpower(speed_y, 2), floatpower(speed_z, 2)))), 185);
format(speedstring, sizeof(speedstring), "%0.0f", Velocidade[playerid]);
TextDrawSetString(Textdraw10[playerid], speedstring);
return 1;
}
Tenho este velocнmetro noutro GameMode, e funciona bem lб. Passei-o para outro GM, e nгo sei porquк, a velocidade fica sempre 0. O que serб?
Re: Velocнmetro nгo funciona -
ViniBorn - 06.08.2014
Nгo falta TextDrawShowForPlayer?
Re: Velocнmetro nгo funciona -
caoraivoso3 - 06.08.2014
faz o que o vini disse, mas para isso nao ea melhor uma playertextdraw em vez de uma global? o estou a dizer que era melhor uma playertextdraw.
Re: Velocнmetro nгo funciona -
bruxo00 - 06.08.2014
A textdraw й mostrada quando o player entra num carro,nгo й esse o problema. O problema й que a velocidade й sempre 0.
Re: Velocнmetro nгo funciona -
ViniBorn - 06.08.2014
Exatamente aн pode estar o problema.
Se TextDraw sу й mostrada quando o jogador entra no carro, ele nгo vai ser mostrado durante as atualizaзхes.
Adicione a funзгo acima e diga o resultado.
Re: Velocнmetro nгo funciona -
bruxo00 - 06.08.2014
Pense comigo.
* Jogador entra no carro
- Textdraw й mostrado
- Comeзa o timer para chamar aquela callback
- A string й actualizada cada vez que o timer acaba
No outro GM estб exactamente igual e funciona muito bem.
Re: Velocнmetro nгo funciona -
ViniBorn - 06.08.2014
Vocк tem que usar TextDrawShowForPlayer apуs TextDrawSetString.
No mesmo bloco de cуdigo ou nгo, mas isso tem que ser feito.
Verifique isso.
Pelo que parece, vocк sу estб usando TextDrawShowForPlayer uma vez, quando o jogador entra no veнculo.
Re: Velocнmetro nгo funciona -
caoraivoso3 - 06.08.2014
Quote:
Originally Posted by bruxo00
Pense comigo.
* Jogador entra no carro
- Textdraw й mostrado
- Comeзa o timer para chamar aquela callback
- A string й actualizada cada vez que o timer acaba
No outro GM estб exactamente igual e funciona muito bem.
|
Bruxo tens de dar show da textdraw cada vez que mudas a string ou quando a alters de alguma maneira.
no outro gm tenho certeza que noutro lado talvez onplayerupdate tem o show dessa textdraw
Re: Velocнmetro nгo funciona -
PT - 07.08.2014
Tens a certeza que tens o timer a chamar a callback apos entrares no carro?
talvez seja por isso.
Re: Velocнmetro nгo funciona -
bruxo00 - 07.08.2014
Sim, tenho.
PHP код:
new TimerActualizarCarro[MAX_PLAYERS];
PHP код:
if(newstate == PLAYER_STATE_DRIVER)
{
TextDrawShowForPlayer(playerid, Textdraw0);
TextDrawShowForPlayer(playerid, Textdraw1);
TextDrawShowForPlayer(playerid, Textdraw2);
TextDrawShowForPlayer(playerid, Textdraw3);
TextDrawShowForPlayer(playerid, Textdraw4);
TextDrawShowForPlayer(playerid, Textdraw5);
TextDrawShowForPlayer(playerid, Textdraw6);
TextDrawShowForPlayer(playerid, Textdraw7);
TextDrawShowForPlayer(playerid, Textdraw8);
TextDrawShowForPlayer(playerid, Textdraw9[playerid]);
TextDrawShowForPlayer(playerid, Textdraw10[playerid]);
TextDrawShowForPlayer(playerid, Textdraw11[playerid]);
TextDrawShowForPlayer(playerid, Textdraw12[playerid]);
TextDrawShowForPlayer(playerid, Textdraw13[playerid]);
TextDrawShowForPlayer(playerid, Textdraw14[playerid]);
TimerActualizarCarro[playerid] = SetTimerEx("ActualizarCarro", 300, true, "i", playerid);
}
Fiz um debug, e o no GetPlayerVelocity, todos os valores estгo a returnar 0... nгo sei o que se passa :/
Edit: acho que descubri o bug. O
GetPlayerVehicleID estб a pegar o ID do carro mal. O carro em que estou й o ID 1 e ele pega o ID 0.
Todos cegos aqui xD
GetPlayerVehicleID(vehicle);
era
GetPlayerVehicleID(playerid);