No, but i found the problem... bug i cant fix it, idk whats wrong...
Ill post my code here
fuelsystem.inc (i made it as an include so it was more easy to add it to my other GM's)
pawn Код:
#if defined _fuelsystem_included
#endinput
#endif
#define _fuelsystem_included
#if !defined _samp_included
#include <a_samp>
#endif
#if !defined _hooks_included
#include <YSI/y_hooks>
#endif
new Fuel[MAX_VEHICLES];
new FuelTimer[MAX_PLAYERS];
new RefillingTimer[MAX_PLAYERS];
new IsRefuelling[MAX_VEHICLES];
new Engine[MAX_VEHICLES];
forward LowerFuelTimer(playerid);
forward ReFuelTimer(playerid);
forward HasFuel();
Hook:LarFS_OnGameModeInit()
{
SetTimer("HasFuel", 1000, 1);
for(new v = 0; v < MAX_VEHICLES; v++)
{
Fuel[v] = 100;
}
return 1;
}
Hook:LarFS_OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(Fuel[vehicleid] > 0)
{
Engine[vehicleid] = 0;
FuelTimer[playerid] = SetTimerEx("LowerFuelTimer", 20000, true, "u", playerid);
return 1;
}
else
{
GameTextForPlayer(playerid,"~r~No fuel!", 5000, 4);
FuelTimer[playerid] = SetTimerEx("LowerFuelTimer", 20000, true, "u", playerid);
return 1;
}
}
else
{
KillTimer(FuelTimer[playerid]);
return 1;
}
}
public LowerFuelTimer(playerid)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(vehicleid != 435 || vehicleid != 450 || vehicleid != 491 || vehicleid != 584) //Trailers
{
if(GetPlayerVehicleSeat(playerid) == 0)
{
if(!IsVehicleBike(vehicleid))
{
if(GetTheVehicleSpeed(playerid) > 10)
{
Fuel[vehicleid] = Fuel[vehicleid] -1;
if(Fuel[vehicleid] < 1)
{
new lights, alarm, doors, bonnet, boot, objective;
GameTextForPlayer(playerid,"~r~You ran out of ~w~Fuel~r~!", 5000, 4);
Fuel[vehicleid] = 0;
SetVehicleParamsEx(vehicleid, false, lights, alarm, doors, bonnet, boot, objective);
Engine[vehicleid] = 0;
}
else
{
if(Fuel[vehicleid] < 1)
{
Fuel[vehicleid] = 0;
return 1;
}
}
}
}
}
}
return 1;
}
public ReFuelTimer(playerid)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(GetPlayerVehicleSeat(playerid) == 0)
{
if(IsPlayerOnGasStation(playerid))
{
if(Fuel[vehicleid] > 99)
{
GameTextForPlayer(playerid,"~r~Tank Refilled", 5000, 4);
IsRefuelling[playerid] = 0;
Fuel[vehicleid] = 100;
KillTimer(RefillingTimer[vehicleid]);
return 1;
}
else
{
Fuel[vehicleid] += 5;
TakeGasMoney(playerid, 14);
return 1;
}
}
else
{
IsRefuelling[vehicleid] = 0;
KillTimer(RefillingTimer[playerid]);
return 1;
}
}
return 1;
}
public HasFuel()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
new vehicleid = GetPlayerVehicleID(i);
if(GetPlayerVehicleSeat(i) == 0)
{
if(Fuel[vehicleid] > 0)
{
if(Engine[vehicleid] == 0)
{
new lights, alarm, doors, bonnet, boot, objective;
SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective);
Engine[vehicleid] = 1;
return 1;
}
}
else if(Fuel[vehicleid] > 99)
{
Fuel[vehicleid] = 100;
return 1;
}
}
}
return 1;
}
stock TakeGasMoney(playerid, money)
{
GivePlayerMoney(playerid, - money);
return 1;
}
stock IsPlayerOnGasStation(playerid)
{
if(IsPlayerInRangeOfPoint(playerid, 10, 2114.790039, 920.438415, 10.820312)) return 1;
if(IsPlayerInRangeOfPoint(playerid, 10, -1676.28810, 413.206700, 7.1797000)) return 1;
return 0;
}
stock IsVehicleBike(vehicleid)
{
switch(GetVehicleModel(vehicleid))
{
case 509, 481, 510, 462:
return 1;
}
return 0;
}
stock GetTheVehicleSpeed(playerid)
{
if(!IsPlayerInAnyVehicle(playerid)) return 1;
new Float: x, Float: y, Float: z;
GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
return floatround((floatmul(floatsqroot(floatpower(x, 2.0) + floatpower(y, 2.0) + floatpower(z, 2.0)), 100.0) / 0.4463), floatround_floor);
}
.pawn
pawn Код:
#include <a_samp>
#include <LAR/fuelsystem>
#include <streamer>
#define COLOR_ERROR 0xFF0000FF
#define GAS_STATION_TEXT "{008080}Honk the horn{FFFFFF}(h) {008080}to refill"
public OnGameModeInit()
{
CreateFuelStation(2114.790039, 920.438415, 10.820312);
CreateFuelStation(-1676.2881, 413.2067, 7.1797);
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(newkeys & KEY_CROUCH)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(IsPlayerOnGasStation(playerid))
{
if(IsRefuelling[vehicleid] == 1) return SendClientMessage(playerid, COLOR_ERROR, "This vehicle is already being refuelled");
{
IsRefuelling[vehicleid] = 1;
GameTextForPlayer(playerid, "~w~Refilling...", 3000, 5);
RefillingTimer[playerid] = SetTimerEx("ReFuelTimer", 1000, true, "u", playerid);
return 1;
}
}
return 0;
}
}
return 1;
}
stock CreateFuelStation(Float:x, Float:y, Float:z)
{
CreatePickup(1244, 1, x, y, z, 0);
Create3DTextLabel(GAS_STATION_TEXT, 0x008080FF, x, y, z + 0.8, 30.0, 0);
CreateDynamicMapIcon(x, y, z, 56, 0, 0, 0, -1, 300.0);
return 1;
}