Jump to content

Question

Posted

Buna ziua am si eu un gen de Speedometer si numi merge fuelul ma puteti ajuta oare ce am gresit?

[pawn]#undef MAX_PLAYERS

#define MAX_PLAYERS 500 //You must enter here the number of slots to optimize loops.

new Text:bg_speedo;

new Text:speedo_txd;

new Text:speedo_fuel[MAX_PLAYERS];

new Text:speedo_vel[MAX_PLAYERS];

new checkgastimer;

#define GasMax 100

#define RunOutTime 15000

#define RefuelWait 5000

#define CAR_AMOUNT 700 //Change to Your Vehicle Amount

new Gas[CAR_AMOUNT];

new NoFuel[MAX_PLAYERS];

new gGas[MAX_PLAYERS];

forward IsAPlane(carid);

new speedo_color[5] = {

    0xffffffff, 0x00ffffff, 0xff00ffff, 0xffff00ff, 0x0000ffff

};

public OnFilterScriptInit()

{

bg_speedo = TextDrawCreate(547.000000, 365.000000, "_~n~_~n~_~n~_~n~_~n~_~n~");

TextDrawBackgroundColor(bg_speedo, 255);

TextDrawFont(bg_speedo, 1);

TextDrawLetterSize(bg_speedo, 0.500000, 1.000000);

TextDrawColor(bg_speedo, -1);

TextDrawSetOutline(bg_speedo, 0);

TextDrawSetProportional(bg_speedo, 1);

TextDrawSetShadow(bg_speedo, 1);

TextDrawUseBox(bg_speedo, 1);

TextDrawBoxColor(bg_speedo, 255);

TextDrawTextSize(bg_speedo, 610.000000, 110.000000);

speedo_txd = TextDrawCreate(530.000000, 342.000000, "samaps:mspmeter");

TextDrawBackgroundColor(speedo_txd, 255);

TextDrawFont(speedo_txd, 4);

TextDrawLetterSize(speedo_txd, 0.500000, 1.000000);

TextDrawColor(speedo_txd, 16777215);

TextDrawSetOutline(speedo_txd, 0);

TextDrawSetProportional(speedo_txd, 1);

TextDrawSetShadow(speedo_txd, 1);

TextDrawUseBox(speedo_txd, 1);

TextDrawBoxColor(speedo_txd, 255);

TextDrawTextSize(speedo_txd, 100.000000, 100.000000);

for(new i=0; i< MAX_PLAYERS; i++)

{

speedo_fuel = TextDrawCreate(564.000000, 376.000000, "100");

TextDrawBackgroundColor(speedo_fuel, 255);

TextDrawFont(speedo_fuel, 1);

TextDrawLetterSize(speedo_fuel, 0.500000, 1.000000);

TextDrawColor(speedo_fuel, -1);

TextDrawSetOutline(speedo_fuel, 0);

TextDrawSetProportional(speedo_fuel, 1);

TextDrawSetShadow(speedo_fuel, 0);

speedo_vel = TextDrawCreate(570.000000, 398.000000, "100");

TextDrawBackgroundColor(speedo_vel, 255);

TextDrawFont(speedo_vel, 1);

TextDrawLetterSize(speedo_vel, 0.390000, 0.799999);

TextDrawColor(speedo_vel, -16776961);

TextDrawSetOutline(speedo_vel, 0);

TextDrawSetProportional(speedo_vel, 1);

TextDrawSetShadow(speedo_vel, 0);

}

return 1;

}

public OnFilterScriptExit()

{

for(new i; i < MAX_PLAYERS; i++)

{

TextDrawDestroy(speedo_fuel);

TextDrawDestroy(speedo_vel);

}

TextDrawDestroy(speedo_txd);

TextDrawDestroy(bg_speedo);

return 1;

}

public OnPlayerDeath(playerid)

{

TextDrawHideForPlayer(playerid, bg_speedo);

TextDrawHideForPlayer(playerid, speedo_txd);

TextDrawHideForPlayer(playerid, speedo_fuel[playerid]);

TextDrawHideForPlayer(playerid, speedo_vel[playerid]);

return 1;

}

public OnPlayerDisconnect(playerid)

{

TextDrawHideForPlayer(playerid, bg_speedo);

TextDrawHideForPlayer(playerid, speedo_txd);

TextDrawHideForPlayer(playerid, speedo_fuel[playerid]);

TextDrawHideForPlayer(playerid, speedo_vel[playerid]);

return 1;

}

public OnPlayerStateChange(playerid, newstate, oldstate)

{

if(newstate == PLAYER_STATE_DRIVER)

{

    TextDrawColor(speedo_txd, speedo_color[random(sizeof speedo_color)]);

    TextDrawShowForPlayer(playerid, bg_speedo);

TextDrawShowForPlayer(playerid, speedo_txd);

TextDrawShowForPlayer(playerid, speedo_fuel[playerid]);

TextDrawShowForPlayer(playerid, speedo_vel[playerid]);

}

if(newstate == PLAYER_STATE_ONFOOT)

{

TextDrawHideForPlayer(playerid, bg_speedo);

TextDrawHideForPlayer(playerid, speedo_txd);

TextDrawHideForPlayer(playerid, speedo_fuel[playerid]);

TextDrawHideForPlayer(playerid, speedo_vel[playerid]);

}

return 1;

}

new Float:vFuel;

new vID;

new str[150];

public OnPlayerUpdate(playerid)

{

if(IsPlayerInAnyVehicle(playerid))

{

vID = GetPlayerVehicleID(playerid);

GetVehicleHealth(vID, vFuel);

        format(str, sizeof(str), "%d", floatround(((vFuel - 250) * 100) / 750));

        TextDrawSetString(speedo_fuel[playerid], str);

        format(str, sizeof(str), "%d", GetVehSpeed(vID));

        TextDrawSetString(speedo_vel[playerid], str);

}

return 1;

}

stock GetVehSpeed(vehid) // By Diler

{

new

Float:X,

Float:Y,

Float:Z;

GetVehicleVelocity(vehid, X, Y, Z);

return floatround(floatsqroot(floatpower(X, 2) + floatpower(Y, 2) + floatpower(Z, 2)) * 200);

}

public CheckGas()

{

new string[256];

for(new i=0;i<MAX_PLAYERS;i++)

{

    if(IsPlayerConnected(i))

      {

          if(GetPlayerState(i) == PLAYER_STATE_DRIVER)

          {

      new vehicle = GetPlayerVehicleID(i);

        if(Gas[vehicle] >= 1)

  {

      if(Gas[vehicle] <= 10) { PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0); }

      if(gGas == 1) {

      format(string, sizeof(string), "~b~~n~~n~~n~~n~~n~~n~~n~~n~~n~Fuel:~w~ %d%",Gas[vehicle]);

      GameTextForPlayer(i,string,15500,3); }

              Gas[vehicle]--;

  }

  else

          {

              NoFuel = 1;

              TogglePlayerControllable(i, 0);

        GameTextForPlayer(i,"~w~~n~~n~~n~~n~~n~~n~~n~~n~No fuel in Vehicle~n~Use /exit to leave the vehicle",1500,3);

}

}

    }

}

return 1;

}[/pawn]

1 answer to this question

Recommended Posts

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.