SA-MP Forums

Go Back   SA-MP Forums > Non-English > Languages > Português/Portuguese

Reply
 
Thread Tools Display Modes
Old 11/08/2012, 03:20 PM   #1
Quazar
Little Clucker
 
Join Date: Aug 2012
Posts: 19
Reputation: 0
Default Velocimetro bugado

O velocimetro fica mostrando a velocidade assim -18949779 KM/H O.O

O certo seria a velocidade.. tipo. 100 KM/H .-.

Code:
public OnPlayerUpdate(playerid)
{
	if(IsPlayerInAnyVehicle(playerid))
	{
		new string[50], carid = GetPlayerVehicleID(playerid);
		GetVehicleVelocity(carid, velokm[0], velokm[1], velokm[2]);

	    TextDrawShowForPlayer(playerid, Textdraw4);
	    TextDrawShowForPlayer(playerid, Textdraw6);

		format(string, sizeof(string), "~p~Gasolina: ~w~%i", gss[playerid]);
		TextDrawSetString(Textdraw4, string);
		
	    new Float: Velocity[3];
		GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]);
		
		format(string, sizeof(string), "~p~Velocidade: ~w~%d KM/H", Velocity[0], Velocity[1], Velocity[2]);
		TextDrawSetString(Textdraw6, string);

		if(floatround(((floatsqroot(((velokm[0] * velokm[0]) + (velokm[1] * velokm[1]) + (velokm[2] * velokm[2]))) * (170.0))) * 1) > 5)
		{
		    if(gss[playerid] == 0 && Avisado[playerid] == false)
		    {
				SendClientMessage(playerid, COR_ERRO, "- Sua gasolina acabou, você pode chamar um Frentista, Guicho ou ir até o posto mais próximo e abastecer.");
				TogglePlayerControllable(playerid, false);
				Avisado[playerid] = true;
		    }
		    if(gss[playerid] > 0)
		    {
		        Retirada[playerid] += 1;
		        if(Retirada[playerid] >= (RETIRAR_KM*13))
		        {
		            gss[playerid]--;
		            TogglePlayerControllable(playerid, true);
		            Retirada[playerid] = 0;
		            Avisado[playerid] = false;
		        }
		    }
		}
	}
	return 1;
}
Quazar is offline   Reply With Quote
Old 11/08/2012, 04:08 PM   #2
Delay
Huge Clucker
 
Delay's Avatar
 
Join Date: Aug 2012
Location: Três Lagoas -MS
Posts: 217
Reputation: 19
Default Re: Velocimetro bugado

[email protected] cara desculpe era pra te postado em otro local, topico erado confundi *-*
__________________
Plugin Streamer 2.6.1


Last edited by Delay; 11/08/2012 at 04:39 PM.
Delay is offline   Reply With Quote
Old 11/08/2012, 04:11 PM   #3
Quazar
Little Clucker
 
Join Date: Aug 2012
Posts: 19
Reputation: 0
Default Re: Velocimetro bugado

Amigo, o meu código é um velocimetro, não um radar..

Preciso saber o que á de errado, que mostra -179848 KM/H ao invéz da velocidade real.
Quazar is offline   Reply With Quote
Old 11/08/2012, 11:22 PM   #4
Prompt
Little Clucker
 
Join Date: Jun 2012
Posts: 13
Reputation: 0
Default Re: Velocimetro bugado

'-' ao inves de
Code:
format(string, sizeof(string), "~p~Velocidade: ~w~%d KM/H", Velocity[0], Velocity[1], Velocity[2]);
Use
Code:
format(string, sizeof(string),"~p~Velocidade: ~w~%d KM/H",GetVehicleVelocity(i, true));
Antes disso no inicio do velocimetro coloca for(new i=0; i<MAX_PLAYERS; i++)
Prompt is offline   Reply With Quote
Old 12/08/2012, 07:34 AM   #5
Quazar
Little Clucker
 
Join Date: Aug 2012
Posts: 19
Reputation: 0
Default Re: Velocimetro bugado

Deu erro de argumentos..
Quazar is offline   Reply With Quote
Old 12/08/2012, 01:56 PM   #6
paulor
High-roller
 
Join Date: Nov 2011
Location: Brasil
Posts: 3,117
Reputation: 222
Default Re: Velocimetro bugado

