1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-11-18 00:08:25 +01:00

Updated pclasses with admin class

- Moved reserved_items into their class file
 - Added admin class for #139
This commit is contained in:
LeMagnesium 2015-07-28 16:14:51 +02:00
parent b87660cdb8
commit d491015a78
5 changed files with 43 additions and 8 deletions

24
mods/pclasses/admin.lua Executable file
View File

@ -0,0 +1,24 @@
-----------------
-- Admin class --
-----------------
--
-- https://github.com/MinetestForFun/minetest-minetestforfun-server/issues/139
--
pclasses.api.register_class("admin", {
determination = function(player)
return minetest.get_player_privs(player:get_player_name()).server
end,
on_assigned = function(pname)
minetest.chat_send_player(pname, "Hello admin.")
end
})
pclasses.api.reserve_item("admin", "3d_armor:helmet_admin")
pclasses.api.reserve_item("admin", "3d_armor:chestplate_admin")
pclasses.api.reserve_item("admin", "3d_armor:leggings_admin")
pclasses.api.reserve_item("admin", "3d_armor:boots_admin")
pclasses.api.reserve_item("admin", "shields:shields_admin")
pclasses.api.reserve_item("admin", "maptools:pick_admin")
pclasses.api.reserve_item("admin", "maptools:pick_admin_with_drops")

View File

@ -82,7 +82,17 @@ function pclasses.api.assign_class(player)
-- Starting from the most important class to the less one
local pname = player:get_player_name()
if pclasses.classes["hunter"].determination(player) then
if pclasses.classes["admin"].determination(player) then
if pclasses.api.get_player_class(pname) ~= "admin" then
if 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.api.set_player_class(pname, "admin")
pclasses.api.get_class_by_name("admin").on_assigned(pname)
end
elseif pclasses.classes["hunter"].determination(player) then
if pclasses.api.get_player_class(pname) ~= "hunter" then
if pclasses.api.get_class_by_name(pclasses.api.get_player_class(pname)).on_unassigned then
pclasses.api.get_class_by_name(pclasses.api.get_player_class(pname)).on_unassigned(pname)
@ -122,13 +132,6 @@ function pclasses.api.reserve_item(cname, itemstring)
table.insert(pclasses.datas.reserved_items[itemstring], 1, cname)
end
pclasses.api.reserve_item("warrior", "moreores:sword_mithril")
pclasses.api.reserve_item("warrior", "default:dungeon_master_s_blood_sword")
pclasses.api.reserve_item("hunter", "throwing:bow_minotaur_horn")
pclasses.api.reserve_item("hunter", "throwing:bow_minotaur_horn_improved")
minetest.register_globalstep(function(dtime)
for id, ref in ipairs(minetest.get_connected_players()) do
local name = ref:get_player_name()

View File

@ -26,3 +26,7 @@ pclasses.api.register_class("hunter", {
sprint.set_default_maxstamina(pname)
end,
})
pclasses.api.reserve_item("hunter", "throwing:bow_minotaur_horn")
pclasses.api.reserve_item("hunter", "throwing:bow_minotaur_horn_improved")

View File

@ -89,4 +89,5 @@ end
dofile(minetest.get_modpath("pclasses") .. "/warrior.lua")
dofile(minetest.get_modpath("pclasses") .. "/hunter.lua")
dofile(minetest.get_modpath("pclasses") .. "/admin.lua")

View File

@ -20,3 +20,6 @@ pclasses.api.register_class("warrior", {
sprint.set_default_maxstamina(pname)
end,
})
pclasses.api.reserve_item("warrior", "moreores:sword_mithril")
pclasses.api.reserve_item("warrior", "default:dungeon_master_s_blood_sword")