Page 1 of 1

help with customPlayerKeys

Posted: 04 Feb 2022, 10:05
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" ??

Re: help with customPlayerKeys

Posted: 05 Feb 2022, 14:18
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.

Re: help with customPlayerKeys

Posted: 05 Feb 2022, 23:54
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;
[...]


Re: help with customPlayerKeys

Posted: 09 Feb 2022, 01:34
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!

Re: help with customPlayerKeys

Posted: 14 Feb 2022, 16:44
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..