Jump to content

Pickup problem


Drakath

Recommended Posts

Posted

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?

Posted (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 by Guest
Posted

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.

Posted

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.

Posted
  
  
function asd () 
  
local x, y, z = getElementPosition(localPlayer) 
  
createPickup(x+2, y+2, z, 0, 20) 
  
end 
  
addCommandHandler("mk", asd) 

Common sense.

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

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