1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-11-05 10:00:26 +01:00

fix pclasse assign now others class on join server, no only the default

fix pclasse assign now if class is same, bug on join server
add on_unassigned for all class
This commit is contained in:
crabman77 2015-12-24 20:36:17 +01:00
parent 6db59ee981
commit 482329bf1d
5 changed files with 27 additions and 19 deletions

View File

@ -10,6 +10,8 @@ pclasses.api.register_class("admin", {
on_assigned = function(pname)
minetest.chat_send_player(pname, "Hello admin.")
end,
on_unassigned = function(pname)
end,
switch_params = {
color = {r = 255, g = 00, b = 224},
holo_item = "maptools:pick_admin"

View File

@ -13,6 +13,8 @@ pclasses.api.register_class("wizard", {
-- Add specs here
minetest.log("action", "[PClasses] Player " .. pname .. " becomes a wizard")
end,
on_unassigned = function(pname)
end,
switch_params = {
color = {r = 230, g = 230, b = 0},
holo_item = "default:book"

View File

@ -10,6 +10,8 @@ pclasses.api.register_class("adventurer", {
},
on_assigned = function(pname)
minetest.chat_send_player(pname, "You are now an adventurer")
end,
on_unassigned = function(pname)
end
})

View File

@ -50,23 +50,21 @@ end
-- Set single player
function pclasses.api.set_player_class(pname, cname)
if pclasses.api.get_class_by_name(cname) then
if pclasses.api.get_player_class(pname) ~= cname then
if pclasses.api.get_player_class(pname) and pclasses.classes[pclasses.api.get_player_class(pname)].on_unassigned then
pclasses.api.get_class_by_name(pclasses.api.get_player_class(pname)).on_unassigned(pname)
end
pclasses.data.players[pname] = cname
pclasses.api.get_class_by_name(cname).on_assigned(pname)
local ref = minetest.get_player_by_name(pname)
local armor_inv = minetest.get_inventory({type = "detached", name = pname .. "_armor"})
local inv = ref:get_inventory()
vacuum_inventory(pname, inv, "armor", true)
vacuum_inventory(pname, armor_inv, "armor", false) -- Don't move to the graveyard
armor:set_player_armor(ref)
armor:update_inventory(ref)
pclasses.api.vacuum_graveyard(minetest.get_player_by_name(pname))
if pclasses.api.get_player_class(pname) then
pclasses.api.get_class_by_name(pclasses.api.get_player_class(pname)).on_unassigned(pname)
end
pclasses.data.players[pname] = cname
pclasses.api.get_class_by_name(cname).on_assigned(pname)
local ref = minetest.get_player_by_name(pname)
local armor_inv = minetest.get_inventory({type = "detached", name = pname .. "_armor"})
local inv = ref:get_inventory()
vacuum_inventory(pname, inv, "armor", true)
vacuum_inventory(pname, armor_inv, "armor", false) -- Don't move to the graveyard
armor:set_player_armor(ref)
armor:update_inventory(ref)
pclasses.api.vacuum_graveyard(minetest.get_player_by_name(pname))
return true
end
return false

View File

@ -75,10 +75,14 @@ end
minetest.register_on_joinplayer(function(player)
local pname = player:get_player_name()
if pclasses.api.get_class_by_name(pclasses.conf.default_class) and pclasses.api.get_player_class(pname) == nil then
pclasses.api.set_player_class(pname, pclasses.conf.default_class)
pclasses.api.create_graveyard_inventory(player) --create inventory before
local cname = pclasses.api.get_player_class(pname)
if cname ~= nil and pclasses.api.get_class_by_name(cname) then
pclasses.api.set_player_class(pname, cname)
elseif pclasses.api.get_class_by_name(pclasses.conf.default_class) then
pclasses.api.set_player_class(pname, pclasses.conf.default_class)
end
pclasses.api.create_graveyard_inventory(player)
end)
minetest.register_on_shutdown(function()