Jump to content

How to put a code on the garages


Eelke

Recommended Posts

Posted

Is wiki or search feature not working?

Hint: Click both links. Both are useful.

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

We won't script for you because you are lazy.

https://wiki.multitheftauto.com/wiki/Scr ... troduction

Learn. It's not hard.

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

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..

Posted

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)

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

  • 4 months later...
Posted

You could try open every garage, and when it opens the correct you will have the ID :P

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...