itHyperoX Posted March 21, 2017 Share Posted March 21, 2017 (edited) Hi. I'm working on my own vehicle shop, and in the end, i got some problems. Here is the code local vehicles = { {411,80000}, {509,5000}, {481,10000}, {462,35000}, {521,115000}, {463,95000}, {510,14000}, {522,175000}, {461,100000}, {448,50000}, {468,95000}, {586,95000} } local carNames = { [500] = "Dozer", [455] = "BMW M4", [597] = "Test" } function getVehicleRealName(vehicle) if vehicle then local vehicleModel = getElementModel(vehicle) if carNames[vehicleModel] then return carNames[vehicleModel] else return getVehicleNameFromModel(v[1]) end end end for i,v in ipairs(vehicles) do local row = guiGridListAddRow(bikglVehicleSelection) guiGridListSetItemText(bikglVehicleSelection,row,1,getVehicleRealName(tostring(v[1])),false,true) -- Here is the error guiGridListSetItemText(bikglVehicleSelection,row,2,tostring(v[2]),false,true) end The problem is, the gui not showing the vehicles real name. I got some debug error, tried to fix, but nothing helped me. debug: Bad argmunet @ 'getElementModel' [Expected element at argument 1, got string '411'] attemt to index global 'v' (nil value) any help please? When i'm using normal vehiclenames, everything work. Here is the default local vehicles = { {411,80000}, {509,5000}, {481,10000}, {462,35000}, {521,115000}, {463,95000}, {510,14000}, {522,175000}, {461,100000}, {448,50000}, {468,95000}, {586,95000} } for i,v in ipairs(vehicles) do local bikName = getVehicleNameFromModel(v[1]) local row = guiGridListAddRow(bikglVehicleSelection) guiGridListSetItemText(bikglVehicleSelection,row,1,bikName,false,true) guiGridListSetItemText(bikglVehicleSelection,row,2,tostring(v[2]),false,true) end Edited March 21, 2017 by TheMOG Link to comment
NeXuS™ Posted March 21, 2017 Share Posted March 21, 2017 Change local vehicleModel = getElementModel(vehicle) to local vehicleModel = tonumber(getElementModel(vehicle)) Link to comment
itHyperoX Posted March 21, 2017 Author Share Posted March 21, 2017 (edited) @NeXuS™ Just Showing the default vehicle names not the "custom" names. But no debug Edited March 21, 2017 by TheMOG Link to comment
NeXuS™ Posted March 21, 2017 Share Posted March 21, 2017 If you do not have a custom name for the model, it wont show it's "custom name", which doesnt exist. if carNames[vehicleModel] then For the 411 (Infernus), you dont have a custom name in your table. Link to comment
itHyperoX Posted March 21, 2017 Author Share Posted March 21, 2017 (edited) ocal biks = { {411,80000}, {455,5000}, {597,10000}, {462,35000}, {521,115000}, {463,95000}, {510,14000}, {522,175000}, {461,100000}, {448,50000}, {468,95000}, {586,95000} } local carNames = { [411] = "Ferrari", [455] = "BMW M4", [597] = "Test" } function getVehicleRealName(vehicle) if vehicle then local vehicleModel = tonumber(getElementModel(vehicle)) if carNames[vehicleModel] then return carNames[vehicleModel] else return getVehicleNameFromModel(vehicleModel) end end end for i,v in ipairs(biks) do local bikName = getVehicleRealName(v[1]) local row = guiGridListAddRow(bikglVehicleSelection) guiGridListSetItemText(bikglVehicleSelection,row,1,bikName,false,true) guiGridListSetItemText(bikglVehicleSelection,row,2,tostring(v[2]),false,true) end Here is, i getting so many debug error From the "carNames" starting the "custom" car names, and i want that, if the vehicle have custom name, it showing the "custom" name, not the default. I hope you understand Edited March 21, 2017 by TheMOG Link to comment
NeXuS™ Posted March 21, 2017 Share Posted March 21, 2017 For the index error btw Change line nr. 29 return getVehicleNameFromModel(v[1]) to return getVehicleNameFromModel(vehicleModel) Try spawning the car which has the 500 ID. Link to comment
itHyperoX Posted March 21, 2017 Author Share Posted March 21, 2017 bad argument #1 to 'ipairs' (table expected, got nil) Link to comment
NeXuS™ Posted March 21, 2017 Share Posted March 21, 2017 (edited) Ohh man, just realised something, Give me a minute, gonna fix it, and send it here. local vehicles = { {411,80000}, {509,5000}, {481,10000}, {462,35000}, {521,115000}, {463,95000}, {510,14000}, {522,175000}, {461,100000}, {448,50000}, {468,95000}, {586,95000} } local carNames = { [500] = "Dozer", [455] = "BMW M4", [597] = "Test" } function getVehicleRealName(vehicleModel) if carNames[vehicleModel] then return carNames[vehicleModel] else return getVehicleNameFromModel(vehicleModel) end end for i,v in ipairs(vehicles) do local row = guiGridListAddRow(bikglVehicleSelection) guiGridListSetItemText(bikglVehicleSelection,row,1,getVehicleRealName(v[1]),false,true) guiGridListSetItemText(bikglVehicleSelection,row,2,tostring(v[2]),false,true) end This one should work. Edited March 21, 2017 by NeXuS™ 1 Link to comment
itHyperoX Posted March 21, 2017 Author Share Posted March 21, 2017 (edited) @NeXuS™ edit: when i'm buying car it saying : ERROR: Database query failed: no such column: Sad When i'm buying the car which is dont have custom name, thats work. Only getting error when trying to buy "custom" named vehicle I tried after the error with the default names, and no debug error. What can be the problem? Edited March 21, 2017 by TheMOG Link to comment
NeXuS™ Posted March 21, 2017 Share Posted March 21, 2017 Can you send me the dbExecute line? Link to comment
itHyperoX Posted March 21, 2017 Author Share Posted March 21, 2017 (edited) addEvent("jarmuVetel1",true) addEventHandler("jarmuVetel1",getRootElement(), function(id,cost,name) if (exports.serverExport:getMoney(source)>= tonumber(cost)) then local account = getPlayerAccount(source) local name = getAccountName(account) local playercar = executeSQLQuery("SELECT vehID FROM jarmuslot1 WHERE AccNAME = ?",name) if #playercar > 0 then outputChatBox("#CA5454[Jármű - Rendszer]#FFFFFF Ezen a sloton már van járműved. (1)",source,255,255,255,true) else exports.serverExport:takeMoney(source,tonumber(cost)) local addVehicle = executeSQLQuery("INSERT INTO jarmuslot1 (AccNAME,vehID,vehiclePRICE) VALUES(?,?,?)", tostring(name), tonumber(id), tonumber(cost), " ", " ", " ") -- Line 51 ERRORMSG if addVehicle then outputChatBox("#6F9F86[Jármű - Rendszer]#FFFFFF Sikeresen megvetted a kiválasztott járművet.",source,255,255,255,true) else outputChatBox("#CA5454[Jármű - Rendszer]#FFFFFF Sikertelen jármű vásárlás.",source,255,255,255,true) end end else outputChatBox("#CA5454[Jármű - Rendszer]#FFFFFF Nincs elég pénzed hogy megvedd ezt a járművet.",source,255,255,255,true) end end) When im buy the car which dont have custom name, i dont get any error. Errors only appear when i'm trying to buy a "custom named" car. I think the problem is the vehicle custom name Edited March 21, 2017 by TheMOG Link to comment
NeXuS™ Posted March 21, 2017 Share Posted March 21, 2017 Can you do a screenshot of the actual debugscript error? Link to comment
itHyperoX Posted March 21, 2017 Author Share Posted March 21, 2017 (edited) when i'm trying to buy the "KatonaiHelikopter" (Custom Named) : http://kephost.com/image/woNc When I'm buying the default named vehicle nothing error, everything work. 100% the problem is in the custom vehicle names. Edited March 21, 2017 by TheMOG Link to comment
NeXuS™ Posted March 21, 2017 Share Posted March 21, 2017 (edited) You are reassigning the local variable with a new one. local name = getAccountName(account) and function(id,cost,name) Edited March 21, 2017 by NeXuS™ Link to comment
itHyperoX Posted March 21, 2017 Author Share Posted March 21, 2017 but when i'm buy the car which is dont have custom name i dont get error. The problem is there i think Link to comment
NeXuS™ Posted March 21, 2017 Share Posted March 21, 2017 Still, fix that problem. If that's fixed, and there is a problem, there should be an another error, not with your account name. Link to comment
itHyperoX Posted March 21, 2017 Author Share Posted March 21, 2017 Can you give me please a little help about this please? Link to comment
NeXuS™ Posted March 21, 2017 Share Posted March 21, 2017 Try this one: local addVehicle = executeSQLQuery("INSERT INTO jarmuslot1 VALUES(?,?,?)", tostring(name), tonumber(id), tonumber(cost)) Link to comment
NeXuS™ Posted March 22, 2017 Share Posted March 22, 2017 Did you fix the line I sent you above? Link to comment
NeXuS™ Posted March 22, 2017 Share Posted March 22, 2017 Post your code here, and a screenshot of the error. Link to comment
itHyperoX Posted March 22, 2017 Author Share Posted March 22, 2017 fixed, rewrited the vehicle creating handler 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