DonPro Posted April 15, 2015 Share Posted April 15, 2015 Hi, im working on a script now that gonna be a boat i can control with commands, but i need them all to be attach'ed so i can build the ship and just add the cordinats once for the ship and yeah i gues you know what i mean so let me show you what i got so far local object1 = createObject(9585, -1514.5, 242, 6.90, 0, 0, 0) local object2 = createObject(9586, -1516.7998046875, 242, 17, 0, 0, 0) function isAclGroup(p,group) if p and getElementType(p) == "player" and type(group) == "string" then local Deadusergroup = getAccountName(getPlayerAccount(p)) if isObjectInACLGroup("user."..Deadusergroup, aclGetGroup(group)) then return true else return false end else return false end end function moveGate(playerSource, cmd) if cmd == "startcruise" then if isAclGroup(playerSource,"Maritime") then moveObject(object1, 5000, -1377.90, 193.69, 6.90, 0, 0, 45) moveObject(object2, 5000, -1377.90, 193.69, 6.90, 0, 0, 45) end Link to comment
DonPro Posted April 15, 2015 Author Share Posted April 15, 2015 use attachElements could you put it in and show me where to put it? Link to comment
ALw7sH Posted April 15, 2015 Share Posted April 15, 2015 local object1 = createObject(9585, -1514.5, 242, 6.90, 0, 0, 0) local object2 = createObject(9586, -1516.7998046875, 242, 17, 0, 0, 0) attachElements(object2,object1,-2.2998046875,0,10.1) -- attach object2 to object1 --[[ x = x2 - x1 = (-1516.7998046875 - -1514.5) = -2.2998046875 y = y2 - y1 = (242 - 242) = 0 z = z2 - z1 = (17 - 6.90) = 10.1 ]]-- function isAclGroup(p,group) if p and getElementType(p) == "player" and type(group) == "string" then local Deadusergroup = getAccountName(getPlayerAccount(p)) if isObjectInACLGroup("user."..Deadusergroup, aclGetGroup(group)) then return true else return false end else return false end end function moveGate(playerSource, cmd) if cmd == "startcruise" then if isAclGroup(playerSource,"Maritime") then moveObject(object1, 5000, -1377.90, 193.69, 6.90, 0, 0, 45) -- move object1 and object2 gonna move with him end end end Link to comment
DonPro Posted April 15, 2015 Author Share Posted April 15, 2015 local object1 = createObject(9585, -1514.5, 242, 6.90, 0, 0, 0) local object2 = createObject(9586, -1516.7998046875, 242, 17, 0, 0, 0) attachElements(object2,object1,-2.2998046875,0,10.1) -- attach object2 to object1 --[[ x = x2 - x1 = (-1516.7998046875 - -1514.5) = -2.2998046875 y = y2 - y1 = (242 - 242) = 0 z = z2 - z1 = (17 - 6.90) = 10.1 ]]-- function isAclGroup(p,group) if p and getElementType(p) == "player" and type(group) == "string" then local Deadusergroup = getAccountName(getPlayerAccount(p)) if isObjectInACLGroup("user."..Deadusergroup, aclGetGroup(group)) then return true else return false end else return false end end function moveGate(playerSource, cmd) if cmd == "startcruise" then if isAclGroup(playerSource,"Maritime") then moveObject(object1, 5000, -1377.90, 193.69, 6.90, 0, 0, 45) -- move object1 and object2 gonna move with him end end end it wont move Link to comment
ALw7sH Posted April 15, 2015 Share Posted April 15, 2015 local object1 = createObject(9585, -1514.5, 242, 6.90, 0, 0, 0) local object2 = createObject(9586, -1516.7998046875, 242, 17, 0, 0, 0) attachElements(object2,object1,-2.2998046875,0,10.1) -- attach object2 to object1 --[[ x = x2 - x1 = (-1516.7998046875 - -1514.5) = -2.2998046875 y = y2 - y1 = (242 - 242) = 0 z = z2 - z1 = (17 - 6.90) = 10.1 ]]-- function isAclGroup(p,group) if p and getElementType(p) == "player" and type(group) == "string" then local Deadusergroup = getAccountName(getPlayerAccount(p)) if isObjectInACLGroup("user."..Deadusergroup, aclGetGroup(group)) then return true else return false end else return false end end function moveGate(playerSource, cmd) if cmd == "startcruise" then if isAclGroup(playerSource,"Maritime") then moveObject(object1, 5000, -1377.90, 193.69, 6.90, 0, 0, 45) -- move object1 and object2 gonna move with him end end end it wont move Have you added the command handler? and are you sure that you are in "Maritime" ACL group? Link to comment
DonPro Posted April 15, 2015 Author Share Posted April 15, 2015 local object1 = createObject(9585, -1514.5, 242, 6.90, 0, 0, 0) local object2 = createObject(9586, -1516.7998046875, 242, 17, 0, 0, 0) attachElements(object2,object1,-2.2998046875,0,10.1) -- attach object2 to object1 --[[ x = x2 - x1 = (-1516.7998046875 - -1514.5) = -2.2998046875 y = y2 - y1 = (242 - 242) = 0 z = z2 - z1 = (17 - 6.90) = 10.1 ]]-- function isAclGroup(p,group) if p and getElementType(p) == "player" and type(group) == "string" then local Deadusergroup = getAccountName(getPlayerAccount(p)) if isObjectInACLGroup("user."..Deadusergroup, aclGetGroup(group)) then return true else return false end else return false end end function moveGate(playerSource, cmd) if cmd == "startcruise" then if isAclGroup(playerSource,"Maritime") then moveObject(object1, 5000, -1377.90, 193.69, 6.90, 0, 0, 45) -- move object1 and object2 gonna move with him end end end it wont move Did you add the command handler? and are you sure that you are in "Maritime" ACL group? im in the ACL group yes, and i tryed to put up the AddcommandHandler, but did not work local object1 = createObject(9585, -1514.5, 242, 6.90, 0, 0, 0) local object2 = createObject(9586, -1516.7998046875, 242, 17, 0, 0, 0) attachElements(object2,object1,-2.2998046875,0,10.1) -- attach object2 to object1 function isAclGroup(p,group) if p and getElementType(p) == "player" and type(group) == "string" then local Deadusergroup = getAccountName(getPlayerAccount(p)) if isObjectInACLGroup("user."..Deadusergroup, aclGetGroup(group)) then return true else return false end else return false end end function moveGate(playerSource, cmd) if cmd == "gostart" then if isAclGroup(playerSource,"Maritime") then moveObject(object1, 5000, -1377.90, 193.69, 6.90, 0, 0, 45) -- move object1 and object2 gonna move with him end addCommandHandler("gostart", moveGate) end end Link to comment
ALw7sH Posted April 15, 2015 Share Posted April 15, 2015 local object1 = createObject(9585, -1514.5, 242, 6.90, 0, 0, 0) local object2 = createObject(9586, -1516.7998046875, 242, 17, 0, 0, 0) attachElements(object2,object1,-2.2998046875,0,10.1) -- attach object2 to object1 function isAclGroup(p,group) if p and getElementType(p) == "player" and type(group) == "string" then local Deadusergroup = getAccountName(getPlayerAccount(p)) if isObjectInACLGroup("user."..Deadusergroup, aclGetGroup(group)) then return true else return false end else return false end end function moveGate(playerSource, cmd) if cmd == "gostart" then if isAclGroup(playerSource,"Maritime") then moveObject(object1, 5000, -1377.90, 193.69, 6.90, 0, 0, 45) -- move object1 and object2 gonna move with him end end end addCommandHandler("gostart", moveGate) Link to comment
DonPro Posted April 15, 2015 Author Share Posted April 15, 2015 local object1 = createObject(9585, -1514.5, 242, 6.90, 0, 0, 0) local object2 = createObject(9586, -1516.7998046875, 242, 17, 0, 0, 0) attachElements(object2,object1,-2.2998046875,0,10.1) -- attach object2 to object1 function isAclGroup(p,group) if p and getElementType(p) == "player" and type(group) == "string" then local Deadusergroup = getAccountName(getPlayerAccount(p)) if isObjectInACLGroup("user."..Deadusergroup, aclGetGroup(group)) then return true else return false end else return false end end function moveGate(playerSource, cmd) if cmd == "gostart" then if isAclGroup(playerSource,"Maritime") then moveObject(object1, 5000, -1377.90, 193.69, 6.90, 0, 0, 45) -- move object1 and object2 gonna move with him end end end addCommandHandler("gostart", moveGate) Oh!!!! thanks man! im realy happy know, i learned something new today to Link to comment
DonPro Posted April 15, 2015 Author Share Posted April 15, 2015 local object1 = createObject(9585, -1514.5, 242, 6.90, 0, 0, 0) local object2 = createObject(9586, -1516.7998046875, 242, 17, 0, 0, 0) attachElements(object2,object1,-2.2998046875,0,10.1) -- attach object2 to object1 function isAclGroup(p,group) if p and getElementType(p) == "player" and type(group) == "string" then local Deadusergroup = getAccountName(getPlayerAccount(p)) if isObjectInACLGroup("user."..Deadusergroup, aclGetGroup(group)) then return true else return false end else return false end end function moveGate(playerSource, cmd) if cmd == "gostart" then if isAclGroup(playerSource,"Maritime") then moveObject(object1, 5000, -1377.90, 193.69, 6.90, 0, 0, 45) -- move object1 and object2 gonna move with him end end end addCommandHandler("gostart", moveGate) one question, how did you find the cordinats for the Element? im trying to keep building more object and it seems to not be correct Link to comment
ALw7sH Posted April 15, 2015 Share Posted April 15, 2015 you had to read what i wrote on the code x = x2 - x1 = (-1516.7998046875 - -1514.5) = -2.2998046875 y = y2 - y1 = (242 - 242) = 0 z = z2 - z1 = (17 - 6.90) = 10.1 Link to comment
DonPro Posted April 15, 2015 Author Share Posted April 15, 2015 you had to read what i wrote on the codex = x2 - x1 = (-1516.7998046875 - -1514.5) = -2.2998046875 y = y2 - y1 = (242 - 242) = 0 z = z2 - z1 = (17 - 6.90) = 10.1 how do i use it? i know i ask much but i just wanna learn pleas. Link to comment
DonPro Posted April 15, 2015 Author Share Posted April 15, 2015 you had to read what i wrote on the codex = x2 - x1 = (-1516.7998046875 - -1514.5) = -2.2998046875 y = y2 - y1 = (242 - 242) = 0 z = z2 - z1 = (17 - 6.90) = 10.1 NVM, NVM i got it! use a calculator! hah, im so stupid Link to comment
DonPro Posted April 15, 2015 Author Share Posted April 15, 2015 you had to read what i wrote on the codex = x2 - x1 = (-1516.7998046875 - -1514.5) = -2.2998046875 y = y2 - y1 = (242 - 242) = 0 z = z2 - z1 = (17 - 6.90) = 10.1 Is it posible to connect this togheter so the ship goes to the first point and then to the second point and then the third point? function moveGate(playerSource, cmd) if cmd == "gostart" then if isAclGroup(playerSource,"Maritime") then moveObject(object1, 70000, -1377.90, 193.69, 6.90, 0, 0, 45) moveObject(object1, 60000, -1150.40, 475.10, 6.90, 0, 0, 60) moveObject(object1, 60000, -1196.19, 648.5, 6.90, 0, 0, 120)-- move object1 and object2 gonna move with him end end end addCommandHandler("gostart", moveGate) Link to comment
ALw7sH Posted April 15, 2015 Share Posted April 15, 2015 yes, you have to use timers function moveGate(playerSource, cmd) if cmd == "gostart" then if isAclGroup(playerSource,"Maritime") then moveObject(object1, 70000, -1377.90, 193.69, 6.90, 0, 0, 45) setTimer( function() moveObject(object1, 60000, -1150.40, 475.10, 6.90, 0, 0, 60) setTimer( function() moveObject(object1, 60000, -1196.19, 648.5, 6.90, 0, 0, 120) end,60000,1) end,70000,1) end end end addCommandHandler("gostart", moveGate) Link to comment
DonPro Posted April 16, 2015 Author Share Posted April 16, 2015 yes, you have to use timers function moveGate(playerSource, cmd) if cmd == "gostart" then if isAclGroup(playerSource,"Maritime") then moveObject(object1, 70000, -1377.90, 193.69, 6.90, 0, 0, 45) setTimer( function() moveObject(object1, 60000, -1150.40, 475.10, 6.90, 0, 0, 60) setTimer( function() moveObject(object1, 60000, -1196.19, 648.5, 6.90, 0, 0, 120) end,60000,1) end,70000,1) end end end addCommandHandler("gostart", moveGate) Thanks Link to comment
DonPro Posted April 16, 2015 Author Share Posted April 16, 2015 yes, you have to use timers function moveGate(playerSource, cmd) if cmd == "gostart" then if isAclGroup(playerSource,"Maritime") then moveObject(object1, 70000, -1377.90, 193.69, 6.90, 0, 0, 45) setTimer( function() moveObject(object1, 60000, -1150.40, 475.10, 6.90, 0, 0, 60) setTimer( function() moveObject(object1, 60000, -1196.19, 648.5, 6.90, 0, 0, 120) end,60000,1) end,70000,1) end end end addCommandHandler("gostart", moveGate) this wont work, it get error (expected to end at line 43) function moveGate(playerSource, cmd) if cmd == "gostart" then if isAclGroup(playerSource,"Maritime") then moveObject(object1, 70000, -2040.59, 1598.5, 7, 0, 0, 90) setTimer( function() moveObject(object1, 60000, -3111.19, 1764.19, 7, 0, 0, 180) setTimer( function() moveObject(object1, 60000, -3204.80, -2873.5, 7, 0, 0, 270) setTimer( function() moveObject(object1, 60000, 2393.69, -3023.69, 7, 0, 0, 0) setTimer( function() moveObject(object1, 60000, 2547.10, -2832.30, 7, 0, 0, 270) setTimer( function() moveObject(object1, 60000, 2544.10, -2682.80, 7, 0, 0, 270) end,60000,1) end,70000,1) end end end addCommandHandler("gostart", moveGate) Link to comment
ALw7sH Posted April 16, 2015 Share Posted April 16, 2015 You didn't get it so i have made an easier code for you local moveTable = { --{time, x, y, z, rotX, rotY, rotZ} {70000, -1377.90, 193.69, 6.90, 0, 0, 45} {60000, -1150.40, 475.10, 6.90, 0, 0, 60} {60000, -1196.19, 648.5, 6.90, 0, 0, 120} } function move() for k,v in ipairs(moveTable) do if k == 1 then moveObject(object1, unpack(v)) else local time = 0 if k ~= 2 then for i=k-1,1 do time = time + moveTable[i][1] end else time = moveTable[1][1] end setTimer(moveObject,time,1, unpack(v)) end end end function moveGate(playerSource, cmd) if cmd == "gostart" then if isAclGroup(playerSource,"Maritime") then move() end end end addCommandHandler("gostart", moveGate) Link to comment
DonPro Posted April 16, 2015 Author Share Posted April 16, 2015 You didn't get it so i have made an easier code for you local moveTable = { --{time, x, y, z, rotX, rotY, rotZ} {70000, -1377.90, 193.69, 6.90, 0, 0, 45} {60000, -1150.40, 475.10, 6.90, 0, 0, 60} {60000, -1196.19, 648.5, 6.90, 0, 0, 120} } function move() for k,v in ipairs(moveTable) do if k == 1 then moveObject(object1, unpack(v)) else local time = 0 if k ~= 2 then for i=k-1,1 do time = time + moveTable[i][1] end else time = moveTable[1][1] end setTimer(moveObject,time,1, unpack(v)) end end end function moveGate(playerSource, cmd) if cmd == "gostart" then if isAclGroup(playerSource,"Maritime") then move() end end end addCommandHandler("gostart", moveGate) now it says its expected '34' " } expexted to close at 31 i dont know man. im realy happy, that you take you're time to help me out local object1 = createObject(9585, -2040.5999755859, 1442, 7, 0, 0, 0) local object2 = createObject(9586, -1516.7998046875, 242, 17, 0, 0, 0) local object3 = createObject(9584, -1471.900390625, 242, 24.89999961853, 0, 0, 0) local object4 = createObject(9698, -1460.4072265625, 240.8203125, 27.780000686646, 0, 0, 0) attachElements(object2,object1,-2.2998046875,0,10.1) -- attach object2 to object1 attachElements(object3,object1,20.400390625,0,17) -- attach object2 to object1 attachElements(object4,object1,31.9,-1.17,19.9) -- attach object2 to object1 --[[ Use Calculator x = x2 - x1 = (-1516.7998046875 - -1514.5) = -2.2998046875 y = y2 - y1 = (242 - 242) = 0 z = z2 - z1 = (17 - 6.90) = 10.1 ]]-- function isAclGroup(p,group) if p and getElementType(p) == "player" and type(group) == "string" then local Deadusergroup = getAccountName(getPlayerAccount(p)) if isObjectInACLGroup("user."..Deadusergroup, aclGetGroup(group)) then return true else return false end else return false end end local moveTable = { --{time, x, y, z, rotX, rotY, rotZ} {70000, -1377.90, 193.69, 6.90, 0, 0, 45} {60000, -1150.40, 475.10, 6.90, 0, 0, 60} {60000, -1196.19, 648.5, 6.90, 0, 0, 120} } function move() for k,v in ipairs(moveTable) do if k == 1 then moveObject(object1, unpack(v)) else local time = 0 if k ~= 2 then for i=k-1,1 do time = time + moveTable[i][1] end else time = moveTable[1][1] end setTimer(moveObject,time,1, unpack(v)) end end end function moveGate(playerSource, cmd) if cmd == "gostart" then if isAclGroup(playerSource,"Maritime") then move() end end end addCommandHandler("gostart", moveGate) Link to comment
ALw7sH Posted April 16, 2015 Share Posted April 16, 2015 lol i forgot to put , on the table, sorry about that local moveTable = { --{time, x, y, z, rotX, rotY, rotZ}, {70000, -1377.90, 193.69, 6.90, 0, 0, 45}, {60000, -1150.40, 475.10, 6.90, 0, 0, 60}, {60000, -1196.19, 648.5, 6.90, 0, 0, 120}, } function move() for k,v in ipairs(moveTable) do if k == 1 then moveObject(object1, unpack(v)) else local time = 0 if k ~= 2 then for i=k-1,1 do time = time + moveTable[i][1] end else time = moveTable[1][1] end setTimer(moveObject,time,1, unpack(v)) end end end function moveGate(playerSource, cmd) if cmd == "gostart" then if isAclGroup(playerSource,"Maritime") then move() end end end addCommandHandler("gostart", moveGate) Link to comment
DonPro Posted April 16, 2015 Author Share Posted April 16, 2015 lol i forgot to put , on the table, sorry about that local moveTable = { --{time, x, y, z, rotX, rotY, rotZ}, {70000, -1377.90, 193.69, 6.90, 0, 0, 45}, {60000, -1150.40, 475.10, 6.90, 0, 0, 60}, {60000, -1196.19, 648.5, 6.90, 0, 0, 120}, } function move() for k,v in ipairs(moveTable) do if k == 1 then moveObject(object1, unpack(v)) else local time = 0 if k ~= 2 then for i=k-1,1 do time = time + moveTable[i][1] end else time = moveTable[1][1] end setTimer(moveObject,time,1, unpack(v)) end end end function moveGate(playerSource, cmd) if cmd == "gostart" then if isAclGroup(playerSource,"Maritime") then move() end end end addCommandHandler("gostart", moveGate) no worries i cant thank you enough for the help. Link to comment
DonPro Posted April 16, 2015 Author Share Posted April 16, 2015 You are welcome How come the ship wont keep sailing after hitting the first point? Warning: Lua:51: bad usage 'setTimer' [interval is below 50] local moveTable = { --{time, x, y, z, rotX, rotY, rotZ}, {60000, -2040.59, 1598.5, 7, 0, 0, 0}, {60000, -3111.19, 1764.19, 7, 0, 0, 180}, {60000, -3204.80, -2873.5, 7, 0, 0, 270}, } function move() for k,v in ipairs(moveTable) do if k == 1 then moveObject(object1, unpack(v)) else local time = 0 if k ~= 2 then for i=k-1,1 do time = time + moveTable[i][1] end else time = moveTable[1][1] end setTimer(moveObject,time,1, unpack(v)) end end end function moveGate(playerSource, cmd) if cmd == "gostart" then if isAclGroup(playerSource,"Maritime") then move() end end end addCommandHandler("gostart", moveGate) Link to comment
ALw7sH Posted April 16, 2015 Share Posted April 16, 2015 local object1 = createObject(9585, -2040.5999755859, 1442, 7, 0, 0, 0) local obj1X, obj1Y, obj1Z = getElementPosition(object1) local object2 = createObject(9586, obj1X-2.2998046875, obj1Y, obj1Z+10.1, 0, 0, 0) local object3 = createObject(9584, obj1X+20.400390625, obj1Y, obj1Z+17, 0, 0, 0) local object4 = createObject(9698, obj1X+31.9, obj1Y-1.17, obj1Z+19.9, 0, 0, 0) attachElements(object2,object1,-2.2998046875,0,10.1) -- attach object2 to object1 attachElements(object3,object1,20.400390625,0,17) -- attach object2 to object1 attachElements(object4,object1,31.9,-1.17,19.9) -- attach object2 to object1 local moveTable = { --{time, x, y, z, rotX, rotY, rotZ}, {60000, -2040.59, 1598.5, 7, 0, 0, 0}, {60000, -3111.19, 1764.19, 7, 0, 0, 180}, {60000, -3204.80, -2873.5, 7, 0, 0, 270}, } function move() for k,v in ipairs(moveTable) do if k == 1 then moveObject(object1, unpack(v)) else local time = 0 if k ~= 2 then for i=1,k-1 do time = time + moveTable[i][1] end else time = moveTable[1][1] end setTimer(moveObject,time,1,object1, unpack(v)) end end end function moveGate(playerSource, cmd) if cmd == "gostart" then if isAclGroup(playerSource,"Maritime") then move() end end end addCommandHandler("gostart", moveGate) Link to comment
DonPro Posted April 16, 2015 Author Share Posted April 16, 2015 local object1 = createObject(9585, -2040.5999755859, 1442, 7, 0, 0, 0) local obj1X, obj1Y, obj1Z = getElementPosition(object1) local object2 = createObject(9586, obj1X-2.2998046875, obj1Y, obj1Z+10.1, 0, 0, 0) local object3 = createObject(9584, obj1X+20.400390625, obj1Y, obj1Z+17, 0, 0, 0) local object4 = createObject(9698, obj1X+31.9, obj1Y-1.17, obj1Z+19.9, 0, 0, 0) attachElements(object2,object1,-2.2998046875,0,10.1) -- attach object2 to object1 attachElements(object3,object1,20.400390625,0,17) -- attach object2 to object1 attachElements(object4,object1,31.9,-1.17,19.9) -- attach object2 to object1 local moveTable = { --{time, x, y, z, rotX, rotY, rotZ}, {60000, -2040.59, 1598.5, 7, 0, 0, 0}, {60000, -3111.19, 1764.19, 7, 0, 0, 180}, {60000, -3204.80, -2873.5, 7, 0, 0, 270}, } function move() for k,v in ipairs(moveTable) do if k == 1 then moveObject(object1, unpack(v)) else local time = 0 if k ~= 2 then for i=1,k-1 do time = time + moveTable[i][1] end else time = moveTable[1][1] end setTimer(moveObject,time,1,object1, unpack(v)) end end end function moveGate(playerSource, cmd) if cmd == "gostart" then if isAclGroup(playerSource,"Maritime") then move() end end end addCommandHandler("gostart", moveGate) Thanks 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