noanshadow 7 Report post Posted December 27, 2021 does anyone know or have the function to count how many players are inside a map? Quote Share this post Link to post Share on other sites
V3ct0r 2,121 Report post Posted December 28, 2021 Hello @noanshadow! Add this variable to the file variable.lua: entrydata = entrydata or {} Write the following script to the file functions.lua: SetMapEntryEventName__Original = SetMapEntryEventName SetMapEntryEventName = function(entry, name) -- Call the original function SetMapEntryEventName__Original(entry, name) -- Save the portal descriptor map_name, posx, posy, tmap_name = GetMapEntryPosInfo(entry) entrydata[tmap_name] = entry end function SetPortalName(map, name) if ( entrydata[map] ~= nil ) then SetMapEntryEventName__Original(entrydata[map], name) end end Open the file ctrl.lua of the map and write some code: function after_enter_<map_name>(role, map_copy) SetPortalName("<map_name>", string.format("%d player(s) inside", GetMapActivePlayer(map_copy))) end function before_leave_<map_name>(role) SetPortalName("<map_name>", string.format("%d player(s) inside", GetMapActivePlayer(GetChaMapCopу(role)) - 1)) end Where <map_name> is the name of the map, for example, garner2. The solution is based on @x3w0r's example from this topic: Note: not tested. 1 Quote Some useful links / Полезные ссылки Tips for making a topic in 'Questions & Help' / Рекомендации по созданию тем в разделе "Помощь" Server Advertising Section Rules / Правила раздела "Реклама серверов" Available e-mail domains for registration / Допустимые e-mail домены для регистрации User groups / Группы пользователей User ranks / Звания пользователей "Broken" pictures on the forum / "Битые" изображения на форуме Beware of scammers! / Осторожно, мошенники! My developments / Мои разработки Mods for client and server / Моды для клиента и сервера PKOdev.NET website for Tales of Pirates Server / PKOdev.NET веб-обвязка для сервера Пиратии I do not provide any help in private messages and outside the forum. Use 'Questions & Help' section please. Thank you for understanding! Я не оказываю какую-либо помощь в личных сообщениях и вне форума. Пожалуйста, используйте раздел "Пиратия: Помощь". Благодарю за понимание! Share this post Link to post Share on other sites
AlGhoul 66 Report post Posted December 28, 2021 12 hours ago, V3ct0r said: function after_enter_<map_name>(role, map_copy) SetPortalName("<map_name>", string.format("%d player(s) inside", GetMapActivePlayer(map_copy))) end function before_leave_<map_name>(role) SetPortalName("<map_name>", string.format("%d player(s) inside", GetMapActivePlayer(GetChaMapCopу(role)))) end this is redundant, you only need those in functions.lua local entrydata = entrydata or {} SetMapEntryEventNameHook = SetMapEntryEventName function SetMapEntryEventName(entry, name) SetMapEntryEventNameHook(entry, name) map_name, posx, posy, tmap_name = GetMapEntryPosInfo(entry) entrydata[tmap_name] = entry end function GetEntryDataByName(map) return entrydata[map] end function SetPortalName(map, name) local entry = GetEntryDataByName(map) if entry ~= nil then SetMapEntryEventName(entry, name) end end and in map_copy_run_<map_name> SetPortalName("puzzleworld", "Demonic World - Survivors: " .. GetMapActivePlayer(map_copy) .. "") the most important part is the following, you collect the entry data by calling the following code inside function after_create_entry(entry) SetMapEntryEventName(entry, EntryName) "puzzle world" is just an example, replace it with ur map name, Quote Kind regards, AG. Share this post Link to post Share on other sites
V3ct0r 2,121 Report post Posted December 29, 2021 9 hours ago, J0k3r said: this is redundant, you only need those in functions.lua Your code will be called every second even if the number of players have not changed. My one only when the player enters or exits the map, when it is really necessary. 1 Quote Some useful links / Полезные ссылки Tips for making a topic in 'Questions & Help' / Рекомендации по созданию тем в разделе "Помощь" Server Advertising Section Rules / Правила раздела "Реклама серверов" Available e-mail domains for registration / Допустимые e-mail домены для регистрации User groups / Группы пользователей User ranks / Звания пользователей "Broken" pictures on the forum / "Битые" изображения на форуме Beware of scammers! / Осторожно, мошенники! My developments / Мои разработки Mods for client and server / Моды для клиента и сервера PKOdev.NET website for Tales of Pirates Server / PKOdev.NET веб-обвязка для сервера Пиратии I do not provide any help in private messages and outside the forum. Use 'Questions & Help' section please. Thank you for understanding! Я не оказываю какую-либо помощь в личных сообщениях и вне форума. Пожалуйста, используйте раздел "Пиратия: Помощь". Благодарю за понимание! Share this post Link to post Share on other sites
squaller 21 Report post Posted December 29, 2021 9 hours ago, J0k3r said: this is redundant, you only need those in functions.lua local entrydata = entrydata or {} SetMapEntryEventNameHook = SetMapEntryEventName function SetMapEntryEventName(entry, name) SetMapEntryEventNameHook(entry, name) map_name, posx, posy, tmap_name = GetMapEntryPosInfo(entry) entrydata[tmap_name] = entry end function GetEntryDataByName(map) return entrydata[map] end function SetPortalName(map, name) local entry = GetEntryDataByName(map) if entry ~= nil then SetMapEntryEventName(entry, name) end end and in map_copy_run_<map_name> SetPortalName("puzzleworld", "Demonic World - Survivors: " .. GetMapActivePlayer(map_copy) .. "") the most important part is the following, you collect the entry data by calling the following code inside function after_create_entry(entry) SetMapEntryEventName(entry, EntryName) "puzzle world" is just an example, replace it with ur map name, your code bugs the server after some time . the v3ctor ones not. Quote Share this post Link to post Share on other sites
AlGhoul 66 Report post Posted December 29, 2021 44 minutes ago, squaller said: your code bugs the server after some time . the v3ctor ones not. funny enough, it is the same just the function called differently. 55 minutes ago, V3ct0r said: Your code will be called every second even if the number of players have not changed. My one only when the player enters or exits the map, when it is really necessary. sure, except the fact that before_leave_<map_name>() won't be called on player relog/closing the game, thus the count will be stuck until another player leaves "for real". Quote Kind regards, AG. Share this post Link to post Share on other sites
V3ct0r 2,121 Report post Posted December 29, 2021 1 hour ago, J0k3r said: sure, except the fact that before_leave_<map_name>() won't be called on player relog/closing the game, thus the count will be stuck until another player leaves "for real". It is called. Quote Some useful links / Полезные ссылки Tips for making a topic in 'Questions & Help' / Рекомендации по созданию тем в разделе "Помощь" Server Advertising Section Rules / Правила раздела "Реклама серверов" Available e-mail domains for registration / Допустимые e-mail домены для регистрации User groups / Группы пользователей User ranks / Звания пользователей "Broken" pictures on the forum / "Битые" изображения на форуме Beware of scammers! / Осторожно, мошенники! My developments / Мои разработки Mods for client and server / Моды для клиента и сервера PKOdev.NET website for Tales of Pirates Server / PKOdev.NET веб-обвязка для сервера Пиратии I do not provide any help in private messages and outside the forum. Use 'Questions & Help' section please. Thank you for understanding! Я не оказываю какую-либо помощь в личных сообщениях и вне форума. Пожалуйста, используйте раздел "Пиратия: Помощь". Благодарю за понимание! Share this post Link to post Share on other sites
squaller 21 Report post Posted December 31, 2021 This happen after using this Quote Share this post Link to post Share on other sites
V3ct0r 2,121 Report post Posted January 1, 2022 Hello @squaller! Can you tell how to repeat the bug? Quote Some useful links / Полезные ссылки Tips for making a topic in 'Questions & Help' / Рекомендации по созданию тем в разделе "Помощь" Server Advertising Section Rules / Правила раздела "Реклама серверов" Available e-mail domains for registration / Допустимые e-mail домены для регистрации User groups / Группы пользователей User ranks / Звания пользователей "Broken" pictures on the forum / "Битые" изображения на форуме Beware of scammers! / Осторожно, мошенники! My developments / Мои разработки Mods for client and server / Моды для клиента и сервера PKOdev.NET website for Tales of Pirates Server / PKOdev.NET веб-обвязка для сервера Пиратии I do not provide any help in private messages and outside the forum. Use 'Questions & Help' section please. Thank you for understanding! Я не оказываю какую-либо помощь в личных сообщениях и вне форума. Пожалуйста, используйте раздел "Пиратия: Помощь". Благодарю за понимание! Share this post Link to post Share on other sites
AlGhoul 66 Report post Posted January 2, 2022 (edited) On 12/29/2021 at 9:04 AM, V3ct0r said: It is called. sure my bad, but anyways the counter doesn't decrement if the player relog/exits the game, I think it is GetMapCopy? I'm not sure haven't really checked for all the errors/flow of the code, just letting you know that ur solution doesn't work in some cases. -- EDIT however the one I posted works correctly, regardless of it being called every second or whatsoever I know performance is a thing to consider tho. Edited January 2, 2022 by J0k3r Quote Kind regards, AG. Share this post Link to post Share on other sites
V3ct0r 2,121 Report post Posted January 2, 2022 5 hours ago, J0k3r said: sure my bad, but anyways the counter doesn't decrement if the player relog/exits the game, I think it is GetMapCopy? I'm not sure haven't really checked for all the errors/flow of the code, just letting you know that ur solution doesn't work in some cases. -- EDIT however the one I posted works correctly, regardless of it being called every second or whatsoever I know performance is a thing to consider tho. Hello @J0k3r! Yes, there was a mistake in the code here: function before_leave_<map_name>(role) SetPortalName("<map_name>", string.format("%d player(s) inside", GetMapActivePlayer(GetChaMapCopу(role)))) end Should be: function before_leave_<map_name>(role) SetPortalName("<map_name>", string.format("%d player(s) inside", GetMapActivePlayer(GetChaMapCopу(role)) - 1)) end 1 Quote Some useful links / Полезные ссылки Tips for making a topic in 'Questions & Help' / Рекомендации по созданию тем в разделе "Помощь" Server Advertising Section Rules / Правила раздела "Реклама серверов" Available e-mail domains for registration / Допустимые e-mail домены для регистрации User groups / Группы пользователей User ranks / Звания пользователей "Broken" pictures on the forum / "Битые" изображения на форуме Beware of scammers! / Осторожно, мошенники! My developments / Мои разработки Mods for client and server / Моды для клиента и сервера PKOdev.NET website for Tales of Pirates Server / PKOdev.NET веб-обвязка для сервера Пиратии I do not provide any help in private messages and outside the forum. Use 'Questions & Help' section please. Thank you for understanding! Я не оказываю какую-либо помощь в личных сообщениях и вне форума. Пожалуйста, используйте раздел "Пиратия: Помощь". Благодарю за понимание! Share this post Link to post Share on other sites
gunnapong 14 Report post Posted May 23, 2022 (edited) On 1/2/2022 at 5:22 PM, V3ct0r said: Hello @J0k3r! Yes, there was a mistake in the code here: function before_leave_<map_name>(role) SetPortalName("<map_name>", string.format("%d player(s) inside", GetMapActivePlayer(GetChaMapCopу(role)))) end Should be: function before_leave_<map_name>(role) SetPortalName("<map_name>", string.format("%d player(s) inside", GetMapActivePlayer(GetChaMapCopу(role)) - 1)) end like having a problem with GetChaMapCopy Error Gameserver If I delete GetChaMapCopу Gameserver no problem, how to fix it? Edited May 23, 2022 by gunnapong Quote Share this post Link to post Share on other sites
V3ct0r 2,121 Report post Posted May 24, 2022 Hello @gunnapong, There is a weird error in GetChaMapCopy word above. Try this code: function before_leave_<map_name>(role) SetPortalName("<map_name>", string.format("%d player(s) inside", GetMapActivePlayer(GetChaMapCopy(role)) - 1)) end Quote Some useful links / Полезные ссылки Tips for making a topic in 'Questions & Help' / Рекомендации по созданию тем в разделе "Помощь" Server Advertising Section Rules / Правила раздела "Реклама серверов" Available e-mail domains for registration / Допустимые e-mail домены для регистрации User groups / Группы пользователей User ranks / Звания пользователей "Broken" pictures on the forum / "Битые" изображения на форуме Beware of scammers! / Осторожно, мошенники! My developments / Мои разработки Mods for client and server / Моды для клиента и сервера PKOdev.NET website for Tales of Pirates Server / PKOdev.NET веб-обвязка для сервера Пиратии I do not provide any help in private messages and outside the forum. Use 'Questions & Help' section please. Thank you for understanding! Я не оказываю какую-либо помощь в личных сообщениях и вне форума. Пожалуйста, используйте раздел "Пиратия: Помощь". Благодарю за понимание! Share this post Link to post Share on other sites