Code:
format(string, sizeof(string), "~p~Velocidade: ~w~%i KM/H", ((floatround(floatsqroot(Velocity[0]*Velocity[0] + Velocity[1]*Velocity[1] + Velocity[2]*Velocity[2]) * 180 / 3.6))/1000));
__________________
[IMG]https://sites.******.com/site/facesbypaulo/MetropoleGames.png[/IMG]
paulor is offline   Reply With Quote
Old 12/08/2012, 02:17 PM   #7
Quazar
Little Clucker
 
Join Date: Aug 2012
Posts: 19
Reputation: 0
Default Re: Velocimetro bugado

Agora o velocimetro não atualiza...
Quazar is offline   Reply With Quote
Old 12/08/2012, 03:42 PM   #8
paulor
High-roller
 
Join Date: Nov 2011
Location: Brasil
Posts: 3,117
Reputation: 222
Default Re: Velocimetro bugado

Quote:
Originally Posted by Quazar View Post
Agora o velocimetro não atualiza...
Pq vc está utilizando no OnPlayerUpdate, esse calculo que postei é para um Timer de 1 segundo...
__________________
[IMG]https://sites.******.com/site/facesbypaulo/MetropoleGames.png[/IMG]
paulor is offline   Reply With Quote
Old 12/08/2012, 04:19 PM   #9
Quazar
Little Clucker
 
Join Date: Aug 2012
Posts: 19
Reputation: 0
Default Re: Velocimetro bugado

Continua não atualizando..

Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	Timer_Velocimetro = SetTimerEx("AttVelocimetro", 1000, true, "is", -1, -1);
	return 1;
}

public OnPlayerUpdate(playerid)
{
	if(IsPlayerInAnyVehicle(playerid))
	{
	    TextDrawShowForPlayer(playerid, Textdraw6);
	}
	else
	{
		TextDrawHideForPlayer(playerid, Textdraw6);
	}
	return 1;
}

forward AttVelocimetro(playerid);
public AttVelocimetro(playerid)
{
    new Float: Velocity[3];
	GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]);

	new string[128];

	format(string, sizeof(string), "~p~Velocidade: ~w~%i KM/H", ((floatround(floatsqroot(Velocity[0]*Velocity[0] + Velocity[1]*Velocity[1] + Velocity[2]*Velocity[2]) * 180 / 3.6))/1000));
	TextDrawSetString(Textdraw6, string);
	return 1;
}
Quazar is offline   Reply With Quote
Old 12/08/2012, 08:55 PM   #10
paulor
High-roller
 
Join Date: Nov 2011
Location: Brasil
Posts: 3,117
Reputation: 222
Default Re: Velocimetro bugado

Tbm que bosta tu fez ai ? LaL.

Code:
public OnPlayerStateChange(playerid, newstate, oldstate) {
	if(newstate == PLAYER_STATE_DRIVER) SetTimerEx("AttVelocimetro", 1000, false, "i", playerid);
    return 1;
}

forward AttVelocimetro(playerid);
public AttVelocimetro(playerid) {
	TextDrawHideForPlayer(playerid, Textdraw6);
	if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
		new Float: Velocity[3];
		GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]);

		new string[128];
		format(string, sizeof(string), "~p~Velocidade: ~w~%i KM/H", ((floatround(floatsqroot(Velocity[0]*Velocity[0] + Velocity[1]*Velocity[1] + Velocity[2]*Velocity[2]) * 180 / 3.6))/1000));
		TextDrawSetString(Textdraw6, string);
		TextDrawShowForPlayer(playerid, Textdraw6);
		SetTimerEx("AttVelocimetro", 1000, false, "i", playerid)
	}
    return 1;
}
__________________
[IMG]https://sites.******.com/site/facesbypaulo/MetropoleGames.png[/IMG]
paulor is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Ajuda] Velocimetro bugado! Arthenry Português/Portuguese 10 26/07/2012 12:00 PM
[AJUDA]Velocimetro BUGADO gugujim Português/Portuguese 4 29/07/2011 10:40 PM
[Ajuda] Meu velocimetro tah bugado! Lucas_ Português/Portuguese 7 04/04/2011 06:41 PM


All times are GMT. The time now is 11:49 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.