Jump to content

getVehicleNameFromModel expected number at argument 1 got boolean


itHyperoX

Recommended Posts

Hello, whats the problem?

Debug error: 
getVehicleNameFromModel expected number at argument 1 got boolean

addCommandHandler("checkplayervehicle",function(source,cmd,target)
    if not (target) then
        outputChatBox("/checkplayervehicle [Player]")
    else
        local target, targetName = exports["serverCore"]:findPlayer(source,target)     
        if target then    
            local targetAccount = getAccountName(getPlayerAccount(target))        
            local playercar1 = executeSQLQuery("SELECT Model FROM vehicleSlot1 WHERE PlayerName = ?",targetAccount)
            if #playercar1 > 1 then
                outputChatBox(getVehicleNameFromModel(playercar1),source)
            else
                outputChatBox("slot 1 empty",source)
            end
      
        
            local playercar2 = executeSQLQuery("SELECT Model FROM vehicleSlot2 WHERE PlayerName = ?",targetAccount)
            if #playercar2 > 1 then
                outputChatBox(getVehicleNameFromModel(playercar2),source)
            else
                outputChatBox("slot 2 empty",source)
            end
            
        end
    end
end)

 

Edited by TheMOG
Link to comment
addCommandHandler("checkplayervehicle",
    function(source, cmd, target)
        if not (target) then
            outputChatBox("/checkplayervehicle [Player]")
            return false 
        end
        local target, targetName = exports["serverCore"]:findPlayer(source,target) 

        if target then    
            local targetAccount = getAccountName(getPlayerAccount(target))        
            local playercar1 = executeSQLQuery("SELECT Model FROM vehicleSlot1 WHERE PlayerName = ?",targetAccount)
            if #playercar1 > 1 then
                outputChatBox(getVehicleNameFromModel(playercar2[1].Model),source)
            else
                outputChatBox("slot 1 empty",source)
            end
            
            local playercar2 = executeSQLQuery("SELECT Model FROM vehicleSlot2 WHERE PlayerName = ?",targetAccount)
            if #playercar2 > 1 then
                outputChatBox(getVehicleNameFromModel(playercar2[1].Model),source)
            else
                outputChatBox("slot 2 empty",source)
            end
        end
    end
)

 

Link to comment
  • Moderators

local playercar1 = executeSQLQuery("SELECT Model FROM vehicleSlot1 WHERE PlayerName = ?",targetAccount)

if #playercar1 > 1 then

outputChatBox(getVehicleNameFromModel(playercar2[1].Model),source)

else

outputChatBox("slot 1 empty",source)

end

Typo.

 

And download a SQL viewer from internet to check your data.

 

 

Link to comment
  • Moderators

local playercar1 = executeSQLQuery("SELECT Model FROM vehicleSlot1 WHERE PlayerName = ?",targetAccount)

if #playercar1 > 1 then

 

local playercar1 = executeSQLQuery("SELECT Model FROM vehicleSlot1 WHERE PlayerName = ? LIMIT 1",targetAccount)
if #playercar1 == 1 then

 

LIMIT 1 = max 1 result, useful for optimisation of the queries.

Edited by IIYAMA
  • Thanks 2
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...