Bean666 Posted July 14, 2015 Share Posted July 14, 2015 Hello , is there anyway to lock a pickup for a team? thanks. Link to comment
Mr.Aleks Posted July 14, 2015 Share Posted July 14, 2015 Could you explain better what you wanna do? If you want to limit the use of the pickup only for the people of the team, you can create a condition with this useful function: https://wiki.multitheftauto.com/wiki/IsPlayerInTeam Link to comment
Bean666 Posted July 14, 2015 Author Share Posted July 14, 2015 example: i'll make an hp pickup locked for a team , not all people can get it , only people in the teamname "Alpha Team" will have access to that hp pickup. i tried making one but they're all a fail. Link to comment
Price. Posted July 14, 2015 Share Posted July 14, 2015 pick = createPickup (x, y, z, theType, 0, amount, model ) function pickup() for _, p in ipairs ( getElementsByType ( "player" ) ) do if getPlayerTeam(p) == getTeamFromName("Alpha Team") then setElementHealth(p, 100) else cancelEvent() end end addEventHandler("onPickupHit", getRootElement(), pickup) Link to comment
Dealman Posted July 14, 2015 Share Posted July 14, 2015 pick = createPickup (x, y, z, theType, 0, amount, model ) function pickup() for _, p in ipairs ( getElementsByType ( "player" ) ) do if getPlayerTeam(p) == getTeamFromName("Alpha Team") then setElementHealth(p, 100) else cancelEvent() end end addEventHandler("onPickupHit", getRootElement(), pickup) That would set the health for all the players in that team every time someone from Alpha Team hits it. Your function would also be triggered when any pickup is hit - not only when pick is hit. You could isolate it a bit further with more checks, which would give you more control - like this; local examplePickup = createPickup(...) function detectPickupHit_Handler(thePlayer) if(source == examplePickup and getPlayerTeam(thePlayer) == getTeamFromName("Example Team")) then -- Do your stuff here else cancelEvent() end end addEventHandler("onPickupHit", root, detectPickupHit_Handler) 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