Fuentes Posted January 3, 2016 Share Posted January 3, 2016 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
Addlibs Posted January 3, 2016 Share Posted January 3, 2016 You're hitting an element that is not a player but neither a fire (hence x2, y2 and z2 are false, a boolean value). You should check if x2 and y2 and z2 then before proceeding to getDistanceBetweenPoints3D. Link to comment
Fuentes Posted January 3, 2016 Author Share Posted January 3, 2016 i dont know sorry please help scripting Link to comment
Fuentes Posted January 3, 2016 Author Share Posted January 3, 2016 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
Addlibs Posted January 3, 2016 Share Posted January 3, 2016 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
Fuentes Posted January 3, 2016 Author Share Posted January 3, 2016 Bad argument @ 'getElementData' [Expected element at argument 1, got nil] local x2 = getElementData(fire, "x") local y2 = getElementData(fire, "y") local x2 = getElementData(fire, "x") Link to comment
Addlibs Posted January 3, 2016 Share Posted January 3, 2016 change 'fire' to 'hitElement' in all three getElementData Link to comment
Fuentes Posted January 3, 2016 Author Share Posted January 3, 2016 local x, y, z = hitX, hitY, hitZ local x2 = getElementData(hitElement, "x") local y2 = getElementData(hitElement, "y") local x2 = getElementData(hitElement, "x") if x2 and y2 and z2 then bad argument getelementdata Link to comment
ViRuZGamiing Posted January 4, 2016 Share Posted January 4, 2016 local x, y, z = hitX, hitY, hitZ local x2 = getElementData(hitElement, "x") local y2 = getElementData(hitElement, "y") local x2 = getElementData(hitElement, "x") if x2 and y2 and z2 then bad argument getelementdata Did you set it as well? setElementData(hitElement, "x", value) Link to comment
Moderators IIYAMA Posted January 4, 2016 Moderators Share Posted January 4, 2016 if not (hitElement) or (getElementType(hitElement)~="player") then -- Didn't attack someone if hitElement and getElementType(hitElement) ~= "player" then -- Didn't attack someone Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now