Jump to content

setElementVisibleTo with pickup


iam2noob4u

Recommended Posts

I'm having some trouble hiding pickups. For testing purposes I've simplified my script to this:

addEventHandler("onResourceStart", root, function() 
    local player = getRandomPlayer(); --lazy way of getting the only player on the server (which is me during testing) 
    local x,y,z = getElementPosition(player); 
    local pickup = createPickup(x+5, y, z, 2, 6, 1000, 100); 
    setElementVisibleTo(pickup, root, false); 
end); 

Whether I use root or player as the second argument for setElementVisibleTo: the script creates the shovel pickup, but I can still see it. I'm pretty sure this is a bug - or intended behaviour that is not mentioned on the wiki, but I'd like to be sure before I submit a bug report :)

Link to comment

Do you want the pickup doesn't get visible for whom?

If you want to show it just for a specific player, use this:

setElementVisibleTo(pickup, root, false) 
setElementVisibleTo(pickup, player, true) 

Edit

Yeah, nevermind. It doesn't work for pickups, forgot about the MTA Wiki note.

Edited by Guest
Link to comment

This does not work with all entities - vehicles, players and objects are exempt. This is because these objects are required for accurate sync (they're physical objects that contribute to the physics engine). This function is particularly useful for changing the visibility of markers, radar blips and radar areas.
Link to comment

Again: the wiki note in no way makes clear that the function does not work on pickups. The explanation for the elements it doesn't work on is basically that it doesn't work on solid elements. Pickups aren't solid.

There is no point in quoting the note multiple times, as it is not an answer to my question.

The note clearly excludes vehicles, players and objects. It also mentiones some elements it is particularly useful on. Particularly doesn't mean "only".

I'll add another 'needs checking' note to the page and just script my way around the problem :)

Link to comment
Again: the wiki note in no way makes clear that the function does not work on pickups. The explanation for the elements it doesn't work on is basically that it doesn't work on solid elements. Pickups aren't solid.

There is no point in quoting the note multiple times, as it is not an answer to my question.

The note clearly excludes vehicles, players and objects. It also mentiones some elements it is particularly useful on. Particularly doesn't mean "only".

I'll add another 'needs checking' note to the page and just script my way around the problem :)

Element is element. Pickups are also elements. Their collision is disabled. They are actually food objects.

Link to comment
Element is element. Pickups are also elements.

I understand, this is not the issue. The function is to be called on elements so it's a good thing pickups are elements.

Their collision is disabled. They are actually food objects.

I think you are confusing the normal pickups (created with createPickup) with the race pickups (created with createObject).

Link to comment
Element is element. Pickups are also elements.

I understand, this is not the issue. The function is to be called on elements so it's a good thing pickups are elements.

Their collision is disabled. They are actually food objects.

I think you are confusing the normal pickups (created with createPickup) with the race pickups (created with createObject).

I thought they were same. :shock:

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