Alan.Alexander Posted September 27, 2012 Share Posted September 27, 2012 Here's a wee gate script I've made, just thought I would post it here (instead of the community since this isn't really a resource) in case it helps anyone. local gatePos = {}; local gate = {}; --gatePos[0] = {ox,oy,oz,orotx,oroty,orotz,cx,cy,cz,crotx,croty,crotz,model,dur} gatePos[1] = {2002.8,-1451,15.3,0,0,180,nil,nil,'-5.4',nil,nil,nil,980,1000}; gatePos[2] = {1997,-1445.2,15.3,0,0,90,nil,nil,'-5.4',nil,nil,nil,980,1000}; gatePos[3] = {-2740.5,569.7,15.15,0,0,90,'-3.95','3.95',nil,nil,nil,-90,985,1000}; gatePos[4] = {-2740.5,561.8,15.15,0,0,90,'-3.95','-3.95',nil,nil,nil,90,986,1000}; local colShapes = {} --colShapes[0] = {x,y,z,sizeX,sizeY,sizeZ,{gate,ids}}; colShapes[1] = {1991,-1458,12,18,19,6,{1,2}}; colShapes[2] = {-2747,557.5,13,15,16,8,{3,4}}; addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function() for i,v in ipairs(gatePos) do gate[i] = createObject(v[13],v[1],v[2],v[3],v[4],v[5],v[6]); setElementData(gate[i],'posData',v); setElementInterior(gate[i],0); setElementDimension(gate[i],0); end gatePos = nil; for i,v in ipairs(colShapes) do local colShape = createColCuboid(v[1],v[2],v[3],v[4],v[5],v[6]); addEventHandler("onColShapeHit",colShape,function(p,d); if getElementType(p) == 'player' and d then openTheFuckingGates(v[7],source); end end); addEventHandler("onColShapeLeave",colShape,function(p,d) if getElementType(p) == 'player' and d then closeTheFuckingGates(v[7],source); end end); end end); function openTheFuckingGates(whatGates,col) for k,v in ipairs(whatGates) do local posData = getElementData(gate[v],'posData'); local x = {}; for data=1,3 do local y =data+6; x[data] = posData[data]; if type(posData[y]) == 'number' then x[data] = posData[y] elseif type(posData[y]) == 'string' then x[data] = x[data] + tonumber(posData[y]) end end for data=4,6 do x[data] = posData[data+6] or 0; end moveObject(gate[v],posData[14],x[1],x[2],x[3],x[4],x[5],x[6]); end end function closeTheFuckingGates(whatGates,col) local eles = getElementsWithinColShape(col,'player'); if #eles then return false; end for k,v in ipairs(whatGates) do local posData = getElementData(gate[v],'posData'); local x = {}; for data=1,3 do local y =data+6; x[data] = posData[data]; end for data=4,6 do if posData[data+6] then x[data] = posData[data+6]-posData[data+6]-posData[data+6]; else x[data] = 0; end end moveObject(gate[v],posData[14],x[1],x[2],x[3],x[4],x[5],x[6]); end end It should be pretty straightforward to understand, you create a colShape by defining a new row in colShapes[], and you can make it more one or more gates. For the gates themselves, you set the open values, and the closed values. For the closed values you can let them as a number for it to just move to that co-ord, or have them as a string like they are there for the example X and Ys in the script, and it will move the gates that much, instead of needing to calculate shit. I'm not sure how well the rotations work on that whole string based thing. And I'm not saying that it's perfect or bugless, it's just here in case anyone can find it useful. Link to comment
Alan.Alexander Posted September 27, 2012 Author Share Posted September 27, 2012 Heh, I just noticed that the filter changed my function names... Awesome... 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