Skip to content

Instantly share code, notes, and snippets.

Created April 21, 2015 18:48
Show Gist options
  • Save anonymous/78b3fb96a2d1e7c2d90b to your computer and use it in GitHub Desktop.
Save anonymous/78b3fb96a2d1e7c2d90b to your computer and use it in GitHub Desktop.
legena.pwn
#include <a_samp>
#include <streamer>
#include "zcmd"
#define COLOR_WHITE (0xFFFFFFFF) // We have this defined in "includes/TMS/Colors" -- John_Brown
#define MAX_GAS_STATIONS 32
#define DIALOG_GAS 1998
enum Coords
{
Float:COORD_X,
Float:COORD_Y,
Float:COORD_Z
};
new
GasStationCoords[][Coords] =
{
{ -1471.5, 1863.75, 32.7 },
{ -1326.5, 2677.5, 50.1 },
{ 611.5, 1694.5, 7.0 },
{ -2249.25, -2559.0, 32.0 },
{ -1606.5, -2714.0, 48.6 },
{ -93.5, -1175.0, 2.3 },
{ 1377.5, 457.0, 19.9 },
{ 651.5, -565.5, 16.4 },
{ -1675.75, 412.75, 7.2 },
{ -2405.50, 976.25, 45.3 },
{ -2023.25, 156.75, 28.9 },
{ -1131.75, -204.25, 14.2 },
{ 66.50, 1220.50, 18.9 },
{ 350.50, 2537.50, 16.8 },
{ 2147.00, 2747.75, 10.9 },
{ 2639.75, 1106.00, 10.9 },
{ 2115.00, 920.00, 10.9 },
{ 2202.00, 2475.00, 10.9 },
{ 1596.50, 2199.75, 10.9 },
{ 1584.25, 1448.25, 10.9 },
{ 1004.25, -940.50, 42.2 },
{ 1935.00, -1772.75, 13.4 }
};
new
Float:VehicleGasLevel[MAX_VEHICLES],
GasStations[MAX_GAS_STATIONS],
FuelConsTimer
;
forward UpdateFuelCons();
public OnFilterScriptInit()
{
new i;
for(i = 0; i <= MAX_VEHICLES; i++)
VehicleGasLevel[i] = 100;
for(i = 0; i < MAX_GAS_STATIONS; ++i)
if(GasStationCoords[i][COORD_Z])
GasStations[i] = CreateDynamicCP(
GasStationCoords[i][COORD_X],
GasStationCoords[i][COORD_Y],
GasStationCoords[i][COORD_Z],
5.0
);
else
break;
FuelConsTimer = SetTimer("UpdateFuelCons", 7500, true);
return 1;
}
public OnFilterScriptExit()
{
KillTimer(FuelConsTimer);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
/*
* TODO: Work on this later
*/
return 1;
}
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
for(new i; i < sizeof(GasStations); i++)
{
if(checkpointid == GasStations[i])
{
if(IsPlayerInAnyVehicle(playerid) == 1)
{
ShowPlayerDialog(
playerid,
DIALOG_GAS,
DIALOG_STYLE_LIST,
"{FF00FF}[{6C6C6C}TMS - Gas Station{FF00FF}]", "{FF00FF}[{6C6C6C}Fill fuel tank [1000$]{FF00FF}]",
"Select",
"Close"
);
TogglePlayerControllable(playerid, 1);
}
}
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_GAS)
{
if(response)
{
switch(listitem)
{
case 0:
{
new vehicleid = GetPlayerVehicleID(playerid);
if(VehicleGasLevel[vehicleid] == 100)
{
SendClientMessage(playerid, COLOR_WHITE, "{FF0000}[{6C6C6C}Your fuel tank is already full!{FF0000}]");
TogglePlayerControllable(playerid, 1);
}
else
{
VehicleGasLevel[vehicleid] = 100;
}
}
}
}
else
{
TogglePlayerControllable(playerid, 1);
}
}
return 0;
}
public UpdateFuelCons()
{
new
engine,
lights,
alarm,
doors,
bonnet,
boot,
objective
;
for(new i; i < MAX_VEHICLES; ++i)
{
GetVehicleParamsEx(
i,
engine,
lights,
alarm,
doors,
bonnet,
boot,
objective
);
if(engine)
{
VehicleGasLevel[i] -= 0.25;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment