Drakath Posted June 12, 2015 Posted June 12, 2015 I got a small problem. function asd () local x, y, z = getElementPosition(localPlayer) createPickup(x+2, y+2, z, 0, 20) end asd() When I hit this pickup, nothing happens. Why?
anumaz Posted June 12, 2015 Posted June 12, 2015 (edited) You need to define the pick up and then trigger the hit or leave with an event: function asd () local x, y, z = getElementPosition(localPlayer) local element = createPickup(x+2, y+2, z, 0, 20) addEventHandler("onClientPickupHit", element, function () --your stuff here end) end asd() It works both client and server side (onClientPickupHit or OnPickupHit) Sorry for indent, TAB doesnt work https://wiki.multitheftauto.com/wiki/OnClientPickupHit Edited June 12, 2015 by Guest
Drakath Posted June 12, 2015 Author Posted June 12, 2015 Can anyone confirm this? Somehow I find this wrong.
anumaz Posted June 12, 2015 Posted June 12, 2015 Have you even tried it out? Is this server side or client side. How are you triggering the createPickup function (asd)? Other than that, yes, it is working.
GTX Posted June 12, 2015 Posted June 12, 2015 If you want to trigger a function when pickup is picked, use onClientPickupHit. Edit: anumaz, it's onClientPickupHit, not OnClientPickupHit. Beware, it's case-sensitive!
Drakath Posted June 12, 2015 Author Posted June 12, 2015 You are both wrong. function asd (t) local x, y, z = getElementPosition(t) createPickup(x+2, y+2, z, 0, 20) end addCommandHandler("mk", asd) Server side script with a working pickup. No event handlers necessary.
Drakath Posted June 12, 2015 Author Posted June 12, 2015 I wonder why doesn't it work client-side though.
Saml1er Posted June 12, 2015 Posted June 12, 2015 function asd () local x, y, z = getElementPosition(localPlayer) createPickup(x+2, y+2, z, 0, 20) end addCommandHandler("mk", asd) Common sense.
Drakath Posted June 12, 2015 Author Posted June 12, 2015 function asd () local x, y, z = getElementPosition(localPlayer) createPickup(x+2, y+2, z, 0, 20) end addCommandHandler("mk", asd) Common sense. Pickup appears but when I hit it, it doesn't give me health points.
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