Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2018-02-17, 00:23


KrySStiano







Wiek: 28
Na forum: 3332 dni
Posty: 13

Piwa: 1

Respekt: 50

Witam, posiadam problem z systemem pojemno?ci w pojazdach. Mianowicie zapisuj? si? one w bazie danych, lecz na serwerze do pojazd?w nie dodaj? si? ?aden handling.
Mo?e tutaj kto? b?dzie w stanie odszuka? b??d w skrypcie/skryptach.

Poni?ej wrzucam kody:

pojemnosc.lua
Kod:

function getVehicleHandlingProperty ( element, property )
if isElement ( element ) and getElementType ( element ) == "vehicle" and type ( property ) == "string" then
local handlingTable = getVehicleHandling ( element )
local value = handlingTable[property]
if value then
return value
end
end
return false
end

function lalal(vehicle)
local pojemnosc = getElementData(vehicle,"vehicle:pojemnosc")
local engineacc = getVehicleHandlingProperty(vehicle,"engineAcceleration")
local maxspeed = getVehicleHandlingProperty(vehicle,"maxVelocity")
if getElementData(vehicle, "vehicle:pojemnosc") == 1 then
setElementData(vehicle, "vehicle:pojemnosc", 1.2)
setVehicleHandling(vehicle, "maxVelocity", velocity+3)
setVehicleHandling(vehicle, "engineAcceleration", acceleration+1)
elseif getElementData(vehicle, "vehicle:pojemnosc") == 2 then
setElementData(vehicle, "vehicle:pojemnosc", 1.4)
setVehicleHandling(vehicle, "maxVelocity", velocity+3.5)
setVehicleHandling(vehicle, "engineAcceleration", acceleration+1.25)
elseif getElementData(vehicle, "vehicle:pojemnosc") == 3 then
setElementData(vehicle, "vehicle:pojemnosc", 1.6)
setVehicleHandling(vehicle, "maxVelocity", velocity+4)
setVehicleHandling(vehicle, "engineAcceleration", acceleration+1.5)
elseif getElementData(vehicle, "vehicle:pojemnosc") == 4 then
setElementData(vehicle, "vehicle:pojemnosc", 1.8)
setVehicleHandling(vehicle, "maxVelocity", velocity+4.5)
setVehicleHandling(vehicle, "engineAcceleration", acceleration+1.75)
elseif getElementData(vehicle, "vehicle:pojemnosc") == 5 then
setElementData(vehicle, "vehicle:pojemnosc", 2.0)
setVehicleHandling(vehicle, "maxVelocity", velocity+5)
setVehicleHandling(vehicle, "engineAcceleration", acceleration+2)
elseif getElementData(vehicle, "vehicle:pojemnosc") == 6 then
setElementData(vehicle, "vehicle:pojemnosc", 2.2)
setVehicleHandling(vehicle, "maxVelocity", velocity+5.5)
setVehicleHandling(vehicle, "engineAcceleration", acceleration+2.25)
elseif getElementData(vehicle, "vehicle:pojemnosc") == 7 then
setElementData(vehicle, "vehicle:pojemnosc", 2.4)
setVehicleHandling(vehicle, "maxVelocity", velocity+6)
setVehicleHandling(vehicle, "engineAcceleration", acceleration+2.5)
elseif getElementData(vehicle, "vehicle:pojemnosc") == 8 then
setElementData(vehicle, "vehicle:pojemnosc", 2.6)
setVehicleHandling(vehicle, "maxVelocity", velocity+6.5)
setVehicleHandling(vehicle, "engineAcceleration", acceleration+2.75)
elseif getElementData(vehicle, "vehicle:pojemnosc") == 9 then
setElementData(vehicle, "vehicle:pojemnosc", 2.8)
setVehicleHandling(vehicle, "maxVelocity", velocity+7)
setVehicleHandling(vehicle, "engineAcceleration", acceleration+3)
end
end



s_vehbuy.lua
Kod:

function getVehicleHandlingProperty ( element, property )
if isElement ( element ) and getElementType ( element ) == "vehicle" and type ( property ) == "string" then
local handlingTable = getVehicleHandling ( element )
local value = handlingTable[property]
if value then
return value
end
end
return false
end

