PDA

View Full Version : Progress Bar Problem


Jakwob
31/07/2015, 03:34 PM
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:

#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;
}

AlexBlack
31/07/2015, 03:41 PM
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.

Jakwob
01/08/2015, 09:08 AM
That didnt work.

Mariciuc223
01/08/2015, 09:19 AM
I found that on wiki , try with it (I'm not sure how it works)

Click me (https://wiki.sa-mp.com/wiki/OnVehicleDamageStatusUpdate)

jamesbond007
01/08/2015, 11:14 AM
- delete