Jump to content

Wood Cutting Job Script


DzMG-LV

Recommended Posts

Hi, i want to make lumberjack script like this:

What functions i need to use to: If i have only chainsaw i can destroy tree, make tree like ped so when u chainsaw it only then it will destroys, to create it and after 20 min when it's destroyed it grows up again.

Thanks ;)

Link to comment

It's not really hard to make, all what you need is to create a ped and wood object then attach the ped into the wood by using attachElements,

and check if the ped got damaged by "Chainsaw" weapon or not.

After, If the ped is dead make the wood object move under the ground, use this function to make that moveObject.

So now you've the basic to make it, try that if you did something wrong post your code.

Note:

I suggest you to create the object server side, If you did it in client only the localPlayer who will be able to see it.

Link to comment

Okey so i created the Ped, Tree and then attached them, i dont know function to create if the ped is attacked with chainsaw then destroy tree, can u help me?

  
function tree() 
local ped = createPed ( 120, -353.5361328125, -426.357421875, 6.944408416748 ) 
local tree = createObject ( 618, -353.5361328125, -426.357421875, 6.944408416748, 0, 0, 0 ) 
setPedFrozen ( ped ) 
attachElements ( ped, tree, 0, 0, 0 ) 
  
end 
addEventHandler ( "onResourceStart", resourceRoot, tree ) 
  

Link to comment

Here you go,

local ped = createPed ( 120, -353.5361328125, -426.357421875, 6.944408416748 ) 
local tree = createObject ( 618, -353.5361328125, -426.357421875, 6.944408416748, 0, 0, 0 ) 
setPedFrozen ( ped ,true) 
attachElements ( ped, tree, 0, 0, 0 ) 
  
function onDamageTree(attacker,weapon) 
if attacker and isElement(attacker) and  getElementType(attacker) == "player" then  
if weapon and weapon == 9 then  
if (getElementHealth(ped) <= 0) then  
  --[[Your code.]] 
      end 
    end 
  end 
end 
addEventHandler("onPlayerDamage",getRootElement(),onDamageTree) 

Link to comment
Here you go,
local ped = createPed ( 120, -353.5361328125, -426.357421875, 6.944408416748 ) 
local tree = createObject ( 618, -353.5361328125, -426.357421875, 6.944408416748, 0, 0, 0 ) 
setPedFrozen ( ped ,true) 
attachElements ( ped, tree, 0, 0, 0 ) 
  
function onDamageTree(attacker,weapon) 
if attacker and isElement(attacker) and  getElementType(attacker) == "player" then  
if weapon and weapon == 9 then  
if (getElementHealth(ped) <= 0) then  
  --[[Your code.]] 
      end 
    end 
  end 
end 
addEventHandler("onPlayerDamage",getRootElement(),onDamageTree) 

Hmm, i cant kill ped, allways 100hp

Link to comment

Still doesnt work

local ped = createPed ( 120, -353.5361328125, -426.357421875, 6.944408416748 ) 
local tree = createObject ( 618, -353.5361328125, -426.357421875, 6.944408416748, 0, 0, 0 ) 
setElementFrozen ( ped ) 
attachElements ( ped, tree, 0, 0, 0 ) 
  
function onDamageTree(attacker,weapon) 
if attacker and isElement(attacker) and  getElementType(attacker) == "player" then 
if weapon and weapon == 9 then 
if (getElementHealth(ped) <= 0) then 
 object = createObject ( 618, -353.5361328125, -426.357421875, 12.944408416748, 0, 0, 0 ) 
      end 
    end 
  end 
end 
addEventHandler("onPlayerDamage",getRootElement(),onDamageTree) 

Link to comment

Attach onPedDamage only to the Ped.

onPlayerDamage gets triggered whenever a player gets hit, but yo are hitting a fed.

And use source instead of ped, then you can create many peds with rhe same event.

Then you dont destroy the tree or the ped.

If you damage the ped again there will be more created objects. You arent destroying the ped or asking if he already died once.

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