Added on_quit, on_eliminate and on_kick callbacks

master
Zughy 2020-05-19 01:46:30 +02:00
parent 5736c56cf9
commit 221f4f5a22
4 changed files with 53 additions and 7 deletions

26
api.lua
View File

@ -719,7 +719,10 @@ end
function arena_lib.remove_player_from_arena(p_name, is_eliminated)
function arena_lib.remove_player_from_arena(p_name, reason)
-- reason 1 = has been eliminated
-- reason 2 = has been kicked
-- reason 3 = has quit
local mod, arena_ID
@ -749,17 +752,32 @@ function arena_lib.remove_player_from_arena(p_name, is_eliminated)
arena_lib.update_sign(arena.sign, arena)
-- se è eliminato, lo teletrasporto fuori dall'arena e ripristino il nome
if is_eliminated then
if reason ~= nil then
local player = minetest.get_player_by_name(p_name)
player:set_pos(mod_ref.hub_spawn_point)
player:set_nametag_attributes({color = {a = 255, r = 255, g = 255, b = 255}})
arena_lib.send_message_players_in_arena(arena, minetest.colorize("#f16a54", "<<< " .. S("@1 has been eliminated", p_name)))
if reason == 1 then
arena_lib.send_message_players_in_arena(arena, minetest.colorize("#f16a54", "<<< " .. S("@1 has been eliminated", p_name)))
if mod_ref.on_eliminate then
mod_ref.on_eliminate(p_name)
end
elseif reason == 2 then
arena_lib.send_message_players_in_arena(arena, minetest.colorize("#f16a54", "<<< " .. S("@1 has been kicked", p_name)))
if mod_ref.on_kick then
mod_ref.on_kick(p_name)
end
elseif reason == 3 then
arena_lib.send_message_players_in_arena(arena, minetest.colorize("#d69298", "<<< " .. S("@1 has quit the arena", p_name)))
if mod_ref.on_quit then
mod_ref.on_quit(p_name)
end
end
else
--TODO: considerare se rimuovere questo avviso dato che il server avvisa di base i giocatori
arena_lib.send_message_players_in_arena(arena, minetest.colorize("#f16a54", "<<< " .. p_name ))
-- TODO: ELSEIF quitta then codice colore d69298. Considerare anche se rimuovere del tutto else precedente dato che il gioco avvisa di default
end
local players_in_arena = arena.players_amount

View File

@ -1,3 +1,5 @@
-- Arena phases
function arena_lib.on_load(mod, func)
arena_lib.mods[mod].on_load = func
end
@ -28,6 +30,28 @@ end
-- Events taking place inside the arena
function arena_lib.on_death(mod, func)
arena_lib.mods[mod].on_death = func
end
-- Leaving the arena
function arena_lib.on_eliminate(mod, func)
arena_lib.mods[mod].on_eliminate = func
end
function arena_lib.on_kick(mod, func)
arena_lib.mods[mod].on_kick = func
end
function arena_lib.on_quit(mod, func)
arena_lib.mods[mod].on_quit = func
end

View File

@ -1,4 +1,4 @@
# version 2.6.0
# version 2.7.0
# author(s): Zughy
# reviewer(s):
# textdomain: arena_lib
@ -30,6 +30,8 @@ Arena successfully enabled=Arena abilitata con successo
Arena @1 successfully disabled=Arena @1 disabilitata con successo
@1 wins the game=@1 ha vinto la partita
@1 has been eliminated=@1 è stato eliminato
@1 has been kicked=@1 è stato cacciato
@1 has quit the arena=@1 ha abbandonato l'arena
# TODO: quit option | @1 has left the game=@1 ha abbandonato la partita
Waiting for more players...=In attesa di più giocatori...
The queue has been cancelled due to not enough players=La coda è stata annullata per troppi pochi giocatori

View File

@ -1,4 +1,4 @@
# version 2.6.0
# version 2.7.0
# author(s):
# reviewer(s):
# textdomain: arena_lib
@ -30,7 +30,9 @@ Arena successfully enabled=
Arena @1 successfully disabled=
@1 wins the game=
@1 has been eliminated=
# TODO: quit option | @1 has left the game=
@1 has been kicked=
@1 has quit the arena=
@1 has left the game=
Waiting for more players...=
The queue has been cancelled due to not enough players=
You're the last player standing: you win!=