MightyAnimals Posted July 5, 2014 Share Posted July 5, 2014 (edited) Deleted Edited July 27, 2014 by Guest Link to comment
.:HyPeX:. Posted July 5, 2014 Share Posted July 5, 2014 1C27BAcc6 seems like a userdata name, check its type. Else, we need to know how you get the variables, we cant just make magic Link to comment
MightyAnimals Posted July 5, 2014 Author Share Posted July 5, 2014 Well, in the begin of the script i've got local carname = { } carname[506] = {"Austin Martin Z12 Zagato MD10"} carname[560] = {"1993 Subaru Impreza"} when I do outputChatBox("(( This " .. tostring(carname) .. " belongs to " .. ownerName .. ". ))", thePlayer, 255, 195, 14) it gives me those variables. in the spoiler it says vehnameid which is the vehicles.sql. shows nil when I enter the car. Link to comment
Catalyst Posted July 5, 2014 Share Posted July 5, 2014 use outputChatBox("(( This " .. tostring(carname[getVehicleModel(source)]) .. " belongs to " .. ownerName .. ". ))", thePlayer, 255, 195, 14) Link to comment
MightyAnimals Posted July 5, 2014 Author Share Posted July 5, 2014 Neither did that work.. Still, I appriciate the help Jajcasz. It's a roleplay script . forgot to say. Link to comment
.:HyPeX:. Posted July 5, 2014 Share Posted July 5, 2014 Oh i get it, that wont work, it was stated in another topic some time ago, using direct numbers as a variable in the table will determine a table position, and therefore, not work. Therefore use something like this: outputChatBox("(( This " .. tostring(carname."a"..getVehicleModel(source)[1]) .. " belongs to " .. ownerName .. ". ))", thePlayer, 255, 195, 14) --Remember to edit the table at the start of the script local carname = { } carname.a506 = {"Austin Martin Z12 Zagato MD10"} carname.a560 = {"1993 Subaru Impreza"} Also, you are returning a table in the carname, since the names are inside a table. Link to comment
MightyAnimals Posted July 5, 2014 Author Share Posted July 5, 2014 That didn't work though.. Still, thanks for trying. That's what i've got to get the new name. function getVehicleCustomNameAndIDFromModel(model) local exists = 0 for k,v in pairs(carname) do if k == model then exists = 1 end end if exists == 1 then local newvehnameid = math.random(1,#carname[model]) return {carname[model][newvehnameid], newvehnameid} else return {getVehicleNameFromModel(model), 1} end end Link to comment
_DrXenon Posted July 5, 2014 Share Posted July 5, 2014 GetVehicleModel function exists? I don't think so, use getElementModel. Link to comment
Addlibs Posted July 5, 2014 Share Posted July 5, 2014 GetVehicleModel function exists?I don't think so, use getElementModel. yep... Try: outputChatBox("(( This " .. tostring(carname[getElementModel(source)]) .. " belongs to " .. ownerName .. ". ))", thePlayer, 255, 195, 14) Link to comment
MightyAnimals Posted July 6, 2014 Author Share Posted July 6, 2014 Still, didn't work. GetVehicleNameFromModel Does exist on the MTA wiki. Link to comment
Moderators IIYAMA Posted July 6, 2014 Moderators Share Posted July 6, 2014 Function works: /srun getVehicleNameFromModel(470) Command results: Patriot [string] I recommend in case of wrong model: return {getVehicleNameFromModel(model) or "", 1} Link to comment
MightyAnimals Posted July 6, 2014 Author Share Posted July 6, 2014 Perhaps, some more explanation? I didn't quite get it the way you've just told me. Link to comment
Moderators IIYAMA Posted July 6, 2014 Moderators Share Posted July 6, 2014 You said the function didn't work.... so I showed you it does work. Never heard of runcode? https://wiki.multitheftauto.com/wiki/Resource:Runcode You can execute all kinds of code with it. (client/server) Example: /start runcode /srun player = getPlayerFromName("[HB]IIYAMA") /srun setElemenPosition(player,0,0,10) /srun setElementHealth(player,100) /srun setElementFrozen(player,true) /srun setElementFrozen(player,false) Je moet meer outputDebugString gebruiken om te zien wat er fout gaat. Ik kan eigenlijk het probleem van je in deze stukjes code niet vinden. Link to comment
MightyAnimals Posted July 6, 2014 Author Share Posted July 6, 2014 Heh, the only thing I wanted was that it actually showed the custom car > Example: This 1993 Sabaru Impreza Belongs to Brian O'Donnald. Since I forgot what I had to do, I made this topic.. Link to comment
Moderators IIYAMA Posted July 6, 2014 Moderators Share Posted July 6, 2014 I am not blind, I can see who wrote the topic. function getVehicleCustomNameAndIDFromModel(model) if model then local carnameBuffered = carname[model] if carnameBuffered then local newvehnameid = math.random(1,#carnameBuffered) return {carnameBuffered[newvehnameid] or getVehicleNameFromModel(model) or "", newvehnameid == 0 and 1 or newvehnameid} else return {getVehicleNameFromModel(model) or "", 1} end else outputDebugString("ERROR: Invalid model") end end Link to comment
MightyAnimals Posted July 6, 2014 Author Share Posted July 6, 2014 That didn't work though. Still thanks for taking the effort. Link to comment
Moderators IIYAMA Posted July 6, 2014 Moderators Share Posted July 6, 2014 That didn't work though.Still thanks for taking the effort. Then your problem is somewhere else. Link to comment
MightyAnimals Posted July 6, 2014 Author Share Posted July 6, 2014 That didn't work though.Still thanks for taking the effort. Then your problem is somewhere else. Perhaps, yes, might have to make some clientside script aswell. Link to comment
.:HyPeX:. Posted July 6, 2014 Share Posted July 6, 2014 That didn't work though.Still thanks for taking the effort. Then your problem is somewhere else. Perhaps, yes, might have to make some clientside script aswell. Not Really. Your error is as he said somewhere else. Any errors in debug? PD: getting the vehicle name from model will return GTA:SA's one. Link to comment
MightyAnimals Posted July 7, 2014 Author Share Posted July 7, 2014 It does post this: ERROR: vehicle-system\s_vehicle_system.lua:868: attempt to concatenate upvalue 'carname' Link to comment
Moderators IIYAMA Posted July 7, 2014 Moderators Share Posted July 7, 2014 Example why you get this error: theError = {} .. "" attempt to concatenate a table value Link to comment
MightyAnimals Posted July 7, 2014 Author Share Posted July 7, 2014 Yea.. That'd explain it. Link to comment
Addlibs Posted July 7, 2014 Share Posted July 7, 2014 outputChatBox("(( This " .. tostring(carname[getElementModel(source)][1]) .. " belongs to " .. ownerName .. ". ))", thePlayer, 255, 195, 14) --use first value of the tabble carname[model] ( carname[model][1] ) OR: local carname = { } carname[506] = "Austin Martin Z12 Zagato MD10" carname[560] = "1993 Subaru Impreza" --notice I moved the strings out of the tables { } with outputChatBox("(( This " .. tostring(carname[getElementModel(source)]) .. " belongs to " .. ownerName .. ". ))", thePlayer, 255, 195, 14) Link to comment
MightyAnimals Posted July 7, 2014 Author Share Posted July 7, 2014 I'll surely give it a try. Link to comment
MightyAnimals Posted July 7, 2014 Author Share Posted July 7, 2014 That did work! I got another problem table.insert(content, {" - " ..(getElementData(source, "carname[model]") or getVehicleNameFromModel( getElementModel( source ) ))} ) I've tried some options neither did they work. I actually want the custom carname to show instead of the mta model 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