Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------------
- ------- ADVANCED VEHICLE SYSTEM FOR CS2D -------
- --------------------------------------------------
- colors = {
- RED = "©255000000",
- GREEN = "©000255000",
- BLUE = "©000000255",
- BLACK = "©000000000",
- WHITE = "©255255255",
- WBLUE = "©000190255",
- DARK_GREEN = "©000100000"
- }
- vehicles = {
- [1] = {
- name = "Car 1"; -- name of car
- speed = 20; -- speed of car
- gfx_path = "gfx/MafiaRP/cars/red.png"; -- path to car's gfx
- fly = false; -- flyable or not
- top = 0;
- health = 100; -- car's health
- fuel_type = "benzol";
- fuel_tank = 30; -- maximum fuel in car
- usage = 10; -- uses 10 litre on 100km
- plate = "HUF-666";
- radio = true;
- rentable = true;
- handling = 1.0;
- price = 5000;
- price_rent = 50;
- age = 5; -- Age of car
- owner = 6943;-- BY USGN ID
- transmission = 6;-- X SPEED TRANSMISSION
- transmission_type = 1;-- auto or manual
- turbo = true;
- doors = 2;
- anti_bullet = true;
- }
- }
- veh = {}
- _vehid = 1;
- function GetCar(veh, x, y, rotation, owner)
- if not rotation then rotation = 0 end;
- if owner then
- if Player[owner] ~= nil then
- table.insert(Player[owner].veh, _vehid);
- end
- end
- local info = {};
- info.enabled = true;
- info.x = x;
- info.y = y;
- info.type = veh;
- info.gfx = image(vehicles[veh].gfx_path, x, y, vehicles[veh].top);
- imagepos(info.gfx, x, y, rotation);
- info.owner = 0;
- info.players = {};
- info.vid = _vehid;
- info.vowner = owner;
- info.rent = 0;
- info.vplayers = {};
- info.vdrivers = {};
- info.health = vehicle[veh].health;
- veh[_vehid] = info;
- local _, info;
- _vehid = _vehid + 1;
- end
- function RemoveCar(veh)
- if veh.owner > 0 then
- Player[veh.owner].vehowner = nil;
- end
- veh.owner = nil;
- local _, info;
- for _, info in pairs(veh.players) do
- Player[k].veh = nil;
- veh.players = nil;
- freeimage(veh.gfx);
- veh.gfx = nil;
- veh.health = nil;
- veh.vplayers = nil;
- veh.vdrivers = nil;
- veh.vid = nil;
- veh.type = nil;
- veh.x = nil;
- veh.y = nil;
- veh.enabled = false;
- veh.rent = nil;
- end
- end
- GetCar(1, 138.5 * 32 + 16, 186 * 32 + 16, 90);
- function checkvehHealth(veh)
- if veh.health <= 0 then
- local x, y = veh.x, veh.y;
- RemoveCar(veh);
- parse("explosion ".. x .." ".. y .." 256 1000 0");
- end
- end
- function RentCar(veh)
- if veh.rentable == true then
- parse("hudtxt 1 "..colors[GREEN].."Rentable "..veh.x.." "..veh.y.."")
- end
- if veh.rentable == false then
- parse("hudtxt 2 "..colors[RED].."Buyable "..veh.x.." "..veh.y"")
- end
- end
- function getDist(x1, y1, x2, y2)
- return math.floor(((x1 - x2)^2 + (y1 - y2)^2)^.5)
- end
- addhook("use","Rent_menu")
- function Rent_menu(id)
- if veh.rentable == true then
- if getDist(player(i, 'x'), player(i, 'y'), player(id, 'x'), player(id, 'y')) <= distance then
- menu(id, "Renting Vehicles, 1 Hour")
- end
- elseif veh.rentable == false then
- msg2(id,""..color[WHITE]"This Vehicle"..color[RED].."NOT RENTABLE!")
- end
- end
- addhook("menu","Renting")
- function Renting(id,title,sel)
- if veh.rentable == true then
- if title=="Renting Vehicles" then
- if sel==1 then
- if veh.owner > 0 then
- msg2(id,""..color[WHITE]"This Vehicle"..color[RED].."HAS BEEN ALREADY RENT!")
- end
- end
- end
- end
- if veh.owner == 0 then do
- veh.owner = (player(id,"usgn"))
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment