DzMG-LV Posted January 25, 2016 Share Posted January 25, 2016 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
KariiiM Posted January 25, 2016 Share Posted January 25, 2016 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
DzMG-LV Posted January 25, 2016 Author Share Posted January 25, 2016 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
DzMG-LV Posted January 25, 2016 Author Share Posted January 25, 2016 Script is on server side. Link to comment
KariiiM Posted January 25, 2016 Share Posted January 25, 2016 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
DzMG-LV Posted January 25, 2016 Author Share Posted January 25, 2016 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
ViRuZGamiing Posted January 25, 2016 Share Posted January 25, 2016 Don't know if it'll fix it but Setpedfrozen has to be setElementFrozen Link to comment
KariiiM Posted January 25, 2016 Share Posted January 25, 2016 Yes you've to change it to setElementFrozen because they're about to remove this function I think, but that won't fix it. Try to debug your code by any action and see what's going on then post the whole code. Link to comment
DzMG-LV Posted January 27, 2016 Author Share Posted January 27, 2016 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
Bonus Posted February 2, 2016 Share Posted February 2, 2016 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
KariiiM Posted February 2, 2016 Share Posted February 2, 2016 Bonus is totally right, but onPedDamage doesn't exist so, use onClientPedDamage atleast and logically we damage a ped not a player Link to comment
Bonus Posted February 2, 2016 Share Posted February 2, 2016 Bonus is totally right, but onPedDamage doesn't exist so, use onClientPedDamage atleast and logically we damage a ped not a player Oh, you are right 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