Antigrief

Place to get help with not working mods / modding interface.
Kerasis
Manual Inserter
Manual Inserter
Posts: 4
Joined: Mon Jan 23, 2017 1:14 pm
Contact:

Antigrief

Post by Kerasis »

Hey there!

Im trying to figure out how to allow a player to deconstruct only his own buildings in a defined timespan.

Code: Select all

script.on_event(defines.events.on_marked_for_deconstruction, function(event)
local player = game.players[event.player_index]

	if not player.admin and ConvertMinutes(player.online_time) < ANTIGRIEF_TIMER then
		  event.entity.cancel_deconstruction("player")
		end
	end
now i wanted to compare the building owner (event.entity.last_user.name) to the player which is trying to deconstruct, but i am always getting the name of the actual player which is trying to deconstruct it. any idea how i can do this?
Articulating
Long Handed Inserter
Long Handed Inserter
Posts: 71
Joined: Mon Oct 17, 2016 10:33 am
Contact:

Re: Antigrief

Post by Articulating »

I'm not able to test (away from PC right now) but I suggest trying the on_player_selected_area event. You'll probably have to do some queue and on_tick stuff so you can cancel the deconstruction but I'm just assuming how the event works.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Antigrief

Post by aubergine18 »

Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Post Reply

Return to “Modding help”