SA-MP Forums Archive
Speedo help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Speedo help (/showthread.php?tid=469356)



Speedo help - TonyII - 12.10.2013

Hey, I just created this speedo and it isn't working like it should, the fuel doesn't update and it wont hide when I get out of the vehicle, here is the code.
pawn Код:
public SpeedoUpdate()
{
    for(new i = 0;i<MAX_PLAYERS;i++)
    {
        if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
        {
            if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
            {
            fuelbar[i] = CreateProgressBar(511.00, 317.00, 86.50, 3.20, 0x33AA33FF, 100.0);
            new Float:x,Float:y,Float:z,string[24],vehicleid = GetPlayerVehicleID(i);
            ShowProgressBarForPlayer(i,fuelbar[i]);
            TextDrawShowForPlayer(i,Box[i]);
            TextDrawShowForPlayer(i,Speed[i]);
            TextDrawShowForPlayer(i,Full[i]);
            TextDrawShowForPlayer(i,Empty[i]);
            TextDrawShowForPlayer(i,Status[i]);
            GetVehicleVelocity(vehicleid,x,y,z);
            format(string,sizeof(string),"MPH: %d",floatround(floatsqroot(((x*x)+(y*y))+(z*z))*156.666667));
            TextDrawSetString(Speed[i],string);
            SetProgressBarValue(Fuel[vehicleid], fuelbar[i]);
            UpdateProgressBar(fuelbar[i], i);
            }
            else
            {
            //HideProgressBarForPlayer(i,fuelbar[i]);
            TextDrawHideForPlayer(i,Box[i]);
            TextDrawHideForPlayer(i,Speed[i]);
            TextDrawHideForPlayer(i,Full[i]);
            TextDrawHideForPlayer(i,Empty[i]);
            TextDrawHideForPlayer(i,Status[i]);
            }
        }
    }
    return 1;
}
//Under OnGameModeInit I set the timer