i need help :D

Started by Williams, Dec 15, 2015, 06:17 PM

Previous topic - Next topic

Williams

Hey, i want to make a fuel system and anyone tell me give me fuel system or help me to make this system.
please i need help so plzz help
Hey, i m always at IRC and Forum you can comtact me at IRC channel :- #GDM @LUNet and Forum :- http://pro-fighter.tk/index.php

Diego^

#1
You can use this:

function onScriptLoad()
{
Fuel <- array( 1000, 100 );
NewTimer( "DecFuel", 20000, 0 );//Every 20 seconds, the fuel will be reduced.
}

function DecFuel()
{
for( local i = 0, player; i < GetMaxPlayers(); i++ )
{
player = FindPlayer( i );
if ( player )
{
local vehicle = player.Vehicle;
if ( vehicle && player.VehicleSlot == 0 )
{
if ( Fuel[ vehicle.ID ] >= 1 )
{
Fuel[ vehicle.ID ] --;
Announce( "~b~Fuel: ~w~" + Fuel[ vehicle.ID ], player, 5 );
if ( Fuel[ vehicle.ID ] == 0 )
{
vehicle.Speed = Vector( 0, 0, 0 );
if ( vehicle.GetHandlingData( 13 ) != 0 ) vehicle.SetHandlingData( 13, 0 );
if ( vehicle.GetHandlingData( 14 ) != 0 ) vehicle.SetHandlingData( 14, 0 );
}
}
}
}
}
}

function onPlayerEnterVehicle( player, vehicle, door )
{
CheckFuel( player, vehicle, door );
}

function onPlayerExitVehicle( player, vehicle )
{
Announce( " ", player, 5 );
}

function CheckFuel( player, vehicle, door )
{
Announce( "~b~Fuel: ~w~" + Fuel[ vehicle.ID ], player, 5 );
if ( Fuel[ vehicle.ID ] == 0 && door == 0 )
{
vehicle.Speed = Vector( 0, 0, 0 );
if ( vehicle.GetHandlingData( 13 ) != 0 ) vehicle.SetHandlingData( 13, 0 );
if ( vehicle.GetHandlingData( 14 ) != 0 ) vehicle.SetHandlingData( 14, 0 );
}
}

function onPlayerCommand( player, cmd, text )
{
if ( cmd == "fuel" )
{
local vehicle = player.Vehicle;
if ( !vehicle  ) MessagePlayer( "[Error] - You must be in a vehicle.", player );
else if ( Fuel[ vehicle.ID ] >= 5 ) MessagePlayer( "[Error] - This car does not need fuel.", player );
else
{
Fuel[ vehicle.ID ] = 100;
MessagePlayer( "Fuelled Vehicle!", player );
if ( vehicle.GetHandlingData( 13 ) == 0 ) vehicle.ResetHandlingData( 13 );
if ( vehicle.GetHandlingData( 14 ) == 0 ) vehicle.ResetHandlingData( 14 );
Announce( "~b~Fuel: ~w~" + Fuel[ vehicle.ID ], player, 5 );
}
}
}

Use the command /fuel for fueling the vehicle.

Note: This system does not work with helicopter.
BRL's Developer.

Williams

Thanks @Diego its Working :D
Hey, i m always at IRC and Forum you can comtact me at IRC channel :- #GDM @LUNet and Forum :- http://pro-fighter.tk/index.php

PaleDx

What is the function Of array(1000 -<

The 1000, what is?

Kewun

Nice bump, nice just nice

its fuel amount

KAKAN

Quote from: Kewun on Jan 29, 2017, 07:24 PMits fuel amount
I guess the 100 next to it is the fuel amount.
I also guess that the 1000 is for the vehicle's fuel left, since you can have 1000 vehicles in your server, so 1000 fuel instances :D
oh no