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

Wysłany: 2017-10-13, 16:15


Janusz_GRA

NO NAME






Wiek: 26
Na forum: 3716 dni
Posty: 223
Nick w MP: michalMonster

Piwa: 175

Respekt: 85,8

Witam mam problem z autami na serwerze. Po restarcie serwera usuwa si? tuning auta oraz przywracaj? si? pojazdy kt?re by?y usuni?te. Korzystam z paczki XaWord czyli SunnyRPG. Kod ze skryptu nm-pojazdy. Dlaczego tak si? dzieje?
client.lua
local screenW,screenH guiGetScreenSize()

function roundedRectangle(xywhcolor)
  exports["nm-blur"]:dxDrawBluredRectangle(xywhtocolor(255,255,255), false)
  exports["nm-blur"]:dxDrawBluredRectangle(2141tocolor(255,255,255), false)
  exports["nm-blur"]:dxDrawBluredRectangle(2h41tocolor(255,255,255), false)
  exports["nm-blur"]:dxDrawBluredRectangle(1214tocolor(255,255,255), false)
  exports["nm-blur"]:dxDrawBluredRectangle(w214tocolor(255,255,255), false)
  dxDrawRectangle(xywhcolorfalse)
  dxDrawRectangle(2141colorfalse)
  dxDrawRectangle(2h41colorfalse)
  dxDrawRectangle(1214colorfalse)
  dxDrawRectangle(w214colorfalse)
end

local sxsy guiGetScreenSize()

function mysz(psx,psy,pssx,pssy,abx,aby)
    if not isCursorShowing() then return end
    cx,cy=getCursorPosition()
    cx,cy=cx*sx,cy*sy
    if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then
        return true,cx,cy
    else
        return false
    end
end


