Page 1 of 1
Any way to get the player nickname?
Posted: Wed Jun 12, 2019 3:37 pm
by Plaigon
Hi guys,
I'm trying to send a custom message containing the player name but I don't see how to get it with a lua function. Do you guys have ever done such a thing? Thanks in advance!
Re: Any way to get the player nickname?
Posted: Wed Jun 12, 2019 5:58 pm
by Marth8880
What do you mean by "custom message"? Messages shown with "ShowMessageText" have to be localized.
As for the function, you could try one of these:
Code: Select all
ScriptCB_GetUniqueLoginName
ScriptCB_GetProfileName
ScriptCB_GetCurrentProfileName
ScriptCB_GetCurrentProfileNetName
Re: Any way to get the player nickname?
Posted: Thu Jun 13, 2019 5:03 am
by Plaigon
I'd like my map to be workable in multiplayer or on lan. So using this script won't work as the host name will be the only one to be sent to any player playing on the map.
I was searching a function like GetEntityName that could give me the player nickname? Any other solution? Thanks in advance!
Re: Any way to get the player nickname?
Posted: Thu Jun 13, 2019 2:56 pm
by Marth8880
Maps already do work in online and offline multiplayer. Are you having issues getting yours working?
Re: Any way to get the player nickname?
Posted: Fri Jun 14, 2019 3:03 pm
by Plaigon
No everything is finy, I was just wondering if there were any callbacks for getting the player nickname given its character index, you know like GetObjectHealth, etc... do? But it seems that doesn't exist.
By the way do you know if we this 2005 lua version can read a file given its path? I want to make a part of my campaign customizable by the player. He has to kill x jedi masters for one objective of the mission. And that x number should be adjustable in the .txt file (config file) that the lua script would read during the mission playing. Do you see what I mean? To make it short, can I use file:open? Becuz I tried file:close but that instruction makes the mod tools crash during the munging phase. Any idea? Thanks in advance!
Re: Any way to get the player nickname?
Posted: Sat Jun 15, 2019 9:45 am
by Marth8880
Unfortunately we do not have access to the i/o Lua library, so the only file system function we really have is ScriptCB_IsFileExist. One of my mods utilized this function to read settings from files created and renamed by an exterior configuration tool:
https://github.com/marth8880/MEUScripts ... gCheck.lua
Re: Any way to get the player nickname?
Posted: Sat Jun 15, 2019 6:49 pm
by Plaigon
Thanks but are you sure that the lua version used at this time (probably 4 or 5) couldn t handle file feature? I mean there is no way to import the lib in the mod tools? Because the Script has its own limits like being unable to write to the cfg file.
Re: Any way to get the player nickname?
Posted: Sat Jun 15, 2019 7:47 pm
by Marth8880
It's not that it couldn't handle it, it's that the library was explicitly removed by Pandemic - probably to prevent the ability to create malicious mods that could write hundreds of megabytes of junk data or something to a user's PC or something of the like.
Re: Any way to get the player nickname?
Posted: Sat Nov 23, 2019 8:01 pm
by [RDH]Zerted
v1.3's uf_processPlayers() will let you use a table of player names*. You could select a person and put an event marker on their unit, so it is possible to go from a player entry to their unit. You'll likely need GetTeamMember(). If in your script you put a 'if not host' check around the message you want to send then only the clients will process that code.
You can use the SaveAndLoadUtils scripts to save/load data in single player games. It uses the same pathways as the campiagn does to save your progress (metagame states).
Trying to display random text as a message was one of the first questions I asked and I don't think we've ever found a solution (if I'm wrong please enlighten me). You could pop-up a message with whatever you want but then the player would have to click way the prompt which would be really annoying if they were in the middle of a fight.
*---- Description ----
-- Calls the given function with a table argument of the ingame players
--
---- Parameters ----
-- A function to handle the table of ingame players
--
-- The format of the table is as follows:
-- table = {
-- { indexstr = "1", namestr = "Alpha"},
-- { indexstr = "2", namestr = "Bravo"},
-- { indexstr = "3", namestr = "Player 1"},
-- { indexstr = "4", namestr = "LastJoinedPlayer"},
-- }
--
---- Returns ----
-- (nothing)