0% found this document useful (0 votes)
71 views6 pages

Message

The document defines code for a vehicle dealership roleplaying module in a FiveM server. It includes code to interface with the FiveM server and vRP framework, retrieve vehicle data from a database, and define vehicle inventory tables for different manufacturers (BMW, Volkswagen, Audi) including vehicle names, prices and stats. The code allows players to browse, view details of, and purchase vehicles from dealerships in the roleplaying game.

Uploaded by

Matei Mandru
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
Download as txt, pdf, or txt
0% found this document useful (0 votes)
71 views6 pages

Message

The document defines code for a vehicle dealership roleplaying module in a FiveM server. It includes code to interface with the FiveM server and vRP framework, retrieve vehicle data from a database, and define vehicle inventory tables for different manufacturers (BMW, Volkswagen, Audi) including vehicle names, prices and stats. The code allows players to browse, view details of, and purchase vehicles from dealerships in the roleplaying game.

Uploaded by

Matei Mandru
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1/ 6

local Tunnel = module("vrp", "lib/Tunnel")

local Proxy = module("vrp", "lib/Proxy")

vRP = Proxy.getInterface("vRP")
vRPclient = Tunnel.getInterface("vRP","esk_showroom")
vRPCshowroom = Tunnel.getInterface("esk_showroom","esk_showroom")
vRPshowroom = {}
Tunnel.bindInterface("esk_showroom",vRPshowroom)
Proxy.addInterface("esk_showroom",vRPshowroom)

local prefix = {
["AB"] = "Alba",
["AR"] = "Arad",
["AG"] = "Arges",
["BC"] = "Bacau",
["BH"] = "Bihor",
["BN"] = "Bistrita-Nasaud",
["BT"] = "Botosani",
["BR"] = "Braila",
["BV"] = "Brasov",
["BZ"] = "Buzau",
["CL"] = "Calarasi",
["CS"] = "Caras-Severin",
["CJ"] = "Cluj",
["CT"] = "Constanta",
["CV"] = "Covasna",
["DB"] = "Dambovita",
["DJ"] = "Dolj",
["GL"] = "Galati",
["GR"] = "Giurgiu",
["GJ"] = "Gorj",
["HR"] = "Harghita",
["HD"] = "Hunedoara",
["IL"] = "Ialomita",
["IS"] = "Iasi",
["IF"] = "Ilfov",
["MM"] = "Maramures",
["MH"] = "Mehedinti",
["MS"] = "Mures",
["NT"] = "Neamt",
["OT"] = "Olt",
["PH"] = "Prahova",
["SJ"] = "Salaj",
["SM"] = "Satu Mare",
["SB"] = "Sibiu",
["SV"] = "Suceava",
["TR"] = "Teleorman",
["TM"] = "Timis",
["TL"] = "Tulcea",
["VL"] = "Valcea",
["VS"] = "Vaslui",
["VN"] = "Vrancea",
["B"] = "Bucuresti"
}

