SA-MP Forums Archive
Hi Guys Someone Help With this - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Hi Guys Someone Help With this (/showthread.php?tid=482337)



Hi Guys Someone Help With this - moustafa0550 - 20.12.2013

Hi Guys Someone Help With this i want help from checkpoint add in fuel systems in lvpd this i want know how to add to add /robstore and ++++ please somne help me its there fs
Quote:

/*
.:: Vehicle Functions ::.
.:: Coded by HomerJay ::.
.:: Version: V3 ::.
.:: © Copyrights X-Tras.Net ::.

*/

#include <a_samp>

#define YELLOW 0xFFFF00AA
#define WHITE 0xFFFFFFAA
#define MAX_GAS 100 // Change as u wanna
#define GAS_PRICE 20 // Per liter

new VehicleGas[MAX_VEHICLES];
new VehicleStarted[MAX_VEHICLES];
new Filling[MAX_PLAYERS];

new Menu:Gas;
new FuelTimer;
new RefillTimer;

new VehicleTittle[][] =
{
"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 1", "Previon", "Coach", "Cabbie", "Stallion", "Rumpo",
"RC Bandit", "Romero", "Packer", "Monster", "Admiral", "Squalo", "Seasparrow",
"Pizzaboy", "Tram", "Trailer 2", "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", "Boxvillde",
"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", "Stratum", "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 3", "Emperor", "Wayfarer", "Euros",
"Hotdog", "Club", "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch",
"LSPD Car", "SFPD Car", "LVPD Car", "Police Ranger", "Picador", "S.W.A.T Tank", "Alpha",
"Phoenix", "Glendale", "Sadler", "Luggage Trailer 1", "Luggage Trailer 2", "Stairs Trailer",
"Boxville", "Utility Trailer 1", "Utility Trailer 2"
};

forward FuelUpdate();
forward SpeedUpdate();
forward IsAtGasStation(playerid);
forward ReFill(playerid);
forward Start(playerid);

public OnFilterScriptInit()
{
FuelTimer = SetTimer("FuelUpdate",11000,1);
for(new c;c<MAX_VEHICLES;c++)
{
VehicleGas[c] = 100;
}
Gas = CreateMenu("~r~G~w~as Station",1,50,220,200,200);
AddMenuItem(Gas,0,"Natural 95");
AddMenuItem(Gas,0,"Normal 98");
AddMenuItem(Gas,0,"Diesel");
AddMenuItem(Gas,0,"Exit");
return 1;
}

public OnFilterScriptExit()
{
DestroyMenu(Gas);
KillTimer(FuelTimer);
return 1;
}

public OnPlayerConnect(playerid)
{
Filling[playerid] = 0;
return 1;
}

public OnVehicleSpawn(vehicleid)
{
VehicleGas[vehicleid] = 100;
return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
new VID = GetPlayerVehicleID(playerid);
new MOD = GetVehicleModel(playerid);

if(strcmp(cmdtext, "/gas", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(!IsPlayerInAnyVehicle(playerid) || MOD == 510 || MOD == 509 || MOD == 481)
{
SendClientMessage(playerid,WHITE,"* You are not in a Vehicle / You can't fill that Vehicle!");
return 1;
}
if(!IsAtGasStation(playerid))
{
SendClientMessage(playerid,WHITE,"* You are not at the Gas Station!");
return 1;
}
if(VehicleGas[VID] < MAX_GAS)
{
ShowMenuForPlayer(Gas,playerid);
TogglePlayerControllable(playerid,0);
}
else
{
SendClientMessage(playerid,WHITE,"* The Tank is full!");
}
}
return 1;
}
if(strcmp(cmdtext, "/exit", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(IsPlayerInAnyVehicle(playerid))
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,YELLOW,"* You left the vehicle.");
TogglePlayerControllable(playerid,1);
}
else
{
SendClientMessage(playerid,WHITE,"* You are not in a Vehicle!");
}
}
return 1;
}
return 0;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
new VID = GetPlayerVehicleID(playerid);
new MOD = GetVehicleModel(playerid);
new string[128];