function lalal(vehicle)
local pojemnosc = getElementData(vehicle,"vehicle:pojemnosc")
local engineacc = getVehicleHandlingProperty(vehicle,"engineAcceleration")
local maxspeed = getVehicleHandlingProperty(vehicle,"maxVelocity")
if getElementData(vehicle, "vehicle:pojemnosc") == 1 then
setElementData(vehicle, "vehicle:pojemnosc", 1.2)
setVehicleHandling(vehicle, "maxVelocity", velocity+3)
setVehicleHandling(vehicle, "engineAcceleration", acceleration+1)
elseif getElementData(vehicle, "vehicle:pojemnosc") == 2 then
setElementData(vehicle, "vehicle:pojemnosc", 1.4)
setVehicleHandling(vehicle, "maxVelocity", velocity+3.5)
setVehicleHandling(vehicle, "engineAcceleration", acceleration+1.25)
elseif getElementData(vehicle, "vehicle:pojemnosc") == 3 then
setElementData(vehicle, "vehicle:pojemnosc", 1.6)
setVehicleHandling(vehicle, "maxVelocity", velocity+4)
setVehicleHandling(vehicle, "engineAcceleration", acceleration+1.5)
elseif getElementData(vehicle, "vehicle:pojemnosc") == 4 then
setElementData(vehicle, "vehicle:pojemnosc", 1.8)
setVehicleHandling(vehicle, "maxVelocity", velocity+4.5)
setVehicleHandling(vehicle, "engineAcceleration", acceleration+1.75)
elseif getElementData(vehicle, "vehicle:pojemnosc") == 5 then
setElementData(vehicle, "vehicle:pojemnosc", 2.0)
setVehicleHandling(vehicle, "maxVelocity", velocity+5)
setVehicleHandling(vehicle, "engineAcceleration", acceleration+2)
elseif getElementData(vehicle, "vehicle:pojemnosc") == 6 then
setElementData(vehicle, "vehicle:pojemnosc", 2.2)
setVehicleHandling(vehicle, "maxVelocity", velocity+5.5)
setVehicleHandling(vehicle, "engineAcceleration", acceleration+2.25)
elseif getElementData(vehicle, "vehicle:pojemnosc") == 7 then
setElementData(vehicle, "vehicle:pojemnosc", 2.4)
setVehicleHandling(vehicle, "maxVelocity", velocity+6)
setVehicleHandling(vehicle, "engineAcceleration", acceleration+2.5)
elseif getElementData(vehicle, "vehicle:pojemnosc") == 8 then
setElementData(vehicle, "vehicle:pojemnosc", 2.6)
setVehicleHandling(vehicle, "maxVelocity", velocity+6.5)
setVehicleHandling(vehicle, "engineAcceleration", acceleration+2.75)
elseif getElementData(vehicle, "vehicle:pojemnosc") == 9 then
setElementData(vehicle, "vehicle:pojemnosc", 2.8)
setVehicleHandling(vehicle, "maxVelocity", velocity+7)
setVehicleHandling(vehicle, "engineAcceleration", acceleration+3)
end
end


Te 2 powy?sze skrypty, s? to skrypty z ogrpg_vehicles

Poni?ej wrzucam kod salonu od strony serwera.

Kod:

local positionVehicles = {
-- nazwa, model, przebieg, cena, x,y,z,rx,ry,rz, sprzedaz
-- Salon Zwykly i luksus
-- CYGAN

-- CYGAN
{'Nazwa: Perennial', 404, 70000, 1400, 1114.10,-313.60,73.69, 359.6, 1.0, 45.5,"1.2"},
{'Nazwa: Manana', 410, 97542, 2250, 1070.79,-293.04,73.59, 356.6, 359.0, 180.8,"1.4"},
{'Nazwa: Moonbeam', 418, 96452, 2000, 1113.63,-341.17,73.89, 0.2, 8.6, 89.8,"1.4"},
{'Nazwa: Walton', 478, 97642, 950, 1016.24,-320.22,73.89, 1.7, 359.6, 180.4,"1.0"},
{'Nazwa: Vincent', 540, 97642, 2600, 1065.17,-333.17,73.89, 1.7, 359.6, 180.4,"1.4"},
{'Nazwa: Sadler', 543, 97642, 1800, 1057.31,-334.80,73.69, 1.7, 359.6, 180.4,"1.2"},
-- LuxCars - AutoBahn
{'Nazwa: Tampa', 549, 67747, 1400, 997.81,-1460.19,13.26, 359.6, 1.0, 0.5,"1.2"},
{'Nazwa: Majestic', 517, 77747, 2454, 1005.70,-1460.32,13.32, 359.6, 1.0, 0.5,"1.4"},
{'Nazwa: Intruder', 546, 77747, 3213, 1012.50,-1459.71,13.35, 359.6, 1.0, 0.5,"1.4"},
-- Salon u Niemca
{'Nazwa: Clover', 542, 9, 11500, 2143.38,-2078.61,13.21, 0.0, 1.0, 90,"3.6"},
{'Nazwa: Tampa', 549, 118, 4250, 2143.84,-2095.04,13.21, 359.6, 1.0, 90.5,"1.2"},
{'Nazwa: Glendale', 466, 26, 7600, 2097.64,-2094.57,13.21, 359.6, 1.0, 90.5,"1.4"},
{'Nazwa: Cadrona', 527, 1, 6200, 2131.27,-2083.88,13.21, 0,0, 90.5 ,"1.2"},
{'Nazwa: Picador', 600, 398, 3900, 2108.08,-2089.88,13.21, 0,0, 90.5 ,"1.2"},
}

