Jump to content

Attempt to compare number with boolean [HELP PLS]


Recommended Posts

(sry for my bad english) 

Hi everyone! In my script when I write the command into game chatbox (/makeveh "myID" "CarModelName" "Faction"  "R, G, B")  i get this Error message to server console:  ERROR: mta_vehicle\sourceS.lua:263: attempt to compare boolean with number.

The code is:

addCommandHandler("makeveh", function(player, _, ownerID, modelID, faction, r, g, b)
    if getElementData(player, "acc:admin") >= 7 then  <--LINE 263
        if not modelID or not tonumber(ownerID) then
            outputChatBox(rovid .. " /makeveh [Név/ID] [Model] [Frakció] [R] [G] ", player, 0, 0, 0, true)
            return
        end
        
        target, targetName = exports.mta_main:findPlayer(player, ownerID)
        if not target then
            return
        else
            ownerID = getElementData(target, "char:id")
        end
        
        if not tonumber(faction) then faction = 0 end
        if not tonumber(r) then r = 0 end
        if not tonumber(g) then g = 0 end
        if not tonumber(b) then b = 0 end
        r = tonumber(r)
        g = tonumber(g)
        b = tonumber(b)
        
        local vehname = tonumber(modelID)
        if not vehname then
            vehname = getVehicleModelFromName(modelID)
        end
        
        if not vehname then
            outputChatBox(rovid .. " Hibás jármű név vagy id", player, 0, 0, 0, true)
            return
        end
        
        local x, y, z = getElementPosition(target)
        
        local insertQuery = dbQuery(con, "INSERT INTO vehicle SET model=?, owner=?, pos=?, color=?, faction=?, rendszam=?", vehname, ownerID, toJSON({x,y,z}), toJSON({r,g,b}), faction, "modify")
        local insertResult, _, insertID = dbPoll(insertQuery, -1)
        if insertResult then
            addVehicle(ownerID, vehname, x, y, z, insertID, r, g, b, faction)
            exports.mta_item:giveItem(target, 34, insertID, 1, 0)
            exports.mta_admin:outputDeveloperMessage("#7cc576"..player:getData("char:anick").." #fffffflétrehozott egy járművet (ID: "..insertID.." Tulaj: "..targetName:gsub("_", " ")..")")
            dbFree(insertQuery)
        end
    end
end)

Edited by Tibi [NextMTA]
Link to comment
1 hour ago, ProMax said:

any proofs?

from this server:

https://www.youtube.com/watch?v=j2WlOyvdKAk&t=9632s

 

And other parts of this script

addCommandHandler("makeveh", function(player, _, ownerID, modelID, faction, r, g, b)
    if getElementData(player, "acc:admin") >= 7 then 
        if not modelID or not tonumber(ownerID) then
            outputChatBox(rovid .. " /makeveh [Név/ID] [Model] [Frakció] [R] [G] [B]", player, 0, 0, 0, true)
            return
        end
        
        target, targetName = exports.mta_main:findPlayer(player, ownerID)
        if not target then
            return
        else
            ownerID = getElementData(target, "char:id")
        end
        
        if not tonumber(faction) then faction = 0 end
        if not tonumber(r) then r = 0 end
        if not tonumber(g) then g = 0 end
        if not tonumber(b) then b = 0 end
        r = tonumber(r)
        g = tonumber(g)
        b = tonumber(b)
        
        local vehname = tonumber(modelID)
        if not vehname then
            vehname = getVehicleModelFromName(modelID)
        end
        
        if not vehname then
            outputChatBox(rovid .. " Hibás jármű név vagy id", player, 0, 0, 0, true)
            return
        end
        
        local x, y, z = getElementPosition(target)
        
        local insertQuery = dbQuery(con, "INSERT INTO vehicle SET model=?, owner=?, pos=?, color=?, faction=?, rendszam=?", vehname, ownerID, toJSON({x,y,z}), toJSON({r,g,b}), faction, "modify")
        local insertResult, _, insertID = dbPoll(insertQuery, -1)
        if insertResult then
            addVehicle(ownerID, vehname, x, y, z, insertID, r, g, b, faction)
            exports.mta_item:giveItem(target, 34, insertID, 1, 0)
            exports.mta_admin:outputDeveloperMessage("#7cc576"..player:getData("char:anick").." #fffffflétrehozott egy járművet (ID: "..insertID.." Tulaj: "..targetName:gsub("_", " ")..")")
            dbFree(insertQuery)
        end
    end
end)


addCommandHandler("delveh", function(player, _, vehID)
    if getElementData(player, "acc:admin") < 7 then return end
    if not tonumber(vehID) then
        outputChatBox(rovid .. " /delveh [ID]", player, 0, 0, 0, true)
        return
    end
    
    vehID = tonumber(vehID)
    
    for _, car in ipairs(getElementsByType("vehicle")) do
        if tonumber(car:getData("veh:id")) == vehID then
            if getElementData(car, "rent.Owner") then setElementData(getElementData(car, "rent.Owner"), "rent.Car", false) end
            destroyElement(car)
            delQuery = dbQuery(con, "DELETE FROM vehicle WHERE id=?", vehID)
            exports.mta_admin:outputDeveloperMessage("#7cc576"..player:getData("char:anick").." #fffffftörölt egy járművet (ID: "..vehID..")")
            dbFree(delQuery)
        end
    end
end)

