Eelke Posted October 24, 2010 Share Posted October 24, 2010 Hi, how can i put a code on a garage so i can open it? Greetz Eelke Link to comment
dzek (varez) Posted October 24, 2010 Share Posted October 24, 2010 Is wiki or search feature not working? Hint: Click both links. Both are useful. Link to comment
Eelke Posted October 24, 2010 Author Share Posted October 24, 2010 But, what has the file where i can find that code, or how do i need to name the file? Link to comment
dzek (varez) Posted October 24, 2010 Share Posted October 24, 2010 https://wiki.multitheftauto.com/wiki/Resources Link to comment
Eelke Posted October 24, 2010 Author Share Posted October 24, 2010 I totally can not script.. So i don't understand how to do it.. Link to comment
dzek (varez) Posted October 24, 2010 Share Posted October 24, 2010 We won't script for you because you are lazy. https://wiki.multitheftauto.com/wiki/Scr ... troduction Learn. It's not hard. Link to comment
Eelke Posted October 25, 2010 Author Share Posted October 25, 2010 This is my meta file: <meta> <info author="Eelke" type="script" name="My Server" description="Garages" /> <script src="script.lua" /> </meta> And this is my script.lua file GARAGE_ID = 18 -- create a collision shape and attach event handlers to it when the resource starts addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function (resource) local garageCube = createColCube(1337, 194, 28, 6, 10, 4) addEventHandler("onColShapeHit", garageCube, onGarageCubeHit) addEventHandler("onColShapeLeave", garageCube, onGarageCubeLeave) end) -- open the door when someone enters the garage's collision shape function onGarageCubeHit(hitElement, matchingDimension) if (getElementType(hitElement) == "player") then -- check to make sure the door is closed if (not isGarageOpen(GARAGE_ID)) then -- open the door setGarageOpen(GARAGE_ID, true) end end end -- close the door when someone leaves the garage's collision shape function onGarageCubeLeave(leaveElement, matchingDimension) if (getElementType(leaveElement) == "player") then -- check to make sure the door is open if (isGarageOpen(GARAGE_ID)) then -- close the door setGarageOpen(GARAGE_ID, false) end end end But it doesn't open.. Link to comment
dzek (varez) Posted October 25, 2010 Share Posted October 25, 2010 new link for you: https://wiki.multitheftauto.com/wiki/Debugging and example of debugging: -- open the door when someone enters the garage's collision shape function onGarageCubeHit(hitElement, matchingDimension) outputDebugString("something hit the sphere") if (getElementType(hitElement) == "player") then outputDebugString("it was player") -- check to make sure the door is closed outputDebugString("garage status:" ..tostring(isGarageOpen(GARAGE_ID))) if (not isGarageOpen(GARAGE_ID)) then outputDebugString("garage was closed") -- open the door local status = setGarageOpen(GARAGE_ID, true) outputDebugString("status of openning garage:"..tostring(status)) end end end if you dont get even first debug message - the something wrong is with event handler or sphere. also you need to define even handler function BEFORE adding the handler - not sure how it will behave in way you have it (adding handler on resource start, with functions below) - it's better to move onGarageCubeHit and onGarageCubeLeave BEFORE onResourceStart handler - more info on addEventHandler wiki page (search pls) Link to comment
dragonofdark Posted March 6, 2011 Share Posted March 6, 2011 Hello, Sorry for the bumping but.. Could I have the ID of the gate at K.A.C.C. Military Fuels ? I can't find it in the garages ID's... Thanks Link to comment
Castillo Posted March 6, 2011 Share Posted March 6, 2011 You could try open every garage, and when it opens the correct you will have the ID 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