How to solve my speedometer problem ?
#1

Hi,
I have a problem,
ID 0 sees the speedo perfectly, but ID 1 sees in double, ID 3 in triple, etc..

Here the ID 5 screenshot for example:
http://www.noelshack.com/2012-21-133...-sa-mp-094.png

Here my script:

IN THE TOP:
pawn Код:
new PlayerText:speedo[MAX_PLAYERS][6];
the array [6] is for some decor of my speedo

The Timer:
pawn Код:
public Speedometer()
{
    new fstring[32], string[512];

    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
        {
           

                      // I have other stuff here, but i have comment them
            format(fstring,sizeof(fstring),"~n~Km/h: ~w~%d", GetPlayerSpeed(i, true));
            strcat(string, fstring, sizeof(string));
           

            PlayerTextDrawSetString(i, speedo[i][5], string);
        }
    }
}
Under OnPlayerConnect I create textdraw for player:
pawn Код:
speedo[playerid][5] = CreatePlayerTextDraw(playerid,436.000000, 319.000000, " ");
        PlayerTextDrawBackgroundColor(playerid,speedo[playerid][5], 255);
        PlayerTextDrawFont(playerid,speedo[playerid][5], 1);
        PlayerTextDrawLetterSize(playerid,speedo[playerid][5], 0.470000, 1.400000);
        PlayerTextDrawColor(playerid,speedo[playerid][5], -1);
        PlayerTextDrawSetOutline(playerid,speedo[playerid][5], 0);
        PlayerTextDrawSetProportional(playerid,speedo[playerid][5], 1);
        PlayerTextDrawSetShadow(playerid,speedo[playerid][5], 1);

What's wrong please ?

Thanks and Have a nice day
Reply
#2

Download the latest version of sscanf, and then re-compile your script.



Код:
This forum requires that you wait 120 seconds between posts. Please try again in 39 seconds.
lame
Reply
#3

i don't use sscanf -_-
Reply
#4

Then use it.
Reply
#5

Reply
#6

I had this problem, but no speedometer, just listen to me. It might be fixed. (Make sure to install the latest version)
Reply
#7

You use strcat what will add all players their speedometer speeds untill it reached the playerid it has to show. You should try strmid instead of strcat, I think that will help..

Best regards,
Jesse

EDIT:
Actually, try this:
pawn Код:
public Speedometer()
{
    new string[512];
    for(new i=0; i < MAX_PLAYERS; i++)
        {
        if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
            {
            format(string,sizeof(string),"~n~Km/h: ~w~%d", GetPlayerSpeed(i, true));
            PlayerTextDrawSetString(i, speedo[i][5], string);
            }
        }
}
In my eyes just that should do the trick.
Reply
#8

doesn't work, even with the latest version... :/
Reply
#9

here my complete code:
pawn Код:
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
        {
           
            vehicleid = GetPlayerVehicleID(i);
            GetVehicleHealth(vehicleid, health);
            GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
           
            strcat(string, , sizeof(string));
           
            strcat(string, "~b~~h~GPS: ~w~", sizeof(string));
            strcat(string, GetPlayer3DZone(i), sizeof(string));
           
            strcat(string, "~n~~b~~h~Vie: ~n~ ~g~", sizeof(string));
            fstring = "||||||||||";
            if(health > 1000.0) strins(fstring, "~r~", 10, sizeof(fstring));
            else if(health < 0.0) strins(fstring, "~r~", 0, sizeof(fstring));
            else strins(fstring, "~r~", floatround(health/100.0), sizeof(fstring));
            strcat(string, fstring, sizeof(string));
           
            strcat(string, "~n~~b~~h~Essence:~n~ ~g~", sizeof(string));
            fstring = "||||||||||";
            if(Fuel[vehicleid] > 100.0) strins(fstring, "~r~", 10, sizeof(fstring));
            else if(Fuel[vehicleid] < 0.0) strins(fstring, "~r~", 0, sizeof(fstring));
            else strins(fstring, "~r~", floatround(Fuel[vehicleid]/10.0), sizeof(fstring));
            strcat(string, fstring, sizeof(string));
           
            strcat(string, "        ~b~~h~", sizeof(string));
            format(fstring,sizeof(fstring),"~n~Km/h: ~w~%d", GetPlayerSpeed(i, true));
            strcat(string, fstring, sizeof(string));
           
            strcat(string, "~n~~b~~h~Moteur: ", sizeof(string));
            if(engine == 1) strcat(string, "~g~on", sizeof(string));
            else strcat(string, "~r~off", sizeof(string));
           
            strcat(string, "        ~b~~h~alarme: ", sizeof(string));
            if(VehicleSecurity[vehicleid] == 1) strcat(string, "~g~on", sizeof(string));
            else strcat(string, "~r~off", sizeof(string));
           
            strcat(string, "        ~b~~h~Porte: ", sizeof(string));
            if(doors == 1) strcat(string, "~r~fermee", sizeof(string));
            else strcat(string, "~g~Ouverte", sizeof(string));
           
           
            PlayerTextDrawSetString(i, speedo[i][5], string);
        }
how to ?
Reply
#10

I had a similar problem, but i fixed it by getting a new speedo
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)