Jump to content

Unable to destroy object after a time delay


Elmatus

Recommended Posts

Hi, I'll appreciate any help, and thanks

I have a funny scrit that throws objects and when they impact, they make an explosion.

The problem is that with the explosion, I writed

 destroyElement(shells.dildos.obj[shells.dildos.shotCount]) 

But this gives me an error in console:

Bad argumenet @'destroyElement' [Expexted element at argument 1, got nil] 

I noticed that if I change the object before moving it, I can change the alpha and all, but after it, i can't

And in both cases I can't destroy the object.

Here is my code:

function DildoShot ( theShooter, weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) 
  
-- Calculate distance for object speed 
  
    shooterX, shooterY, shooterZ = getElementPosition (theShooter) 
    targetDistance = getDistanceBetweenPoints3D ( shooterX, shooterY, shooterZ, hitX, hitY, hitZ ) 
     
     
    local startX, startY, startZ = getPointInFrontOfPlayer(theShooter, 1.5 ) 
    local rx,ry,rz = math.random(360),  math.random(360),  math.random(360) 
    startZ = startZ - 0.5 
  
    if isPedInVehicle(theShooter) == true or isBadWeapon(weapon) == true then 
     
    else 
        -- does paint marker exist destroy if it did 
        if shells.dildos.obj[shells.dildos.shotCount] ~= nil then 
            if isElement(shells.dildos.obj[shells.dildos.shotCount])  then 
                destroyElement(shells.dildos.obj[shells.dildos.shotCount]) 
            end 
            shells.dildos.obj[shells.dildos.shotCount] = nil 
        end 
         
        shells.dildos.obj[shells.dildos.shotCount] = createObject(321, startX, startY, startZ)   
        setObjectScale ( shells.dildos.obj[shells.dildos.shotCount], 5) 
        moveObject ( shells.dildos.obj[shells.dildos.shotCount], targetDistance*10, hitX, hitY, hitZ, rx, ry, rz ) 
  
        if ( (targetDistance*10) < 50) then 
            createExplosion ( hitX, hitY, hitZ, 2) 
        else 
            setTimer ( function() 
                createExplosion ( hitX, hitY, hitZ, 2 ) 
            end, targetDistance*10, 1 ) 
         end 
  
        -- check for limit 
        if shells.dildos.shotCount > 20 then 
            shells.dildos.shotCount = 1 
        else 
            shells.dildos.shotCount = shells.dildos.shotCount + 1 
        end  
  
  
    end 
--  local outString = string.format(“DildoShot Count: %d  Element: %s", shells.dildos.shotCount, tostring(shells.dildos.obj[shells.dildos.shotCount])) 
--  outputDebugString( outString ) 
end 

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