RobbieG-NL Posted November 20, 2012 Share Posted November 20, 2012 Hello, Today I finally made this show my model in MTA (viewtopic.php?f=91&t=50434&p=493519). Unfortunately I can't get the seperate parts to be rotated in the correct way. I can only rotate the first part (line 2, by changing the 0 into another number for degrees). What I want to do is give the 4 seperate parts their own rotation. I'm pretty sure line 3 has something to do with it, but since I am a total idiot/n00b when it comes to coding, I'm not sure at all. Been trying for some hours now, in numerous ways, but so far, without any success. What am I missing here? local modelsToReplace = {1915} local castleBasePosition, castleZRotation = {20, -1995, 5}, 0 --Located just west of Area 69. local castleObjects = {--{modelID, xOffset, yOffset, zOffset} {1915, -129.182, 0, 0, 0, 0, 270}, {1915, -129.182, -129.182, 0, 0, 0, 180}, {1915, 0, -129.182, 0, 0, 0, 90}, {1915, 0, 0, 0, 0, 0, 0}, } local function resourceStart() local castle = createElement("castle", "castlea") setElementPosition(castle, castleBasePosition[1], castleBasePosition[2], castleBasePosition[3]) setElementRotation(castle, 0, 0, castleZRotation) for i,v in ipairs(castleObjects) do local x, y, z = (castleBasePosition[1] + v[2]), (castleBasePosition[2] + v[3]), (castleBasePosition[3] + v[4]) local newObject = createObject(v[1], x, y, z, 0, 0, castleZRotation) setElementParent(newObject, castle) end for i,v in ipairs(modelsToReplace) do local texture = engineLoadTXD("castle.txd") engineImportTXD(texture, v) local colission = engineLoadCOL("castle.col") local model = engineLoadDFF("castle.dff", 1915) engineReplaceCOL(colission, v) engineReplaceModel(model, v) engineSetModelLODDistance(v, 500) end local castleBlip = createBlip(castleBasePosition[1], castleBasePosition[2], castleBasePosition[3], 19, 2, 255, 0, 0, 255, 0, 500) setElementParent(castleBlip, castle) --This is to reload the collision data when the local player gets near the castle local streamingColShape = createColCircle(castleBasePosition[1], castleBasePosition[2], 250) setElementParent(streamingColShape, castle) addEventHandler("onClientColShapeHit", streamingColShape, streamInCastle) --addEventHandler("onClientColShapeLeave", streamingColShape, streamOutCastle) end addEventHandler("onClientResourceStart", resourceRoot, resourceStart) --Streams the castle IN function streamInCastle(hitElement, dimensionMatch) if hitElement ~= localPlayer or not dimensionMatch then return end for i,v in ipairs(modelsToReplace) do local texture = engineLoadTXD("castle.txd") engineImportTXD(texture, v) local colission = engineLoadCOL("castle.col") local model = engineLoadDFF("castle.dff", 0) engineReplaceCOL(colission, v) engineReplaceModel(model, v) engineSetModelLODDistance(v, 500) end end BTW, debugscript is giving me no errors or anything. Link to comment
Castillo Posted November 20, 2012 Share Posted November 20, 2012 local modelsToReplace = {1915} local castleBasePosition, castleZRotation = {20, -1995, 5}, 0 --Located just west of Area 69. local castleObjects = {--{modelID, xOffset, yOffset, zOffset} {1915, -129.182, 0, 0, 0, 0, 270}, {1915, -129.182, -129.182, 0, 0, 0, 180}, {1915, 0, -129.182, 0, 0, 0, 90}, {1915, 0, 0, 0, 0, 0, 0}, } local function resourceStart() local castle = createElement("castle", "castlea") setElementPosition(castle, castleBasePosition[1], castleBasePosition[2], castleBasePosition[3]) setElementRotation(castle, 0, 0, castleZRotation) for i,v in ipairs(castleObjects) do local x, y, z = (castleBasePosition[1] + v[2]), (castleBasePosition[2] + v[3]), (castleBasePosition[3] + v[4]) local newObject = createObject(v[1], x, y, z, 0, 0, v[7]) setElementParent(newObject, castle) end for i,v in ipairs(modelsToReplace) do local texture = engineLoadTXD("castle.txd") engineImportTXD(texture, v) local colission = engineLoadCOL("castle.col") local model = engineLoadDFF("castle.dff", 1915) engineReplaceCOL(colission, v) engineReplaceModel(model, v) engineSetModelLODDistance(v, 500) end local castleBlip = createBlip(castleBasePosition[1], castleBasePosition[2], castleBasePosition[3], 19, 2, 255, 0, 0, 255, 0, 500) setElementParent(castleBlip, castle) --This is to reload the collision data when the local player gets near the castle local streamingColShape = createColCircle(castleBasePosition[1], castleBasePosition[2], 250) setElementParent(streamingColShape, castle) addEventHandler("onClientColShapeHit", streamingColShape, streamInCastle) --addEventHandler("onClientColShapeLeave", streamingColShape, streamOutCastle) end addEventHandler("onClientResourceStart", resourceRoot, resourceStart) --Streams the castle IN function streamInCastle(hitElement, dimensionMatch) if hitElement ~= localPlayer or not dimensionMatch then return end for i,v in ipairs(modelsToReplace) do local texture = engineLoadTXD("castle.txd") engineImportTXD(texture, v) local colission = engineLoadCOL("castle.col") local model = engineLoadDFF("castle.dff", 0) engineReplaceCOL(colission, v) engineReplaceModel(model, v) engineSetModelLODDistance(v, 500) end end Try that. Link to comment
RobbieG-NL Posted November 20, 2012 Author Share Posted November 20, 2012 Hahaha, nice. I've had something else working in the meantime, but that required me to copy/paste most of the script 4 times. This is a much cleaner way to do it. Thanks a million. Got another question though: can I add interior objects in this same lua script? If so, how? Or would it be better to do that in a new file? Again, if so, how? Link to comment
Castillo Posted November 20, 2012 Share Posted November 20, 2012 What do you mean by interior objects? Link to comment
RobbieG-NL Posted November 20, 2012 Author Share Posted November 20, 2012 Lmao, never mind that. I figured it out. By interior objects I meant the standard GTA interiors that are used in houses, for example: ID 14502 Turns out I can now simple add lines under the coordinates for ID's 1915. Thanks a lot. If you ever need a model of anything, just let me know and I'll do what I can for you. I can make them small in kb's or very detailed with more kb's. Any way you like it. Thanks a lot for all your time, effort and patience. 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