Jump to content

Restriction


Drakath

Recommended Posts

How can I restrict this garage to open just for 1 player by his username?

Script:

local cjGarage = createColRectangle(2502.7883300781, -1698.60546875,5.8679199219,16.1025390625) 
addEventHandler("onColShapeHit",cjGarage,function(h) if getElementType(h) == "player" then setGarageOpen(9,true) local tpi = getElementData(cjGarage,"tpi") or 0 setElementData(cjGarage,"tpi",tpi+1,false) end end) 
addEventHandler("onColShapeLeave",cjGarage,function(h) if getElementType(h) == "player" then local tpi = getElementData(cjGarage,"tpi") or 0 if not tpi or tpi <= 1 then setGarageOpen(9,false)end setElementData(cjGarage,"tpi",tpi-1,false) end end) 

Link to comment
How can I restrict this garage to open just for 1 player by his username?

Script:

local cjGarage = createColRectangle(2502.7883300781, -1698.60546875,5.8679199219,16.1025390625) 
addEventHandler("onColShapeHit",cjGarage,function(h) if getElementType(h) == "player" then setGarageOpen(9,true) local tpi = getElementData(cjGarage,"tpi") or 0 setElementData(cjGarage,"tpi",tpi+1,false) end end) 
addEventHandler("onColShapeLeave",cjGarage,function(h) if getElementType(h) == "player" then local tpi = getElementData(cjGarage,"tpi") or 0 if not tpi or tpi <= 1 then setGarageOpen(9,false)end setElementData(cjGarage,"tpi",tpi-1,false) end end) 

maybe you can use

getAccountName 

Link to comment
local cjGarage = createColRectangle(2502.7883300781, -1698.60546875,5.8679199219,16.1025390625) 
setElementData ( cjGarage, "owner", "Drakath" ) 
  
addEventHandler ( "onColShapeHit", cjGarage, 
    function ( h ) 
        if ( getElementType ( h ) == "player" ) then 
            if ( getElementData ( source, "owner" ) == getPlayerName ( h ) ) then 
                setGarageOpen ( 9, true ) 
                local tpi = getElementData ( cjGarage, "tpi" ) or 0 
                setElementData ( cjGarage, "tpi", ( tpi + 1 ), false ) 
            end 
        end 
    end 
) 
addEventHandler ( "onColShapeLeave", cjGarage, 
    function ( h ) 
        if ( getElementType ( h ) == "player" ) then 
            if ( getElementData ( source, "owner" ) == getPlayerName ( h ) ) then 
                local tpi = getElementData ( cjGarage, "tpi" ) or 0 
                if ( not tpi or tpi <= 1 ) then 
                    setGarageOpen ( 9, false ) 
                end 
                setElementData ( cjGarage, "tpi", ( tpi - 1 ), false ) 
            end 
        end 
    end 
) 

Link to comment

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