Senna Posted August 15, 2018 Share Posted August 15, 2018 (edited) Hi everyone. I'm not strong in scripting. Can you pls help me with apllying assignLod to this https://pastecode.xyz/view/8905019f https://wiki.multitheftauto.com/wiki/AssignLod Thanks Edited August 15, 2018 by Senna Link to comment
!#NssoR_) Posted August 15, 2018 Share Posted August 15, 2018 Positions = { {1941,197.7,2352,25.9,0,0,0,1, true}, {1943,412.20001,2455.1001,15.5,0,0,90,1, false}, {1941,268.5,2396.7,25.5,0,0,0,1, true}, } addEventHandler ("onResourceStart", resourceRoot, function() for i,v in pairs ( Positions ) do assignLOD(createObject(v[1], v[2],v[3], v[4], v[5], v[6], v[7])) end end ) function assignLOD(element) local lod = createObject(getElementModel(element),0, 0 ,0, 0, 0, 0, true) setElementDimension(lod,getElementDimension(element)) setElementPosition(lod, getElementPosition(element)) setElementRotation(lod, getElementRotation(element)) setElementCollisionsEnabled(lod,false) setLowLODElement(element,lod) return lod end 1 Link to comment
Dimos7 Posted August 15, 2018 Share Posted August 15, 2018 Copy the code to script file you want and done Link to comment
Discord Moderators Pirulax Posted August 15, 2018 Discord Moderators Share Posted August 15, 2018 (edited) @!#NssoR_) Even simpler: assignLOD(createObject(unpack(v))) Edited August 15, 2018 by Pirulax 2 Link to comment
Discord Moderators Pirulax Posted August 16, 2018 Discord Moderators Share Posted August 16, 2018 Or actually not.. local positions = { {1941, 197.7, 2352,2 5.9, 0, 0, 0}, {1943, 412.20001, 2455.1001, 15.5, 0, 0, 90}, {1941, 268.5, 2396.7, 25.5, 0, 0, 0}, } Now it should be fine. 1 Link to comment
Rockyz Posted August 16, 2018 Share Posted August 16, 2018 (edited) 1 hour ago, Pirulax said: Or actually not.. local positions = { {1941, 197.7, 2352,2 5.9, 0, 0, 0}, {1943, 412.20001, 2455.1001, 15.5, 0, 0, 90}, {1941, 268.5, 2396.7, 25.5, 0, 0, 0}, } Now it should be fine. well, you can do this with the old table assignLOD(createObject(unpack(v, 1, 7))) Edited August 16, 2018 by #,xiRocKyz 1 1 Link to comment
Senna Posted August 16, 2018 Author Share Posted August 16, 2018 (edited) @!#NssoR_) @#,xiRocKyz Thank you, but you forgot about setObjectScale(obj, v[8]) setElementDoubleSided(obj, v[9]) Edited August 16, 2018 by Senna Link to comment
Discord Moderators Pirulax Posted August 16, 2018 Discord Moderators Share Posted August 16, 2018 @#,xiRocKyz Thanks! I good to know that little life hack Link to comment
Senna Posted August 17, 2018 Author Share Posted August 17, 2018 On 15.08.2018 at 22:28, !#NssoR_) said: Positions = { {1941,197.7,2352,25.9,0,0,0,1, true}, {1943,412.20001,2455.1001,15.5,0,0,90,1, false}, {1941,268.5,2396.7,25.5,0,0,0,1, true}, } addEventHandler ("onResourceStart", resourceRoot, function() for i,v in pairs ( Positions ) do assignLOD(createObject(v[1], v[2],v[3], v[4], v[5], v[6], v[7])) end end ) function assignLOD(element) local lod = createObject(getElementModel(element),0, 0 ,0, 0, 0, 0, true) setElementDimension(lod,getElementDimension(element)) setElementPosition(lod, getElementPosition(element)) setElementRotation(lod, getElementRotation(element)) setElementCollisionsEnabled(lod,false) setLowLODElement(element,lod) return lod end 20 hours ago, #,xiRocKyz said: well, you can do this with the old table assignLOD(createObject(unpack(v, 1, 7))) These codes don't work. Errors: [2018-08-16 20:26:45] WARNING: servermapp\server.lua:5270: Bad argument @ 'getElementModel' [Expected element at argument 1, got boolean] [2018-08-16 20:26:45] WARNING: servermapp\server.lua:5270: Bad argument @ 'createObject' [Expected number at argument 1, got boolean] [2018-08-16 20:26:45] WARNING: servermapp\server.lua:5271: Bad argument @ 'getElementDimension' [Expected element at argument 1, got boolean] [2018-08-16 20:26:45] WARNING: servermapp\server.lua:5271: Bad argument @ 'setElementDimension' [Expected element at argument 1, got boolean] [2018-08-16 20:26:45] WARNING: servermapp\server.lua:5272: Bad argument @ 'getElementPosition' [Expected element at argument 1, got boolean] [2018-08-16 20:26:45] WARNING: servermapp\server.lua:5272: Bad argument @ 'setElementPosition' [Expected element at argument 1, got boolean] [2018-08-16 20:26:45] WARNING: servermapp\server.lua:5273: Bad argument @ 'getElementRotation' [Expected element at argument 1, got boolean] [2018-08-16 20:26:45] WARNING: servermapp\server.lua:5273: Bad argument @ 'setElementRotation' [Expected element at argument 1, got boolean] [2018-08-16 20:26:45] WARNING: servermapp\server.lua:5274: Bad argument @ 'setElementCollisionsEnabled' [Expected element at argument 1, got boolean] [2018-08-16 20:26:45] WARNING: servermapp\server.lua:5275: Bad argument @ 'setLowLODElement' [Expected element at argument 1, got boolean] [2018-08-16 20:26:45] WARNING: servermapp\server.lua:5264: Bad argument @ 'setObjectScale' [Expected object at argument 1, got number '1'] [2018-08-16 20:26:45] WARNING: servermapp\server.lua:5265: Bad argument @ 'setElementDoubleSided' [Expected element at argument 1, got boolean] Also, objects don't create Link to comment
!#NssoR_) Posted August 17, 2018 Share Posted August 17, 2018 Positions = { {1941,197.7,2352,25.9,0,0,0,1, true}, {1943,412.20001,2455.1001,15.5,0,0,90,1, false}, {1941,268.5,2396.7,25.5,0,0,0,1, true}, } addEventHandler ("onResourceStart", resourceRoot, function() for i,v in ipairs ( Positions ) do local OB = createObject(unpack(v,1,7)) setElementDoubleSided(OB, v[9]) assignLOD(OB,v[8]) end end ) function assignLOD(element,Scale) local lod = createObject(getElementModel(element),0, 0 ,0, 0, 0, 0, true) setElementDimension(lod,getElementDimension(element)) setElementPosition(lod, getElementPosition(element)) setElementRotation(lod, getElementRotation(element)) setObjectScale(element, Scale) setObjectScale(lod, Scale) setElementCollisionsEnabled(lod,false) setLowLODElement(element,lod) return lod end 1 Link to comment
Senna Posted August 18, 2018 Author Share Posted August 18, 2018 On 17.08.2018 at 15:27, !#NssoR_) said: Positions = { {1941,197.7,2352,25.9,0,0,0,1, true}, {1943,412.20001,2455.1001,15.5,0,0,90,1, false}, {1941,268.5,2396.7,25.5,0,0,0,1, true}, } addEventHandler ("onResourceStart", resourceRoot, function() for i,v in ipairs ( Positions ) do local OB = createObject(unpack(v,1,7)) setElementDoubleSided(OB, v[9]) assignLOD(OB,v[8]) end end ) function assignLOD(element,Scale) local lod = createObject(getElementModel(element),0, 0 ,0, 0, 0, 0, true) setElementDimension(lod,getElementDimension(element)) setElementPosition(lod, getElementPosition(element)) setElementRotation(lod, getElementRotation(element)) setObjectScale(element, Scale) setObjectScale(lod, Scale) setElementCollisionsEnabled(lod,false) setLowLODElement(element,lod) return lod end Thank you! Works fine! It is what I wanted 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