mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-24 01:30:38 +01:00
Updated pclasses with admin class
- Moved reserved_items into their class file - Added admin class for #139
This commit is contained in:
parent
b87660cdb8
commit
d491015a78
24
mods/pclasses/admin.lua
Executable file
24
mods/pclasses/admin.lua
Executable 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")
|
@ -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()
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user