Jump to content

onClientPlayerPickupHit


Drakath

Recommended Posts

Posted

How can I use onClientPlayerPickupHit event handler only for pickups created by the same resource?

I tried:

addEventHandler("onClientPlayerPickupHit", resourceRoot, handlePickups) 

but it doesn't trigger at all.

Posted

if the source is the pickup that you hit resourceRoot should work

but you can insert any pickup you create into table and check

local Pickups = {} 
function handlePickups() 
    if Pickups[source] then 
     
    end 
end 
addEventHandler("onClientPlayerPickupHit", resourceRoot, handlePickups) 

Posted
if the source is the pickup that you hit resourceRoot should work

but you can insert any pickup you create into table and check

local Pickups = {} 
function handlePickups() 
    if Pickups[source] then 
     
    end 
end 
addEventHandler("onClientPlayerPickupHit", resourceRoot, handlePickups) 

resourceRoot doesn't work.

Posted (edited)

Try to use sth like this

local PickupTable = { 
    -- Add all your pickups here  
} 
  
function handlePickups() 
    -- Your code here 
end  
  
  
for i=1,#PickupTable do 
    local thePickup = createPickup ( PickupTable[i][1], PickupTable[i][2], PickupTable[i][3], 3, 1242, 0) 
    addEventHandler("onClientPickupHit",thePickup, handlePickups) 
end 

Edited by Guest
Posted
Try to use sth like this
local PickupTable = { 
    -- Add all your pickups here  
} 
  
function handlePickups() 
    -- Your code here 
end  
  
  
for i=1,#PickupTable do 
    local thePickup = createPickup ( PickupTable[i][1], PickupTable[i][2], PickupTable[i][3], 3, 1242, 0) 
    addEventHandler("onClientPlayerPickupHit",thePickup, handlePickups) 
end 

I thought about this at first but is this really the only way? I can swear that I once saw a script that could trigger an event just for elements created by the same resource.

Posted

resourceRoot doesn't works because as i told you

the pickup must be the source to make it work

but on this event "onClientPlayerPickupHit" the source is the player who hit the pickup

you must use "onClientPickupHit" instead of "onClientPlayerPickupHit"

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