This Speedometer is broke.
#1

The speedometer I'm using works perfectly fine. One issue if a second player enters a vehicle the other players speedometer shows as well.
Thanks in Advance.

PHP код:
new Text:SpeedoText[MAX_PLAYERS]; 
(Under OnPlayerConnect)
PHP код:
SpeedoText[playerid] = TextDrawCreate(540.000000400.000000" ");
TextDrawAlignment(SpeedoText[playerid], 1);
TextDrawFont(SpeedoText[playerid],2);
TextDrawLetterSize(SpeedoText[playerid], 0.3101.400);
TextDrawSetShadow(SpeedoText[playerid],0);
TextDrawUseBox(SpeedoText[playerid], 0);
TextDrawBoxColor(SpeedoText[playerid], 0x00); 
(Under OnPlayerDisconnect)
PHP код:
TextDrawDestroy(SpeedoText[playerid]); 
PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
IsPlayerInAnyVehicle(playerid) && !IsBicycle(GetPlayerVehicleID(playerid)))
    {
        
TextDrawShowForPlayer(playeridSpeedoText[playerid]);
    }
    else
    {
        
TextDrawHideForPlayer(playeridSpeedoText[playerid]);
    } 
Reply
#2

PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
newstate == PLAY_STATE_DRIVER && !IsBicycle(GetPlayerVehicleID(playerid)))
    {
        
TextDrawShowForPlayer(playeridSpeedoText[playerid]);
    }
    else
    {
        
TextDrawHideForPlayer(playeridSpeedoText[playerid]);
    }
    return 
1;

Reply
#3

Quote:
Originally Posted by Juvanii
Посмотреть сообщение
PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
newstate == PLAY_STATE_DRIVER && !IsBicycle(GetPlayerVehicleID(playerid)))
    {
        
TextDrawShowForPlayer(playeridSpeedoText[playerid]);
    }
    else
    {
        
TextDrawHideForPlayer(playeridSpeedoText[playerid]);
    }
    return 
1;

Thanks but the Speedometer still shows up 2x when two players are inside of a vehicle at the same time.
Reply
#4

A few questions, why are you using TextDrawCreate to make a textdraw per player instead of CreatePlayerTextDraw, is the speedometer showing 2 times for the driver or the passenger and how exactly does the speedometer behave while there is 2 players inside of a vehicle?
Reply
#5

Quote:
Originally Posted by thefirestate
Посмотреть сообщение
A few questions, why are you using TextDrawCreate to make a textdraw per player instead of CreatePlayerTextDraw, is the speedometer showing 2 times for the driver of the passenger and how exactly does the speedometer behave while there is 2 players inside of a vehicle?
First of all, good question but I don't know (did not rly make this script this speedometer). When there is a passenger in the vehicle it also shows the speedometer twice.
What happens is that if I enter a vehicle my speedometer shows up But when for instance bobby enters a vehicle his speedometer overlaps mine.
Reply
#6

You're talking about 2 different vehicles, right? Let's say you enter your Bullet and you see normally working Speedo but then when Bobby enters his let's say Infernus you see the speedo showing information about the speed of the infernus or fuel or w/e info you're showing like you can see your speedo going 150 mph(which is the Infernus speed) while you stay still in the Bullet?
Reply
#7

Quote:
Originally Posted by thefirestate
Посмотреть сообщение
You're talking about 2 different vehicles, right? Let's say you enter your Bullet and you see normally working Speedo but then when Bobby enters his let's say Infernus you see the speedo showing information about the speed of the infernus or fuel or w/e info you're showing like you can see your speedo going 150 mph(which is the Infernus speed) while you stay still in the Bullet?
exactly.
Reply
#8

Right, this speedo's speed is update via OnPlayerUpdate or a Timer, can you give me this timer/OnPlayerUpdate code?
Reply
#9

Quote:
Originally Posted by thefirestate
Посмотреть сообщение
Right, this speedo's speed is update via OnPlayerUpdate or a Timer, can you give me this timer/OnPlayerUpdate code?
It's a Timer.

PHP код:
forward Speedometer();
public 
Speedometer()
{
    new 
vehicleidFloat:health;
    new 
fstring[32], string[512];
    foreach (new 
Player)
    {
        if(
IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
        {
            
vehicleid GetPlayerVehicleID(i);
            
GetVehicleHealth(vehicleidhealth);
            
string "~w~";
            
strcat(string"~w~~h~fuel: ~g~"sizeof(string));
            
fstring "iiiiiiiiii";
            if(
VehicleInfo[vehicleid][eVehicleFuel] > 100.0strins(fstring"~r~"10sizeof(fstring));
            else if(
VehicleInfo[vehicleid][eVehicleFuel] < 0.0strins(fstring"~r~"0sizeof(fstring));
            else 
strins(fstring"~r~"floatround(VehicleInfo[vehicleid][eVehicleFuel]/10.0), sizeof(fstring));
            
strcat(stringfstringsizeof(string));
            
strcat(string"~n~~w~~h~"sizeof(string));
            if(
GetPVarInt(i"Speedo")) format(fstring,sizeof(fstring),"mph: ~w~%d"GetPlayerSpeed(ifalse));
            else 
format(fstring,sizeof(fstring),"kph: ~w~%d"GetPlayerSpeed(itrue));
            
strcat(stringfstringsizeof(string));
            
TextDrawSetString(SpeedoText[i], string);
        }
    }

Reply
#10

I guess you are showing the speedometer to passengers too.
Check if players are passengers before showing the speedometer


pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && !IsBicycle(GetPlayerVehicleID(playerid)))
    {
        TextDrawShowForPlayer(playerid, SpeedoText[playerid]);
    }
    else
    {
        TextDrawHideForPlayer(playerid, SpeedoText[playerid]);
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)