function findVehsIds()
theLastID = 0
local pvehicles = exports['ghmattimysql']:executeSync("SELECT id FROM
vrp_user_vehicles ORDER BY id DESC LIMIT 1")
if #pvehicles > 0 then
theLastID = tonumber(pvehicles[1].id)
else
theLastID = 0
end
Citizen.Wait(100)
return theLastID
end

local vehicles = {
[1] = {
tablename = 'BMW',
{numeVehicul ='mansc8', price = 7500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='[NOU] 2020 BMW X7', maxspeed=
69420, maxspeedbar = 91,tip='premium' },
{numeVehicul ='rs6', price = 7500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='BMW 760i 2017', maxspeed=
69420, maxspeedbar = 91,tip='premium' },
{numeVehicul ='sentinel', price = 4000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='BMW 440i', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='bmwm8', price = 15000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='BMW M8', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='e34', price = 2500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='BMW 1993', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='bmci', price = 7000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='BMW M5 F90', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='m3e46', price = 3500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='BMW E46', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='m4', price = 4500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='BMW M4', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='m4comp', price = 4000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='BMW M4 Competition', maxspeed=
69420, maxspeedbar = 91,tip='premium' },
{numeVehicul ='m3f80', price = 5500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='BMW M3 F80', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='bmwe34', price = 3500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='BMW E34 1989', maxspeed=
69420, maxspeedbar = 91,tip='premium' },
{numeVehicul ='rmodm3e36', price = 7500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='M3 E36', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='e60', price = 4000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='E60', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='m2', price = 6250000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='M2', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='m3f80', price = 8000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='M3 F80', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='m6c2013', price = 15000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='M6', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='bmwz4', price = 2500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Z4 2019', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='540l', price = 7000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='540i G30', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='x6m', price = 3500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='X6M', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='i8', price = 4500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='I8', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='17m760i', price = 4000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='760li', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='m82020', price = 5500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='M8', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
},
[2] = {
tablename = 'Volkswagen',
{numeVehicul ='amarok', price = 2500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Volkswagen Amarok', maxspeed=
69420, maxspeedbar = 91,tip='premium' },
{numeVehicul ='fuluxt2', price = 2000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Volkswagen Beetle Duba',
maxspeed= 69420, maxspeedbar = 91,tip='premium' },
{numeVehicul ='golf7r', price = 3500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Volkswagen Golf 7', maxspeed=
69420, maxspeedbar = 91,tip='premium' },
{numeVehicul ='golfmk6', price = 3250000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Volkswagen MK 6', maxspeed=
69420, maxspeedbar = 91,tip='premium' },
{numeVehicul ='passatr', price = 2500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Volkswagen Passat', maxspeed=
69420, maxspeedbar = 91,tip='premium' },
{numeVehicul ='R50', price = 3000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Volkswagen Touareg R50',
maxspeed= 69420, maxspeedbar = 91,tip='premium' },
{numeVehicul ='vwpolo', price = 2250000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Volkswagen Polo', maxspeed=
69420, maxspeedbar = 91,tip='premium' },
{numeVehicul ='mk1rabbit', price = 1000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Volkswagen MK 1 Rabbit',
maxspeed= 69420, maxspeedbar = 91,tip='premium' },
},
[3] = {
tablename = 'Audi',
{numeVehicul ='rs72021', price = 4500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='[NOU] Audi Rs7 ABT 2021',
maxspeed= 69420, maxspeedbar = 91,tip='premium' },
{numeVehicul ='a6', price = 4500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Audi A6', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='aaq4', price = 5250000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Audi A4 ABT', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='audis8om', price = 5000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Audi S8', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='c5rs6', price = 2000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Audi S3', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='q820', price = 6000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Audi Q8', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='r820', price = 9000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Audi R8 LB', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='audis8om', price = 7000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Audi R8', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='tts', price = 5000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Audi RS6 C7', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='rs7', price = 7250000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Audi RS7', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='audis32', price = 4500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Audi RS6 Sedan', maxspeed=
69420, maxspeedbar = 91,tip='premium' },
{numeVehicul ='rs5', price = 2750000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Audi RS3', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='as7', price = 1500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Audi S1', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='audirs6tk', price = 3000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Audi Q7', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='sq72016', price = 6000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Audi S4A', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='rs6sedan', price = 4000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Audi R8 V10 Widebody',
maxspeed= 69420, maxspeedbar = 91,tip='premium' },
{numeVehicul ='RS62', price = 7500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Audi RS3', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='r820', price = 8000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Audi R8 2020', maxspeed=
69420, maxspeedbar = 91,tip='premium' },
{numeVehicul ='b5s4', price = 3000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Audi B5 S4', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='c5rs6', price = 3000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='Audi RS6 C5', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='a6avant', price = 9531350,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='A6 Avant', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='rs5', price = 5250000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='RS5', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='rs4walk', price = 3500000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='RS4 Walk', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='rs615', price = 6000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='RS6 2015', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
{numeVehicul ='sq72016', price = 9000000,
speed=10,acceleration=10,brakes=10,hp=10,numemasina='SQ7 2016', maxspeed= 69420,
maxspeedbar = 91,tip='premium' },
}
}

function vRPshowroom.cumparaMasina(model,pret,selectie,categorie,tuning)
local user_id = vRP.getUserId({source})
local player = vRP.getUserSource({user_id})

local vehID = findVehsIds()+1


if vehID < 10 then
vehID = "0000"..vehID
elseif vehID <= 99 and vehID > 9 then
vehID = "000"..vehID
elseif vehID <= 999 and vehID > 99 then
vehID = "00"..vehID
elseif vehID <= 9999 and vehID > 999 then
vehID = "0"..vehID
elseif vehID <= 99999 and vehID > 9999 then
vehID = vehID
end
local cityPrefix = {}
for i, v in pairs(prefix) do
table.insert(cityPrefix, i)
end
local thePlate = cityPrefix[math.random(#cityPrefix)].." "..vehID

if vehicles[categorie][selectie].numeVehicul == model then


if vehicles[categorie][selectie].price == pret then

exports.ghmattimysql:execute("SELECT * FROM vrp_user_vehicles WHERE


user_id = @user_id AND vehicle = @vehicle", {['@user_id'] = user_id, ['@vehicle'] =
model}, function (haveCar)
if #haveCar > 0 then
vRPclient.notify(player,{"Ai deja aceasta masina!"})
else
if vRP.tryFullPayment({user_id,pret}) then
vRP.getUserIdentity({user_id, function(identity)

exports.ghmattimysql:execute("INSERT IGNORE INTO


vrp_user_vehicles(user_id,vehicle,upgrades,vehicle_plate)
VALUES(@user_id,@vehicle,@upgrades,@vehicle_plate)", {
['@user_id'] = user_id,
['@vehicle'] = model,
['@upgrades'] = json.encode(tuning),
['@vehicle_plate'] = thePlate
}, function (rows) end)

vRPclient.notify(player, {"Ai platit ~g~$"..pret.."~w~


pentru acest vehicul!\nDu-te la un garaj pentru a-l scoate!"})
end})
else
vRPclient.notify(player, {"~r~Nu ai suficienti bani"})
end
end
end)
else
vRPclient.notify(player,{"~r~[ERROR]~w~Pretul acestei masini nu
corespunde cu cel selectat! Contacteaza un fondator!"})
end
end
end

You might also like