Any way to get the player nickname?

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Recruit Womprat Killer
Posts: 12
Joined: Fri Dec 14, 2018 6:22 pm
Projects :: No Mod project currently.
Games I'm Playing :: SWBF2
xbox live or psn: No gamertag set

Any way to get the player nickname?

Postby Plaigon » Wed Jun 12, 2019 3:37 pm

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!

Resistance Leader
User avatar
Posts: 5243
Joined: Tue Feb 09, 2010 8:43 pm
Location: Edinburgh, UK
Projects :: EVERYWHERE + Project Infiltrator
Games I'm Playing :: The Forest
xbox live or psn: Marth8880

Re: Any way to get the player nickname?

Postby Marth8880 » Wed Jun 12, 2019 5:58 pm

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

Recruit Womprat Killer
Posts: 12
Joined: Fri Dec 14, 2018 6:22 pm
Projects :: No Mod project currently.
Games I'm Playing :: SWBF2
xbox live or psn: No gamertag set

Re: Any way to get the player nickname?

Postby Plaigon » Thu Jun 13, 2019 5:03 am

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!

Resistance Leader
User avatar
Posts: 5243
Joined: Tue Feb 09, 2010 8:43 pm
Location: Edinburgh, UK
Projects :: EVERYWHERE + Project Infiltrator
Games I'm Playing :: The Forest
xbox live or psn: Marth8880

Re: Any way to get the player nickname?

Postby Marth8880 » Thu Jun 13, 2019 2:56 pm

Maps already do work in online and offline multiplayer. Are you having issues getting yours working?

Recruit Womprat Killer
Posts: 12
Joined: Fri Dec 14, 2018 6:22 pm
Projects :: No Mod project currently.
Games I'm Playing :: SWBF2
xbox live or psn: No gamertag set

Re: Any way to get the player nickname?

Postby Plaigon » Fri Jun 14, 2019 3:03 pm

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!

Resistance Leader
User avatar
Posts: 5243
Joined: Tue Feb 09, 2010 8:43 pm
Location: Edinburgh, UK
Projects :: EVERYWHERE + Project Infiltrator
Games I'm Playing :: The Forest
xbox live or psn: Marth8880

Re: Any way to get the player nickname?

Postby Marth8880 » Sat Jun 15, 2019 9:45 am

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: 12
Joined: Fri Dec 14, 2018 6:22 pm
Projects :: No Mod project currently.
Games I'm Playing :: SWBF2
xbox live or psn: No gamertag set

Re: Any way to get the player nickname?

Postby Plaigon » Sat Jun 15, 2019 6:49 pm

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
User avatar
Posts: 5243
Joined: Tue Feb 09, 2010 8:43 pm
Location: Edinburgh, UK
Projects :: EVERYWHERE + Project Infiltrator
Games I'm Playing :: The Forest
xbox live or psn: Marth8880

Re: Any way to get the player nickname?

Postby Marth8880 » Sat Jun 15, 2019 7:47 pm

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.

Return to SWBF2 Modding

Who is online

Users browsing this forum: No registered users and 1 guest