addEventHandler("onClientRender"root, function()
  for i,v in ipairs(getElementsByType("vehicle")) do
    if getElementData(v"obracanie"then
      local rxryrz getVehicleRotation(v)
      setElementRotation(v00rz+1)
    end
  end
end)

-- kary --

function guikary()
        local auto getPedOccupiedVehicle (localPlayer)
        local kwota getElementData(auto,"kwotakary")
        local powod getElementData(auto,"powodkary")
        dxDrawRectangle(screenW 0.3715screenH 0.2378screenW 0.2875screenH 0.4867tocolor(000180), false)
        dxDrawRectangle(screenW 0.3715screenH 0.1978screenW 0.2875screenH 0.0622tocolor(741781255), false)
        dxDrawText("Kara"screenW 0.3708screenH 0.1967screenW 0.6590screenH 0.2600tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
        dxDrawText("Auto posiada na?o?on? kare przez policje\n\nKwota: "..kwota.."\n\nPow?d: "..powod.."\n\n Aby zap?aci? za kare i m?c je?dzi? swoim autem kliknij \"Op?a? kare\""screenW 0.3701screenH 0.2600screenW 0.6590screenH 0.5111tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
        dxDrawRectangle(screenW 0.4007screenH 0.5167screenW 0.2250screenH 0.0700tocolor(741781255), false)
        dxDrawRectangle(screenW 0.4007screenH 0.6078screenW 0.2250screenH 0.0700tocolor(741781255), false)
        dxDrawText("Op?a? kare"screenW 0.4000screenH 0.5156screenW 0.6257screenH 0.5867tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
        dxDrawText("Nie p?ac za kare"screenW 0.4000screenH 0.6067screenW 0.6257screenH 0.6778tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
end

jestoknokary false

addEvent("oknoKary"true)
addEventHandler("oknoKary"root, function()
    addEventHandler("onClientRender"rootguikary)
    jestoknokary true
    showCursor(true)
end)

addEventHandler("onClientClick"root, function(btnstate)
if btn == "left" and state == "down" then
if mysz(screenW 0.4007screenH 0.5167screenW 0.2250screenH 0.0700) and jestoknokary == true then
local kasa getElementData(localPlayer,"pieniadze")
local auto getPedOccupiedVehicle (localPlayer)
local kwota getElementData(auto,"kwotakary")
setElementData(localPlayer,"pieniadze"kasa-kwota)
outputChatBox("Zap?aci?e? za kare "..kwota.."")
jestoknokary false
showCursor(false)
removeEventHandler("onClientRender"rootguikary)
setElementData(auto,"kara"false)
elseif mysz(screenW 0.4007screenH 0.6078screenW 0.2250screenH 0.0700) and jestoknokary == true then
triggerServerEvent("wybralnieplace"localPlayer)
jestoknokary false
showCursor(false)
removeEventHandler("onClientRender"rootguikary)
end
end
end)


addCommandHandler("dajkare", function()
local auto getPedOccupiedVehicle (localPlayer)
setElementData(auto,"powodkary""Ty ****")
setElementData(auto,"kwotakary"5)
setElementData(auto,"kara"true)
end)


server.lua
addEventHandler("onVehicleEnter"root, function(plrseat)
if seat ~= 0 then return end
local kto getPlayerName(plr)
setElementData(source"ostatnikierowca"kto)
end)

-- system odsylania pojazdow do przechowalni po okreslonym czasie

addEventHandler("onVehicleExit"resourceRoot, function(gracztryb)
    if tryb ~= 0 then return end
    setElementData(source"naliczanie"true)
    local pojazd source
    setTimer(function()
        if pojazd and isElement(pojazdthen
            if getElementData(pojazd"naliczanie"then
                exports.mysql:wykonaj("UPDATE pojazdy SET przechowalnia=1 WHERE id=?"getElementData(pojazd"id"))
                destroyElement(pojazd)
            end
        end
    end252000001)
end)

addEventHandler("onVehicleEnter"resourceRoot, function(gracztryb)
    if tryb ~= 0 then return end
    setElementData(source"naliczanie"false)
end)


-- koniec

addEventHandler("onResourceStart"resourceRoot, function()
    local spr exports.mysql:wykonaj("SELECT * FROM pojazdy WHERE przechowalnia=0")
    for _p in ipairs(spr) do
        stworzPojazdy(p)
    end
end)

addEventHandler("onResourceStop"resourceRoot, function()
    for _p in ipairs(getElementsByType("vehicle")) do
        zapiszPojazdy(p)
    end
end)

function stworzPojazdy(p,x,y,z,rx,ry,rz)
    local pozycja split(p.pozycja",")
    local kolor split(p.kolor",")
    local pojazd false
    if and and and rx and ry and rz then
        pojazd createVehicle(p.modelxyzrxryrz)
    else
        pojazd createVehicle(p.modelpozycja[1], pozycja[2], pozycja[3], pozycja[4], pozycja[5], pozycja[6])
    end
    setVehicleColor(pojazdkolor[1], kolor[2], kolor[3], kolor[4], kolor[5], kolor[6])
    setElementData(pojazd"wlasciciel"p.wlasciciel)
    setElementData(pojazd"id"p.id)
    setElementData(pojazd"przebieg"p.przebieg)
    setElementData(pojazd"paliwo"p.paliwo)
    setElementData(pojazd"pojemnosc1"p.pojemnosc)
        setElementData(pojazd"veh:cb"p.cb)
    setElementHealth(pojazdp.zdrowie)
    if (p.panelstates~="0,0,0,0,0,0,0"then
        p.panelstates=split(p.panelstates,",")
        for i,v in ipairs(p.panelstates) do
          setVehiclePanelState(pojazd,i-1tonumber(v))
        end
    else
        p.panelstates=split(p.panelstates,",")
    end
    local tuning split(p.tuning",")
    for i=1,#tuning do
        addVehicleUpgrade(pojazdtuning[i])
    end
    --dodatki mechaniczne
    if p.intercooler == 1 then
        local handling getVehicleHandling(pojazd)
        setVehicleHandling(pojazd"engineAcceleration"handling.engineAcceleration+0.75)
        setElementData(pojazd,"up1",true)
    end
    if p.filtr == 1 then
        local handling getVehicleHandling(pojazd)
        setVehicleHandling(pojazd"engineAcceleration"handling.engineAcceleration+1.25)
        setElementData(pojazd,"up2",true)
    end
    if p.sturbo == 1 then
        local handling getVehicleHandling(pojazd)
        setVehicleHandling(pojazd"maxVelocity"handling.maxVelocity+15)
        setVehicleHandling(pojazd"engineAcceleration"handling.engineAcceleration+2)
        setElementData(pojazd,"up3",true)
    end
    if p.duklad == 1 then
        local handling getVehicleHandling(pojazd)
        setVehicleHandling(pojazd"maxVelocity"handling.maxVelocity+8)
        setVehicleHandling(pojazd"engineAcceleration"handling.engineAcceleration+1.2)
        setElementData(pojazd,"up4",true)
    end
    if p.zawieszenie == 1 then
        setElementData(pojazd"zawieszenie"2)
    end
    setElementData(pojazd"bak"p.bak)
    --
    if p.organizacja:len() > 2 then
        setElementData(pojazd"organizacja"p.organizacja)
    else
        setElementData(pojazd"organizacja"false)
    end
    if p.rejestracja:len() > 1 then
        setVehiclePlateText(pojazdp.rejestracja)
    else
        setVehiclePlateText(pojazd"FC "..p.id)
    end
    if p.naped:len() > 1 then
        setVehicleHandling(pojazd"driveType"p.naped)
    end
    if p.swiatla:len() > 1 then
        local swiatla split(p.swiatla",")
        setVehicleHeadLightColor(pojazdswiatla[1], swiatla[2], swiatla[3])
    end

if getElementData(pojazd"pojemnosc1") == 1 then
        setElementData(pojazd,"pojemnosc"1.2)
        setVehicleHandling(pojazd"maxVelocity"getVehicleHandling(pojazd).maxVelocity+1)
        setVehicleHandling(pojazd"engineAcceleration"getVehicleHandling(pojazd).engineAcceleration)
elseif getElementData(pojazd"pojemnosc1") == 2 then
        setElementData(pojazd,"pojemnosc"1.4)
        setVehicleHandling(pojazd"maxVelocity"getVehicleHandling(pojazd).maxVelocity+5)
        setVehicleHandling(pojazd"engineAcceleration"getVehicleHandling(pojazd).engineAcceleration)
elseif getElementData(pojazd"pojemnosc1") == 3 then
        setElementData(pojazd,"pojemnosc"1.6)
        setVehicleHandling(pojazd"maxVelocity"getVehicleHandling(pojazd).maxVelocity+10)
        setVehicleHandling(pojazd"engineAcceleration"getVehicleHandling(pojazd).engineAcceleration+1)
elseif getElementData(pojazd"pojemnosc1") == 4 then
        setElementData(pojazd,"pojemnosc"1.8)
        setVehicleHandling(pojazd"maxVelocity"getVehicleHandling(pojazd).maxVelocity+15)
        setVehicleHandling(pojazd"engineAcceleration"getVehicleHandling(pojazd).engineAcceleration+2)
elseif getElementData(pojazd"pojemnosc1") == 5 then
        setElementData(pojazd,"pojemnosc"2.0)
        setVehicleHandling(pojazd"maxVelocity"getVehicleHandling(pojazd).maxVelocity+20)
        setVehicleHandling(pojazd"engineAcceleration"getVehicleHandling(pojazd).engineAcceleration+4)
elseif getElementData(pojazd"pojemnosc1") == 6 then
        setElementData(pojazd,"pojemnosc"2.2)
        setVehicleHandling(pojazd"maxVelocity"getVehicleHandling(pojazd).maxVelocity+25)
        setVehicleHandling(pojazd"engineAcceleration"getVehicleHandling(pojazd).engineAcceleration+6)
elseif getElementData(pojazd"pojemnosc1") == 7 then
        setElementData(pojazd,"pojemnosc"2.4)
        setVehicleHandling(pojazd"maxVelocity"getVehicleHandling(pojazd).maxVelocity+30)
        setVehicleHandling(pojazd"engineAcceleration"getVehicleHandling(pojazd).engineAcceleration+8)
elseif getElementData(pojazd"pojemnosc1") == 8 then
        setElementData(pojazd,"pojemnosc"2.6)
        setVehicleHandling(pojazd"maxVelocity"getVehicleHandling(pojazd).maxVelocity+35)
        setVehicleHandling(pojazd"engineAcceleration"getVehicleHandling(pojazd).engineAcceleration+10)
elseif getElementData(pojazd"pojemnosc1") == 9 then
        setElementData(pojazd,"pojemnosc"2.8)
         setVehicleHandling(pojazd"maxVelocity"getVehicleHandling(pojazd).maxVelocity+40)
        setVehicleHandling(pojazd"engineAcceleration"getVehicleHandling(pojazd).engineAcceleration+12)
        elseif getElementData(pojazd"pojemnosc1") == 10 then
        setElementData(pojazd,"pojemnosc"3.0)
         setVehicleHandling(pojazd"maxVelocity"getVehicleHandling(pojazd).maxVelocity+100)
        setVehicleHandling(pojazd"engineAcceleration"getVehicleHandling(pojazd).engineAcceleration+36)
    end
    return pojazd
end

function zapiszPojazdy(p)
    local id getElementData(p"id")
    if not id then return end
    local xygetElementPosition(p)
    local model getVehicleModel(p)
    local rxryrz getElementRotation(p)
    local r1,g1,b1r2,g2,b2 getVehicleColor(ptrue)
    local pozycja x..", "..y..", "..z..", "..rx..", "..ry..", "..rz
    local kolor r1..", "..g1..", "..b1..", "..r2..", "..g2..", "..b2
    local zdrowie getElementHealth(p)
    local paliwo getElementData(p"paliwo")
    local przebieg getElementData(p"przebieg")
        local pojemnosc getElementData(p,"pojemnosc1")
        local cb getElementData(p"veh:cb") or 0
    local panelstates={}
    for i=0,do
        table.insert(panelstatesgetVehiclePanelState(p,i))
    end
    panelstates=table.concat(panelstates,",")
    local licznik getElementData(p"lrgb")
    local r,g,false
    if licznik then
        r licznik.r
        g licznik.g
        b licznik.b
    else
        255
        g 255
        b 255
    end
    local r3g3b3 getVehicleHeadLightColor(p)
    local swiatla r3..", "..g3..", "..b3
    licznik r..", "..g..", "..b
    local tuning getVehicleUpgrades(p)
    if not tuning then
        tuning = {}
    end
    tuning table.concat(tuning",")
    local wyk exports.mysql:wykonaj("UPDATE pojazdy SET pozycja=?, model=?, kolor=?, panelstates=?, zdrowie=?, paliwo=?, przebieg=?, licznik=?, swiatla=?, pojemnosc=?, tuning=?, cb=? WHERE id=?"pozycjamodelkolorpanelstateszdrowiepaliwoprzebieglicznikswiatlapojemnosctuningcbid)
    if not wyk then
        outputDebugString("Nie udalo sie zapisac pojazdu o id "..id)
    end
end

addEventHandler("onVehicleStartEnter"root, function(graczseat)
    if seat ~= 0 then return end
    if getElementData(source"id"then
        if getElementData(source"keys") and getElementData(source"keys") == getElementData(gracz"dbid"then return end
        if getElementData(source"organizacja") and getElementData(source"organizacja") == getElementData(gracz"organizacja"then return end
        if getElementData(source"wlasciciel") ~= getElementData(gracz"dbid"then
            cancelEvent()
            exports["nm-noti"]:noti("Ten pojazd nie nale?y do ciebie."gracz)
        end
    end
end)

local motory = {
{"Freeway"},
{"FCR-900"},
{"Faggio"},
{"Pizzaboy"},
{"BF-400"},
{"NRG-500"},
{"PCJ-600"},
{"HPV-1000"},
{"Wayfarer"},
{"Sanchez"},
{"Quadbike"},
}

addEventHandler("onVehicleStartEnter"root, function(gtyp)
    if typ ~= 0 then return end
    local serial getPlayerSerial(g)
    local spr exports.mysql:wykonaj("SELECT * FROM prawka WHERE serial=? AND data>NOW()"serial)
    if #spr > 0 then
        exports["nm-noti"]:noti("Posiadasz zawieszone prawo jazdy kat. A,B,C od "..spr[1].admin.." do "..spr[1].datag)
        cancelEvent()
    else
        exports.mysql:wykonaj("DELETE FROM prawka WHERE serial=?"serial)
    end
end)

addEventHandler("onVehicleStartEnter"root, function(graczseat)
    if seat ~= 0 then return end
    if not getElementData(source"id"then return end
     for i,v in ipairs(motory) do
         if v[1] == getVehicleName(sourcethen 
             if getElementData(gracz"prawko_a") ~= 1 then
                 cancelEvent()
                exports["nm-noti"]:noti("Nie posiadasz prawa jazdy kategorii A."gracz)
                 return 
             end
         end
     end
    if getElementData(gracz"prawko_b") ~= 1 then
        cancelEvent()
        exports["nm-noti"]:noti("Nie posiadasz prawa jazdy kategorii B."gracz)
    end
end)

-- anty wybuch pojazdow

setTimer(function()
for _vehicle in pairs(getElementsByType("vehicle")) do
if getElementHealth(vehicle) < 300 then
setVehicleDamageProof(vehicletrue)
elseif getElementHealth(vehicle) > 301 then
if getVehicleController (vehiclethen
setVehicleDamageProof(vehiclefalse)
end
end
end
end5000)

setTimer(function()
for _vehicle in pairs(getElementsByType("vehicle")) do
if not getVehicleController(vehiclethen
setVehicleDamageProof(vehicletrue)
end
end
end5000)

addEventHandler("onVehicleEnter"resourceRoot, function(gracztryb)
  if tryb ~= 0 then return end
  local pojazd source
  if getElementData(pojazd"kara"then
    triggerClientEvent(gracz"oknoKary"source)
  end
end)

addEvent("wybralnieplace"true)
addEventHandler("wybralnieplace",root, function()
removePedFromVehicle(source)
end)

Licz? na szybk? pomoc, oczywi?cie stawiam :piwo: R*

Postaw piwo autorowi tego posta
 

 
Tagi: pojazdy
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Pojazdy 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