if(newstate == PLAYER_STATE_DRIVER)
{
format(string, sizeof(string), "~g~%s",VehicleTittle[GetVehicleModel(VID)-400]);
GameTextForPlayer(playerid,string,3500,1);
if(VehicleStarted[VID] == 0 && MOD != 510 && MOD != 509 && MOD != 481)
{
TogglePlayerControllable(playerid,0);
SendClientMessage(playerid,WHITE,"* This Vehicle is not Started yet. You can start it with key: 'TAB'");
}
else
{
SendClientMessage(playerid,YELLOW,"* This Vehicle is already started!");
}
if(VehicleGas[VID] < 1)
{
SendClientMessage(playerid,WHITE,"* No fuel in Vehicle!");
}
}
return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_ACTION)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(IsPlayerConnected(playerid))
{
new VID = GetPlayerVehicleID(playerid);
if(VehicleStarted[VID] == 0)
{
SendClientMessage(playerid,YELLOW,"* Starting Vehicle ...");
SetTimerEx("Start",3500,0,"i",playerid);
}
}
}
}
return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
new Menu:Current = GetPlayerMenu(playerid);
if(Current == Gas)
{
switch(row)
{
case 0:
{
GameTextForPlayer(playerid,"~b~Natural 95 ~n~ ~w~Refueling vehicle ~n~~g~Please wait..",4000,3);
RefillTimer = SetTimerEx("ReFill",2000,1,"i",playerid);
Filling[playerid] = 1;
TogglePlayerControllable(playerid,0);
}
case 1:
{
GameTextForPlayer(playerid,"~b~Natural 98 ~n~ ~w~Refueling vehicle ~n~~g~Please wait..",4000,3);
RefillTimer = SetTimerEx("ReFill",2000,1,"i",playerid);
Filling[playerid] = 1;
TogglePlayerControllable(playerid,0);
}
case 2:
{
GameTextForPlayer(playerid,"~b~Super Diesel ~n~ ~w~Refueling vehicle ~n~~g~Please wait..",4000,3);
RefillTimer = SetTimerEx("ReFill",2000,1,"i",playerid);
Filling[playerid] = 1;
TogglePlayerControllable(playerid,0);
}
case 3:
{
HideMenuForPlayer(Gas,playerid);
TogglePlayerControllable(playerid,1);
}
}
}
return 1;
}

public OnPlayerExitedMenu(playerid)
{
TogglePlayerControllable(playerid,1);
return 1;
}

public FuelUpdate()
{
new string[256];
for(new i=0;i<MAX_PLAYERS;i++)
{
new VID = GetPlayerVehicleID(i);
new MOD = GetVehicleModel(i);
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
if(IsPlayerConnected(i))
{
if(Filling[i] == 0 && VehicleStarted[VID] == 1 && MOD != 510 && MOD != 509 && MOD != 481)
{
if(VehicleGas[VID] >= 1)
{
VehicleGas[VID] -= 1;
format(string, sizeof(string),"~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~|~b~ FUEL: ~w~%d%|",VehicleGas[VID]);
GameTextForPlayer(i,string,11500,3);
}
else
{
TogglePlayerControllable(i,0);
GameTextForPlayer(i,"~n~~n~~n~~n~~b~Your car is without fuel!",2500,3);
SendClientMessage(i,WHITE,"* Your Vehicle is without an Gas! Use '/exit' to get out.");
}
}
}
}
}
return 1;
}

public ReFill(playerid)
{
new VID = GetPlayerVehicleID(playerid);
new string[128];
if(IsPlayerConnected(playerid))
{
if(IsPlayerInAnyVehicle(playerid))
{
if(VehicleGas[VID] < 100)
{
if(GetPlayerMoney(playerid) >= 200)
{
VehicleGas[VID] += 5;
format(string, sizeof(string),"~n~~n~~n~~y~FUEL: ~w~%d%",VehicleGas[VID]);
GameTextForPlayer(playerid,string,2000,3);
GivePlayerMoney(playerid,-200);
}
else
{
format(string, sizeof(string),"* You don't have $%d to pay!",GAS_PRICE);
SendClientMessage(playerid,WHITE,string);
TogglePlayerControllable(playerid,1);
Filling[playerid] = 0;
KillTimer(RefillTimer);
}
}
else
{
SendClientMessage(playerid,YELLOW,"* Your Vehicle has been successfully Filled Up!");
VehicleGas[VID] = 100;
Filling[playerid] = 0;
KillTimer(RefillTimer);
TogglePlayerControllable(playerid,1);
}
}
}
return 1;
}

