Szerző Téma: progressbar  (Megtekintve 450 alkalommal)

Nem elérhető sGx

progressbar
« Dátum: 2012. június 23. - 09:55:10 »
0 Show voters
Helló.
Valaki meg tudná nekem csinálni ezt a scriptet taxtdraw helyett progressbarosra?
 
//********************* [ Credits ] ******************************************//
/*
      Car Fuel Script by Cameltoe
              Version 1.3
             
I do not demand to keep the credits but it is appreciated.
*/
//******************** [ Includes ] ******************************************//
#include <a_samp>
#include <zcmd>
#include <progress>
//******************** [ Forwards ] ******************************************//
forward FuelDown(playerid);
//******************** [ Defines ] ******************************************//
// Vehicles
#undef MAX_VEHICLES
#define MAX_VEHICLES 50
// Fuel
#define REFUEL_COST 100
#define MAX_FUEL 100
#define FUEL_DECREASE 1
// Colors
#define COLOR_RED         0xFF000000
#define COLOR_YELLOW       0xFFFF0000
#define COLOR_BLUE          0x0000FF00
#define COLOR_GREEN       0x00FF0000
//******************** [ Enums ] *********************************************//
enum Car
{
Float:Fuel,
}
//******************** [ Symbols ] *******************************************//
new Carinfo[MAX_VEHICLES][Car];
new Text:FuelText[MAX_PLAYERS];
new FuelTimer[MAX_PLAYERS];
new Bar:vhealth2[MAX_PLAYERS] = {INVALID_BAR_ID, ...};
forward ProgressBar2();
//******************** [ Callbakcs ] *****************************************//
public OnFilterScriptInit()
{
printf(\"_____________________________________\");
printf(\"|                                   |\");
printf(\"|           Fuel FS v1.1            |\");
printf(\"|               By                  |\");
printf(\"|            Cameltoe               |\");
printf(\"|___________________________________|\");
for(new vehicleid; vehicleid < MAX_VEHICLES; vehicleid++)
{
Carinfo[vehicleid][Fuel] = MAX_FUEL;
}
SetTimer(\"ProgressBar2\", 500, 1);
return 1;
}
/*main()
{
printf(\"_____________________________________\");
printf(\"|                                   |\");
printf(\"|           Fuel FS v1.1            |\");
printf(\"|               By                  |\");
printf(\"|            Cameltoe               |\");
printf(\"|___________________________________|\");
for(new vehicleid; vehicleid < MAX_VEHICLES; vehicleid++)
{
Carinfo[vehicleid][Fuel] = MAX_FUEL;
}
return 1;
}*/
public OnPlayerConnect(playerid)
{
FuelText[playerid] = TextDrawCreate(450.0, 405.0,\"         \");
TextDrawHideForPlayer(playerid,FuelText[playerid]);
TextDrawAlignment(FuelText[playerid],0);
TextDrawSetProportional(FuelText[playerid],1);
TextDrawSetShadow(FuelText[playerid], 1);
TextDrawSetOutline(FuelText[playerid], 2);
TextDrawLetterSize(FuelText[playerid],0.60,2.0);
TextDrawFont(FuelText[playerid], 3);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
    TextDrawDestroy(FuelText[playerid]);
return 1;
}
 
public OnPlayerStateChange(playerid,newstate,oldstate)
{
if(oldstate == PLAYER_STATE_DRIVER)
    {
        DestroyProgressBar(vhealth2[playerid]);
        vhealth2[playerid] = INVALID_BAR_ID;
    }
    if(newstate == PLAYER_STATE_DRIVER)
    {
        vhealth2[playerid] = CreateProgressBar(144.00, 430.00, _, _, 0x0000FFFF, 1000.0);
        ShowProgressBarForPlayer(playerid, floatround(Carinfo[vehicleid][Fuel]));
    }
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
return 0;
}
//******************** [ Functions ] ********************************************//
public FuelDown(playerid)
{
new string[128];
new vehicleid = GetPlayerVehicleID(playerid);
if(IsPlayerInAnyVehicle(playerid))
{
if(floatround(Carinfo[vehicleid][Fuel]) <= 0 || Carinfo[vehicleid][Fuel] - GetPlayerSpeed(playerid) * FUEL_DECREASE / 100 < 0)
{
   format(string,sizeof(string),\"~g~ Fuel: ~w~ 0\");
   SendClientMessage(playerid, COLOR_RED, \"This vehicle has ran out of fuel\");
   KillTimer(FuelTimer[playerid]);
   ToggleVehicleEngine(vehicleid, false);
   TextDrawSetString(FuelText[playerid], string);
}
else
{
   Carinfo[vehicleid][Fuel] = Carinfo[vehicleid][Fuel] - GetPlayerSpeed(playerid) * FUEL_DECREASE / 100;
   format(string,sizeof(string),\"~g~ Fuel: ~w~ %d\", floatround(Carinfo[vehicleid][Fuel]));
   TextDrawSetString(FuelText[playerid], string);
}
}
else
{
format(string,sizeof(string),\"~g~ Fuel: ~w~ \");
KillTimer(FuelTimer[playerid]);
}
}
//******************** [ Stocks ] ********************************************//
stock ToggleVehicleEngine(vehicleid, bool: Mode)
{
    new engine,lights,alarm,doors,bonnet,boot,objective;
    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
    if(Mode == false) SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
    else SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective);
}
stock GetPlayerSpeed(playerid)
{
new Float:ST[4];
if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]); else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 180;
return floatround(ST[3]);
}
//******************** [ Commands ] ******************************************//
command(car, playerid, params[])
{
new Float:Pos[4]; GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]); GetPlayerFacingAngle(playerid, Pos[3]);
    new vehicleid = CreateVehicle(411, Pos[0], Pos[1], Pos[2], Pos[3], 0, 0, 60*10000);
    PutPlayerInVehicle(playerid, vehicleid, 0);
return 1;
}
command(money, playerid, params[])
{
GivePlayerMoney(playerid, 500);
return 1;
}
command(refuel, playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_YELLOW, \"You to be inside an vehicle to refuel it.\");
    if(GetPlayerMoney(playerid) < REFUEL_COST) return SendClientMessage(playerid, COLOR_YELLOW, \"You do not have enough money to refuel your vehicle.\");
Carinfo[GetPlayerVehicleID(playerid)][Fuel] = MAX_FUEL;
KillTimer(FuelTimer[playerid]);
ToggleVehicleEngine(GetPlayerVehicleID(playerid), true);
FuelTimer[playerid] = SetTimerEx(\"FuelDown\", 1000, true, \"i\", playerid); // Fueldown timer
GivePlayerMoney(playerid, -REFUEL_COST);
SendClientMessage(playerid, COLOR_YELLOW, \"You refueled your vehicle.\");
return 1;
}
public ProgressBar2() //I prefer not to use OnPlayerUpdate with textdraws
{
    for(new playerid; playerid < MAX_PLAYERS; playerid++) //I recommend foreach(Player, playerid)
    {
        new vehicleid;
        if((vehicleid = GetPlayerVehicleID(playerid)) && vhealth[playerid] != INVALID_BAR_ID)
        {
            new Float:health;
            GetVehicleHealth(vehicleid, health);
            SetProgressBarValue(floatround(Carinfo[vehicleid][Fuel]));
            UpdateProgressBar(floatround(Carinfo[vehicleid][Fuel]), playerid);
        }
    }
}

 
Nagyon hálás lennék érte :)

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal