Author Topic: Retrieve players profile name and active campaign  (Read 1562 times)

0 Members and 1 Guest are viewing this topic.

Offline Luke

Retrieve players profile name and active campaign
Hi

Like the topic says, is it possible?

In documentation i found "getName()" and "getCampaignFilename()", but i am not sure if this are the correct functions and i don't know how i must use this. This functions need a "player handle" but in the FSO LUA docu i found nothing about this.

Any ideas?

 

Offline niffiwan

  • 211
  • Eluder Class
Re: Retrieve players profile name and active campaign
They look like the correct functions to me.  I think you need to use them like this:

Code: (data/tables/somefile-sct.tbm) [Select]
#Conditional Hooks

$Application: FS2_Open

$On Game Init:
[
player_name = ""
player_campaign_file = ""
]

$State: GS_STATE_GAME_PLAY
$On State Start:
[
player_name = hv.Player:getName()
player_campaign_file = hv.Player:getCampaignFilename()
]

$On HUD Draw:
[
if hu.HUDDrawn == true then
    gr.drawString(player_name)
    gr.drawString(player_campaign_file)
end
]

#End
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

 

Offline m!m

  • 211
Re: Retrieve players profile name and active campaign
I don't think that is going to work as hv.Player is a ship handle and not the player handle.
Actually I haven't found any point in the code where a player handle is ever created for the scripting system which means that it's impossible to get a player handle at the moment.

 

Offline niffiwan

  • 211
  • Eluder Class
Re: Retrieve players profile name and active campaign
Yeah, you're right, my suggested script doesn't work at all.  I should have tested it before posting  :nervous:
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

 

Offline Luke

Re: Retrieve players profile name and active campaign
Ok, thanks anyway.

 

Offline m!m

  • 211
Re: Retrieve players profile name and active campaign
I'll see if I can get around to add that in, this should be a quick addition.