Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getVehicleHandlingProperty ( element, property )
- if isElement ( element ) and getElementType ( element ) == "vehicle" and type ( property ) == "string" then -- Make sure there's a valid vehicle and a property string
- local handlingTable = getVehicleHandling ( element ) -- Get the handling as table and save as handlingTable
- local value = handlingTable[property] -- Get the value from the table
- if value then -- If there's a value (valid property)
- return value -- Return it
- end
- end
- return false -- Not an element, not a vehicle or no valid property string. Return failure
- end
- db = exports['sy_db']
- -- db:setDB("INSERT INTO `pystories-vehicles` (`model`,`ownedPlayer`,`mileage`,`registered`,`parking`,`engine`,`color`,`fuel`) VALUES (?,?,?,?,1,?,?,?)", model, getElementData(player,"player:sid"),0,"true",data['engine'],"255,255,255,255,255,255,255,255,255,255,255,255",'15')
- local vehicles = {
- -- id,x,y,z,rx,ry,rz,cena,silnik,paliwo,naped
- {422,2797.37, -2012.66, 13.54, 359.1, 0.0, 55.0,4100,'1.2',math.random(70000,140000),255,255}, -- bobcat
- {404,2789.74, -2027.07, 13.29, 359.7, 0.0, 70.0,2400,'1.2',math.random(70000,140000),0,0}, -- perek
- {600,2776.90, -2010.20, 13.29, 359.2, 360.0, 281.0,3600,'1.2',math.random(70000,140000),255,255}, -- picador
- {478,2765.90, -2023.73, 13.54, 359.2, 360.0, 315.0,1300,'1.2',math.random(70000,140000),0,0}, -- walton
- {418,2768.31, -2006.18, 13.65, 0.1, 360.0, 221.7,2200,'1.2',math.random(70000,140000),0,0}, -- klocek
- {410,2775.28, -2026.31, 13.21, 359.4, 0.0, 298.1,2300,'1.2',math.random(70000,140000),1,1}, -- manana
- }
- functions = {}
- functions.spawnAllVehicles = function()
- for k,v in pairs(vehicles) do
- veh = createVehicle(v[1],v[2],v[3],v[4],v[5],v[6],v[7],'SALON')
- sphere = createColSphere(v[2],v[3],v[4],3)
- setElementFrozen(veh,true)
- setVehicleColor(veh,75,75,75)
- local model = getModelHandling(tonumber(v[1]))
- local naped = string.upper(model["driveType"])
- setVehicleVariant(veh,v[11],v[12])
- setElementData(veh,'vehicle:salon',true)
- createBlip(2780.97, -2017.18, 13.55,55,2,255,255,255,255,0,300)
- setElementData(sphere,'vehicle:sell:info',{
- ['model'] = v[1],
- ['cost'] = v[8],
- ['engine'] = v[9],
- ['naped'] = naped,
- ['variant'] = {v[11],v[12]},
- ['mileage1'] = v[10],
- },
- true)
- setElementData(veh,'vehicle:sell:info',{
- ['model'] = v[1],
- ['cost'] = v[8],
- ['engine'] = v[9],
- ['naped'] = naped,
- ['variant'] = {v[11],v[12]},
- ['mileage1'] = v[10],
- },
- true)
- end
- end
- --exports["sy_noti"]:noti("Zasób "..getResourceName(getThisResource())..' został przeładowany. Przepraszamy za utrudnienia.',root, "error", 10000)
- addEventHandler('onResourceStart',resourceRoot,functions.spawnAllVehicles)
- functions.onShapeHit = function(hitElement)
- if getElementType(hitElement) == 'player' then
- local x = getElementData(source,'vehicle:sell:info')
- setElementData(hitElement,'vehicle:sell:info',x)
- exports["sy_noti"]:noti("Kliknij K aby kupić pojazd.","info", 5000,hitElement)
- bindKey(hitElement,'K','down',functions.buy)
- end
- end
- addEventHandler('onColShapeHit',resourceRoot,functions.onShapeHit)
- functions.buy = function(player)
- local data = getElementData(player,'vehicle:sell:info')
- cost = data.cost
- model = data.model
- engine = data.engine
- naped = data.naped
- fueltype = data.fueltype
- variant = data.variant
- mileage = data.mileage1
- iprint(variant)
- if cost > getPlayerMoney(player) then
- exports["sy_noti"]:noti("Nie masz tyle gotĂłwki!","error", 5000,player)
- return
- end
- takePlayerMoney(player,cost)
- exports['pystories-vehicles']:purchaseVehicle(player, data.model, 25, engine, mileage, variant, {2777.44, -1999.83, 13.15, 359.9, 10.6, 92.3})
- exports["sy_noti"]:noti("Pomyślnie zakupiłeś pojazd "..getVehicleNameFromModel(model)..'.',"sukces", 5000,player)
- return
- end
- functions.removeAllDatas = function(hitElement)
- if getElementType(hitElement) == 'player' then
- local x = getElementData(hitElement,'vehicle:sell:info')
- if x then
- setElementData(hitElement,'vehicle:sell:info',false)
- unbindKey(hitElement,'K','down')
- end
- end
- end
- addEventHandler('onColShapeLeave',resourceRoot,functions.removeAllDatas)
- addEventHandler('onVehicleStartEnter',resourceRoot,function()
- for i,v in ipairs(getElementsByType('vehicle')) do
- if getElementData(v,'vehicle:salon') then
- cancelEvent()
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment