Jump to content

createPickup problem.


Ride1234

Recommended Posts

Hello, I create pickups and have some problem with it.

When I create pickup using server function

createPickup

it creates and works great, but if someone pick it up , it disappears on the all players. But I want, that every player can pick ip up, and these pickup wouldn't disappear on the other players. I mean, that each player can pick it up only one time. How to do it?

p.s. if create pickup on client side it doesn't pick up.

Link to comment
maybe try something with?

https://wiki.multitheftauto.com/wiki/SetElementVisibleTo

but im not sure if pickup like this will be "pickable" by others (i mean, one player will pick up all the pickups)

I tried to destroy picked up pickup then create it again and hide to player, who picked up, bit it didn't work :D. Here is my code:

function onPickupPickup(player)
if(source == pickup[1]) then
--[[ here is pickup's actions ]]
destroyElement(pickup[1])
pickup[1] = createPickup (-3381.484131,-1083.058105,95.289009,3,1272,99999999999) -- i created the same pickup like it was
setElementVisibleTo(pickup[1], getRootElement(), true)
setElementVisibleTo(pickup[1], player, false) -- and hided it to player , who picked it up
end
end

Pick up appeared again , but was not pickupable..

So i guess mta doesn't support per-player pickups.. :cry:

Link to comment
Create it client side then use a colshape around it to detect when you hit it, then destroy it (and the colshape) when the player hits it.

I tried, but when one player pick ups the pickup it destroys for all players. Code:

server side:

triggerClientEvent(val,"createKeys",getRootElement())

client side:

function createKeys2()
key[1] = createPickup (-3231.484131,-2383.058105,81.289009,3,1272,9999999999)
cls[1] = createColCircle ( -3231.484131,-2383.058105, 2.5 )
end
 
addEvent("createKeys",true)
addEventHandler( "createKeys", getRootElement(), createKeys2 )
 
function onClientColShapeHit()
if(source == cls[1]) then
outputChatBox("1",getLocalPlayer())
destroyElement(key[1])
destroyElement(cls[1])
end	
end
 
addEventHandler("onClientColShapeHit",getRootElement(),onClientColShapeHit)

pickup and colshape destroys for all players, and message sends too.

Link to comment

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