1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-12-25 02:00:37 +01:00
remove old fix(itemdrop timer,now useless)
This commit is contained in:
crabman77 2016-03-05 16:37:10 +01:00
parent 5b926f753c
commit c54bdbef03
3 changed files with 109 additions and 128 deletions

View File

@ -181,13 +181,27 @@ minetest.register_on_joinplayer(function(player)
beds.read_spawns() beds.read_spawns()
end) end)
-- respawn player at bed if enabled and valid position is found
minetest.register_on_respawnplayer(function(player) local dead_players = {}
--MFF DEBUT crabman(8/01/2016 ) respawn player in special area(event) if a spawn is set. local have_areas_mod = false
if ((minetest.get_modpath("areas") ~= nil) and (areas:onRespawn(player))) then if (minetest.get_modpath("areas") ~= nil) and areas.getSpawn then
return true have_areas_mod = true
end end
local function teleport_player(player, clear)
local name = player:get_player_name()
if not name or name == "" then return false end
if have_areas_mod and dead_players[name] ~= nil then
local pos = areas:getSpawn(dead_players[name])
if clear then
dead_players[name] = nil
end
if pos then
player:setpos(pos)
return true
end
end
if not enable_respawn then if not enable_respawn then
return false return false
end end
@ -197,8 +211,31 @@ minetest.register_on_respawnplayer(function(player)
player:setpos(pos) player:setpos(pos)
return true return true
end end
--if not areas or bed spawnpoint, tp to the spawn
local spawn = minetest.string_to_pos(minetest.setting_get("static_spawnpoint") or "0,0,0")
player:setpos(spawn)
return false
end
minetest.register_on_dieplayer(function(player)
local name = player:get_player_name()
if not name or name == "" then return end
if have_areas_mod then
local pos = player:getpos()
if pos then
dead_players[name] = pos
end
end
minetest.after(0.20, teleport_player, player) -- tp after all others on_dieplayer callback otherwise their pos is wrong
end) end)
-- respawn player at bed if enabled and valid position is found
minetest.register_on_respawnplayer(function(player)
return teleport_player(player, true)
end)
minetest.register_on_leaveplayer(function(player) minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name() local name = player:get_player_name()
lay_down(player, nil, nil, false, true) lay_down(player, nil, nil, false, true)

View File

@ -162,32 +162,13 @@ function areas:canMakeArea(pos1, pos2, name) --MFF crabman(25/02/2016) fix areas
end end
--MFF DEBUT crabman(17/09/2015 ) respawn player in special area(event) if a spawn is set. --MFF crabman(5/03/2016 ) return special area pos if a spawn is set.
--1 party (2 party in beds mod) --1 party (2 party in beds mod)
local dead_players = {} function areas:getSpawn(pos)
minetest.register_on_dieplayer(function(player)
local player_name = player:get_player_name()
if not player_name then return end
local pos = player:getpos()
if pos then
dead_players[player_name] = pos
end
end)
function areas:onRespawn(player)
local player_name = player:get_player_name()
if not player_name or not dead_players[player_name] then return false end
local pos = dead_players[player_name]
dead_players[player_name] = nil
if pos then
for _, area in pairs(areas:getAreasAtPos(pos)) do for _, area in pairs(areas:getAreasAtPos(pos)) do
if area.spawn then if area.spawn and area.spawn.x then
player:setpos(area.spawn) return area.spawn
return true
end end
end end
return nil
end end
return false
end
--FIN

View File

@ -4,36 +4,6 @@ local creative_mode = minetest.setting_getbool("creative_mode")
local TICK_UPDATE = 0.1 local TICK_UPDATE = 0.1
local die_timeout = 20
local die_time = {}
local die_respawned = {}
minetest.register_on_joinplayer(function(player)
local player_name = player:get_player_name()
die_time[player_name] = 0
die_respawned[player_name] = false
end)
minetest.register_on_leaveplayer(function(player)
local player_name = player:get_player_name()
die_time[player_name] = nil
die_respawned[player_name] = nil
end)
minetest.register_on_dieplayer(function(player)
local player_name = player:get_player_name()
if not player_name then return end
die_respawned[player_name] = false
die_time[player_name] = die_timeout
end)
minetest.register_on_respawnplayer(function(player)
local player_name = player:get_player_name()
if not player_name then return end
die_respawned[player_name] = true
end)
-- Following edits by gravgun -- Following edits by gravgun
item_drop.drop_callbacks = {} item_drop.drop_callbacks = {}
@ -67,8 +37,6 @@ local pickup_inv_duration = 1/pickup_duration*0.7
local function tick() local function tick()
local tstamp = minetest.get_us_time() local tstamp = minetest.get_us_time()
for _,player in ipairs(minetest.get_connected_players()) do for _,player in ipairs(minetest.get_connected_players()) do
local player_name = player:get_player_name()
if die_time[player_name] and die_time[player_name] < 1 then
if player:get_hp() > 0 or not enable_damage then if player:get_hp() > 0 or not enable_damage then
local pos = player:getpos() local pos = player:getpos()
pos.y = pos.y + player_half_height pos.y = pos.y + player_half_height
@ -140,11 +108,6 @@ local function tick()
end end
end end
end end
else
if die_respawned[player_name] then
die_time[player_name] = (die_time[player_name] or die_timeout) - TICK_UPDATE
end
end
end end
minetest.after(TICK_UPDATE, tick) minetest.after(TICK_UPDATE, tick)
end end