Jump to content

Pickup?


Bean666

Recommended Posts

Posted

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.

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

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

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