Jump to content

Fire scripting help


Fuentes

Recommended Posts

create fire position fX fY fZ

function startTheFire (fX,fY,fZ) 
  
setElementData(fire, "x", fX) 
setElementData(fire, "y", fY) 
setElementData(fire, "z", fZ) 
  
    setTimer ( function() 
     
        createFire(fX,fY,fZ,60) 
    end, 420000, 1) 
    
     
    local Soundone = playSound3D( "files/firealarm.mp3",fX,fY,fZ, false ) 
    setSoundMinDistance(Soundone, 25) 
    setSoundMaxDistance(Soundone, 70) 
     
    local Soundtwo = playSound3D( "files/firealarmsecond.mp3",-2039.7060546875 ,78.998046875 ,28.397680282593, false ) 
    setSoundMinDistance(Soundtwo, 25) 
    setSoundMaxDistance(Soundtwo, 70) 
     
     
     --setSoundVolume( Sound, 1 ) 
  
    local fire = engineLoadDFF("fire.dff",1) 
    engineReplaceModel(fire,fireModel) 
end 
addEvent("startTheFire",true) 
addEventHandler( "startTheFire", getRootElement(), startTheFire) 

Problem:

function firelost(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) 
    if (weapon==42) then 
        local team = getPlayerTeam(getLocalPlayer()) 
        local ftype = getElementData(getLocalPlayer(), "faction") 
         
  
        if (ftype==4)  then 
            if not (hitElement) or (getElementType(hitElement)~="player") then  
                 
                if not cooldown then 
                    if (ammoInClip>10) and (weapon==42) then 
                local x, y, z = hitX, hitY, hitZ 
         
    local x2 = getElementData(fire, "x") 
    local y2 = getElementData(fire, "y") 
local z2 = getElementData(fire, "z") 
    if getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) > 10  then 
                            outputChatBox("Are not fire.", 255, 0, 0) 
                            count = 0 
                            cooldown = setTimer(resetCooldown, 5000, 1, false) 
                        else 
            count = count + 1 
                             
                            if (count==20) then 
                                count = 0 
                                cooldown = setTimer(resetCooldown, 30000, 1, false) 
            triggerServerEvent("cancelrandomfires", localPlayer)  
    end 
    end 
    end 
    end 
    end 
    end 
    end 
    end 
    addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(),firelost) 

error:

Bad argument @ 'getDistanceBetweenPoints3D' [Expected vector3 at argument 4, got boolean]

Thank You

Link to comment
function firelost(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) 
    if (weapon==42) then 
        local team = getPlayerTeam(getLocalPlayer()) 
        local ftype = getElementData(getLocalPlayer(), "faction") 
        ---outputChatBox("." ..hitX.." "..hitY.." "..hitZ, 255, 0, 0) 
  
        if (ftype==4)  then 
            if not (hitElement) or (getElementType(hitElement)~="player") then -- Didn't attack someone 
                 
                if not cooldown then 
                    if (ammoInClip>10) and (weapon==42) then 
                local x, y, z = hitX, hitY, hitZ 
         
    local x2 = getElementData(fire, "x") 
    local y2 = getElementData(fire, "y") 
local x2 = getElementData(fire, "x") 
    if x2 and y2 and z2 then 
                            outputChatBox("Not are fire.", 255, 0, 0) 
                            count = 0 
                            cooldown = setTimer(resetCooldown, 5000, 1, false) 
                        else 
            count = count + 1 
                             
                            if (count==20) then 
                                count = 0 
                                cooldown = setTimer(resetCooldown, 30000, 1, false) 
            triggerServerEvent("cancelrandomfires", localPlayer)  
    end 
    end 
    end 
    end 
    end 
    end 
    end 
    end 
    addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(),firelost) 

Bad argument @ 'getElementData' [Expected element at argument 1, got nil]

Link to comment
if x2 and y2 and z2 then 
     if getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) > 10  then 
         outputChatBox("Are not fire.", 255, 0, 0) 
         count = 0 
         cooldown = setTimer(resetCooldown, 5000, 1, false) 
     else 
         count = count + 1 
         if (count==20) then 
             count = 0 
             cooldown = setTimer(resetCooldown, 30000, 1, false) 
             triggerServerEvent("cancelrandomfires", localPlayer) 
        end 
    end 
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...