public Start(playerid)
{
new VID = GetPlayerVehicleID(playerid);
new RandStart = random(2);
if(IsPlayerConnected(playerid))
{
if(IsPlayerInAnyVehicle(playerid))
{
switch(RandStart)
{
case 0:
{
VehicleStarted[VID] = 1;
TogglePlayerControllable(playerid,1);
SendClientMessage(playerid,YELLOW,"* Vehicle successfully Started!");
}
case 1:
{
SendClientMessage(playerid,WHITE,"* Starting Vehicle Failed!");
}
}
}
}
return 1;
}

public IsAtGasStation(playerid)
{
if(IsPlayerConnected(playerid))
{
if(PlayerToPoint(playerid,1595.5406, 2198.0520, 10.3863,10))
{
return 1;
}
else if(PlayerToPoint(playerid,2202.0649, 2472.6697, 10.5677,10))
{
return 1;
}
else if(PlayerToPoint(playerid,2115.1929, 919.9908, 10.5266,10))
{
return 1;
}
else if(PlayerToPoint(playerid,2640.7209, 1105.9565, 10.5274,10))
{
return 1;
}
else if(PlayerToPoint(playerid,608.5971, 1699.6238, 6.9922,10))
{
return 1;
}
else if(PlayerToPoint(playerid,618.4878, 1684.5792, 6.9922,10))
{
return 1;
}
else if(PlayerToPoint(playerid,2146.3467, 2748.2893, 10.5245,10))
{
return 1;
}
else if(PlayerToPoint(playerid,-1679.4595, 412.5129, 6.9973,10))
{
return 1;
}
else if(PlayerToPoint(playerid,-1327.5607, 2677.4316, 49.8093,10))
{
return 1;
}
else if(PlayerToPoint(playerid,-1470.0050, 1863.2375, 32.3521,10))
{
return 1;
}
else if(PlayerToPoint(playerid,-2409.2200, 976.2798, 45.2969,10))
{
return 1;
}
else if(PlayerToPoint(playerid,-2244.1396, -2560.5833, 31.9219,10))
{
return 1;
}
else if(PlayerToPoint(playerid,-1606.0544, -2714.3083, 48.5335,10))
{
return 1;
}
else if(PlayerToPoint(playerid,1937.4293, -1773.1865, 13.3828,10))
{
return 1;
}
else if(PlayerToPoint(playerid,-91.3854, -1169.9175, 2.4213,10))
{
return 1;
}
else if(PlayerToPoint(playerid,1383.4221, 462.5385, 20.1506,10))
{
return 1;
}
else if(PlayerToPoint(playerid,660.4590, -565.0394, 16.3359,10))
{
return 1;
}
else if(PlayerToPoint(playerid,1381.7206, 459.1907, 20.3452,10))
{
return 1;
}
else if(PlayerToPoint(playerid,-1605.7156, -2714.4573, 48.5335,10))
{
return 1;
}
}
return 0;
}

PlayerToPoint(playerid,Float,Float:y,Float:z,rad ius) //Not my script
{
if(GetPlayerDistanceToPointEx(playerid,x,y,z) < radius)
{
return 1;
}
return 0;
}

GetPlayerDistanceToPointEx(playerid,Float,Float: y,Float:z)
{
new Float1,Float:y1,Float:z1;
new Float:tmpdis;
GetPlayerPos(playerid,x1,y1,z1);
tmpdis = floatsqroot(floatpower(floatabs(floatsub(x,x1)),2) +floatpower(floatabs(floatsub(y,y1)),2)+floatpower (floatabs(floatsub(z,z1)),2));
return floatround(tmpdis);
}

help + rep to i know how to add


Re: Hi Guys Someone Help With this - moustafa0550 - 20.12.2013

help please?