Page 1 of 1

Antigrief

Posted: Mon Jan 23, 2017 1:22 pm
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?

Re: Antigrief

Posted: Mon Jan 23, 2017 2:38 pm
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.

Re: Antigrief

Posted: Wed Feb 01, 2017 11:32 pm
by aubergine18