damien111 Posted November 5, 2012 Share Posted November 5, 2012 Hey, im trying to make it spawn a new fire every minute or so, and if the person who puts out the fire is on team emergency, they get money, and i cant get it to make the fire. I used someone elses script and im editing it bcause it keeps the fires synced. Here is the code. The Resource Was Not A FireFighter Job. It was calleD fire sync. Thanks Guys Client --client function makeboom () x2, y2, z2 = getRandomCoordinates ( ) local fire = engineLoadDFF("fire.dff",1) engineReplaceModel(fire,fireModel) end addEvent( "onGreeting", true ) addEventHandler( "onGreeting", getRootElement(), makeboom ) local coordinates = { { 2485, -1669, 13.34375} --fire coords go here } function getRandomCoordinates ( ) return unpack ( coordinates [ math.random ( #coordinates ) ] ) end local fireModel = 2023 function applyFire() local fire = engineLoadDFF("fire.dff",1) engineReplaceModel(fire,fireModel) end addEventHandler("onClientResourceStart",resourceRoot,applyFire) function createExtinguisher(wep,_,_,hitX,hitY,hitZ) if wep ~= 42 then return end for k, v in ipairs(getElementsByType("object",resourceRoot)) do if getElementModel(v) == fireModel then local fX,fY,fZ = getElementPosition(v) local dist = getDistanceBetweenPoints2D(hitX,hitY,fX,fY) if dist < 1 then destroyElement(theBlip) triggerServerEvent("fireExtinguished",localPlayer,v) end end end end addEventHandler("onClientPlayerWeaponFire",localPlayer,createExtinguisher) function enterTruck(veh,seat) if getElementModel(veh) ~= 407 or seat > 0 then return end if not rendering then addEventHandler("onClientRender",root,checkTurret) end end addEventHandler("onClientPlayerVehicleEnter",localPlayer,enterTruck) function exitTruck() if rendering then removeEventHandler("onClientRender",root,checkTurret) end end addEventHandler("onClientPlayerVehicleExit",localPlayer,exitTruck) addEventHandler("onClientPlayerWasted",localPlayer,exitTruck) function checkTurret() if not getKeyState("vehicle_fire") and not getKeyState("vehicle_secondary_fire") then return end outputDebugString("0") local veh = getPedOccupiedVehicle(localPlayer) outputDebugString("1") if not veh then return end outputDebugString("2") local fX,fY,fZ = getElementPosition(veh) outputDebugString("3") local turretPosX,turretPosY = getVehicleTurretPosition(veh) outputDebugString("4") local turretPosX = math.deg(turretPosX) outputDebugString("5") if turretPosX < 0 then turretPosX = turretPosX+360 end outputDebugString("6") local rotX,rotY,rotZ = getVehicleRotation(veh) outputDebugString("7") local turretPosX = turretPosX+rotZ-360 outputDebugString("8") if turretPosX < 0 then turretPosX = turretPosX+360 end outputDebugString("9") local firetruckShape = createColCircle(fX,fY,20) outputDebugString("10") local burningVehicles = getElementsWithinColShape(firetruckShape,"object") outputDebugString("11") for k, v in pairs(burningVehicles) do local bX,bY,bZ = getElementPosition(v) local neededRot = findRotation(fX,fY,bX,bY) outputDebugString(tostring(neededRot)) if turretPosX > neededRot-30 and turretPosX < neededRot+30 then destroyElement(theBlip) triggerServerEvent("fireExtinguished",localPlayer,v) break end end destroyElement(firetruckShape) end function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t+360 end return t end Server local fireModel = 2023 local fires = {} addEvent("onFireExtinguished",true) addEvent("onFireCreate",true) function makefireforfireman () x2, y2, z2 = getRandomCoordinates ( ) if getPlayerTeam(player) ~= getTeamFromName(Team) then triggerClientEvent ( "onGreeting", getRootElement(), "Hello World!" ) local fireElem = createObject(fireModel,x,y,z) setElementCollisionsEnabled(fireElem,false) local col = createColSphere(x2,y2,z2+1,2) fires[fireElem] = {fireElem,col} addEventHandler("onColShapeHit",col,setFire) return fireElem end end setTimer ( makefireforfireman, 90000, 0 ) createTeam("Emergency") function createFire(x,y,z) local fireElem = createObject(fireModel,x,y,z) setElementCollisionsEnabled(fireElem,false) local col = createColSphere(x,y,z+1,2) fires[fireElem] = {fireElem,col} addEventHandler("onColShapeHit",col,setFire) return fireElem end function setFire(elem,dim) if not dim then return end if not elem or not isElement(elem) then return end if getElementType(elem) == "player" then setPedOnFire(elem,true) end end function fireExtinguished(fireElem) triggerEvent("onFireExtinguished",source,fireElem) destroyElement(fires[fireElem][1]) destroyElement(fires[fireElem][2]) fires[fireElem] = nil if getPlayerTeam(player) == getTeamFromName(Team) then givePlayerMoney ( source, 100 ) end end addEvent("fireExtinguished",true) addEventHandler("fireExtinguished",root,fireExtinguished) Link to comment
damien111 Posted November 6, 2012 Author Share Posted November 6, 2012 Helpp me please. Link to comment
Tete omar Posted November 6, 2012 Share Posted November 6, 2012 Hey, im trying to make it spawn a new fire every minute or so, and if the person who puts out the fire is on team emergency, they get money, and i cant get it to make the fire. I used someone elses script and im editing it bcause it keeps the fires synced. Here is the code. The Resource Was Not A FireFighter Job. It was calleD fire sync. Thanks Guys Did you know that no one here helps for a 'ready-made' codes. Link to comment
damien111 Posted November 7, 2012 Author Share Posted November 7, 2012 So nobody will help me with how to spawn fire? I was going to use this guys fire sync script built in to keep the fires sync. Not leech it. 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