Jump to content

Getting the object


tosfera

Recommended Posts

Posted

HEy,

I was asking myself, can you get an attached object? Like, I'll create a marker @ 0,0,0 (position) and a box at 5, 5, 5. I'll use a forklift to grab and lift the box, and when I hit the marker it has to say like; good job! you are holding the object: .

I've no idea if that is possible, if it is. Does anyone have a idea how to check it? :shock:

Posted
/me punches tosfera in the face

And you are welcome :)

Keep getting the message;"You need to pickup the supplies first!"

  
addEventHandler("onClientMarkerLeave", root, 
    function ( hitElement ) 
        local v = getPedOccupiedVehicle ( hitElement )  
        local element = getElementAttachedTo ( v ) 
        local object = getAttachedElements ( element ) 
        if object then 
            outputChatBox("ok!") 
        else 
            outputChatBox("You need to pickup the supplies first!") 
        end 
    end 
) 

results I got back:

  
local v = userdata 
local element = false 
local object = false 
  

Posted
For the "element" variable: i think your vehicle is not attached to any element, why do you want to get it?

getAttachedElements returns a table.

Thats the point, is an object getting attached to a forklift if you try to lift it?

Posted
50p*

I also got some ideas how to it, but can't try it now, just tomorrow...

Would be awesome, I do have an idea how to fix it in another way, but that isn't rly realistic. :P

Posted
For the "element" variable: i think your vehicle is not attached to any element, why do you want to get it?

getAttachedElements returns a table.

Thats the point, is an object getting attached to a forklift if you try to lift it?

No as far as I know, the only way would be attaching it yourself.

Posted

You can only do it with attachments. It's not that hard to do but if you want some advanced system then you'd have to spend some more time.

I've seen this video on youtube some time ago:

/me punches tosfera in the face

And you are welcome :)

Keep getting the message;"You need to pickup the supplies first!"

  
addEventHandler("onClientMarkerLeave", root, 
    function ( hitElement ) 
        local v = getPedOccupiedVehicle ( hitElement )  
        local element = getElementAttachedTo ( v ) 
        local object = getAttachedElements ( element ) 
        if object then 
            outputChatBox("ok!") 
        else 
            outputChatBox("You need to pickup the supplies first!") 
        end 
    end 
) 

...

  
local v = userdata 
local element = false -- reason is you're getting what element your vehicle is attached to, your vehicle is not attached to anything so it returns false 
local object = false -- this is obvious, if element is false then getAttachedElements will return false too 
  

Posted

Thanks Solid and 50p for clearing it up; An element in not being attached tot he forklift when you're trying to pick it up.

Time to write my other idea now :3

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