help with customPlayerKeys

help with customPlayerKeys

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
daryl
Posts: 195
Joined: 08 Oct 2006, 10:33

help with customPlayerKeys

Post by daryl »

Hello,
please can you help me about customPlayerKeys ?

I see in wiki:

Code: Select all

Spring.GetPlayerInfo ( number playerID )
return: nil | string "name", bool active, bool spectator, number teamID, number allyTeamID, number pingTime, number cpuUsage, string "country", number rank, table customPlayerKeys
is the "customPlayerKeys" a string to insert into the "script.txt" like "countrycode" or "rank" ??
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: help with customPlayerKeys

Post by zwzsg »

Yes!

Though I mostly use customTeamKeys, and I don't remember well but maybe there was an issue with customPlayerKeys not being transmitted.
User avatar
daryl
Posts: 195
Joined: 08 Oct 2006, 10:33

Re: help with customPlayerKeys

Post by daryl »

zwzsg wrote: 05 Feb 2022, 14:18 Yes!

Though I mostly use customTeamKeys, and I don't remember well but maybe there was an issue with customPlayerKeys not being transmitted.
I can't receive data from customPlayerKeys wrote into the "script.txt", and I think that my code is wrong, could you please check it?:

Code: Select all

[...]
[player1]
{
countrycode=Italy;
isfromdemo=0;
name=playername;
password=xxxx;
rank=0;
spectator=0;
team=0;
}
[customPlayerKeys]		//--- is customPlayerKeys parameter for player 1 ?
{					//--- is customPlayerKeys parameter for player 1 ?
avatar=aa; 			//--- is customPlayerKeys parameter for player 1 ? (in this case i set by client the player 1 avatar )
}					//<<--- is customPlayerKeys parameter for player 1 ?


[player2]
{
countrycode=Italy;
isfromdemo=0;
name=playername;
[...]

User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: help with customPlayerKeys

Post by zwzsg »

If it's like custom team options, you don't need the [customPlayerKeys] {}
In the script, declare them like regular player options.

Well, they need to be inside the [PLAYERX] {} though!
User avatar
daryl
Posts: 195
Joined: 08 Oct 2006, 10:33

Re: help with customPlayerKeys

Post by daryl »

yes... I tried, like

Code: Select all

[player1]
{
countrycode=Italy;
[...]
team=0;
avatar = xx;    ---<<< custom parameters
othervariable = yy; ---<<< custom parameters

}
but nothing... also I tried using:

Code: Select all

[player1]
{
countrycode=Italy;
[..]
team0
}
[customPlayerKeys1]		 ---<<< custom parameters player 1
{					
avatar=aa; 			
}		
but nothing again, when I declare variable into the .lua script like this:

Code: Select all

--[[Spring.GetPlayerInfo ( number playerID )
return: nil | string "name", bool active, bool spectator, number teamID, number allyTeamID, number pingTime, number cpuUsage, string "country", number rank, table customPlayerKeys
]]--

_,_, _,_,_,_,_,_,_,avatar = Spring_GetPlayerInfo(myPlayerID)
the result of avatar is an empty table..
Post Reply

Return to “Lua Scripts”