[DooD]Heavyair Posted May 25, 2008 Share Posted May 25, 2008 (edited) im trying to make a ferry but when i put parts of ferry together with attach element to element the parts stack on top of each other function ferry ( player, commandname ) local bridge = createObject ( 9584, -754, 609, 5, 0, 0, 0 ) local hull = createObject ( 9585, -752, 609, -4, 0, 0, 0 ) local deck = createObject ( 9586, -827, 609, 14, 0, 0, 0.5 ) attacheElementToElement ( bridge, deck, 73, 0, 0, 0, 0, -0.5 ) attachElementToElement ( deck, hull, 75, 0, 18, 0, 0, 0.5 ) end addCommandHandler ( "ferry", ferry ) not sure how to get the offset coordinates right / also not sure how to upload screenshot i also get an error on attach element to element line 5 attempt to call global attach element to element nil value i have tried this with no offset coordinates but it does the same thing any ideas appreciated Edited May 28, 2008 by Guest Link to comment
[DooD]Heavyair Posted May 25, 2008 Author Share Posted May 25, 2008 (edited) im trying to make a ferry but when i put parts of ferry together with attach element to element the parts stack on top of each other function ferry ( player, commandname ) local bridge = createObject ( 9584, -754, 609, 5, 0, 0, 0 ) local hull = createObject ( 9585, -752, 609, -4, 0, 0, 0 ) local deck = createObject ( 9586, -827, 609, 14, 0, 0, 0.5 ) attacheElementToElement ( bridge, deck, 73, 0, 0, 0, 0, -0.5 ) attachElementToElement ( deck, hull, 75, 0, 18, 0, 0, 0.5 )end addCommandHandler ( "ferry", ferry ) not sure how to get the offset coordinates right / also not sure how to upload screenshot i also get an error on attach element to element line 5 attempt to call global attach element to element nil value i have tried this with no offset coordinates but it does the same thing any ideas appreciated Edited May 28, 2008 by Guest Link to comment
Ace_Gambit Posted May 25, 2008 Share Posted May 25, 2008 You are attaching one element to the next. Instead you should try to glue all elements to one parent element, the hull for example. This makes it easier to calculate the required offset values. The offset values are relative to the element you are attaching to. Take a look at the carrier resource. There is a server side function that calculates the right offsets on the fly. Also: attacheElementToElement Should be: attachElementToElement Link to comment
Ace_Gambit Posted May 25, 2008 Share Posted May 25, 2008 You are attaching one element to the next. Instead you should try to glue all elements to one parent element, the hull for example. This makes it easier to calculate the required offset values. The offset values are relative to the element you are attaching to. Take a look at the carrier resource. There is a server side function that calculates the right offsets on the fly. Also: attacheElementToElement Should be: attachElementToElement Link to comment
[DooD]Heavyair Posted May 25, 2008 Author Share Posted May 25, 2008 thank u again ace_gambit u r a * Link to comment
[DooD]Heavyair Posted May 25, 2008 Author Share Posted May 25, 2008 thank u again ace_gambit u r a * Link to comment
Ace_Gambit Posted May 25, 2008 Share Posted May 25, 2008 Here's a simplified function that calculates the offset values relative to posX, posY, posZ and outputs pseudo Lua script code. The object configuration file is read from objects.xml (create this file in the root of your game mode folder). You can build a ferry boat in the race map editor and copy the object elements to the objects.xml file. Example objects.xml "hull" posX="2150.595703" posY="-1724.988647" posZ="6.562508" rotX="0.0000" rotY="0.0000" rotZ="270.0000" model="10771" /> "ldeck" posX="2150.602051" posY="-1662.088379" posZ="5.380146" rotX="0.0000" rotY="0.0000" rotZ="270.0000" model="11145" /> "hangar" posX="2151.157227" posY="-1716.000000" posZ="13.407950" rotX="0.0000" rotY="0.0000" rotZ="269.9999" model="11146" /> "bits" posX="2143.061523" posY="-1728.324463" posZ="39.771801" rotX="0.0000" rotY="0.0000" rotZ="269.9999" model="11237" /> Don't forget to add this line to your meta.xml file: "objects.xml" type="server" /> local objects = {} function outputOffsetDebug(posX, posY, posZ) local rootNode = getResourceConfig(getThisResource(), "objects.xml") local nextSibling = 0 local node = false local gX, gY, gZ = 0, 0, 0 local oX, oY, oZ = 0, 0, 0 objects = {} if (rootNode) then node = xmlFindSubNode(rootNode, "object", nextSibling) while (node) do table.insert(objects, { ["name"] = xmlNodeGetAttribute(node, "name"), ["model"] = tonumber(xmlNodeGetAttribute(node, "model") or 0), ["posX"] = tonumber(xmlNodeGetAttribute(node, "posX") or 0), ["posY"] = tonumber(xmlNodeGetAttribute(node, "posY") or 0), ["posZ"] = tonumber(xmlNodeGetAttribute(node, "posZ") or 0), ["rotX"] = tonumber(xmlNodeGetAttribute(node, "rotX") or 0), ["rotY"] = tonumber(xmlNodeGetAttribute(node, "rotY") or 0), ["rotZ"] = tonumber(xmlNodeGetAttribute(node, "rotZ") or 0), ["xPosOffset"] = 0, ["yPosOffset"] = 0, ["zPosOffset"] = 0 } ) nextSibling = nextSibling + 1 node = xmlFindSubNode(rootNode, "object", nextSibling) end end oX, oY, oZ = objects[1].posX, objects[1].posY, objects[1].posZ for _, object in ipairs(objects) do gX = math.abs(posX - oX) gY = math.abs(posY - oY) if (object.posX > posX) then gX = object.posX - gX else gX = object.posX + gX end if (object.posY > posY) then gY = object.posY - gY else gY = object.posY + gY end object.posX = gX object.posY = gY end for _, object in ipairs(objects) do gX = math.abs(posX - object.posX) gY = math.abs(posY - object.posY) gZ = object.posZ if (object.posX < posX) then gX = -(gX) end if (object.posY < posY) then gY = -(gY) end object.xPosOffset = gX object.yPosOffset = gY object.zPosOffset = gZ outputDebugString("attachElementToElement(createObject(" .. object.model .. ", " .. object.posX .. ", " .. object.posY .. ", " .. object.posZ .. ", " .. object.rotX .. ", " .. object.rotY .. ", " .. object.rotZ .. "), [element theParent], " .. object.xPosOffset .. ", " .. object.yPosOffset .. ", " .. object.zPosOffset .. ", " .. object.rotX .. ", " .. object.rotY .. ", " .. object.rotZ .. ")") end end Link to comment
Ace_Gambit Posted May 25, 2008 Share Posted May 25, 2008 Here's a simplified function that calculates the offset values relative to posX, posY, posZ and outputs pseudo Lua script code. The object configuration file is read from objects.xml (create this file in the root of your game mode folder). You can build a ferry boat in the race map editor and copy the object elements to the objects.xml file. Example objects.xml "hull" posX="2150.595703" posY="-1724.988647" posZ="6.562508" rotX="0.0000" rotY="0.0000" rotZ="270.0000" model="10771" /> "ldeck" posX="2150.602051" posY="-1662.088379" posZ="5.380146" rotX="0.0000" rotY="0.0000" rotZ="270.0000" model="11145" /> "hangar" posX="2151.157227" posY="-1716.000000" posZ="13.407950" rotX="0.0000" rotY="0.0000" rotZ="269.9999" model="11146" /> "bits" posX="2143.061523" posY="-1728.324463" posZ="39.771801" rotX="0.0000" rotY="0.0000" rotZ="269.9999" model="11237" /> Don't forget to add this line to your meta.xml file: "objects.xml" type="server" /> local objects = {} function outputOffsetDebug(posX, posY, posZ) local rootNode = getResourceConfig(getThisResource(), "objects.xml") local nextSibling = 0 local node = false local gX, gY, gZ = 0, 0, 0 local oX, oY, oZ = 0, 0, 0 objects = {} if (rootNode) then node = xmlFindSubNode(rootNode, "object", nextSibling) while (node) do table.insert(objects, { ["name"] = xmlNodeGetAttribute(node, "name"), ["model"] = tonumber(xmlNodeGetAttribute(node, "model") or 0), ["posX"] = tonumber(xmlNodeGetAttribute(node, "posX") or 0), ["posY"] = tonumber(xmlNodeGetAttribute(node, "posY") or 0), ["posZ"] = tonumber(xmlNodeGetAttribute(node, "posZ") or 0), ["rotX"] = tonumber(xmlNodeGetAttribute(node, "rotX") or 0), ["rotY"] = tonumber(xmlNodeGetAttribute(node, "rotY") or 0), ["rotZ"] = tonumber(xmlNodeGetAttribute(node, "rotZ") or 0), ["xPosOffset"] = 0, ["yPosOffset"] = 0, ["zPosOffset"] = 0 } ) nextSibling = nextSibling + 1 node = xmlFindSubNode(rootNode, "object", nextSibling) end end oX, oY, oZ = objects[1].posX, objects[1].posY, objects[1].posZ for _, object in ipairs(objects) do gX = math.abs(posX - oX) gY = math.abs(posY - oY) if (object.posX > posX) then gX = object.posX - gX else gX = object.posX + gX end if (object.posY > posY) then gY = object.posY - gY else gY = object.posY + gY end object.posX = gX object.posY = gY end for _, object in ipairs(objects) do gX = math.abs(posX - object.posX) gY = math.abs(posY - object.posY) gZ = object.posZ if (object.posX < posX) then gX = -(gX) end if (object.posY < posY) then gY = -(gY) end object.xPosOffset = gX object.yPosOffset = gY object.zPosOffset = gZ outputDebugString("attachElementToElement(createObject(" .. object.model .. ", " .. object.posX .. ", " .. object.posY .. ", " .. object.posZ .. ", " .. object.rotX .. ", " .. object.rotY .. ", " .. object.rotZ .. "), [element theParent], " .. object.xPosOffset .. ", " .. object.yPosOffset .. ", " .. object.zPosOffset .. ", " .. object.rotX .. ", " .. object.rotY .. ", " .. object.rotZ .. ")") end end Link to comment
[DooD]Heavyair Posted May 25, 2008 Author Share Posted May 25, 2008 WOW Awesome thanx loads man thats well cool Link to comment
[DooD]Heavyair Posted May 25, 2008 Author Share Posted May 25, 2008 WOW Awesome thanx loads man thats well cool Link to comment
[DooD]Heavyair Posted May 25, 2008 Author Share Posted May 25, 2008 right ive built my ferry and all pieces are attached properly but is there any way to attach players/vehicles to it when they land on it and allow them to jump off/ takeoff when they want at the moment if u stand on the deck or land plane / chopper on deck they slide off when ferry moves even if i move it slow i have downloaded the GLUE script form MTA resources but i need a way of turning it on and off without player having to type command or press key i was thinking of using collision shapes at each port that ferry stops to activate / deactivate the GLUE script but that means u will have to wait until ferry stops before u can get off if i use collision shape to stick and unstick players / vehicles at each port would it mess everything up if i leave the keybind for GLUE script switched on so u can leave / board ferry when u want or u can wait for it to stop and it will GLUE u by itself like if u fly to the ferry while its moving land and then press key to GLUE yourself and then wait till it gets to port and will then unstick u or u get on ferry while its stopped and it GLUEs u to the deck before moving off then someone flys past and u want to chase them so u just press key to unglue yourself without having to wait for ferry to stop hope that makes sense i was thinking of using a collision shape that calls this check function to get the PLAYER / VEHICLE to be glued function samSite ( element, matchingDimension ) if ( getElementType ( element ) == "player" ) then veh = getPlayerOccupiedVehicle ( element ) id = getVehicleID ( veh ) if ( id == 592 or id == 577 or id == 511 or id == 548 or id == 512 or id == 593 or id == 417 or id == 487 or id == 553 or id == 488 or id == 497 or id == 563 or id == 476 or id == 447 or id == 519 or id == 460 or id == 469 or id == 513 or id == 464 or id == 501 or id == 465 ) then triggerClientEvent ( element, "onSamTrigger", getRootElement() ) outputChatBox ( "Surface to air missiles have been fired!", element, 255, 0, 0 ) end end end i know ill have to edit it a bit ( take ID check out so it just looks for vehicle/ player / jetpack ) and then i will trigger the GLUE script for whoever / whatever is in collision area i want to be able to just spawn a few vehicles on top of it to give an idea what its for which is the main reason for switching GLUE on and off without any commands EDIT :: glue doesnt seem to work on the ferry u still just slide off. i think its only meant for vehicles looking at the scripts for it 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