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

Wysłany: 2019-11-15, 01:53


Kulegg







Wiek: 46
Na forum: 3125 dni
Posty: 283

Piwa: 20

Respekt: 50

Cze??,
Posiadam dashboard i jest tam opcja "Pojazdy"
i gdy klikniemy to wy?wietlaj? nam si? jakie auta kupione posiadamy, jest te? zrobiona funkcja na lokalizacje auta ale chyba nie dzia?aj?ca, gdy? pisze N/A, nawet je?li auto jest wyj?te lub jest w przechowywalni, co musz? zrobi? aby to naprawi??

Kod :

        for i,v in ipairs(pojazdy) do
            if >= k2 and <= n2 then 
                x2 x2 1
                local dodatekY = (87*py)*(x2-1)
                local dodatekY2 = (174*py)*(x2-1)

                local model getVehicleNameFromModel(v.model)

                local lokalizacja "N/A";
                if tonumber(v.parking) == 1 then
                 lokalizacja "Przechowalnia pojazd?w"
                else
                 for k,p in ipairs(getElementsByType("vehicle")) do
                         local id getElementData(p"vehicle:id")
                         if id and id == v["vehicle:id"then
                         local x,y,getElementPosition(p)
                         lokalizacja getZoneName(x,y,z,true)..", "..getZoneName(x,y,z,false)
                         end
                  end
               end
                dxDrawRectangle(441*px353*py dodatekY562*px87*pytocolor(000140), false)
                dxDrawLine(441*px440*py+dodatekY1003*px440*py+dodatekYtocolor(240128255255), 2false)
                dxDrawImage(448*px358*py dodatekY75*px75*py"grafiki/auto.png"000tocolor(255255255255), false)
                shadowText(model.." ["..v.id.."]"567*px353*py dodatekY2779*px396*pytocolor(255255255255), 1.00font"left""center"falsefalsefalsefalsefalse)
                shadowText(lokalizacja567*px396*py dodatekY2779*px439*pytocolor(255255255255), 1.00fontsmall"left""center"falsefalsefalsefalsefalse)
            end
       end
    end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-11-15, 14:03


Pan.Holingo







Wiek: 22
Na forum: 3354 dni
Posty: 22
Nick w MP: Holingo

Piwa: 158

Respekt: 50

W kodzie chcesz, aby po podj?ciu warto?? logiczn? zrobi? dane dzia?anie... lecz skrypt nie wie co skrywa si? pod warto?ci? v.parking. Dlatego oddaje Ci N/A, bo tak jest domy?lnie ustawione przez Ciebie.

if tonumber(v.parking) == 1 then


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-11-15, 17:31


Kulegg







Wiek: 46
Na forum: 3125 dni
Posty: 283

Piwa: 20

Respekt: 50

czyli co musz? zrobi?? :/

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-11-15, 19:10


Pan.Holingo







Wiek: 22
Na forum: 3354 dni
Posty: 22
Nick w MP: Holingo

Piwa: 158

Respekt: 50

Musisz pokaza? pe?ny skrypt, brakuje mi tu kod. R?wnie? jakby? m?g? pokaza? przynajmniej jedn? p?l danych w MySQL. (Z t? kt?r? si? ??czy i s? zapisywane dane)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-11-15, 20:56


Kulegg







Wiek: 46
Na forum: 3125 dni
Posty: 283

Piwa: 20

Respekt: 50

Pelen kod:

--[[
AutorMalentas
EditDylemaT929
Edit by Asper for Nike69
]]

local screenWscreenH guiGetScreenSize()
local sxsy guiGetScreenSize()
local pxpy screenW/1440screenH/900

local listaaut false
local statystyki false
local kary false
local ustawienia false
local dashboard false
local lokalizacja "N/A"

local k 1
local n 4
local m 4

local k2 1
local n2 4
local m2 4

local pojazdy = {}

local fontsmall dxCreateFont("cz.ttf"10)
local font dxCreateFont("cz.ttf"12)
local font2 dxCreateFont("cz.ttf"25)

local width 1082*px
local height 324*py
local scrollPos 0
local scrollOffset 5.0

local maxRender dxCreateRenderTarget(widthheighttrue)

on=dxCreateTexture("grafy/switch_off.png""argb"false"clamp")
off=dxCreateTexture("grafy/switch_on.png""argb"false"clamp")

sw,sh guiGetScreenSize()
zoom=1920/sw

function gui()
    dxDrawRectangle(00screenWscreenHtocolor(000100), false)
        dxDrawImage((screenW * -0.0039) + 1, (screenH * -0.0100) - 1, (screenW 1.0050) + 1, (screenH 1.0270) - 1":np-dashboard/grafy/Dashboard.png"000tocolor(255255255255), false)
    if mysz(1115*px150*py46/zoom46/zoomthen
        dxDrawImage(1040*px50*py256/zoom256/zoom":np-dashboard/grafy/informacje_on.png"000tocolor(2552150255), false)  -- info
    else
        dxDrawImage(1040*px50*py256/zoom256/zoom":np-dashboard/grafy/informacje_off.png"000tocolor(255255255255), false) -- info
    end
    if mysz(1115*px230*py46/zoom46/zoomthen
        dxDrawImage(1040*px137*py256/zoom256/zoom":np-dashboard/grafy/informacje_on.png"000tocolor(2552150255), false) -- regulamin
    else
        dxDrawImage(1040*px137*py256/zoom256/zoom":np-dashboard/grafy/informacje_off.png"000tocolor(255255255255), false) -- regulamin
    end
    if mysz(1115*px315*py46/zoom46/zoomthen
        dxDrawImage(1040*px229*py256/zoom256/zoom":np-dashboard/grafy/informacje_on.png"000tocolor(2552150255), false) -- pojazdy
    else
        dxDrawImage(1040*px229*py256/zoom256/zoom":np-dashboard/grafy/informacje_off.png"000tocolor(255255255255), false) -- pojazdy
    end
    if mysz(1115*px405*py46/zoom46/zoomthen
        dxDrawImage(1040*px319*py256/zoom256/zoom":np-dashboard/grafy/informacje_on.png"000tocolor(2552150255), false) -- premium
    else
        dxDrawImage(1040*px319*py256/zoom256/zoom":np-dashboard/grafy/informacje_off.png"000tocolor(255255255255), false) -- premium
    end
    if statystyki == true then 
        local dbid getElementData(localPlayer"player:uid") or 0
        local pieniadze getPlayerMoney(localPlayer)
        local bankomat getElementData(localPlayer"player:bankomat") or 0
        local rp getElementData(localPlayer"player:reputation") or 0
        local minuty getElementData(localPlayer"player:hours") or 0

        local prawkoA getElementData(localPlayer"player:license:pjA") or 0
        if prawkoA == 1 then
            prawkoA "Posiadasz"
            prawkoA2 "#ff80f9Posiadasz"
        else
            prawkoA "Nie posiadasz"
            prawkoA2 "#ff0000Nie posiadasz"
        end

        local prawkoB getElementData(localPlayer"player:license:pjB") or 0
        if prawkoB == 1 then
            prawkoB "Posiadasz"
            prawkoB2 "#ff80f9Posiadasz"
        else
            prawkoB "Nie posiadasz"
            prawkoB2 "#ff0000Nie posiadasz"
        end

        local prawkoC getElementData(localPlayer"player:license:pjC") or 0
        if prawkoC == 1 then
            prawkoC "Posiadasz"
            prawkoC2 "#ff80f9Posiadasz"
        else
            prawkoC "Nie posiadasz"
            prawkoC2 "#ff0000Nie posiadasz"
        end
        
        local lics getElementData(localPlayer"player:license:licS") or 0
        if lics == 1 then
            lics "Posiadasz"
            lics2 "#FFD700Posiadasz"
        else
            lics "Nie posiadasz"
            lics2 "#ff0000Nie posiadasz"
        end
        local przynety getElementData(localPlayer"przynety") or 0
        --dxDrawText("Nick: "..getPlayerName(localPlayer).."\nData rejestracji: "..(getElementData(localPlayer"player:registerdate") or "?")..""380*px738*py481*px806*pytocolor(000255), 1.00font"center""center"falsefalsefalsefalsefalse)  
        dxDrawText("Nick: #ff80f9"..getPlayerName(localPlayer).."#ffffff\nData rejestracji: #ff80f9"..(getElementData(localPlayer"player:registerdate") or "?")..""347*px, -20*py1108*px740*pytocolor(255255255255), 1.00font"center""center"falsefalsefalsetruefalse)    
        dxDrawText("uID: "..dbid.."\nGot?wka: "..pieniadze.." PLN\nCzas online: "..mth(minuty)[1].."h "..mth(minuty)[2].."m\nPunkty RP: "..rp.."\n\nPrawo jazdy kat.A: "..prawkoA.."\nPrawo jazdy kat.B: "..prawkoB.."\nPrawo jazdy kat.C: "..prawkoC.."\nLicencja na bro?:"..lics..""347*px299*py1108*px740*pytocolor(000255), 1.00font"center""center"falsefalsefalsefalsefalse)
        dxDrawText("UID: #ff80f9"..dbid.."#ffffff\nGot?wka: #ff80f9"..pieniadze.." PLN#ffffff\nCzas online: #ff80f9"..mth(minuty)[1].."h "..mth(minuty)[2].."m#ffffff\nPunkty RP: #ff80f9"..rp.."\n\n#ffffffPrawo jazdy kat.A: "..prawkoA2.."\n#ffffffPrawo jazdy kat.B: "..prawkoB2.."\n#ffffffPrawo jazdy kat.C: "..prawkoC2.."\n#ffffffLicencja na bro?: "..lics2..""346*px298*py1107*px739*pytocolor(255255255255), 1.00font"center""center"falsefalsefalsetruefalse)
        if not myElement or not myObject then return end
        local projPosXprojPosY guiGetPosition(guiWindow,true)
        local projSizeXprojSizeY guiGetSize(guiWindowtrue)
        exports.object_preview:setProjection(myObjectprojPosXprojPosYprojSizeXprojSizeYtruetrue)
    end
    if kary == true then
        dxDrawText("x Zabrania si? obra?anie graczy/administracji\nx Zabrania si? u?ywanie wulgaryzm?w\nx Zabrania si? przeszkadzanie w RP\nx Zabrania si? bieganie po drogach tylko po chodnikach.\nx Zabrania si? taranowanie innych graczy\nx Zabrania si? prowadzenia w ubera rozwalonym autem\nx Zabrania si? rozje?dzania ludzi\nx Zabrania si? parkowa? auta w nie dozwolonym miejscu\nx Zabrania si? pchania si? w kolejce\nx Zabrania si? wychodzenie z serwera w czasie. RP\nx Zabrania si? ignorowanie wy?szej rangi\nx Zabrania si? Je?d?enie pod pr?d\nx Zabrania si? przeszkadzania w pracy"345*px262*py1097*px640*pytocolor(255128249255), 0.40font2"center""center"falsefalsefalsefalsefalse)
    end
    if listaaut == true then
        local x2 0 
        shadowText("Lista twoich pojazd?w ("..#pojazdy..")", 581*px, 289*py, 864*px, 369*py, tocolor(255, 255, 255, 255), 1.00, font, "center", "center", false, false, false, false, false)
        for i,v in ipairs(pojazdy) do
            if >= k2 and <= n2 then 
                x2 x2 1
                local dodatekY = (87*py)*(x2-1)
                local dodatekY2 = (174*py)*(x2-1)

                local model getVehicleNameFromModel(v.model)

                local lokalizacja "N/A";
                if tonumber(v.parking) == 1 then
                 lokalizacja "Przechowalnia pojazd?w"
                else
                 for k,p in ipairs(getElementsByType("vehicle")) do
                         local id getElementData(p"vehicle:id")
                         if id and id == v["vehicle:id"then
                         local x,y,getElementPosition(p)
                         lokalizacja getZoneName(x,y,z,true)..", "..getZoneName(x,y,z,false)
                         end
                  end
               end
                dxDrawRectangle(441*px353*py dodatekY562*px87*pytocolor(000140), false)
                dxDrawLine(441*px440*py+dodatekY1003*px440*py+dodatekYtocolor(240128255255), 2false)
                dxDrawImage(448*px358*py dodatekY75*px75*py":np-dashboard/grafy/auto.png"000tocolor(255255255255), false)
                shadowText(model.." ["..v.id.."]"567*px353*py dodatekY2779*px396*pytocolor(255255255255), 1.00font"left""center"falsefalsefalsefalsefalse)
                shadowText(lokalizacja567*px396*py dodatekY2779*px439*pytocolor(255255255255), 1.00fontsmall"left""center"falsefalsefalsefalsefalse)
            end
       end
    end
        if ustawienia == true then
        dxDrawText("- Premium -\nPosiada:\nCo godzinne wynagrodzenie za gre, 1000$\nSkiny tylko dla premium,\nChat dla premium,\nOg?oszenia premium,\nLekko(bardzo ma?o) zwi?kszone zarobki w niekt?rych pracach,\nKolorowy nick,\n"345*px262*py1097*px640*pytocolor(255128249255), 0.40font2"center""center"falsefalsefalsefalsefalse)
    end
end
addEventHandler("onClientClick"root, function(btnstate)
  if btn == "left" and state == "down" then
      --statystyki
    if mysz(1115*px150*py46/zoom46/zoom) and dashboard == true and statystyki == false then
        statystyki true
        kary false
        listaaut false
        ustawienia false
        local x1y1z1 getCameraMatrix()
        myElement createPed(getElementData(localPlayer"player:skin"), x1y1z10)
        myObject exports.object_preview:createObjectPreview(myElement000100.511truetruetrue)
        guiWindow guiCreateWindow(96*px163*py428*px704*py""falsefalse)
        guiSetAlpha(guiWindow0)
        local projPosXprojPosY guiGetPosition(guiWindow,true)
        local projSizeXprojSizeY guiGetSize(guiWindowtrue)
        exports.object_preview:setProjection(myObjectprojPosXprojPosYprojSizeXprojSizeYtruetrue)
        exports.object_preview:setRotation(myObject, -100200)
    elseif mysz(1115*px230*py46/zoom46/zoom) and dashboard == true and kary == false then
        kary true
        statystyki false
        listaaut false
        ustawienia false
        if isElement(myElementthen
            destroyElement(myElement)
            destroyElement(guiWindow)
        end
    elseif mysz(1115*px315*py46/zoom46/zoom) and dashboard == true and listaaut == false then
        triggerServerEvent("pokazPojazdySource"localPlayer)
        listaaut true
        statystyki false
        kary false
        ustawienia false
        if isElement(myElementthen
            destroyElement(myElement)
            destroyElement(guiWindow)
        end
    elseif mysz(1115*px405*py46/zoom46/zoom) and dashboard == true and ustawienia == false then
        listaaut false
        statystyki false
        kary false
        ustawienia true
        if isElement(myElementthen
            destroyElement(myElement)
            destroyElement(guiWindow)
        end
    --elseif mysz(770*px336*py100*px50*py) and dashboard == true and ustawienia == true then
        if getElementData(localPlayer"player:blackwhite"then
            setElementData(localPlayer"player:blackwhite"false)
        else
             setElementData(localPlayer"player:blackwhite"true)
        end
    --elseif mysz(770*px386*py100*px50*py) and dashboard == true and ustawienia == true then
        if getElementData(localPlayer"shader:1"then
            setElementData(localPlayer"shader:1"false)
        else
             setElementData(localPlayer"shader:1"true)
        end
    --elseif mysz(770*px436*py100*px50*py) and dashboard == true and ustawienia == true then
        if getElementData(localPlayer"shader:3"then
            setElementData(localPlayer"shader:3"false)
        else
             setElementData(localPlayer"shader:3"true)
        end
    --elseif mysz(770*px486*py100*px50*py) and dashboard == true and ustawienia == true then
        if getElementData(localPlayer"shader:6"then
            setElementData(localPlayer"shader:6"false)
        else
             setElementData(localPlayer"shader:6"true)
        end
    --elseif mysz(770*px536*py100*px50*py) and dashboard == true and ustawienia == true then
        if getElementData(localPlayer"shader:2"then
            setElementData(localPlayer"shader:2"false)
        else
             setElementData(localPlayer"shader:2"true)
        end

    -- ustawienia gry
    elseif mysz(347*px336*py100*px50*py) and dashboard == true and ustawienia == true then
        if getElementData(localPlayer"poff"then
            setElementData(localPlayer"poff"false)
        else
             setElementData(localPlayer"poff"true)
        end
    elseif mysz(347*px386*py100*px50*py) and dashboard == true and ustawienia == true then
        if getElementData(localPlayer"cpoff"then
            setElementData(localPlayer"cpoff"false)
        else
             setElementData(localPlayer"cpoff"true)
        end
    elseif mysz(347*px436*py100*px50*py) and dashboard == true and ustawienia == true then
        if getElementData(localPlayer"shader:fps"then
            setElementData(localPlayer"shader:fps"false)
        else
             setElementData(localPlayer"shader:fps"true)
        end
    elseif mysz(347*px486*py100*px50*py) and dashboard == true and ustawienia == true then
        local muza getElementData(localPlayer"muzyka") or 0
        if muza == 0 then
            setElementData(localPlayer"muzyka"1)
        else
            setElementData(localPlayer"muzyka"0)
        end
    end
    end
end)

bindKey("f1","down", function()        
    if dashboard == true then
        dashboard false
        removeEventHandler("onClientRender"rootgui)
        showCursor(false)
        listaaut false
        statystyki false
        kary false
        ustawienia false
        showChat(true)
        if isElement(myElementthen
            destroyElement(myElement)
            destroyElement(guiWindow)
        end
    else
        dashboard true
        statystyki true
        addEventHandler("onClientRender"rootgui)
        showCursor(true)
        showChat(false)
        local x1y1z1 getCameraMatrix()
        myElement createPed(getElementData(localPlayer"player:skin"), x1y1z10)
        myObject exports.object_preview:createObjectPreview(myElement000100.511truetruetrue)
        guiWindow guiCreateWindow(96*px163*py428*px704*py""falsefalse)
        guiSetAlpha(guiWindow0)
        local projPosXprojPosY guiGetPosition(guiWindow,true)
        local projSizeXprojSizeY guiGetSize(guiWindowtrue)
        exports.object_preview:setProjection(myObjectprojPosXprojPosYprojSizeXprojSizeYtruetrue)
        exports.object_preview:setRotation(myObject, -100200)
    end
end)

addEvent("pokazPojazdyClient"true)
addEventHandler("pokazPojazdyClient"root, function(tabelka)
  pojazdy tabelka
end)

bindKey("mouse_wheel_down""both", function()
    if listaaut == true then
        scrollUp2()
    end
end)

bindKey("mouse_wheel_up""both", function()
    if listaaut == true then
        scrollDown2()
    end
end)

function scrollDown2()
    if n2 == m2 then return end
    k2 k2-1
    n2 n2-1
end

function scrollUp2()
    if n2 >= #pojazdy then return end
    k2 k2+1
    n2 n2+1
end

function mth(minutes)
    local h math.floor(minutes/60)
    local m minutes - (h*60)
    return {h,m}
end

function shadowText(text,x,y,w,h,color,size,font,xx,yy,x1,x2,x3,x4,x5)
    dxDrawText(text,x+1,y+1,w+1,h+1,tocolor(0,0,0),size,font,xx,yy,x1,x2,x3,x4,x5)
    dxDrawText(text,x,y,w,h,color,size,font,xx,yy,x1,x2,x3,x4,x5)
end

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


drugi kod z wczytaniem tego jakby:


function pokazpojazdy(plr)
    local q exports['ogrpg-db']:dbGet("SELECT * FROM ogrpg_vehicles WHERE ownedPlayer=?"getElementData(plr"player:uid"))
    local pojazdy = {}

    for 1#q do
        table.insert(pojazdy, {model q[i]["model"], id q[i]["id"], przecho q[i]["parking"]})
    end

    return pojazdy
end

addEvent("pokazPojazdySource"true)
addEventHandler("pokazPojazdySource"root, function()
    triggerClientEvent(source"pokazPojazdyClient"sourcepokazpojazdy(source));
end)


Kod z ogrpg-db:

--[[
    ResourceOURGame v2
    DevelopersSplit <split.programista@gmail.com>
    You have no right to use this code without my permission.
    (c2015 <split.programista@gmail.com>. All rights reserved.
]]

-- Settings
DBHandler=nil
DBName="d93"
DBUser="d3"
DBPass="xE" 
DBHost="14"

-- Functions
function dbSet(...)
    if not {...} then return end
    local qh dbQuery(DBHandler, ...)
    if not qh then return false end
    local resultnum_affected_rowslast_insert_id dbPoll(qh, -1)
    return resultnum_affected_rowslast_insert_id
end

function dbGet(...)
    if not {...} then return end
    local stringe=dbPrepareString(DBHandler,...)
    local query=dbQuery(DBHandlerstringe)
    local result,num_affected_rowslast_insert_id =dbPoll(query, -1)
    return result
end


addEventHandler("onResourceStart"resourceRoot, function()
    DBHandler=dbConnect("mysql""dbname="..DBName..";host="..DBHost..""DBUserDBPass"share=1;autoreconnect=1")
    if DBHandler then
        outputDebugString("* Po??czono pomy?lnie! (MySQL)")
        dbSet("SET NAMES utf8")
    else
        outputDebugString("* Brak po??czenia! (MySQL)")
    end
end)


local SQL_LOGIN="
local SQL_PASSWD="sDkSxE"
local SQL_DB="db_"
local SQL_HOST="94"
local SQL_PORT=3

local root = getRootElement()

local SQL

local function connect()
    SQL = mysql_connect(SQL_HOST, SQL_LOGIN, SQL_PASSWD, SQL_DB, SQL_PORT)
    if (not SQL) then
        outputServerLog("BRAK POLACZENIA Z BAZA DANYCH!")
    else
        mysql_query(SQL,"SET NAMES utf8")
        --outputServerLog("Modul mysql polaczony!")
    end

end


local function keepAlive()
    if (not mysql_ping(SQL)) then
        outputServerLog("Zerwane polaczenie z baza danychnawiazywanie...")
        connect()
    end
end
addEventHandler("onResourceStart",getResourceRootElement(),function()
    connect()
    setTimer(keepAlive, 30000, 0)
end)

function esc(value)
    return mysql_escape_string(SQL,value)
end

function pobierzTabeleWynikow(query)
    local result=mysql_query(SQL,query)
    if (not result) then
        outputDebugString("mysql_query failed: (" .. mysql_errno(SQL) .. "" .. mysql_error(SQL))
        outputServerLog("mysql_query failed: (" .. mysql_errno(SQL) .. "" .. mysql_error(SQL))
        return nil
    end
    local tabela={}
    for result,row in mysql_rows_assoc(result) do
        table.insert(tabela,row)
    end
    mysql_free_result(result)
    return tabela
end

function q(sQuery, ...)
    local qHandler=dbQuery(CDatabase.hCon, sQuery, ...)
    local result, iRows, sError=dbPoll(qHandler, 90)
    if result==nil then
        result, iRows, sError=dbPoll(qHandler, -1)
        if result==nil then
            dbFree(qHandler)
            outputDebugString('Max query runtime reached: ' ..sQuery.. '|' ..iRows.. '|' ..sError)
            return false
        end
    end
    if result==false then
        outputDebugString('Error executing query: ' ..sQuery.. '|' ..iRows.. '|' ..sError)
        return false
    end
    return result, iRows, (sError or '-')
end

function pobierzWyniki(query)
    local result=mysql_query(SQL,query)
    if (not result) then return nil end
    row = mysql_fetch_assoc(result)
    mysql_free_result(result)
    return row
end


function zapytanie(query)
    local result=mysql_query(SQL,query)
    if (result) then mysql_free_result(result) return true end
    return
end

function insertID()
    return mysql_insert_id(SQL)
end

function affectedRows()
    return mysql_affected_rows(SQL)
end


function fetchRows(query)
    local result=mysql_query(SQL,query)
    if (not result) then return nil end
    local tabela={}

    while true do
        local row = mysql_fetch_row(result)
        if (not row) then break end
        table.insert(tabela,row)
    end
    mysql_free_result(result)
    return tabela
end


function getSQLLink()
    return SQL
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-11-15, 21:33


Pan.Holingo







Wiek: 22
Na forum: 3354 dni
Posty: 22
Nick w MP: Holingo

Piwa: 158

Respekt: 50

Jeszcze daj p?l danych, z tabeli ogrpg_vehicles. Wystarczy, ?e dasz jedn?.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-11-15, 23:46


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Spr?buj podmieni?
if tonumber(v.parking) == 1 then

na
if tonumber(v.przecho) == 1 then


Daj koniecznie zna? o efektach.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-11-17, 09:38


Kulegg







Wiek: 46
Na forum: 3125 dni
Posty: 283

Piwa: 20

Respekt: 50

Dzia?a, po podmienieniu tej linijki w twoj?, gdy pojazd jest w przechowywalni, pisze ?e auta tam s?. Jednak?e nadal gdy auto jest wyj?te z przecho i jest gdziekolwiek, nie ma lokalizacji

Kod z ogrpg-vehicles:


local pozwolone = {[453] = true, [509] = true, [481] = true, [510] = true}
local nlIDX = {396221131784205424282352}
local nlOffsets = {
    [411] = {-1,0,-0.6},    -- infernus
    [470] = {-1,0,-0.4},    -- patriot
    [541] = {-0.9,0,-0.4},    -- bulelt
    [549] = {-0.9,0,-0.4},    -- tampa
    [587] = {-1,0,-0.5},    -- euros
}

function onRespawnVehicles(_idpositionplayerwarpTo)
    if id then result exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_vehicles WHERE parking=1 and not(police=1) AND id=?"idquery exports["ogrpg-db"]:dbSet("UPDATE ogrpg_vehicles SET parking=0 WHERE id=?"id) else result exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_vehicles WHERE parking=0 and not(police=1)"end
    for k,vehicle in pairs(result) do
        if id then pos = {position[1], position[2], position[3], position[4], position[5], position[6]} else pos split(vehicle["pos"], ","end

        local color split(vehicle["color"], ",")
        local lights split(vehicle["headlights"], ",")
        local veh Vehicle(vehicle["model"], pos[1], pos[2], pos[3], pos[4], pos[5], pos[6])
        veh:setColor(color[1], color[2], color[3], color[4],color[5], color[6], color[7], color[8],color[9], color[10], color[11], color[12])
        if vehicle["plateText"] ~= "" then veh.plateText vehicle["plateText"] else veh.plateText tostring("SA "..vehicle["id"]) end
        if vehicle["paintjob"] ~= 3 then setVehiclePaintjob(vehvehicle["paintjob"]) end
        veh:setHeadLightColor(lights[1], lights[2], lights[3])
        veh.frozen = ((vehicle["frozen"]) > 0)
        
        veh.dimension 0
        veh.health vehicle["health"]
        veh:setData("vehicle:spawn"true)
        veh:setData("vehicle:id"vehicle["id"])
        veh:setData("vehicle:fuel"vehicle["fuel"])
        --veh:setData("vehicle:desc"vehicle["text"] or false)
        if string.len(vehicle["text"]) > 1 then
        exports["iyw_vehtexts"]:add3DTextForElement(veh,{0,0,0},tostring(vehicle["text"]),{255,255,255,255},"czcionka4",1.0,30,1)
        end
        veh:setData("vehicle:mileage"vehicle["mileage"])
        veh:setData("vehicle:driver"vehicle["driver"])
        veh:setData("vehicle:ownedGroup"vehicle["ownedGroup"])
        veh:setData("vehicle:ownedPlayer"vehicle["ownedPlayer"])
        veh:setData("vehicle:engine_upgrade_one"vehicle["mk1"])
        veh:setData("vehicle:engine_upgrade_two"vehicle["mk2"])
        veh:setData("vehicle:suspension"vehicle["rh"])
        veh:setData("vehicle:drive"vehicle["naped"])
        veh:setData("vehicle:capacity"vehicle["capacity"])
        
        local mk1 vehicle["mk1"]
        local mk2 vehicle["mk2"]
        local xfour vehicle["naped"]
        local model vehicle["model"]
        
        if getElementData(veh"vehicle:capacity") == "1.2" then
            setVehicleHandling(veh"engineAcceleration"getVehicleHandling(veh).engineAcceleration+0)
        elseif getElementData(veh"vehicle:capacity") == "1.4" then
            setVehicleHandling(veh"engineAcceleration"getVehicleHandling(veh).engineAcceleration+0.1)
        elseif getElementData(veh"vehicle:capacity") == "1.6" then
            setVehicleHandling(veh"engineAcceleration"getVehicleHandling(veh).engineAcceleration+0.2)
        elseif getElementData(veh"vehicle:capacity") == "1.8" then
            setVehicleHandling(veh"engineAcceleration"getVehicleHandling(veh).engineAcceleration+0.3)
        elseif getElementData(veh"vehicle:capacity") == "2.0" then
            setVehicleHandling(veh"engineAcceleration"getVehicleHandling(veh).engineAcceleration+0.4)
        elseif getElementData(veh"vehicle:capacity") == "2.2" then
            setVehicleHandling(veh"engineAcceleration"getVehicleHandling(veh).engineAcceleration+0.5)
        elseif getElementData(veh"vehicle:capacity") == "2.4" then
            setVehicleHandling(veh"engineAcceleration"getVehicleHandling(veh).engineAcceleration+0.6)
        elseif getElementData(veh"vehicle:capacity") == "2.6" then
            setVehicleHandling(veh"engineAcceleration"getVehicleHandling(veh).engineAcceleration+0.7)
        elseif getElementData(veh"vehicle:capacity") == "2.8" then
            setVehicleHandling(veh"engineAcceleration"getVehicleHandling(veh).engineAcceleration+0.8)
        elseif getElementData(veh"vehicle:capacity") == "3.0" then
            setVehicleHandling(veh"engineAcceleration"getVehicleHandling(veh).engineAcceleration+0.9)
        elseif getElementData(veh"vehicle:capacity") == "3.2" then
            setVehicleHandling(veh"engineAcceleration"getVehicleHandling(veh).engineAcceleration+1.1)
        elseif getElementData(veh"vehicle:capacity") == "3.4" then
            setVehicleHandling(veh"engineAcceleration"getVehicleHandling(veh).engineAcceleration+1.2)
        elseif getElementData(veh"vehicle:capacity") == "3.6" then
            setVehicleHandling(veh"engineAcceleration"getVehicleHandling(veh).engineAcceleration+1.3)
        elseif getElementData(veh"vehicle:capacity") == "3.8" then
            setVehicleHandling(veh"engineAcceleration"getVehicleHandling(veh).engineAcceleration+1.4)
        end
    
        if tonumber(xfour) == 1 then
            setVehicleHandling(veh"driveType""awd")
        end
        
        if tonumber(mk1) ~= 0 then
            local handling getModelHandling(tonumber(model))
            local fast handling["engineAcceleration"]
            local maxfast handling["maxVelocity"]
            setVehicleHandling(veh"engineAcceleration"fast+2.5)
            setVehicleHandling(veh"maxVelocity"maxfast+20)
        end
        
        if tonumber(mk2) ~= 0 then
            local handling getModelHandling(tonumber(model))
            local fast handling["engineAcceleration"]
            local maxfast handling["maxVelocity"]
            setVehicleHandling(veh"engineAcceleration"fast+5)
            setVehicleHandling(veh"maxVelocity"maxfast+40)
        end

        if (type(vehicle["rent"]) == "string"then
            local tabelka = {}
            if tonumber(vehicle["removehood"]) == 1 then veh:setData("vehicle:bonnet"trueend
            if tonumber(vehicle["masked"]) ~= 0 then veh:setData("vehicle:masked"vehicle["masked"]) end
            for k,v in ipairs(split(vehicle["rent"], ",")) do 
                tabelka[#tabelka+1] = v
            end
            
            veh:setData("vehicle:rent"tabelka or false)
        else
            veh:setData("vehicle:rent",0)
        end
        
        veh:setData("neony"vehicle["neon"])
        for i,v in ipairs(split(vehicle["tuning"], ",")) do veh:addUpgrade(vend
        for i,v in ipairs(split(vehicle["panelstates"], ",")) do setVehiclePanelState(vehitonumber(v)) end
        setVehicleFuelTankExplodable(vehfalse)
        veh.damageProof true
        
        if warpTo then
            fadeCamera(playerfalse1000)
            setTimer(function()
                warpPedIntoVehicle(playerveh)
            end15001)
            setTimer(fadeCamera20001playertrue1)
        end
    end
end

function onSaveVehicle(vehicle)
    if vehicle and vehicle:getData("vehicle:spawn"then    
        local model vehicle.model
        local health vehicle.health
        local x,y,getElementPosition(vehicle)
        local rx,ry,rz getElementRotation(vehicle)
        local desc exports["iyw_vehtexts"]:get3DTextForElement(vehicle) or ""
        local id vehicle:getData("vehicle:id")
        local fuel vehicle:getData("vehicle:fuel")
        local mileage vehicle:getData("vehicle:mileage")
        local c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12 vehicle:getColor(true)
        local drivervehicle:getData("vehicle:driver") or ""
        local rent vehicle:getData("vehicle:rent")
        local player vehicle:getData("vehicle:ownedPlayer")
        local blokada vehicle:getData("vehicle:block")
        local neon vehicle:getData("neony")
        local h1,h2,h3 vehicle:getHeadLightColor()
        local paintjob vehicle.paintjob
        local mask vehicle:getData("vehicle:masked") or 0
        local mk1 vehicle:getData("vehicle:engine_upgrade_one")
        local mk2 vehicle:getData("vehicle:engine_upgrade_two")
        local naped vehicle:getData("vehicle:suspension")
        local rh vehicle:getData("vehicle:drive")
        local capacity vehicle:getData("vehicle:capacity")
        local frozen vehicle.frozen and or 0
        local rear "Brak"
        
        local panelstates = {}
        local upgrades vehicle.upgrades
        for i=0,do panelstates[#panelstates+1] = vehicle:getPanelState(i) end
        panelstates table.concat(panelstates,",")
        if not upgrades then upgrades = {} end
        upgrades table.concat(upgrades",")
        
        local query exports["ogrpg-db"]:dbSet(string.format("UPDATE ogrpg_vehicles SET model='%d', pos='%.2f,%.2f,%.2f,%.2f,%.2f,%.2f', rent='%d',text='%s', masked='%d', health='%d', fuel='%d', mileage='%d', frozen='%d', driver='%s', color='%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d', panelstates='%s', paintjob='%d', tuning='%s', headlights='%d,%d,%d', ownedPlayer='%d', neon='%d', blokada='%s', mk1='%d', mk2='%d', naped='%d', rh='%d', capacity='%s' WHERE id=%d"modelx,y,zrx,ry,rz"0",descmask,healthfuelmileagefrozendriverc1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12panelstatespaintjobupgradesh1,h2,h3playerneontostring(blokada), mk1mk2napedrhcapacityid))
        if (type(rent) == "table"then
            local query2exports["ogrpg-db"]:dbSet("UPDATE ogrpg_vehicles SET rent=? WHERE id=?"string.format("%s"table.concat(rent",")), id)
        end
    end
end

addEventHandler("onResourceStart"resourceRoot, function()
    onRespawnVehicles(_false)
end)

function onParkVehicle(vehicle) 
    local query exports["ogrpg-db"]:dbSet("UPDATE ogrpg_vehicles SET parking=1 WHERE id=?"vehicle:getData("vehicle:id"))
    if query then
        local zneony vehicle:getData("zneony")
        if zneony and type(zneony) == "table" then
            zneony[1]:destroy()
            zneony[2]:destroy()
            vehicle:removeData("zneony")
        end
        vehicle:destroy()
    end
end

addEventHandler("onVehicleExit"root, function(plrseat)
    if not source or seat ~= 0 then return false end
    if source:getData("vehicle:masked"then
        plr.name plr:getData("player:old:nick")
    end
    
       onSaveVehicle(source)
       source.engineState false
    source.damageProof true
    unbindKey(plr"h""down"bindHoron4)
end)

addEventHandler("onPlayerQuit"root, function()
    local vehicle source.vehicle
    if vehicle then
        source.damageProof true
        onSaveVehicle(vehicle)
    end
end)

addEventHandler("onResourceStop"resourceRoot, function()
    for i,v in ipairs(Element.getAllByType("vehicle")) do
        onSaveVehicle(v)
        local zneony v:getData("zneony")
        if zneony and type(zneony) == "table" then
            zneony[1]:destroy()
            zneony[2]:destroy()
            v:removeData("zneony")
        end
    end
end)

addEventHandler("onVehicleEnter"root, function(plrseat)
    if not source or seat ~= 0 then return false end
    if source:getData("vehicle:masked"then
        plr:setData("player:old:nick"plr.name)
        plr.name string.format("#040707%s"string.gsub(plr.name"#%x%x%x%x%x%x"""))
    end

    source.engineState false
    source:setData("vehicle:driver"plr.name)
    if source:getData("neony") and source:getData("neony") ~= 0 then
        triggerClientEvent(plr"onClientAddNotification"plr"Posiadasz neony w poje?dzie, mo?esz w??czy? i wy?aczyc je za pomoc? przycisku H.""info")
        bindKey(plr"h""down"bindHoron4plr)
    end
end)

addEventHandler("onVehicleStartEnter"root, function(plrseatjacked)
    if source.health 302 then source.health 302 end
    if jacked then 
        if source:getData("vehicle:ownedPlayer") == plr:getData("player:uid"then return false end
        cancelEvent()
    end
    
    if seat == 0 then
        if source:getData("spawnowany"then
            if not plr:getData("player:admin"then
                cancelEvent()
            end
        end
        
        if not pozwolone[source.modelthen
            if categoryA[source.modelthen
                if exports["ogrpg-prace-settings"]:getVehicleLicense(plr"A"then
                    cancelEvent()
                end
            elseif categoryB[source.modelthen
                if exports["ogrpg-prace-settings"]:getVehicleLicense(plr"B"then
                    cancelEvent()
                end
            elseif categoryC[source.modelthen
                if exports["ogrpg-prace-settings"]:getVehicleLicense(plr"C"then
                    cancelEvent()
                end
            end
        end
        
        local rent source:getData("vehicle:rent")
        local group source:getData("vehicle:ownedGroup")
        local player source:getData("vehicle:ownedPlayer")
        if group == "0" then group "Brak" end
        if getAdmin2(plr4then return end
        if rent and (type(rent) == "table"then
            for i,s in pairs(rent) do
                if tonumber(s) == plr:getData("player:uid"then return end
            end
        end
        
        local plrgroup plr:getData("player:organization")
        if plrgroup then if getSettings(plrfalse"organization") == group then return end end
        if player and player ~= getSettings(plrfalse"owner"then
            triggerClientEvent(plr"onClientAddNotification"plr"Ten pojazd nie nale?y do Ciebie!""error")
            cancelEvent()
        end
    end
end)

addEvent("neonfix",true)
addEventHandler("neonfix"resourceRoot, function(vehicledistance)
    if not vehicle then return end
    if not distance then return end
    montujneony(vehicledistance)
end)

function hasNeon(vehicle)
    if not vehicle then return end
    if vehicle:getData("zneony"then
        return true
    else
        return false
    end
end

function montujneony(vehicledistance)
    local rodzajneonu tonumber(vehicle:getData("neony"))
    if not vehicle or not distance or not rodzajneonu or hasNeon(vehiclethen return false end
    if rodzajneonu == 0 then
        return plr:outputChat("* Brak Neonow."255,0)
    end
    
    local zDis distance
    local position = {getElementPosition(vehicle)}
    local rotation = {getElementRotation(vehicle)}
    local rDis getVehicleHandling(vehicle).suspensionLowerLimit
    local neon1 Object(nlIDX[rodzajneonu], position[1], position[2], position[3])
    local neon2 Object(nlIDX[rodzajneonu], position[1], position[2], position[3])
    setElementRotation(neon1rotation[1], rotation[2], rotation[3])
    setElementRotation(neon2rotation[1], rotation[2], rotation[3])
    neon1:attach(vehicle0.80, -(zDis+rDis))
    neon2:attach(vehicle, -0.80, -(zDis+rDis))
    vehicle:setData("zneony", {neon1neon2})
end

function bindHoron4(plr)
    local vehicle plr.vehicle
    local rodzajneonu tonumber(vehicle:getData("neony"))
    if not vehicle or not rodzajneonu then return false end
    if rodzajneonu == 0 then 
        return outputChatBox('* Brak Neonow.'plr255,0)
    end
        
    local zneony vehicle:getData("zneony")
    if (zneony and type(zneony) == "table"then
        zneony[1]:destroy()
        zneony[2]:destroy()
        vehicle:removeData("zneony")
    else
        triggerClientEvent(plr"neonfix"resourceRoot)
    end
end

addEventHandler("onElementDestroy"root, function()
    if source.type == "vehicle" then
        local zneony source:getData("zneony")
        if zneony and type(zneony) == "table" then
            zneony[1]:destroy()
            zneony[2]:destroy()
            v:removeData("zneony")
        end
        
        if source:getData("vehicle:masked"then
            for i,v in pairs(source.occupants) do
                v.name v:getData("player:old:nick")
            end
        end
    end
end)

addEventHandler("onVehicleStartEnter"root, function(plr,seat,jacked)
    if seat ~= or source:getData("multiseat") or pozwolone[source.modelthen return end
    
    if not categoryL[source.modelthen
        local result exports["ogrpg-db"]:pobierzWyniki(string.format("SELECT * FROM ogrpg_punish WHERE type=%q AND active=1 AND serial=%q AND time>NOW() LIMIT 1","prawko"plr.serial))
        if result then
            triggerClientEvent(plr"onClientAddNotification"plr"Posiadasz zawieszone prawo jazdy do\n"..result["time"].." za "..result["reason"], "error")
            cancelEvent()
        else
            exports["ogrpg-db"]:dbSet("DELETE FROM ogrpg_punish WHERE type=? AND active=1 AND serial=?""prawko"plr.serial)
        end
    else
        local result exports["ogrpg-db"]:pobierzWyniki(string.format("SELECT * FROM ogrpg_punish WHERE type=%q AND active=1 AND serial=%q AND time>NOW() LIMIT 1","L"plr.serial))
        if result then
            triggerClientEvent(plr"onClientAddNotification"plr"Posiadasz zawieszon? licencj? lotnicz? do\n"..result["time"].." za "..result["reason"], "error")
            cancelEvent()
        else
            exports["ogrpg-db"]:dbSet("DELETE FROM ogrpg_punish WHERE type=? AND active=1 AND serial=?""L"plr.serial)
        end
    end
endtrue"low-1")

addEventHandler("onVehicleEnter"root, function(plr,seat,jacked)
    if seat ~= or source:getData("mutiseat") or pozwolone[source.modelthen return end
    
    if not categoryL[source.modelthen
        local result exports["ogrpg-db"]:pobierzWyniki(string.format("SELECT * FROM ogrpg_punish WHERE type=%q AND active=1 AND serial=%q AND time>NOW() LIMIT 1","prawko"plr.serial))
        if result then
            Timer(setControlState8001plr"enter_exit"true)
            Timer(setControlState18001plr"enter_exit"false)
            triggerClientEvent(plr"onClientAddNotification"plr"Posiadasz zawieszone prawo jazdy do\n"..result["time"].." za "..result["reason"], "error")
        else
            exports["ogrpg-db"]:dbSet("DELETE FROM ogrpg_punish WHERE type=? AND active=1 AND serial=?""prawko"plr.serial)
        end
    else
        local result exports["ogrpg-db"]:pobierzWyniki(string.format("SELECT * FROM ogrpg_punish WHERE type=%q AND active=1 AND serial=%q AND time>NOW() LIMIT 1","L"plr.serial))
        if result then
            Timer(setControlState8001plr"enter_exit"true)
            Timer(setControlState18001plr"enter_exit"false)
            triggerClientEvent(plr"onClientAddNotification"plr"Posiadasz zawieszon? licencj? lotnicz? do\n"..result["time"].." za "..result["reason"], "error")
        else
            exports["ogrpg-db"]:dbSet("DELETE FROM ogrpg_punish WHERE type=? AND active=1 AND serial=?""L"plr.serial)
        end
    end
endtrue"low-1")


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-11-17, 15:24


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Bo to efekt sklejania pierdyliarda serwer?w w jeden. Nie zgadzaj? si? dan? z tabeli, kt?r? pobierasz a tym co chcesz sprawdzi?. Mo?e by? przeanalizowa? kod (nie napisz?, ?e 'sw?j') i dowiedzia? si? jak on po kolei dzia?a.

v["vehicle:id"]

zamieniasz na
v.id


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Kulegg
Wysłany: 2019-11-18, 18:31


Kulegg







Wiek: 46
Na forum: 3125 dni
Posty: 283

Piwa: 20

Respekt: 50

Dzi?kuje, :piwo: dla ciebie.
Nadal pr?buj? si? nauczy? lua ale te? chce naprawi? pozosta?e skrypty w kt?rych jest b??d a je?li w?a?nie tego nie umiem to pisz? tutaj :)

mo?na del temat

Postaw piwo autorowi tego posta
 

 
Tagi: lokalizacja :: aut :: poprzez :: dashboard
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

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