Jump to content

Pickup?


Bean666

Recommended Posts

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

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