Maruchan Posted April 21, 2021 Posted April 21, 2021 Hello guys, how are you? I have a problem destroying the campfire, the wood is destroyed but I can't make the fire disappear. They could help me, I have tried but I do not understand how to solve it :c usedFires = {} usedFireTimers = {} function onPlayerMakeAFire(itemName) setElementData(source,"Madera",getElementData(source,"Madera")-1) local x,y,z = getElementPosition(source) local xr,yr,zr = getElementRotation(source) px, py, pz = getElementPosition(source) prot = getPedRotation(source) local offsetRot = math.rad(prot+90) local vx = px + 1 * math.cos(offsetRot) local vy = py + 1 * math.sin(offsetRot) local vz = pz + 2 local vrot = prot+90 local wood = createObject(1463,vx,vy,pz-0.75,xr,yr,vrot) usedFires[wood] = {} setObjectScale(wood,0.55) setElementCollisionsEnabled(wood, false) setElementFrozen (wood,true) local fire = createObject(3525,vx,vy,pz-0.75,xr,yr,vrot) setObjectScale(fire,0) local fireCol = createColSphere(x,y,z,2) local fireColFar = createColSphere(x,y,z,10) if usedFireTimers[source] and isTimer ( usedFireTimers[source][1] ) then killTimer ( usedFireTimers[source][1] ) end usedFireTimers[source] = { setTimer (checkPlayerNearFire,5000,1,source), fireColFar } addEventHandler ( "onColShapeHit", fireColFar, fireColFarHit ) setElementData(fireCol,"parent",wood) setElementData(wood,"parent",fireCol) setElementData(fireCol,"Cocinar",true) setPedWeaponSlot(source, 0) fireX,fireY,fireZ = getElementPosition(fire) triggerClientEvent(source,"FogataEncendida",source,fireX,fireY,fireZ) triggerClientEvent(source,"refreshInventoryManual",source) setPedAnimation (source,"BOMBER","BOM_Plant", -1, false, false, false, false) setTimer(function() destroyElement(fireCol) destroyElement(fireColFar) destroyElement(fire) destroyElement(wood) triggerClientEvent(source,"FogataApagada",source) end,720000,1) end addEvent("onPlayerMakeAFire",true) addEventHandler("onPlayerMakeAFire",getRootElement(),onPlayerMakeAFire) function DestruirFogata(col) wood = getElementData(col,'parent') -- if wood and isElement(wood) then destroyElement(wood) end -- setPedAnimation (source,"BOMBER","BOM_Plant", -1, false, false, false, false) end addEvent("Destruir_Fogata", true) addEventHandler("Destruir_Fogata", root, DestruirFogata)
Moderators Tut Posted April 21, 2021 Moderators Posted April 21, 2021 Thread's been moved into the Scripting section.
Moderators IIYAMA Posted April 21, 2021 Moderators Posted April 21, 2021 3 hours ago, Maruchan said: I can't make the fire disappear. Place the following line setElementParent(fire, wood) between: setPedAnimation (source,"BOMBER","BOM_Plant", -1, false, false, false, false) -- < setTimer(function() When destroyElement(wood) is called, propagation is applied and the same function will be executed for it's children. Which is in this case the fire element. 1
Maruchan Posted April 21, 2021 Author Posted April 21, 2021 6 hours ago, IIYAMA said: Place the following line setElementParent(fire, wood) between: setPedAnimation (source,"BOMBER","BOM_Plant", -1, false, false, false, false) -- < setTimer(function() When destroyElement(wood) is called, propagation is applied and the same function will be executed for it's children. Which is in this case the fire element. But this: setElementParent(fire, wood) - is not the same as this: setElementData(fireCol,"parent",wood) ?????
Moderators IIYAMA Posted April 21, 2021 Moderators Posted April 21, 2021 19 minutes ago, Maruchan said: But this: setElementParent(fire, wood) - is not the same as this: setElementData(fireCol,"parent",wood) ????? That is correct, it is not the same. setElementData does not modify the parent<>child relationship. It only makes a reference between the 2. setElementParent does modify the parent<>child relationship: And therefore you can use call-propagation. Using the destroyElement function on the parent will also apply the function on it's children. 1
Moderators Patrick Posted April 21, 2021 Moderators Posted April 21, 2021 @Maruchan (Please name your threads properly, instead of "help me pls". This isn't the first time I have renamed it. Thanks.)
Maruchan Posted April 21, 2021 Author Posted April 21, 2021 (edited) I really appreciate you, I have one last little thing that I can't fix. Is it possible to add a font to this? I have tried it this way but it doesn't work: gridlistItems["loot_colum"] = guiGridListAddColumn(gridlistItems["loot"],"LOOT",0.7) gridlistItems["loot_colum_amount"] = guiGridListAddColumn(gridlistItems["loot"],"",0.2) guiSetFont(gridlistItems["loot_colum"],Fuente) Edited April 21, 2021 by Maruchan
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