08.04.2017, 02:08
I have fuel system script, like this :
I want the fuel system is running when the engine of life is, if the dead engine fuel system is not running. how to make the engine system like this? :
PHP Code:
//------------------------------
// OH BABY, OH BABY. SAY MY NAME> SAY MY NAME. *CLUCK*- bi- lay . RUSSEL peters!
#define FILTERSCRIPT
#include <a_samp>
#include <zcmd>
#include <streamer>
#include <sscanf2>
#include <evf>
#include <evi>
#define SCM SendClientMessage
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_RED 0xAA3333AA
#define COLOR_LIME 0x10F441AA
#define COLOR_MAGENTA 0xFF00FFFF
#define COLOR_NAVY 0x000080AA
#define COLOR_AQUA 0xF0F8FFAA
#define COLOR_CRIMSON 0xDC143CAA
#define COLOR_FLBLUE 0x6495EDAA
#define COLOR_BISQUE 0xFFE4C4AA
#define COLOR_BLACK 0x000000AA
#define COLOR_CHARTREUSE 0x7FFF00AA
#define COLOR_BROWN 0XA52A2AAA
#define COLOR_CORAL 0xFF7F50AA
#define COLOR_GOLD 0xB8860BAA
#define COLOR_GREENYELLOW 0xADFF2FAA
#define COLOR_INDIGO 0x4B00B0AA
#define COLOR_IVORY 0xFFFF82AA
#define COLOR_LAWNGREEN 0x7CFC00AA
#define COLOR_SEAGREEN 0x20B2AAAA
#define COLOR_LIMEGREEN 0x32CD32AA //<--- Dark lime
#define COLOR_MIDNIGHTBLUE 0X191970AA
#define COLOR_MAROON 0x800000AA
#define COLOR_OLIVE 0x808000AA
#define COLOR_ORANGERED 0xFF4500AA
#define COLOR_PINK 0xFFC0CBAA // - Light light pink
#define COLOR_SPRINGGREEN 0x00FF7FAA
#define COLOR_TOMATO 0xFF6347AA // - Tomato >:/ sounds wrong lol... well... :P
#define COLOR_YELLOWGREEN 0x9ACD32AA //- like military green
#define COLOR_MEDIUMAQUA 0x83BFBFAA
#define COLOR_MEDIUMMAGENTA 0x8B008BAA // dark magenta ^^
new Text:Date;
forward settime(playerid);
new Text:td_fuel[MAX_PLAYERS];
forward timer_update();
forward timer_refuel(playerid);
new isrefuelling[MAX_PLAYERS] = 0;
new fuel[MAX_VEHICLES];
new Float:max_vhealth[MAX_VEHICLES];
new Engine[MAX_PLAYERS];
new VehicleNames[][] =
{
"Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel",
"Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus",
"Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
"Esperanto", "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection",
"Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus",
"Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach", "Cabbie",
"Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral",
"Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder",
"Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair", "Berkley's RC Van",
"Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale",
"Oceanic","Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy",
"Hermes", "Sabre", "Rustler", "ZR-350", "Walton", "Regina", "Comet", "BMX",
"Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper",
"Rancher", "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking",
"Blista Compact", "Police Maverick", "Boxville", "Benson", "Mesa", "RC Goblin",
"Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher", "Super GT",
"Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster", "Stunt",
"Tanker", "Roadtrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra",
"FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune",
"Cadrona", "FBI Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer",
"Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent",
"Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder", "Primo",
"Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite",
"Windsor", "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratium",
"Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
"Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper",
"Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400",
"News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
"Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car",
"Police Car", "Police Car", "Police Ranger", "Picador", "S.W.A.T", "Alpha",
"Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs", "Boxville",
"Tiller", "Utility Trailer"
};
new vstring[128];
new fstring[128];
stock GetVehicleName(vehicleid)
{
format(vstring,sizeof(vstring),"%s",VehicleNames[GetVehicleModel(vehicleid) - 400]);
return vstring;
}
//-------------------------------------------------------
new Text:dua;
new Text:tiga;
new Text:empat;
new Text:lima;
new Text:enam;
new Text:tujuh;
new Text:Textdraw2[MAX_PLAYERS];
new Text:Textdraw1[MAX_PLAYERS];
new Text:HEALTH[MAX_PLAYERS];
//-------------------------------------------------------
forward Speedometer(playerid);
//-------------------------------------------------------
public OnFilterScriptInit()
{
Date = TextDrawCreate(547.000000,11.000000,"--");
TextDrawFont(Date,3);
TextDrawLetterSize(Date,0.399999,1.600000);
TextDrawColor(Date,0xffffffff);
SetTimer("Speedometer", 100, true);
for(new i=0;i<MAX_VEHICLES;i++)
{
GetVehicleHealth(i,max_vhealth[i]); //getting max health
fuel[i] = 250 + random(150); //setting fuel for vehicles
}
for(new i=0;i<MAX_PLAYERS;i++) { //setting up all textdraws
td_fuel[i] = TextDrawCreate(566.427551, 289.750030, " ");
TextDrawLetterSize(td_fuel[i], 0.400000, 1.600000);
TextDrawAlignment(td_fuel[i], 1);
TextDrawColor(td_fuel[i], 65535);
TextDrawSetShadow(td_fuel[i], 0);
TextDrawSetOutline(td_fuel[i], 1);
TextDrawBackgroundColor(td_fuel[i], 255);
TextDrawFont(td_fuel[i], 1);
TextDrawSetProportional(td_fuel[i], 1);
TextDrawSetShadow(td_fuel[i], 0);
}
SetTimer("timer_update",1000,true);
return 1;
}
public OnFilterScriptExit()
{
for(new i=0;i<MAX_PLAYERS;i++) {
TextDrawDestroy(td_fuel[i]);
}
return 1;
}
stock IsPlayerAtRefuelStation(playerid)
{
if (IsPlayerInRangeOfPoint(playerid,10,655.5993,-564.9833,16.3359)) return 1; //Dilimore
if (IsPlayerInRangeOfPoint(playerid,10,4,5,6)) return 1; //random
return 0;
}
public Speedometer(playerid)
{
new vehicleid,Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,speed_string[256],final_speed_int;
vehicleid = GetPlayerVehicleID(playerid);
new Float:vehicle_health,final_vehicle_health,health_string[256];
if(vehicleid != 0)
{
GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*180.666667;
final_speed_int = floatround(final_speed,floatround_round);
format(speed_string,256,"%i mph",final_speed_int);
TextDrawSetString(Textdraw1[playerid], speed_string);
GetVehicleHealth(vehicleid,vehicle_health);
final_vehicle_health = floatround(floatround(vehicle_health - 250)/ 7.5);
while(final_vehicle_health<0)
{
final_vehicle_health=0;
}
format(health_string,256,"%i pcnt", final_vehicle_health);
TextDrawSetString(HEALTH[playerid], health_string);
format(vstring,sizeof(vstring),"%s",GetVehicleName(vehicleid));
TextDrawSetString(Textdraw2[playerid],vstring);
}
else
{
TextDrawSetString(Textdraw1[playerid], " ");
TextDrawSetString(HEALTH[playerid], " ");
}
return 1;
}
#pragma unused fstring
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
Textdraw1[playerid]= TextDrawCreate( 563.147888, 259.416687," ");
TextDrawLetterSize(Textdraw1[playerid], 0.400000, 1.600000);
TextDrawAlignment( Textdraw1[playerid], 1);
TextDrawColor( Textdraw1[playerid], 65535);
TextDrawSetShadow( Textdraw1[playerid], 0);
TextDrawSetOutline( Textdraw1[playerid], 1);
TextDrawBackgroundColor( Textdraw1[playerid], 255);
TextDrawFont( Textdraw1[playerid], 1);
TextDrawSetProportional( Textdraw1[playerid], 1);
Textdraw2[playerid]= TextDrawCreate( 474.129455, 230.249755, " ");
TextDrawLetterSize(Textdraw2[playerid], 0.699999, 2.000000);
TextDrawAlignment( Textdraw2[playerid], 1);
TextDrawColor( Textdraw2[playerid], -16776961);
TextDrawSetShadow( Textdraw2[playerid], 0);
TextDrawSetOutline( Textdraw2[playerid], 0);
TextDrawBackgroundColor( Textdraw2[playerid], 255);
TextDrawFont( Textdraw2[playerid], 3);
TextDrawSetProportional( Textdraw2[playerid], 1);
HEALTH[playerid]= TextDrawCreate( 565.958984, 274.583282, " pcnt");
TextDrawLetterSize(HEALTH[playerid], 0.400000, 1.600000);
TextDrawAlignment( HEALTH[playerid], 1);
TextDrawColor( HEALTH[playerid], 65535);
TextDrawSetShadow(HEALTH[playerid], 0);
TextDrawSetOutline(HEALTH[playerid], 1);
TextDrawBackgroundColor(HEALTH[playerid], 255);
TextDrawFont(HEALTH[playerid], 1);
TextDrawSetProportional(HEALTH[playerid], 1);
dua = TextDrawCreate(471.786346, 243.083312, "============================");
TextDrawLetterSize(dua, 0.400000, 1.600000);
TextDrawAlignment(dua, 1);
TextDrawColor(dua, 65535);
TextDrawSetShadow(dua, 0);
TextDrawSetOutline(dua, 0);
TextDrawBackgroundColor(dua, 255);
TextDrawFont(dua, 1);
TextDrawSetProportional(dua, 1);
TextDrawSetShadow(dua, 0);
tiga = TextDrawCreate(480.219268, 229.666580, "~n~~n~Speed__~n~Health~n~Fuel");
TextDrawLetterSize(tiga, 0.400000, 1.600000);
TextDrawAlignment(tiga, 1);
TextDrawColor(tiga, -16776961);
TextDrawSetShadow(tiga, 0);
TextDrawSetOutline(tiga, 0);
TextDrawBackgroundColor(tiga, 255);
TextDrawFont(tiga, 1);
TextDrawSetProportional(tiga, 1);
TextDrawSetShadow(tiga, 0);
empat = TextDrawCreate(473.660491, 303.750396, "============================");
TextDrawLetterSize(empat, 0.400000, 1.600000);
TextDrawAlignment(empat, 1);
TextDrawColor(empat, 65535);
TextDrawSetShadow(empat, 0);
TextDrawSetOutline(empat, 0);
TextDrawBackgroundColor(empat, 255);
TextDrawFont(empat, 1);
TextDrawSetProportional(empat, 1);
TextDrawSetShadow(empat, 0);
lima = TextDrawCreate(542.064636, 260.000061, "=");
TextDrawLetterSize(lima, 0.400000, 1.600000);
TextDrawAlignment(lima, 1);
TextDrawColor(lima, -16776961);
TextDrawSetShadow(lima, 0);
TextDrawSetOutline(lima, 0);
TextDrawBackgroundColor(lima, 255);
TextDrawFont(lima, 1);
TextDrawSetProportional(lima, 1);
TextDrawSetShadow(lima, 0);
enam = TextDrawCreate(542.064636, 274.000213, "=");
TextDrawLetterSize(enam, 0.400000, 1.600000);
TextDrawAlignment(enam, 1);
TextDrawColor(enam, -16776961);
TextDrawSetShadow(enam, 0);
TextDrawSetOutline(enam, 0);
TextDrawBackgroundColor(enam, 255);
TextDrawFont(enam, 1);
TextDrawSetProportional(enam, 1);
TextDrawSetShadow(enam, 0);
tujuh = TextDrawCreate(542.533142, 289.167083, "=");
TextDrawLetterSize(tujuh, 0.400000, 1.600000);
TextDrawAlignment(tujuh, 1);
TextDrawColor(tujuh, -16776961);
TextDrawSetShadow(tujuh, 0);
TextDrawSetOutline(tujuh, 0);
TextDrawBackgroundColor(tujuh, 255);
TextDrawFont(tujuh, 1);
TextDrawSetProportional(tujuh, 1);
TextDrawSetShadow(tujuh, 0);
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
TextDrawHideForPlayer(playerid,HEALTH[playerid]);
TextDrawHideForPlayer(playerid,Textdraw1[playerid]);
TextDrawHideForPlayer(playerid,Textdraw2[playerid]);
TextDrawHideForPlayer(playerid, dua);
TextDrawHideForPlayer(playerid, tiga);
TextDrawHideForPlayer(playerid, empat);
TextDrawHideForPlayer(playerid, lima);
TextDrawHideForPlayer(playerid, enam);
TextDrawHideForPlayer(playerid, tujuh);
TextDrawHideForPlayer(playerid,td_fuel[playerid]);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
TextDrawShowForPlayer(playerid,Textdraw2[playerid]);
TextDrawShowForPlayer(playerid,Textdraw1[playerid]);
TextDrawShowForPlayer(playerid,HEALTH[playerid]);
TextDrawShowForPlayer(playerid, dua);
TextDrawShowForPlayer(playerid, tiga);
TextDrawShowForPlayer(playerid, empat);
TextDrawShowForPlayer(playerid, lima);
TextDrawShowForPlayer(playerid, enam);
TextDrawShowForPlayer(playerid, tujuh);
TextDrawSetString(td_fuel[playerid]," ");
TextDrawShowForPlayer(playerid,td_fuel[playerid]);//showing if an player is a driver or passenger of the ar
} else {
TextDrawHideForPlayer(playerid,Textdraw2[playerid]);
TextDrawHideForPlayer(playerid,Textdraw1[playerid]);
TextDrawHideForPlayer(playerid,HEALTH[playerid]);
TextDrawHideForPlayer(playerid, dua);
TextDrawHideForPlayer(playerid, tiga);
TextDrawHideForPlayer(playerid, empat);
TextDrawHideForPlayer(playerid, lima);
TextDrawHideForPlayer(playerid, enam);
TextDrawHideForPlayer(playerid, tujuh);
TextDrawHideForPlayer(playerid,td_fuel[playerid]);
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
TextDrawHideForPlayer(playerid, Date);
return true;
}
public OnPlayerSpawn(playerid)
{
TextDrawShowForPlayer(playerid, Date);
return 1;
}
public settime(playerid)
{
new string[256],year,month,day;
getdate(year, month, day);
format(string, sizeof string, "%d/%s%d/%s%d", day, ((month < 10) ? ("0") : ("")), month, (year < 10) ? ("0") : (""), year);
TextDrawSetString(Date, string);
}
CMD:refill(playerid, params[])
{
new id = GetPlayerVehicleID(playerid);
if (!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,-1,"{FF0000}[Vehicle]{FFFFFF} Kamu Tidak Di Dalam Sebuah Kendaraan"); //if a player isnt in a vehicle, it stops here
if (!IsPlayerAtRefuelStation(playerid)) return SendClientMessage(playerid,-1,"{FF0000}[Vehicle]{FFFFFF} Kamu Harus Berada di Gas Station Untuk Mengisi Bahan Bakar");
if (isrefuelling[playerid]) return SendClientMessage(playerid,-1,"{FF0000}[Vehicle]{FFFFFF} Kamu Sedang Melakukan Pengisian Bahan Bakar"); //if a player is already refuelling, it stops here
if (GetPlayerMoney(playerid) - 10 <0) return SendClientMessage(playerid,-1,"{FF0000}[Vehicle]{FFFFFF} Kamu Tidak Memiliki Uang Sebesar {32CD32}$10 "); //if a player doesnt have $80 anymore, it stops here
if(GetVehicleParams(id, VEHICLE_TYPE_ENGINE))
{
SendClientMessage(playerid,-1,"{FF0000}[Vehicle]{FFFFFF} Anda Harus Mematikan Mesih Terlebih Dahulu Sebelum Mengisi Bahan Bakar");
}
else
{
GivePlayerMoney(playerid, -10); //Sets the player's cash -$80
SetCameraBehindPlayer(playerid); //Sets the camera behind the player (looks better because the player will be frozen for a few secs)
isrefuelling[playerid] = 1; //setting isrefuelling to 1 so the player cant spam /refuel
TextDrawSetString(td_fuel[playerid],"Refuelling..."); //changing textdraw to /refuel
SetTimerEx("timer_refuel",4500,false,"i",playerid); //setting refueltimer
}
return 1;
}
public timer_update()
{
for(new i=0;i<MAX_PLAYERS;i++)
{
if (isrefuelling[i]) return 0;
new vid = GetPlayerVehicleID(i);
if (GetPlayerVehicleSeat(i) == 0)
{
fuel[vid] = fuel[vid] - 1;
if (fuel[vid]<1)
{
fuel[vid] = 0;
new veh = GetPlayerVehicleID(i);
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(veh,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
Engine[i]=0;
GameTextForPlayer(i,"~r~You are out of ~w~fuel~r~!",5000,4);
}
}
new string[128];format(string,sizeof string,"%i",fuel[vid] /40);
TextDrawSetString(td_fuel[i],string);
new Float:speed_x,Float:speed_y,Float:speed_z,Float:temp_speed,final_speed,Float:health;
GetVehicleVelocity(vid,speed_x,speed_y,speed_z);
temp_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*136.666667;
final_speed = floatround(temp_speed,floatround_round);
format(string,sizeof string,"Speed: %i",final_speed);
GetVehicleHealth(vid,health);
if (max_vhealth[vid] == 0)//if its an random spawned vehicle
{
fuel[vid] = 4000;
GetVehicleHealth(vid,max_vhealth[vid]);
}
health = (((health - max_vhealth[vid]) /max_vhealth[vid]) *100)+ 100;
format(string,sizeof string,"Health: %i",floatround(health,floatround_round));
}
return 1;
}
public timer_refuel(playerid)
{
new vid = GetPlayerVehicleID(playerid);
if(Engine[playerid]==0)
{
new veh = GetPlayerVehicleID(playerid);
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(veh,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
Engine[playerid]=1;
}
fuel[vid] = fuel[vid] = 4000;
isrefuelling[playerid] = 0;
TextDrawSetString(td_fuel[playerid],"100");
}
I want the fuel system is running when the engine of life is, if the dead engine fuel system is not running. how to make the engine system like this? :
PHP Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && (newkeys & KEY_NO))
{
new id = GetPlayerVehicleID(playerid);
new string[200];
if(GetVehicleParams(id, VEHICLE_TYPE_ENGINE))
{
SetVehicleParams(id, VEHICLE_TYPE_ENGINE, 0);
SendClientMessage(playerid, -1, "{FF0000}[Vehicle] {FFFFFF}Mesin Kendaraan Berhasil Anda Matikan.");
format(string, sizeof(string), "* %s stoped engine", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE);
}
else
{
Vehicle_StartEngine(id);
SendClientMessage(playerid, -1, "{FF0000}[Vehicle] {FFFFFF}Mesin Kendaraan Berhasil Anda Hidupkan.");
format(string, sizeof(string), "* %s started engine", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE);
}
}
return 1;
}