local shape = {}

for i,v in pairs(positionVehicles) do
local veh=createVehicle(v[2], v[5], v[6], v[7], v[8], v[9], v[10], v[11])
setElementData(veh, "wystawowy", true)
setElementData(veh,'vehicle:desc',' '..v[1]..'\nCena: '..v[4]..' PLN\nPrzebieg: '..v[3]..' km\nPojemno?? silnika: '..v[11]..' dm3\nAby go zakupi?, wejdz do pojazdu!')
setElementData(veh, "obracanie", true)
setElementCollisionsEnabled(veh, true)
setVehicleOverrideLights(veh, 2)
setElementFrozen(veh,true)
setVehicleColor(veh, 0,125,255)
setVehicleHeadLightColor(veh, 0, 0, 0)
setVehiclePlateText(veh,v[1])
setVehicleDamageProof(veh, true)
setElementData(veh,'vehicle.selling', true)

veh:setData('vehsell:info', {
['cost']=(v[4]),
['model']=v[2],
['mileage']=v[3],
['selling']=v[12],
['pojemnosc']=v[11]
}, false)
end

addEventHandler('onVehicleEnter', resourceRoot, function(plr, seat, jacked)
if seat~=0 then return end
if source:getData('vehsell:info') and source:getData('vehsell:info').selling==1 then
--plr:outputChat('* Pojazd nie jest dostepny w sprzedazy.', 255, 0, 0)
return
end

local data=source:getData('vehsell:info')
if not data then return end

plr:setData('vehsell:info', {
['cost']=data.cost,
['model']=data.model,
['mileage']=data.mileage,
['pojemnosc']=data.pojemnosc,
}, false)

exports["er-notyfikacje"]:showBox(plr, "info", "Ten pojazd jest na sprzeda?! Aby go zakupi?, u?yj komendy /zakuppojazd!")
end)

addEventHandler('onVehicleExit', resourceRoot, function(plr, seat, jacked)
if seat~=0 then return end

local data=plr:getData('vehsell:info')
if not data then return end

plr:removeData('vehsell:info')
end)

addCommandHandler('zakuppojazd', function(plr, cmd)
local data=plr:getData('vehsell:info')
if not data then return end

if getPlayerMoney(plr) < data.cost then
exports["er-notyfikacje"]:showBox(plr, "error", "Nie sta? Ci? na ten pojazd! Brakuje Ci ".. data.cost - getPlayerMoney(plr).." PLN!")
return
end

local cost=data.cost
local model=data.model
local mileage=data.mileage
local pojemnosc=data.pojemnosc
local uid=getElementData(plr,'player:uid') or 0
takePlayerMoney(plr, cost)
if mileage <= 2000 then
exports["ogrpg-db"]:dbSet("INSERT INTO ogrpg_vehicles (model,ownedPlayer,mileage,registered,pojemnosc,parking) VALUES (?,?,?,?,?,1)", model, getElementData(plr,"player:uid"),mileage,"false",pojemnosc)
else
exports["ogrpg-db"]:dbSet("INSERT INTO ogrpg_vehicles (model,ownedPlayer,mileage,registered,pojemnosc,parking) VALUES (?,?,?,?,?,1)", model, getElementData(plr,"player:uid"),mileage,"true",pojemnosc)
end
fadeCamera(plr, false)
setTimer(function()
local vehicle=plr:getOccupiedVehicle()
if vehicle then
removePedFromVehicle(plr)
end
fadeCamera(plr, true)
exports["er-notyfikacje"]:showBox(plr, "success", "Zakup "..getVehicleName(vehicle).." przebieg? pomy?lnie! Przenie?li?my Ciebie pod przechowywalnie!")
setElementPosition(plr, 2533.05, 2334.07, 10.82)
setElementRotation(plr, 0, 0, -90)
end, 2050, 1)
end)


createBlip(1001.69,-1448.84,23.29, 55,2,0,0,0,0,0,275)
createBlip(1034.61,-337.19,83.49, 55,2,0,0,0,0,0,275)
createBlip(1644.27,-1817.76,21.89, 55,2,0,0,0,0,0,275)


Prosz? o pomoc :)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-02-17, 17:16


Ciastuuś

Truck soon...






Wiek: 26
Na forum: 3071 dni
Posty: 799
Nick w MP: Ciastuuś

Piwa: 4297

Respekt: 640
Respekt: 640Respekt: 640

Prosz? Ci?, aby? da? to w znacznikach lua, czyli [lua] [./lua] - bez kropki

Do tego s? jakie? b??dy w debugscript 3?

Podpis
Truck soon...
Postaw piwo autorowi tego posta
 

 
Tagi: nie :: dziala :: system :: pojemnosci :: samochodach :: ogrpg :: aspire
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku