Fuel And Speedometer [Help]
#1

Hi friends!
i have a problem with my fuel and speedometer textdraws
when a player seat in a vehicle it will work good but when when two players drive in same time fuel meter and speedometer will start blinking!
PHP код:
    // Fuelmeter
    
fuelmeter TextDrawCreate(200.000000432.000000"Fuel:");
    
TextDrawBackgroundColor(fuelmeter255);
    
TextDrawFont(fuelmeter1);
    
TextDrawLetterSize(fuelmeter0.5000001.000000);
    
TextDrawColor(fuelmeter16777215);
    
TextDrawSetOutline(fuelmeter0);
    
TextDrawSetProportional(fuelmeter1);
    
TextDrawSetShadow(fuelmeter1);
    
TextDrawSetSelectable(fuelmeter0);
    
// Speedometer
    
speedometer TextDrawCreate(301.000000432.000000"MPH:");
    
TextDrawBackgroundColor(speedometer255);
    
TextDrawFont(speedometer1);
    
TextDrawLetterSize(speedometer0.5000001.000000);
    
TextDrawColor(speedometer16777215);
    
TextDrawSetOutline(speedometer0);
    
TextDrawSetProportional(speedometer1);
    
TextDrawSetShadow(speedometer1);
    
TextDrawSetSelectable(speedometer0); 
i put it under onplayerupdate
PHP код:
        if(Speedo[playerid] && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new 
string[64], speed GetVehicleSpeed(GetPlayerVehicleID(playerid), 0);
            
format(string,sizeof(string),"MPH: %d"speed);
            
TextDrawSetString(speedometerstring);
        }
        if(
fMeter[playerid] && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new 
string[64];
               
format(string,sizeof(string),"Fuel: %d%"Fuel[GetPlayerVehicleID(playerid)]);
            
TextDrawSetString(fuelmeterstring);
        } 
and put it under onplayerstatechange
PHP код:
    if(newstate == PLAYER_STATE_DRIVER)
    {
     
fMeter[playerid] =1;
     
Speedo[playerid] = 1;
     
TextDrawShowForPlayer(playerid,speedometer);
     
TextDrawShowForPlayer(playerid,fuelmeter);
    } 
Help for +rep
Reply
#2

It's because you used normal (global) textdraws.
Use player textdraws instead.

You have only one textdraw for fuel and one for the speed.
That's only 2 textdraws in total for 50 players.
And you're updating (overwriting) the text on it for each player, while the same textdraw is shown for everyone.

Each player needs his own textdraw, which is only visible by himself.
Reply
#3

Quote:
Originally Posted by PowerPC603
Посмотреть сообщение
It's because you used normal (global) textdraws.
Use player textdraws instead.

You have only one textdraw for fuel and one for the speed.
That's only 2 textdraws in total for 50 players.
And you're updating (overwriting) the text on it for each player, while the same textdraw is shown for everyone.

Each player needs his own textdraw, which is only visible by himself.
thanks so much +REP
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)