rafull6 Posted July 3, 2010 Share Posted July 3, 2010 Hello guys. I'm newbe in scripting, so i need your help a bit... The problem consists in that i cant force my gate moving, when someone coming up to them. The idea in that this gate should move away when someone coming to them nearer (i don't know how this "number" named... it set in script to 3. Looks like a51col = createColCircle ( 213.94564819336, 1875.40234375, 13.938992500305, 3 ) ) doors must open up, and when someone going away it's closing. I tried to made script by myself, because i didn't this resource. I tried to make it script. Here is original script: a51gate1 = createObject ( 2929, 215.99548339844, 1875.40234375, 13.938992500305, 0, 0, 0 ) a51gate2 = createObject ( 2929, 211.94564819336, 1875.40234375, 13.938992500305, 0, 0, 0 ) a51col = createColCircle ( 213.94564819336, 1875.40234375, 13.938992500305, 7 ) function opena51gates(thePlayer) if getElementModel( thePlayer ) == 287 then moveObject (a51gate1, 5000, 218.99548339844, 1875.40234375, 13.938992500305 ) moveObject (a51gate2, 5000, 208.94564819336, 1875.40234375, 13.938992500305 ) end end addEventHandler( "onColShapeHit", a51col, opena51gates ) function closea51gates(thePlayer) if getElementModel( thePlayer ) == 287 then moveObject (a51gate1, 5000, 215.99548339844, 1875.40234375, 13.938992500305 ) moveObject (a51gate2, 5000, 211.94564819336, 1875.40234375, 13.938992500305 ) end end addEventHandler( "onColShapeLeave", a51col, closea51gates ) i've deleted this lines: a51gate2 = createObject ( 2929, 211.94564819336, 1875.40234375, 13.938992500305, 0, 0, 0 ) moveObject (a51gate2, 5000, 208.94564819336, 1875.40234375, 13.938992500305 ) moveObject (a51gate2, 5000, 211.94564819336, 1875.40234375, 13.938992500305 ) then i renamed a51gate2 to a1gate everywhere, and tested. It has worked! BUT!!!!!!!!! when i changed lines of cordinates to what i wanted - work stoped. Here is my script: a1gate = createObject ( 2929, 215.99548339844, 1875.40234375, 13.938992500305, 0, 0, 0 ) a51col = createColCircle ( 213.94564819336, 1875.40234375, 13.938992500305, 3 ) function opena1gate(thePlayer) moveObject (a1gate, 5000, 218.99548339844, 1875.40234375, 13.938992500305 ) end addEventHandler( "onColShapeHit", a51col, opena1gate ) function closea1gate(thePlayer) moveObject (a1gate, 5000, 215.99548339844, 1875.40234375, 13.938992500305 ) end addEventHandler( "onColShapeLeave", a51col, closea1gate ) Where have i made a mistake? What is wrong? Correct me, please... P.S. createColCircle cordinated i changed too. Link to comment
NotAvailable Posted July 3, 2010 Share Posted July 3, 2010 Colshape = A zone somewhere in front of the gate. So when you hit the ColShape the gate will be triggered ( opened ) Link to comment
rafull6 Posted July 3, 2010 Author Share Posted July 3, 2010 i know that =) but problem still exist. i can't make them automaticly open\close Link to comment
rafull6 Posted July 3, 2010 Author Share Posted July 3, 2010 Guys, post someone script with automaticly gate opening/closing, or tell me what's wrong with my script, please! Link to comment
TheRealCow Posted July 3, 2010 Share Posted July 3, 2010 function createob () ob = createObject ( 2933, -221.83, 2629.10, 63.55, 0.0000, 0.0000, 0.0000) marker = createMarker ( 0, 0, 0, "cylinder", 5, 0, 0, 255, 0 ) end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource ()), createob ) function obCheck ( thePlayer, matchingDimension ) if hasObjectPermissionTo (thePlayer, "command.kick", false ) then moveObject ( ob, 3000, -221.83, 2629.10, 66.55) outputChatBox ( "Command Recived , opening Admin Base!", thePlayer, 0, 255, 0) end end addCommandHandler ( "open", obCheck ) addEventHandler ( "onMarkerHit", marker, obCheck ) function onPlrLeaveob ( thePlayer, matchingDimension ) if hasObjectPermissionTo (thePlayer, "command.kick", false ) then setTimer ( movingBackob, 1000, 1, thePlayer ) outputChatBox ( "Command Recived! Closing Admin Base!", thePlayer, 0, 255, 0 ) end end addCommandHandler ( "close", onPlrLeaveob) addEventHandler ( "onMarkerLeave", marker, onPlrLeaveob ) function movingBackob () moveObject ( ob, 3000, -221.83, 2629.10, 63.55 ) end Link to comment
50p Posted July 3, 2010 Share Posted July 3, 2010 You can try this resource: https://community.multitheftauto.com/index.html?p ... ils&id=614 Link to comment
rafull6 Posted July 3, 2010 Author Share Posted July 3, 2010 nice resource =), but i want to understand what im doing wrong!?! i've tested a lot mine script and understood that problem in Colshape. Mb i doing something wrong when im getting cordinates for colshape zone? How i'm getting cordinates: Im standing in front of my gates. Then copypasting cordinates to lua script. After reloading gates sdanding where they must be, but hwen im going to colshape zone nothing happen =( WHY!? Link to comment
rafull6 Posted July 3, 2010 Author Share Posted July 3, 2010 I "killed" this problem using ColCuboid. Probably, "gates" did not work, becouse landscape wasn't equal =) Link to comment
rafull6 Posted July 3, 2010 Author Share Posted July 3, 2010 Problem! I'm going to create server with script "Zday", and when zombies came up to gates, they're opening for them too. How make that gates will open for players only!? Link to comment
dzek (varez) Posted July 3, 2010 Share Posted July 3, 2010 if (getElementType(element)=="player") Link to comment
Mr.Hankey Posted July 3, 2010 Share Posted July 3, 2010 RAFuLL note that there is an Edit function. There is no need to make 3 posts in a row... Link to comment
rafull6 Posted July 4, 2010 Author Share Posted July 4, 2010 Sorry... I'll remember it. ---------------------------------------------------------- Guys, i tried to do like varez told me to do. I've added line: if (getElementType(element)=="player") and now my script looks like that: agate1 = createObject ( 988, -1972.7886962891, 293.92767333984, 35.171875, 0, 0, 90 ) acol = createColCuboid ( -1975.0732373047, 290.97298681641, 35.171875, 5, 7, 3) function opena51gates(thePlayer) if ( getElementType ( element ) == "player" ) then moveObject (agate1, 3000, -1972.7886962891, 303.92767333984, 35.171875 ) end end addEventHandler( "onColShapeHit", acol, opena51gates ) function closea51gates(thePlayer) if ( getElementType ( elemen t) == "player" ) then moveObject (agate1, 3000, -1972.7886962891, 293.92767333984, 35.171875 ) end end addEventHandler( "onColShapeLeave", acol, closea51gates ) But it won't work! Why? What have i did wrong? Link to comment
TheRealCow Posted July 5, 2010 Share Posted July 5, 2010 agate1 = createObject ( 988, -1972.7886962891, 293.92767333984, 35.171875, 0, 0, 90 ) acol = createColCuboid ( -1975.0732373047, 290.97298681641, 35.171875, 5, 7, 3) function opena51gates(thePlayer) if ( getElementType ( thePlayer ) == "player" ) then moveObject (agate1, 3000, -1972.7886962891, 303.92767333984, 35.171875 ) end end addEventHandler( "onColShapeHit", acol, opena51gates ) function closea51gates(thePlayer) if ( getElementType ( thePlayer ) == "player" ) then moveObject (agate1, 3000, -1972.7886962891, 293.92767333984, 35.171875 ) end end addEventHandler( "onColShapeLeave", acol, closea51gates ) and first, look that : if ( getElementType ( elemen t) == "player" ) then Link to comment
rafull6 Posted July 7, 2010 Author Share Posted July 7, 2010 Problem is finished if ( getElementType (element) == "player" ) then " element" must be changed. In my way to thePlayer. Link to comment
TheRealCow Posted July 7, 2010 Share Posted July 7, 2010 agate1 = createObject ( 988, -1972.7886962891, 293.92767333984, 35.171875, 0, 0, 90 ) acol = createColCuboid ( -1975.0732373047, 290.97298681641, 35.171875, 5, 7, 3) function opena51gates(thePlayer) if ( getElementType ( thePlayer ) == "player" ) then moveObject (agate1, 3000, -1972.7886962891, 303.92767333984, 35.171875 ) end end addEventHandler( "onColShapeHit", acol, opena51gates ) function closea51gates(thePlayer) if ( getElementType ( thePlayer ) == "player" ) then moveObject (agate1, 3000, -1972.7886962891, 293.92767333984, 35.171875 ) end end addEventHandler( "onColShapeLeave", acol, closea51gates ) and first, look that : if ( getElementType ( elemen t) == "player" ) then like i sayd... 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