Jump to content

[HELP] Remove breakable trees forever.


koragg

Recommended Posts

Hey guys, I want to remove the breakable trees mainly found at Back'O'Beyond's forests. I tried this code but they don't get removed, but when I output their IDs in the loop they do show up in chatbox and there're no errors in debug. Any idea how to permanently remove those small and annoying random trees? Server-side:

local trees = {
	[881] = true,
	[882] = true,
	[883] = true,
	[884] = true,
	[885] = true,
	[889] = true,
	[891] = true,
}
-------------------------------------------------------------------------------------------------------------------------
function onResourceStart()
	for key, value in pairs(trees) do
		removeWorldModel(key, 10000, 0, 0, 0, 0)
		removeWorldModel(key, 10000, 0, 0, 0, 13)
	end
end
addEventHandler("onResourceStart", resourceRoot, onResourceStart)

 

Link to comment
34 minutes ago, koragg said:

Hey guys, I want to remove the breakable trees mainly found at Back'O'Beyond's forests. I tried this code but they don't get removed, but when I output their IDs in the loop they do show up in chatbox and there're no errors in debug. Any idea how to permanently remove those small and annoying random trees? Server-side:


local trees = {
	[881] = true,
	[882] = true,
	[883] = true,
	[884] = true,
	[885] = true,
	[889] = true,
	[891] = true,
}
-------------------------------------------------------------------------------------------------------------------------
function onResourceStart()
	for key, value in pairs(trees) do
		removeWorldModel(key, 10000, 0, 0, 0, 0)
		removeWorldModel(key, 10000, 0, 0, 0, 13)
	end
end
addEventHandler("onResourceStart", resourceRoot, onResourceStart)

 

You can use this, this only works so long as the script is running. There's no way to permanently remove the trees, but what you could do is put this in a script and put the script in auto launch in the mta server config.

local trees = {881,882,883,884,885,889,891}

addEventHandler('onResourceStart',resourceRoot,function()
	for i=1,#trees do
		removeWorldModel(trees[i],10000,0,0,0,0)
		removeWorldModel(trees[i],10000,0,0,0,13)
	end
end)


 

Link to comment
Just now, MadnessReloaded said:

Seen no errors at first glance, but I tried the script in a local server anyway just to be sure and it works just fine.

 

 

The trees are removed? How?!? I tried it at my server as well and they were still there.

2 minutes ago, ShayF said:

You can use this, this only works so long as the script is running. There's no way to permanently remove the trees, but what you could do is put this in a script and put the script in auto launch in the mta server config.


local trees = {881,882,883,884,885,889,891}

addEventHandler('onResourceStart',resourceRoot,function()
	for i=1,#trees do
		removeWorldModel(trees[i],10000,0,0,0,0)
		removeWorldModel(trees[i],10000,0,0,0,13)
	end
end)


 

Isn't this the same as what I've done but just done in another 'for' loop way? And yes, by permanently I meant as long as the script is running :)

Link to comment
1 minute ago, koragg said:

The trees are removed? How?!? I tried it at my server as well and they were still there.

Isn't this the same as what I've done but just done in another 'for' loop way? And yes, by permanently I meant as long as the script is running :)

I've compacted your code for you, removing any unnecessary things. I always do this with code, so nothing to worry about. I hope it helps.

  • Like 1
Link to comment
4 minutes ago, koragg said:

The trees are removed? How?!? I tried it at my server as well and they were still there.

Haven't tried with the trees, but with other objects. The code works, so it's probably MTA or models' fault.

Edited by MadnessReloaded
  • Like 1
  • Sad 1
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...