Jump to content

fire extinguisher don't remove all objects and errors


tommyken

Recommended Posts

Hi everyone,

i try to get in LUA scripting and coding. But its hard without help. So i hope you can help me out. I do always the same mistakes ...

i tried to script that remove fire and 'broken car' with a fire extinguisher.

But the fire object still excist and got also after the car itself is gone the error

  
local spawnX, spawnY, spawnZ = 2485.90112, -1667.03516, 13.34375 
  
fireBlip = createBlip( spawnX, spawnY, spawnZ, 20 ) 
fireMarker = createMarker (spawnX, spawnY, spawnZ, "corona", 5, 255,0,0,0) 
local fireElem1 = createObject( 3525, spawnX, spawnY, spawnZ-1 ) 
local fireElem2 = createObject( 3525, spawnX, spawnY-1, spawnZ-1 ) 
local fireElem3 = createObject( 12957, spawnX, spawnY, spawnZ ) 
  
function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) 
    --outputChatBox( "test" ) 
    if (weapon == 42) then -- fire extinguisher weapon 
  
        if getElementType( hitElement ) == "object" then -- If the player shoots with a fire exting 
            outputChatBox( "object beschoten" ) 
         
            if (getElementModel( hitElement ) == 12957) then --Broken car object 
                destroyElement( hitElement ) 
            elseif (getElementModel( hitElement ) == 3525) then -- the two fire objects 
                destroyElement( hitElement ) 
            end 
        else 
            cancelEvent(  ) 
        end 
    end 
end 
-- Add this as a handler so that the function will be triggered every time a player fires. 
addEventHandler("onClientPlayerWeaponFire", root, onClientPlayerWeaponFireFunc) 
  

Is there a way to destroyelement fireElem1 , fireElem2 and fireElem3 instead of destroyelement (hitelement)

after i got destroyed 12957 , i got this error "bad argument @ 'getElementType' [Expected element at argument 1, got nil]"

Thanks in advance ,

greetings

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