SA-MP Forums Archive
Progress Bar Problem - 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: Progress Bar Problem (/showthread.php?tid=583848)



Progress Bar Problem - Jakwob - 31.07.2015

Hey guys im making a Progress bar for my server that will be identical to the health bar, the only problem is it wont update and stays at a solid position. if you could help it would be most appreciated.

Here is my entire code:
pawn Code:
#include <a_samp>
#include <progress2>

new PlayerBar:vbar;
new VBTimer[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    vbar = CreatePlayerProgressBar(playerid, 320.0, 240.0, 55.5, 3.2, 0xFF0000FF, 100.0, BAR_DIRECTION_DOWN);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    DestroyPlayerProgressBar(playerid, vbar);
    KillTimer(VBTimer[playerid]);
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_DRIVER) // Exiting a vehicle.
    {
        HidePlayerProgressBar(playerid, vbar); // Hide the progress bar when a player exits the vehicle.
        KillTimer(VBTimer[playerid]);
    }
    if(newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT) // Getting into a vehicle.
    {
        new Float:vhealth;
        new veh = GetPlayerVehicleID(playerid);
        GetVehicleHealth(veh, vhealth);
        ShowPlayerProgressBar(playerid, vbar); // Show the progress bar when a player enters the vehicle.
        SetPlayerProgressBarValue(playerid, vbar, vhealth);
        VBTimer[playerid] = SetTimerEx("UpdateVehicleBar", 1000, true, "i", playerid);
    }
    if(newstate == PLAYER_STATE_WASTED && oldstate == PLAYER_STATE_DRIVER) // Dying in a vehcile.
    {
        HidePlayerProgressBar(playerid, vbar); // Hide the progress bar if the player dies in a vehicle.
        KillTimer(VBTimer[playerid]);
    }
    return 1;
}

forward UpdateVehicleBar(playerid);
public UpdateVehicleBar(playerid)
{
    new Float:vhealth;
    new veh = GetPlayerVehicleID(playerid);
    GetVehicleHealth(veh, vhealth);
    SetPlayerProgressBarValue(playerid, vbar, vhealth);
    return 1;
}



Re : Progress Bar Problem - AlexBlack - 31.07.2015

vbar = CreatePlayerProgressBar(playerid, 320.0, 240.0, 55.5, 3.2, 0xFF0000FF, 100.0, BAR_DIRECTION_DOWN);

Vehicle Health max value is 1000 i think.


Re: Progress Bar Problem - Jakwob - 01.08.2015

That didnt work.


Re: Progress Bar Problem - Mariciuc223 - 01.08.2015

I found that on wiki , try with it (I'm not sure how it works)

Click me


Re: Progress Bar Problem - jamesbond007 - 01.08.2015

- delete