SA-MP Forums Archive
[Pedido] Velocimetro - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Pedido] Velocimetro (/showthread.php?tid=298265)



[Pedido] Velocimetro - Laercio - 20.11.2011

Queria um Velocimetro , que marcase somente a Velocidade do carro/moto/aviгo/helicoptero , Se possivel , passa ai , Tentei achar no Search , mas achei so completo mas eu quero um que Registre somente a velocidade do veiculo


Re: [Pedido] - Pharrel - 20.11.2011

Crie o textdraw do jeito q vc quiser e use este codigo q acabei de fazer,

Vc sу vai precisar salvar o textdraw na variavel TextdrawSpeedometer.

pawn Код:
new Iterator:Driver<MAXPLAYERS>;//topo do GM
new Text:TextdrawSpeedometer;
forward SpeedometerUpdate

//ongamemodeinit
SetTimer("SpeedometerUpdate", TEMPO Q VC QUISER, true);

//public OnPlayerStateChange
    if(newstate == PLAYER_STATE_DRIVER)
    {
        Iter_Add(Driver, playerid);
        TextDrawSetString(TextdrawSpeedometer, "000");
        TextDrawShowForPlayer(playerid, TextdrawSpeedometer);
    }
    else if(oldstate == PLAYER_STATE_DRIVER)
    {
        Iter_Remove(Driver, playerid);
        TextDrawHideForPlayer(playerid, TextdrawSpeedometer);
    }

public SpeedometerUpdate()
{
    new pharrel[5];
    foreach(Driver, i)
    {
        if(!IsPlayerConnected(i)) Iter_Remove(Driver, i);
        format(pharrel, 4, "%03d", floatround(GetVehicleSpeed(GetPlayerVehicleID(playerid)]));
        TextDrawSetString(TextdrawSpeedometer, pharrel);
    }
    return 1;
}

stock Float:GetVehicleSpeed(vehicleid)
{
    new Float:speed_x,Float:speed_y,Float:speed_z,Float:temp_speed;
    GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
    temp_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*136.666667;
    floatround(temp_speed,floatround_round); return temp_speed;
}
VAI PRECISAR DA INCLUDE FOREACH!



Re: [Pedido] - Lуs - 21.11.2011

Quote:
Originally Posted by Pharrel
Посмотреть сообщение
Crie o textdraw do jeito q vc quiser e use este codigo q acabei de fazer,

Vc sу vai precisar salvar o textdraw na variavel TextdrawSpeedometer.

pawn Код:
new Iterator:Driver<MAXPLAYERS>;//topo do GM
new Text:TextdrawSpeedometer;
forward SpeedometerUpdate

//ongamemodeinit
SetTimer("SpeedometerUpdate", TEMPO Q VC QUISER, true);

//public OnPlayerStateChange
    if(newstate == PLAYER_STATE_DRIVER)
    {
        Iter_Add(Driver, playerid);
        TextDrawSetString(TextdrawSpeedometer, "000");
        TextDrawShowForPlayer(playerid, TextdrawSpeedometer);
    }
    else if(oldstate == PLAYER_STATE_DRIVER)
    {
        Iter_Remove(Driver, playerid);
        TextDrawHideForPlayer(playerid, TextdrawSpeedometer);
    }

public SpeedometerUpdate()
{
    new pharrel[5];
    foreach(Driver, i)
    {
        if(!IsPlayerConnected(i)) Iter_Remove(Driver, i);
        format(pharrel, 4, "%03d", floatround(GetVehicleSpeed(GetPlayerVehicleID(playerid)]));
        TextDrawSetString(TextdrawSpeedometer, pharrel);
    }
    return 1;
}

stock Float:GetVehicleSpeed(vehicleid)
{
    new Float:speed_x,Float:speed_y,Float:speed_z,Float:temp_speed;
    GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
    temp_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*136.666667;
    floatround(temp_speed,floatround_round); return temp_speed;
}
VAI PRECISAR DA INCLUDE FOREACH!
Obrigado cara, aprendi sobre Iter_Add e Iter_Remove, й como se fosse uma vбriavel, sу que para foreach, ele seta a variбvel para cada player que entrar em um veнculo e faz o loop somente nos players que tem esse variбvel, vlw. REPpatu


Re: [Pedido] - Pharrel - 21.11.2011

Quote:
Originally Posted by Los
Посмотреть сообщение
Obrigado cara, aprendi sobre Iter_Add e Iter_Remove, й como se fosse uma vбriavel, sу que para foreach, ele seta a variбvel para cada player que entrar em um veнculo e faz o loop somente nos players que tem esse variбvel, vlw. REPpatu
o_O

vlw