PDA

Просмотр полной версии : [Вопрос] Спидометр(нет отображения)



Nurick
11.06.2016, 02:17
Делал спидометр, но нет никакого отображения, то есть сажусь в транспорт выводит TextDraw спидометра но функция SpeedVehicle( playerid ) не хочет отображаться


new speedometer_timer[ MAX_PLAYERS ];


if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
{
for( new sr; sr != sizeof( speedometer ); sr++ ) PlayerTextDrawShow( playerid, speedometer[ playerid ][ sr ] );
speedometer_timer[ playerid ] = SetTimerEx( "SpeedometerUpdatePlayer", 100, true, "i", playerid );
}
else
{
for( new sr; sr != sizeof( speedometer ); sr++ ) PlayerTextDrawHide( playerid, speedometer[ playerid ][ sr ] );
KillTimer( speedometer_timer[ playerid ] );
}


forward SpeedometerUpdatePlayer( playerid );

public SpeedometerUpdatePlayer( playerid )
{
switch( SpeedVehicle( playerid ) )
{
case 0 .. 1: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIII" );
case 2 .. 20: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~III" );
case 21 .. 40: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~IIIIII" );
case 41 .. 60: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~IIIIIIIII" );
case 61 .. 80: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~IIIIIIIII~y~III" );
case 81 .. 100: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~IIIIIIIII~y~IIIIII" );
case 101 .. 120: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~IIIIIIIII~y~IIIIIIIII" );
case 121 .. 140: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~IIIIIIIII~y~IIIIIIIII~r~III" );
case 141 .. 160: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~IIIIIIIII~y~IIIIIIIII~r~IIIIII" );
case 161 .. 180: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~IIIIIIIII~y~IIIIIIIII~r~IIIIIIIII" );
case 181 .. 195: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~IIIIIIIII~y~IIIIIIIII~r~IIIIIIIIIIIII" );
}
}


stock SpeedVehicle( playerid )
{
new Float: Velocity[ 3 ];
if( IsPlayerInAnyVehicle( playerid ) ) GetVehicleVelocity( GetPlayerVehicleID( playerid ), Velocity[ 0 ], Velocity[ 1 ], Velocity[ 2 ] );
else GetVehicleVelocity( playerid, Velocity[ 0 ], Velocity[ 1 ], Velocity[ 2 ] );
return floatround( floatsqroot( ( Velocity[ 0 ] * Velocity[ 0 ] ) + ( Velocity[ 1 ] * Velocity[ 1 ] ) + ( Velocity[ 2 ] * Velocity[ 2 ] ) ) * 195 );
}

L0ndl3m
11.06.2016, 11:00
GetVehicleVelocity( playerid, Velocity[ 0 ], Velocity[ 1 ], Velocity[ 2 ] );
???

- - - Добавлено - - -


if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
на

if (newstate == PLAYER_STATE_DRIVER )

И вместо else:

else if (oldstate == PLAYER_STATE_DRIVER)

Nurick
13.06.2016, 18:12
Всё равно такой же эффект, сажусь в ТС открываются все боксы спидометра но не функционирует stock SpeedVehicle( playerid )
Нет отображения этого индикатора:

switch( SpeedVehicle( playerid ) )
{
case 0 .. 1: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIII" );
case 2 .. 20: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~III" );
case 21 .. 40: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~IIIIII" );
case 41 .. 60: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~IIIIIIIII" );
case 61 .. 80: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~IIIIIIIII~y~III" );
case 81 .. 100: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~IIIIIIIII~y~IIIIII" );
case 101 .. 120: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~IIIIIIIII~y~IIIIIIIII" );
case 121 .. 140: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~IIIIIIIII~y~IIIIIIIII~r~III" );
case 141 .. 160: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~IIIIIIIII~y~IIIIIIIII~r~IIIIII" );
case 161 .. 180: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~IIIIIIIII~y~IIIIIIIII~r~IIIIIIIII" );
case 181 .. 195: PlayerTextDrawSetString( playerid, speedometer[ playerid ][ 1 ], "~g~IIIIIIIII~y~IIIIIIIII~r~IIIIIIIIIIIII" );
}


speedometer[ playerid ][ 1 ] = CreatePlayerTextDraw( playerid, 449.375000, 354.083312, "_" );
PlayerTextDrawLetterSize( playerid, speedometer[ playerid ][ 1 ], 0.449999, 1.600000 );
PlayerTextDrawTextSize( playerid, speedometer[ playerid ][ 1 ], 618.750000, -6.416663 );
PlayerTextDrawColor( playerid, speedometer[ playerid ][ 1 ], 0x000000AA );
PlayerTextDrawFont( playerid, speedometer[ playerid ][ 1 ], 2 );
PlayerTextDrawAlignment( playerid, speedometer[ playerid ][ 1 ], 1 );
PlayerTextDrawUseBox( playerid, speedometer[ playerid ][ 1 ], 1 );
PlayerTextDrawBoxColor( playerid, speedometer[ playerid ][ 1 ], 0x15171980 );
PlayerTextDrawSetShadow( playerid, speedometer[ playerid ][ 1 ], 0 );

- - - Добавлено - - -

http://s008.radikal.ru/i306/1606/f3/7f80aa5c2a29.png

Nurick
14.06.2016, 02:00
Задам тут же вопрос, вообще правильная формула скорости? или не правильна подсчитана она у меня:

stock SpeedVehicle( playerid )
{
new Float: Velocity[ 3 ], vehicleid = GetPlayerVehicleID( playerid );
if( IsPlayerInAnyVehicle( playerid ) )
{
GetVehicleVelocity( vehicleid, Velocity[ 0 ], Velocity[ 1 ], Velocity[ 2 ] );
}
return floatround( floatsqroot( ( Velocity[ 0 ] * Velocity[ 0 ] ) + ( Velocity[ 1 ] * Velocity[ 1 ] ) + ( Velocity[ 2 ] * Velocity[ 2 ] ) ) * 195 );
}