function addVehicle(tulajID, modelID, x, y, z, sqlID, r, g, b, fraki)
    if not fraki then fraki = 0 end
    local vehicleCreate = createVehicle(modelID,x,y,z)
    
    local str = "abcdefghijklmnopqrstuvwxyz"
    local plate = ""
    for index = 1, 3 do
        plate = plate .. string.char(str:byte(math.random(1, #str)))
    end
    plate = string.upper(plate)
    plate = plate .. "-"
    for index = 1, 3 do
        plate = plate .. math.random(1, 9)
    end
    
    setVehiclePlateText(vehicleCreate, plate)
    local insertQuery = dbQuery(con, "UPDATE vehicle SET rendszam=? WHERE id=?", plate, tonumber(sqlID))
    dbFree(insertQuery)

    vehicleCreate:setData("veh:id",tonumber(sqlID))
    vehicleCreate:setData("veh:perm",true)
    vehicleCreate:setData("veh:interior",0)
    vehicleCreate:setData("veh:dimension",0)
    vehicleCreate:setData("veh:fuel",10)
    vehicleCreate:setData("veh:light",true)
    vehicleCreate:setData("veh:motor",false)
    vehicleCreate:setData("veh:owner",tonumber(tulajID))
    for _, v in ipairs(getElementsByType("player")) do
        if v:getData("char:id") == tulajID then
            oname = v:getData("char:name")
        end
    end
    vehicleCreate:setData("veh:oname", oname)
    vehicleCreate:setData("veh:faction",tonumber(fraki))
    vehicleCreate:setData("handbrake",false)
    
    setVehicleColor(vehicleCreate,r,g,b)
    setVehicleOverrideLights(vehicleCreate, 1) -- Kikapcsolva
    setElementInterior(vehicleCreate,0)
    setElementDimension(vehicleCreate,0)
    if getVehicleType(vehicleCreate) == "BMX" then
        setVehicleEngineState(vehicleCreate,true)
    else
        setVehicleEngineState(vehicleCreate,false)
    end
end

function saveVehicle(veh)
    local dbid = tonumber(getElementData(veh, "veh:id")) or 0
    
    if isElement(veh) and tostring(getElementType(veh)) == "vehicle" and dbid >= 0 then
        local fuel = getElementData(veh, "veh:status")
        local engine = getElementData(veh, "veh:motor") or false
        local locked = isVehicleLocked(veh)
        local fuel = getElementData(veh, "veh:fuel")
        local neon = tonumber(getElementData(veh, "veh:neon") or 0)
        local lights = getVehicleOverrideLights(veh)
        local health = getElementHealth(veh)
        local wheel1, wheel2, wheel3, wheel4 = getVehicleWheelStates(veh)
        local wheelState = toJSON( { wheel1, wheel2, wheel3, wheel4 } )    
        local panel0 = getVehiclePanelState(veh, 0)
        local panel1 = getVehiclePanelState(veh, 1)
        local panel2 = getVehiclePanelState(veh, 2)
        local panel3 = getVehiclePanelState(veh, 3)
        local panel4 = getVehiclePanelState(veh, 4)
        local panel5 = getVehiclePanelState(veh, 5)
        local panel6 = getVehiclePanelState(veh, 6)
        local panelState = toJSON( { panel0, panel1, panel2, panel3, panel4, panel5, panel6 } )
            
        local door0 = getVehicleDoorState(veh, 0)
        local door1 = getVehicleDoorState(veh, 1)
        local door2 = getVehicleDoorState(veh, 2)
        local door3 = getVehicleDoorState(veh, 3)
        local door4 = getVehicleDoorState(veh, 4)
        local door5 = getVehicleDoorState(veh, 5)
        local doorState = toJSON( { door0, door1, door2, door3, door4, door5 } )
        
        local x,y,z = getElementPosition(veh)
        local int = getElementInterior(veh)
        local dim = getElementDimension(veh)
        --local pos = toJSON({x,y,z,int,dim})

        if dbPoll ( dbQuery( con, "UPDATE vehicle SET panel=?, wheel=?, door=?, fuel=?, motor=?, status=?, lampa=?, hp=? WHERE id='?'", panelState, wheelState, doorState, fuel, engine, locked, lights, health,dbid), -1 ) then
        --    outputDebugString("Mentve")
        end
    --    if dbPoll (dbQuery( kapcsolat,"UPDATE jarmuvek SET TuningMotor=?,TuningTurbo=?,TuningGumi=?,TuningFek=? WHERE id=?",Motor,Turbo,Gumik,Fek,dbid), -1 ) then
        --    outputDebugString("Jármű teljesítmény-ek mentve!")
    --    end
    end
end

function saveAllVeh()
    local count = 0
    for i, p in ipairs(getElementsByType("vehicle")) do
        if (tonumber(getElementData(p, "veh:owner") or 0) >= 1) then
            saveVehicle(p)
            count = count + 1
        end
    end
    outputDebugString("El lett mentve "..count.." kocsi adata!",0,0,130,150)
end

 

  • Like 1
Link to comment
  • Discord Moderators

The problem is that the element data named "acc:admin" doesnt exists.. try to relog.. if that doesnt help, then just download the newest version..The newest mod is publicated by DNS.. like 6 days ago

And guys, it is a leaked script... But let him open an External edit server, and i cant do some NON on it >DD

Edited by Pirulax
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...