MightyAnimals Posted July 5, 2014 Posted July 5, 2014 (edited) Deleted Edited July 27, 2014 by Guest Need help with something? Message me, and maybe I'll get back to you. And might even do it for a fair price.
.:HyPeX:. Posted July 5, 2014 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 My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
MightyAnimals Posted July 5, 2014 Author 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. Need help with something? Message me, and maybe I'll get back to you. And might even do it for a fair price.
Catalyst Posted July 5, 2014 Posted July 5, 2014 use outputChatBox("(( This " .. tostring(carname[getVehicleModel(source)]) .. " belongs to " .. ownerName .. ". ))", thePlayer, 255, 195, 14)
MightyAnimals Posted July 5, 2014 Author Posted July 5, 2014 Neither did that work.. Still, I appriciate the help Jajcasz. It's a roleplay script . forgot to say. Need help with something? Message me, and maybe I'll get back to you. And might even do it for a fair price.
.:HyPeX:. Posted July 5, 2014 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. My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
MightyAnimals Posted July 5, 2014 Author 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 Need help with something? Message me, and maybe I'll get back to you. And might even do it for a fair price.
_DrXenon Posted July 5, 2014 Posted July 5, 2014 GetVehicleModel function exists? I don't think so, use getElementModel. ●●● Rage Gaming Society Coming Soon ●●●
Addlibs Posted July 5, 2014 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) Previously known as MrTasty.
MightyAnimals Posted July 6, 2014 Author Posted July 6, 2014 Still, didn't work. GetVehicleNameFromModel Does exist on the MTA wiki. Need help with something? Message me, and maybe I'll get back to you. And might even do it for a fair price.
Moderators IIYAMA Posted July 6, 2014 Moderators 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} Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
MightyAnimals Posted July 6, 2014 Author Posted July 6, 2014 Perhaps, some more explanation? I didn't quite get it the way you've just told me. Need help with something? Message me, and maybe I'll get back to you. And might even do it for a fair price.
Moderators IIYAMA Posted July 6, 2014 Moderators 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. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
MightyAnimals Posted July 6, 2014 Author 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.. Need help with something? Message me, and maybe I'll get back to you. And might even do it for a fair price.
Moderators IIYAMA Posted July 6, 2014 Moderators 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 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
MightyAnimals Posted July 6, 2014 Author Posted July 6, 2014 That didn't work though. Still thanks for taking the effort. Need help with something? Message me, and maybe I'll get back to you. And might even do it for a fair price.
Moderators IIYAMA Posted July 6, 2014 Moderators Posted July 6, 2014 That didn't work though.Still thanks for taking the effort. Then your problem is somewhere else. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
MightyAnimals Posted July 6, 2014 Author 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. Need help with something? Message me, and maybe I'll get back to you. And might even do it for a fair price.
.:HyPeX:. Posted July 6, 2014 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. My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
MightyAnimals Posted July 7, 2014 Author Posted July 7, 2014 It does post this: ERROR: vehicle-system\s_vehicle_system.lua:868: attempt to concatenate upvalue 'carname' Need help with something? Message me, and maybe I'll get back to you. And might even do it for a fair price.
Moderators IIYAMA Posted July 7, 2014 Moderators Posted July 7, 2014 Example why you get this error: theError = {} .. "" attempt to concatenate a table value Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
MightyAnimals Posted July 7, 2014 Author Posted July 7, 2014 Yea.. That'd explain it. Need help with something? Message me, and maybe I'll get back to you. And might even do it for a fair price.
Addlibs Posted July 7, 2014 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) Previously known as MrTasty.
MightyAnimals Posted July 7, 2014 Author Posted July 7, 2014 I'll surely give it a try. Need help with something? Message me, and maybe I'll get back to you. And might even do it for a fair price.
MightyAnimals Posted July 7, 2014 Author 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 Need help with something? Message me, and maybe I'll get back to you. And might even do it for a fair price.
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