Automatically change skin if the one a player's wearing is removed
This commit is contained in:
parent
2f81629d2a
commit
e150f0034f
@ -8,6 +8,7 @@ Wear=Tragen
|
|||||||
##[ src/api.lua ]##
|
##[ src/api.lua ]##
|
||||||
You've unlocked the skin @1!=
|
You've unlocked the skin @1!=
|
||||||
Your skin @1 has been removed...=
|
Your skin @1 has been removed...=
|
||||||
|
The skin you were wearing has been removed from you. A default skin has been put instead=
|
||||||
|
|
||||||
##[ src/commands.lua ]##
|
##[ src/commands.lua ]##
|
||||||
Skin @1 doesn't exist!=
|
Skin @1 doesn't exist!=
|
||||||
|
@ -8,6 +8,7 @@ Wear=Usar
|
|||||||
##[ src/api.lua ]##
|
##[ src/api.lua ]##
|
||||||
You've unlocked the skin @1!=
|
You've unlocked the skin @1!=
|
||||||
Your skin @1 has been removed...=
|
Your skin @1 has been removed...=
|
||||||
|
The skin you were wearing has been removed from you. A default skin has been put instead=
|
||||||
|
|
||||||
##[ src/commands.lua ]##
|
##[ src/commands.lua ]##
|
||||||
Skin @1 doesn't exist!=
|
Skin @1 doesn't exist!=
|
||||||
|
@ -8,6 +8,7 @@ Wear=Viselni
|
|||||||
##[ src/api.lua ]##
|
##[ src/api.lua ]##
|
||||||
You've unlocked the skin @1!=
|
You've unlocked the skin @1!=
|
||||||
Your skin @1 has been removed...=
|
Your skin @1 has been removed...=
|
||||||
|
The skin you were wearing has been removed from you. A default skin has been put instead=
|
||||||
|
|
||||||
##[ src/commands.lua ]##
|
##[ src/commands.lua ]##
|
||||||
Skin @1 doesn't exist!=
|
Skin @1 doesn't exist!=
|
||||||
|
@ -8,6 +8,7 @@ Wear=Indossa
|
|||||||
##[ src/api.lua ]##
|
##[ src/api.lua ]##
|
||||||
You've unlocked the skin @1!=Hai sbloccato l'aspetto @1!
|
You've unlocked the skin @1!=Hai sbloccato l'aspetto @1!
|
||||||
Your skin @1 has been removed...=Ti è stato rimosso l'aspetto @1...
|
Your skin @1 has been removed...=Ti è stato rimosso l'aspetto @1...
|
||||||
|
The skin you were wearing has been removed from you. A default skin has been put instead=L'aspetto che stavi indossando ti è stato rimosso. Ora ne hai uno predefinito
|
||||||
|
|
||||||
##[ src/commands.lua ]##
|
##[ src/commands.lua ]##
|
||||||
Skin @1 doesn't exist!=Non esiste nessun aspetto @1!
|
Skin @1 doesn't exist!=Non esiste nessun aspetto @1!
|
||||||
|
@ -8,6 +8,7 @@ Wear=Ubierz
|
|||||||
##[ src/api.lua ]##
|
##[ src/api.lua ]##
|
||||||
You've unlocked the skin @1!=
|
You've unlocked the skin @1!=
|
||||||
Your skin @1 has been removed...=
|
Your skin @1 has been removed...=
|
||||||
|
The skin you were wearing has been removed from you. A default skin has been put instead=
|
||||||
|
|
||||||
##[ src/commands.lua ]##
|
##[ src/commands.lua ]##
|
||||||
Skin @1 doesn't exist!=
|
Skin @1 doesn't exist!=
|
||||||
|
@ -8,6 +8,7 @@ Wear=
|
|||||||
##[ src/api.lua ]##
|
##[ src/api.lua ]##
|
||||||
You've unlocked the skin @1!=
|
You've unlocked the skin @1!=
|
||||||
Your skin @1 has been removed...=
|
Your skin @1 has been removed...=
|
||||||
|
The skin you were wearing has been removed from you. A default skin has been put instead=
|
||||||
|
|
||||||
##[ src/commands.lua ]##
|
##[ src/commands.lua ]##
|
||||||
Skin @1 doesn't exist!=
|
Skin @1 doesn't exist!=
|
||||||
|
28
src/api.lua
28
src/api.lua
@ -177,7 +177,7 @@ end
|
|||||||
function collectible_skins.remove_skin(p_name, skin_name)
|
function collectible_skins.remove_skin(p_name, skin_name)
|
||||||
try_to_load_player(p_name)
|
try_to_load_player(p_name)
|
||||||
|
|
||||||
-- se la skin non esiste, annullo
|
-- se l'aspetto non esiste, annullo
|
||||||
if not loaded_skins[skin_name] then
|
if not loaded_skins[skin_name] then
|
||||||
collectible_skins.print_warning("There has been an attempt to remove player " .. p_name .. " a skin that doesn't exist (`" .. skin_name .. "`)!")
|
collectible_skins.print_warning("There has been an attempt to remove player " .. p_name .. " a skin that doesn't exist (`" .. skin_name .. "`)!")
|
||||||
return end
|
return end
|
||||||
@ -191,11 +191,24 @@ function collectible_skins.remove_skin(p_name, skin_name)
|
|||||||
if not collectible_skins.has_skin(p_name, skin_name) then return end
|
if not collectible_skins.has_skin(p_name, skin_name) then return end
|
||||||
|
|
||||||
local p_skins
|
local p_skins
|
||||||
|
local player = minetest.get_player_by_name(p_name)
|
||||||
|
|
||||||
-- se è online
|
-- se è online
|
||||||
if minetest.get_player_by_name(p_name) then
|
if player then
|
||||||
p_skins = players_skins[p_name]
|
p_skins = players_skins[p_name]
|
||||||
minetest.chat_send_player(p_name, S("Your skin @1 has been removed...", loaded_skins[skin_name].name))
|
minetest.chat_send_player(p_name, S("Your skin @1 has been removed...", loaded_skins[skin_name].name))
|
||||||
|
|
||||||
|
-- se ce l'aveva addosso, ne metto uno casuale tra i predefiniti
|
||||||
|
if equipped_skin[p_name] == skin_name then
|
||||||
|
for _, sk_name in ipairs(default_skins) do
|
||||||
|
if skin_name ~= sk_name and players_skins[p_name][sk_name] then
|
||||||
|
minetest.chat_send_player(p_name, S("The skin you were wearing has been removed from you. A default skin has been put instead"))
|
||||||
|
collectible_skins.set_skin(player, sk_name, true)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- se è offline
|
-- se è offline
|
||||||
else
|
else
|
||||||
p_skins = minetest.deserialize(storage:get_string(p_name))
|
p_skins = minetest.deserialize(storage:get_string(p_name))
|
||||||
@ -442,6 +455,17 @@ function load_player_data(player)
|
|||||||
players_skins[p_name] = minetest.deserialize(storage:get_string(p_name))
|
players_skins[p_name] = minetest.deserialize(storage:get_string(p_name))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- se l'aspetto che aveva lə è stato rimosso, ne metto uno casuale tra i predefiniti
|
||||||
|
if not players_skins[p_name][skin_name] then
|
||||||
|
for _, sk_name in ipairs(default_skins) do
|
||||||
|
if players_skins[p_name][sk_name] then
|
||||||
|
skin_name = sk_name
|
||||||
|
minetest.chat_send_player(p_name, S("The skin you were wearing has been removed from you. A default skin has been put instead"))
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
collectible_skins.set_skin(player, skin_name, false, true)
|
collectible_skins.set_skin(player, skin_name, false, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user