Drakath Posted June 12, 2015 Share 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? Link to comment
anumaz Posted June 12, 2015 Share 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 Link to comment
Drakath Posted June 12, 2015 Author Share Posted June 12, 2015 Can anyone confirm this? Somehow I find this wrong. Link to comment
anumaz Posted June 12, 2015 Share 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. Link to comment
GTX Posted June 12, 2015 Share 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! Link to comment
Drakath Posted June 12, 2015 Author Share 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. Link to comment
Drakath Posted June 12, 2015 Author Share Posted June 12, 2015 I wonder why doesn't it work client-side though. Link to comment
Saml1er Posted June 12, 2015 Share 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. Link to comment
Drakath Posted June 12, 2015 Author Share 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. Link to comment
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