joedajoester Posted November 6, 2011 Share Posted November 6, 2011 Hi, i am editing my admin base, and need that when a player enters a collision zone it binds a key to lower/lift an object. I need the buttons ; and ' to be binded to lower and lift. It starts out lifted. Link to comment
Castillo Posted November 6, 2011 Share Posted November 6, 2011 If you don't post the script, we cannot help you... Link to comment
joedajoester Posted November 6, 2011 Author Share Posted November 6, 2011 I dont have the gates made yet but i can make it but it needs editing to remove collision zone https://community.multitheftauto.com/index.php?p= ... ls&id=3177 thats mine, i edited it where the rc vehicles are and below that is where the lift is. If i must make it, i will but im busy right now, if i must make the script for just the lift tell me and i will. Link to comment
Castillo Posted November 6, 2011 Share Posted November 6, 2011 We are here to HELP not to script things for you because you're either lazy or busy. Link to comment
joedajoester Posted November 6, 2011 Author Share Posted November 6, 2011 Okay, give me 15 min and sorry, i didnt really mean that im lazy, its that i dont really know how to script that well, and i never used binding functions or worked with them. Link to comment
joedajoester Posted November 6, 2011 Author Share Posted November 6, 2011 Here it is col = createColTube (-1851, -3112.1000976563, 51.700000762939, 10, 3) -- enter your cooderates here for your colshape please note 10 and 3 is to do with the size of the shape. root = getRootElement () lift = createObject ( 3095, -1851, -3112.1000976563, 51.700000762939, 0, 0, 228.49365234375) -- enter the ID of the object followed by the coordinates -- note the rotx y and z may not be required so you just remove these. x y and z is where you would put your cordinates. function Open ( pla ) if getElementType ( pla ) == "player" then if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(pla)), aclGetGroup ( "Admin" ) ) then moveObject (lift, 2500, -1851, -3112.1000976563, 38.900001525879) -- here is where you enter the coordinatess of the new location of the object, 2200 = the speed of the movent. end end end addEventHandler ( "onColShapeHit", col, Open) function Close ( pla ) if getElementType ( pla ) == "player" then if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(pla)), aclGetGroup ( "Admin" ) ) then moveObject (lift, 2500, -1851, -3112.1000976563, 51.700000762939) -- here is where you copy the coordinates of the orginal location of the object, 2951 = the timer of movent. end end end addEventHandler ( "onColShapeLeave", col, Close ) It works but as you know it has the collision zone which needs to be replaced to bind keys when in the collision zone Link to comment
^Dev-PoinT^ Posted November 6, 2011 Share Posted November 6, 2011 You Mean Like This ? function Open ( pla ) if getElementType ( pla ) == "player" then if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(pla)), aclGetGroup ( "Admin" ) ) then moveObject (lift, 2500, -1851, -3112.1000976563, 38.900001525879) -- here is where you enter the coordinatess of the new location of the object, 2200 = the speed of the movent. end end end addEventHandler ( "onColShapeHit", col, Open) function Close ( pla ) if getElementType ( pla ) == "player" then if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(pla)), aclGetGroup ( "Admin" ) ) then moveObject (lift, 2500, -1851, -3112.1000976563, 51.700000762939) -- here is where you copy bindKey ( player, "F3", "down", Open ) Link to comment
joedajoester Posted November 6, 2011 Author Share Posted November 6, 2011 I get an error.. = expected near the Link to comment
Charlie_Jefferson Posted November 6, 2011 Share Posted November 6, 2011 function Open ( pla ) if getElementType ( pla ) == "player" then if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(pla)), aclGetGroup ( "Admin" ) ) then moveObject (lift, 2500, -1851, -3112.1000976563, 38.900001525879) end end end addEventHandler ( "onColShapeHit", col, Open) function Close ( pla ) if getElementType ( pla ) == "player" then if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(pla)), aclGetGroup ( "Admin" ) ) then moveObject (lift, 2500, -1851, -3112.1000976563, 51.700000762939) bindKey ( player, "F3", "down", Open ) Obviously when copying a script from the wiki, remove the random text and comments... Link to comment
myonlake Posted November 6, 2011 Share Posted November 6, 2011 Well it was a chaos. I decided to clean it up a bit. Make sure you got that "col" colshape there and that you're an admin, otherwise it's not going to work. I'd like to see the whole script but as you gave us this little, I can't help you much in case if an unknown error happens. function open(hitPlayer, matchingDimension) local acc = getAccountName(getPlayerAccount(hitPlayer)) if hitPlayer then if isObjectInACLGroup("user." .. acc, aclGetGroup("Admin")) then moveObject(lift, 2500, -1851, -3112.1000976563, 38.900001525879) end end end addEventHandler("onColShapeHit", col, open) function close(player) local acc = getAccountName(getPlayerAccount(hitPlayer)) if getElementType(player) == "player" then if isObjectInACLGroup("user." .. acc, aclGetGroup("Admin")) then moveObject (lift, 2500, -1851, -3112.1000976563, 51.700000762939) end end end addEventHandler("onColShapeLeave", col, close) function binding() bindKey(source, ",", "down", open) bindKey(source, "/", "down", close) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), binding) Link to comment
TAPL Posted November 6, 2011 Share Posted November 6, 2011 who is source? function binding() for i,player in ipairs(getElementsByType("player")) do if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then bindKey(player, ",", "down", open) bindKey(player, "/", "down", close) end end end addEventHandler("onResourceStart", resourceRoot, binding) Link to comment
joedajoester Posted November 6, 2011 Author Share Posted November 6, 2011 None of these work. I tried all of them, the one scozialz made i get an error.. Bad 'player' pointer at 'bindKey'(1) Please help me the lift doesnt even spawn because of that error *EDIT! I replaced the bindkey part with tapl 's and it didnt work but i got no error so i realized theres no part of the script that created the object so i added that back in and it works, but it does not go back up. So it lowers and does not lift. Were makin progress Link to comment
Jaysds1 Posted November 6, 2011 Share Posted November 6, 2011 try this: function open(hitPlayer, matchingDimension) local acc = getAccountName(getPlayerAccount(hitPlayer)) if hitPlayer then if isObjectInACLGroup("user." .. acc, aclGetGroup("Admin")) then moveObject(lift, 2500, -1851, -3112.1000976563, 38.900001525879) end end end addEventHandler("onColShapeHit", col, open) function close(player) local acc = getAccountName(getPlayerAccount(hitPlayer)) if getElementType(player) == "player" then if isObjectInACLGroup("user." .. acc, aclGetGroup("Admin")) then moveObject (lift, 2500, -1851, -3112.1000976563, 51.700000762939) end end end addEventHandler("onColShapeLeave", col, close) addEventHandler("onPlayerJoin",getRootElement(), function() bindKey(source, ",", "down", open) bindKey(source, "/", "down", close) end) Link to comment
joedajoester Posted November 6, 2011 Author Share Posted November 6, 2011 For tapls one i edited it only lowers, and does not lift. When i press the button for lift i get this error Bad argument @ getPlayerAccount expected element at argument 1 got nill Bad argument @ getAccountName expected account at argument 1 got boolean attempt to concatenate local 'acc' (a boolean value) Link to comment
Jaysds1 Posted November 6, 2011 Share Posted November 6, 2011 Does your server have a login system? Try This: function open(hitPlayer, matchingDimension) local acc = getAccountName(getPlayerAccount(hitPlayer)) if hitPlayer then if isObjectInACLGroup("user." .. acc, aclGetGroup("Admin")) then moveObject(lift, 2500, -1851, -3112.1000976563, 38.900001525879) end end end addEventHandler("onColShapeHit", col, open) function close(player) local acc = getAccountName(getPlayerAccount(hitPlayer)) if getElementType(player) == "player" then if isObjectInACLGroup("user." .. acc, aclGetGroup("Admin")) then moveObject (lift, 2500, -1851, -3112.1000976563, 51.700000762939) end end end addEventHandler("onColShapeLeave", col, close) addEventHandler("onPlayerLogin",getRootElement(), function() bindKey(source, ",", "down", open) bindKey(source, "/", "down", close) end) Link to comment
joedajoester Posted November 6, 2011 Author Share Posted November 6, 2011 Anyone?? It only lowers, and get this error when i press the button to lift. Bad argument @ getPlayerAccount expected element at argument 1 got nill Bad argument @ getAccountName expected account at argument 1 got boolean attempt to concatenate local 'acc' (a boolean value) Heres the script im using now. lift = createObject (3095, -1851, -3112.1000976563, 51.700000762939, 0, 0, 228.49365234375) function open(hitPlayer, matchingDimension) local acc = getAccountName(getPlayerAccount(hitPlayer)) if hitPlayer then if isObjectInACLGroup("user." .. acc, aclGetGroup("Admin")) then moveObject(lift, 2500, -1851, -3112.1000976563, 38.900001525879) end end end addEventHandler("onColShapeHit", col, open) function close(player) local acc = getAccountName(getPlayerAccount(hitPlayer)) if getElementType(player) == "player" then if isObjectInACLGroup("user." .. acc, aclGetGroup("Admin")) then moveObject (lift, 2500, -1851, -3112.1000976563, 51.700000762939) end end end addEventHandler("onColShapeLeave", col, close) function binding() for i,player in ipairs(getElementsByType("player")) do if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then bindKey(player, ",", "down", open) bindKey(player, "/", "down", close) end end end addEventHandler("onResourceStart", resourceRoot, binding) Link to comment
TAPL Posted November 6, 2011 Share Posted November 6, 2011 lift = createObject (3095, -1851, -3112.1000976563, 51.700000762939, 0, 0, 228.49365234375) function open(hitPlayer, matchingDimension) if getElementType(hitPlayer) == "player" then local acc = getAccountName(getPlayerAccount(hitPlayer)) if isObjectInACLGroup("user." .. acc, aclGetGroup("Admin")) then moveObject(lift, 2500, -1851, -3112.1000976563, 38.900001525879) end end end addEventHandler("onColShapeHit", col, open) function close(leaveElement, matchingDimension) if getElementType(leaveElement) == "player" then local acc = getAccountName(getPlayerAccount(leaveElement)) if isObjectInACLGroup("user." .. acc, aclGetGroup("Admin")) then moveObject (lift, 2500, -1851, -3112.1000976563, 51.700000762939) end end end addEventHandler("onColShapeLeave", col, close) function binding() for i,player in ipairs(getElementsByType("player")) do if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then bindKey(player, ",", "down", open) bindKey(player, "/", "down", close) end end end addEventHandler("onResourceStart", resourceRoot, binding) Link to comment
joedajoester Posted November 6, 2011 Author Share Posted November 6, 2011 nvm yayayayayayay thank you tapl and everone else it works I will give u credit and try to learn this for future times. I wanna give u a cookie It doesnt bind the key when i enter hte collisin zone, it allways does i dont need that. It was a misunderstanding please help with that. and i need to unbind keys when leaving? unbindKey ( player, ",", "down", open ) unbindKey ( player, "/", "down", close ) I dont know where to place it Link to comment
TAPL Posted November 7, 2011 Share Posted November 7, 2011 do you want the gate open when an admin hit the col? or just bind a key to open/close the gate when the admin hit the col? maybe this what you want? lift = createObject (3095, -1851, -3112.1000976563, 51.700000762939, 0, 0, 228.49365234375) function open(player) local acc = getAccountName(getPlayerAccount(player)) if acc then if isObjectInACLGroup("user." .. acc, aclGetGroup("Admin")) then moveObject(lift, 2500, -1851, -3112.1000976563, 38.900001525879) end end end function close(player) local acc = getAccountName(getPlayerAccount(player)) if acc then if isObjectInACLGroup("user." .. acc, aclGetGroup("Admin")) then moveObject (lift, 2500, -1851, -3112.1000976563, 51.700000762939) end end end function bind(hitPlayer, matchingDimension) bindKey(hitPlayer, ",", "down", open) bindKey(hitPlayer, "/", "down", close) end addEventHandler("onColShapeHit", col, bind) function unbind(leaveElement, matchingDimension) unbindKey(leaveElement, ",", "down", open) unbindKey(leaveElement, "/", "down", close) end addEventHandler("onColShapeLeave", col, unbind) Link to comment
joedajoester Posted November 7, 2011 Author Share Posted November 7, 2011 Bad 'player' pointer @ 'bindkey'(1) Bad 'player' pointer @ 'unbindkey'(1) Link to comment
TAPL Posted November 7, 2011 Share Posted November 7, 2011 lift = createObject (3095, -1851, -3112.1000976563, 51.700000762939, 0, 0, 228.49365234375) function open(player) local acc = getAccountName(getPlayerAccount(player)) if acc then if isObjectInACLGroup("user." .. acc, aclGetGroup("Admin")) then moveObject(lift, 2500, -1851, -3112.1000976563, 38.900001525879) end end end function close(player) local acc = getAccountName(getPlayerAccount(player)) if acc then if isObjectInACLGroup("user." .. acc, aclGetGroup("Admin")) then moveObject (lift, 2500, -1851, -3112.1000976563, 51.700000762939) end end end function bind(hitPlayer, matchingDimension) if getElementType(hitPlayer) == "player" then bindKey(hitPlayer, ",", "down", open) bindKey(hitPlayer, "/", "down", close) end end addEventHandler("onColShapeHit", col, bind) function unbind(leaveElement, matchingDimension) if getElementType(leaveElement) == "player" then unbindKey(leaveElement, ",", "down", open) unbindKey(leaveElement, "/", "down", close) end end addEventHandler("onColShapeLeave", col, unbind) Link to comment
Jaysds1 Posted November 7, 2011 Share Posted November 7, 2011 You forgot to add the brackets: function bind(hitPlayer, matchingDimension) if (getElementType(hitPlayer) == "player") then bindKey(hitPlayer, ",", "down", open) bindKey(hitPlayer, "/", "down", close) end end addEventHandler("onColShapeHit", col, bind) function unbind(leaveElement, matchingDimension) if (getElementType(leaveElement) == "player") then unbindKey(leaveElement, ",", "down", open) unbindKey(leaveElement, "/", "down", close) end end addEventHandler("onColShapeLeave", col, unbind) Link to comment
TAPL Posted November 7, 2011 Share Posted November 7, 2011 i don't forgot anything, the brackets is not needed the code can work with brackets and can work without brackets. Link to comment
joedajoester Posted November 7, 2011 Author Share Posted November 7, 2011 Theres no col thats why right? 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