Drakath Posted August 21, 2012 Share Posted August 21, 2012 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
Perfect Posted August 21, 2012 Share Posted August 21, 2012 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
Twiz. Posted August 21, 2012 Share Posted August 21, 2012 Maybe this ? I dont know if you means just for a Player with a Name, or for a kind of Faction ? getPlayerName Link to comment
Drakath Posted August 21, 2012 Author Share Posted August 21, 2012 I need it to be by usernames because I will add garages to the houses so only players who owns a garage will be able to open it. Link to comment
Castillo Posted August 21, 2012 Share Posted August 21, 2012 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
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