itHyperoX Posted September 20, 2017 Share Posted September 20, 2017 (edited) 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 September 20, 2017 by TheMOG Link to comment
Anubhav Posted September 20, 2017 Share Posted September 20, 2017 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
itHyperoX Posted September 21, 2017 Author Share Posted September 21, 2017 always returning slot 1 empty slot 2 empty Link to comment
Moderators IIYAMA Posted September 21, 2017 Moderators Share Posted September 21, 2017 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
itHyperoX Posted September 21, 2017 Author Share Posted September 21, 2017 i tried that, still same, the data is right. Link to comment
Moderators IIYAMA Posted September 21, 2017 Moderators Share Posted September 21, 2017 (edited) 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 September 21, 2017 by IIYAMA 2 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now