1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-12-24 17:50:37 +01:00

fix only play pclasses sound to player and only if player switch classes

This commit is contained in:
crabman77 2016-01-03 23:01:40 +01:00
parent 7621b867c3
commit e0ce022cac
7 changed files with 26 additions and 16 deletions

View File

@ -7,8 +7,10 @@
--
pclasses.api.register_class("admin", {
on_assigned = function(pname)
on_assigned = function(pname, inform)
if inform then
minetest.chat_send_player(pname, "Hello admin.")
end
end,
on_unassigned = function(pname)
end,

View File

@ -7,9 +7,11 @@
--
pclasses.api.register_class("hunter", {
on_assigned = function(pname)
on_assigned = function(pname, inform)
if inform then
minetest.chat_send_player(pname, "You are now a hunter")
minetest.sound_play("pclasses_full_hunter")
minetest.sound_play("pclasses_full_hunter", {to_player=pname, gain=1})
end
local reinforced = pclasses.api.util.does_wear_full_armor(pname, "reinforcedleather", true)
if reinforced then
sprint.increase_maxstamina(pname, 20)

View File

@ -7,9 +7,11 @@
--
pclasses.api.register_class("warrior", {
on_assigned = function(pname)
minetest.sound_play("pclasses_full_warrior")
on_assigned = function(pname, inform)
if inform then
minetest.sound_play("pclasses_full_warrior", {to_player=pname, gain=1})
minetest.chat_send_player(pname, "You are now a warrior")
end
sprint.set_maxstamina(pname, 20)
minetest.log("action", "[PClasses] Player " .. pname .. " becomes a warrior")
end,

View File

@ -7,9 +7,11 @@
--
pclasses.api.register_class("wizard", {
on_assigned = function(pname)
-- minetest.sound_play("pclasses_full_wizard")
on_assigned = function(pname, inform)
if inform then
-- minetest.sound_play("pclasses_full_wizard", {to_player=pname, gain=1})
minetest.chat_send_player(pname, "You are now a wizard.")
end
-- Add specs here
minetest.log("action", "[PClasses] Player " .. pname .. " becomes a wizard")
end,

View File

@ -8,8 +8,10 @@ pclasses.api.register_class("adventurer", {
tile = "wool_white.png",
holo_item = "unified_inventory:bag_large"
},
on_assigned = function(pname)
on_assigned = function(pname, inform)
if inform then
minetest.chat_send_player(pname, "You are now an adventurer")
end
end,
on_unassigned = function(pname)
end

View File

@ -48,13 +48,13 @@ function pclasses.api.get_class_players(cname)
end
-- Set single player
function pclasses.api.set_player_class(pname, cname)
function pclasses.api.set_player_class(pname, cname, inform)
if pclasses.api.get_class_by_name(cname) then
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)
pclasses.api.get_class_by_name(cname).on_assigned(pname, inform)
local ref = minetest.get_player_by_name(pname)
local armor_inv = minetest.get_inventory({type = "detached", name = pname .. "_armor"})

View File

@ -48,7 +48,7 @@ minetest.register_entity("pclasses:item", {
"class_switch_" .. clicker:get_player_name(),
3600,
pclasses.api.set_player_class,
{clicker:get_player_name(), self.class}
{clicker:get_player_name(), self.class, true}
)
end,
on_activate = function(self, staticdata)