Drakath Posted August 21, 2012 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)
Perfect Posted August 21, 2012 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 Multi Theft Auto Player since middle of 2011. Everybody want to act Crazy/Smart/Intelligent/Different/Unique/Innocent and Thats why I am Perfect.
Twiz. Posted August 21, 2012 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 Logic Fan <3
Drakath Posted August 21, 2012 Author 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.
Castillo Posted August 21, 2012 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 ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted August 21, 2012 Posted August 21, 2012 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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