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!
Any way to get the player nickname?
Moderator: Moderators
-
- Recruit Womprat Killer
- Posts: 13
- Joined: Fri Dec 14, 2018 6:22 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
-
- Resistance Leader
- Posts: 5042
- Joined: Tue Feb 09, 2010 8:43 pm
- Projects :: DI2 + Psychosis
- xbox live or psn: Marth8880
- Location: Edinburgh, UK
- Contact:
Re: Any way to get the player nickname?
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:
As for the function, you could try one of these:
Code: Select all
ScriptCB_GetUniqueLoginName
ScriptCB_GetProfileName
ScriptCB_GetCurrentProfileName
ScriptCB_GetCurrentProfileNetName
-
- Recruit Womprat Killer
- Posts: 13
- Joined: Fri Dec 14, 2018 6:22 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
Re: Any way to get the player nickname?
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!
I was searching a function like GetEntityName that could give me the player nickname? Any other solution? Thanks in advance!
-
- Resistance Leader
- Posts: 5042
- Joined: Tue Feb 09, 2010 8:43 pm
- Projects :: DI2 + Psychosis
- xbox live or psn: Marth8880
- Location: Edinburgh, UK
- Contact:
Re: Any way to get the player nickname?
Maps already do work in online and offline multiplayer. Are you having issues getting yours working?
-
- Recruit Womprat Killer
- Posts: 13
- Joined: Fri Dec 14, 2018 6:22 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
Re: Any way to get the player nickname?
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!
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!
-
- Resistance Leader
- Posts: 5042
- Joined: Tue Feb 09, 2010 8:43 pm
- Projects :: DI2 + Psychosis
- xbox live or psn: Marth8880
- Location: Edinburgh, UK
- Contact:
Re: Any way to get the player nickname?
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
-
- Recruit Womprat Killer
- Posts: 13
- Joined: Fri Dec 14, 2018 6:22 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
Re: Any way to get the player nickname?
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.
-
- Resistance Leader
- Posts: 5042
- Joined: Tue Feb 09, 2010 8:43 pm
- Projects :: DI2 + Psychosis
- xbox live or psn: Marth8880
- Location: Edinburgh, UK
- Contact:
Re: Any way to get the player nickname?
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.
- [RDH]Zerted
- Gametoast Staff
- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: Any way to get the player nickname?
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)
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)