Drakath Posted June 13, 2015 Posted June 13, 2015 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.
ALw7sH Posted June 13, 2015 Posted June 13, 2015 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)
Drakath Posted June 13, 2015 Author Posted June 13, 2015 if the source is the pickup that you hit resourceRoot should workbut 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.
Walid Posted June 13, 2015 Posted June 13, 2015 (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 June 13, 2015 by Guest
Drakath Posted June 13, 2015 Author Posted June 13, 2015 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.
ALw7sH Posted June 13, 2015 Posted June 13, 2015 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"
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