Jump to content

[HELP] Tables with blip and colsphere


squar

Recommended Posts

Posted

Oh, what if i've got an object using createObject? My bad... I should've pointed out that I wanted the col and blip attached to the object. However, the blip isn't a problem now. Since it will be deleted if i get the object deleted. You know how i can fix that?

The plan though is to get the object, blip and colsphere deleted when i hit that colsphere...

Posted

I don't have the knowledge to do that. I just tried throwing them all in a table like showed above, and some other weird ways. However, that ended with a failure you see. That's why I would like you guys to give me a clue about how to do it :)

Posted

Lemme get it right: you created an object, and you want to attach to this object a blip and a colshape, and when you hit this colshape, you want all the three things destroyed?

Posted

Yes. I want it tabled since it will be creating a new object with blip and colsphere like every sec. Therefore I want it to be like; when I hits the col, it will destroy the blip, col and object. Of course there's other things added to that than it getting deleted only. Its just that part I'm having problems with.

Posted
local aTable = { } 
  
function test ( ) 
    local obj = createObject ( ) -- Create an object. 
    local col = createColTube ( ) -- Create a colshape. 
    local blip = createBlipAttachedTo ( obj, 0 ) -- Create a blip attached to the object. 
    attachElements ( col, obj ) -- Attach the colshape to the object. 
    aTable [ col ] = { } -- Create a sub table inside 'aTable' using the colshape as index. 
    aTable [ col ].object = obj -- Store the object element in this subtable. 
    aTable [ col ].blip = blip -- Store the blip element in this subtable. 
    addEventHandler ( "onClientColShapeHit", col, test2 ) 
end 
  
function test2 ( element ) 
    if ( element == localPlayer ) then 
        local data = aTable [ source ] 
        if ( type ( data ) == "table" ) then 
            destroyElement ( source ) 
            destroyElement ( data.blip ) 
            destroyElement ( data.object ) 
            aTable [ source ] = nil 
        end 
    end 
end 

Posted

It didnt work.

        local data = aTable [ source ] 
        outputChatBox("test") 
        if ( type ( data ) == "table" ) then 

I tried an output under the "if" and it didnt work. However above did work, so i guess its something wrong with that line

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