Retrieving NexGen player's account type

Discussions about Coding and Scripting
User avatar
Barbie
Godlike
Posts: 2393
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Retrieving NexGen player's account type

Post by Barbie » Fri Oct 02, 2020 10:29 pm

How can I retrieve NexGen player's account type? Like "Level 4 Admin" in screenshot.
You do not have the required permissions to view the files attached to this post.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett

Letylove49
Experienced
Posts: 117
Joined: Tue Feb 28, 2012 7:47 pm
Personal rank: <[MHA]>Admin
Location: suisse

Re: Retrieving NexGen player's account type

Post by Letylove49 » Sun May 15, 2022 8:09 pm

the default setting in Nexgen112N

you can creat 30 acountype in this version



atTypeName[0]=<Default>
atTypeName[1]=VIP
atTypeName[2]=Level 3 Admin
atTypeName[3]=Level 4 Admin
atTypeName[4]=Level 5 Admin
atTypeName[5]=Level 6 Admin
atTypeName[6]=Level 7 Admin
atTypeName[7]=Level 8 Admin
atTypeName[8]=Hidden Admin
atTypeName[9]=
atTypeName[10]=
atTypeName[11]=
atTypeName[12]=
atTypeName[13]=
atTypeName[14]=
atTypeName[15]=
atTypeName[16]=
atTypeName[17]=
atTypeName[18]=
atTypeName[19]=
atTypeName[20]=
atTypeName[21]=
atTypeName[22]=
atTypeName[23]=
atTypeName[24]=
atTypeName[25]=
atTypeName[26]=
atTypeName[27]=
atTypeName[28]=
atTypeName[29]=
atRights[0]=A
atRights[1]=A,B
atRights[2]=A,B,C,D,F
atRights[3]=A,B,C,D,F,G
atRights[4]=A,B,C,D,E,F,G,H,K
atRights[5]=A,B,C,D,E,F,G,H,I,K,M
atRights[6]=A,B,C,D,E,F,G,H,I,J,K,M
atRights[7]=A,B,C,D,E,F,G,H,I,J,K,L,M
atRights[8]=A,B,C,D,E,F,G,H,K,N
atRights[9]=
atRights[10]=
atRights[11]=
atRights[12]=
atRights[13]=
atRights[14]=
atRights[15]=
atRights[16]=
atRights[17]=
atRights[18]=
atRights[19]=
atRights[20]=
atRights[21]=
atRights[22]=
atRights[23]=
atRights[24]=
atRights[25]=
atRights[26]=
atRights[27]=
atRights[28]=
atRights[29]=
atTitle[0]=Player
atTitle[1]=
atTitle[2]=L3 Admin
atTitle[3]=L4 Admin
atTitle[4]=L5 Admin
atTitle[5]=L6 Admin
atTitle[6]=L7 Admin
atTitle[7]=L8 Admin
atTitle[8]=
atTitle[9]=
atTitle[10]=
atTitle[11]=
atTitle[12]=
atTitle[13]=
atTitle[14]=
atTitle[15]=
atTitle[16]=
atTitle[17]=
atTitle[18]=
atTitle[19]=
atTitle[20]=
atTitle[21]=
atTitle[22]=
atTitle[23]=
atTitle[24]=
atTitle[25]=
atTitle[26]=
atTitle[27]=
atTitle[28]=
atTitle[29]=
<[MHA]>Letylove49 aka Shado170

User avatar
Barbie
Godlike
Posts: 2393
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Retrieving NexGen player's account type

Post by Barbie » Sun May 15, 2022 9:08 pm

Took some time but topic is still hot.

What I meant: How can I get nexgen player's information by code? For player's indent string (that UUID) I tried something like this:

Code: Select all

static function string GetPlayerIdent(Tournamentplayer P, bool bDebug) {
//local string result;

return P.PlayerReplicationInfo.Playername;

// NexgenClient does not exist at the time when ModifyPlayer() is executed
/*
	if (NexgenClient_PlayerIDFind(P, result))
	{
		if (bDebug)
			P.log(CSelfname $ ".GetPlayerIdent() returns" @ result);
		return result;
	}
	else
	{
		if (bDebug)
			P.log(CSelfname $ ".GetPlayerIdent() returns the Playername:" @ P.PlayerReplicationInfo.Playername);
		return P.PlayerReplicationInfo.Playername;
	}
*/
}

Code: Select all

static function bool NexgenClient_PlayerIDFind(Tournamentplayer P, out string NexgenPlayerID) {
local Info NexgenClient;

//	if PlayerReplicationInfoSB(P.PlayerReplicationInfo).NexgenClient != None)
	ForEach P.AllActors(class'Info', NexgenClient)
		if (NexgenClient.Class.Name == 'NexgenClient') // NexgenClient.Tag is NONE, so not usable
		{
			if (string(P.PlayerReplicationInfo.PlayerID) == NexgenClient.GetPropertyText("playerNum"))
			{
				NexgenPlayerID = NexgenClient.GetPropertyText("playerID");
				return NexgenPlayerID != "";
			}
		}
	return false;
}
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett

Buggie
Godlike
Posts: 1483
Joined: Sat Mar 21, 2020 5:32 am

Re: Retrieving NexGen player's account type

Post by Buggie » Mon May 16, 2022 3:51 am

What exactly "nexgen player's information" you need?

Automatically merged

Code: Select all

//=============================================================================
// MyMutator.
//=============================================================================
class MyMutator expands Mutator;

function PostBeginPlay() {
	Super.PostBeginPlay();
	Level.Game.BaseMutator.AddMutator(self);
}

function Mutate(string MutateString, PlayerPawn Sender) {
	local Info NexgenClient;
	
	Super.Mutate(MutateString, Sender);
	
	if (MutateString ~= "NI") {
		NexgenClient = GetNexgenClient(Sender);
		if (NexgenClient == None)
			Sender.ClientMessage("NexgenClient not found for" @ Sender.GetHumanName());
		else {
			Sender.ClientMessage("For" @ Sender.GetHumanName() @ "found" @ NexgenClient.Name);
			
			// for full set of options look at
			// https://github.com/dscheerens/nexgen/blob/master/Nexgen/Classes/NexgenClient.uc
			
			Sender.ClientMessage("bNetLogin:" @ NexgenClient.GetPropertyText("bNetLogin"));
			Sender.ClientMessage("bNetWait:" @ NexgenClient.GetPropertyText("bNetWait"));
			Sender.ClientMessage("loginComplete:" @ NexgenClient.GetPropertyText("loginComplete"));
			Sender.ClientMessage("ipAddress:" @ NexgenClient.GetPropertyText("ipAddress"));
			Sender.ClientMessage("playerID:" @ NexgenClient.GetPropertyText("playerID"));
			Sender.ClientMessage("playerNum:" @ NexgenClient.GetPropertyText("playerNum"));
			Sender.ClientMessage("bHasAccount:" @ NexgenClient.GetPropertyText("bHasAccount"));
			
			Sender.ClientMessage("loginOptions:" @ NexgenClient.GetPropertyText("loginOptions"));
			
			Sender.ClientMessage("playerName:" @ NexgenClient.GetPropertyText("playerName"));
			Sender.ClientMessage("team:" @ NexgenClient.GetPropertyText("team"));
			Sender.ClientMessage("rights:" @ NexgenClient.GetPropertyText("rights"));
			Sender.ClientMessage("title:" @ NexgenClient.GetPropertyText("title"));
			Sender.ClientMessage("country:" @ NexgenClient.GetPropertyText("country"));
			Sender.ClientMessage("bSpectator:" @ NexgenClient.GetPropertyText("bSpectator"));
			Sender.ClientMessage("bFirePressed:" @ NexgenClient.GetPropertyText("bFirePressed"));
			
			Sender.ClientMessage("bInitialized:" @ NexgenClient.GetPropertyText("bInitialized"));
			Sender.ClientMessage("badConnectionSince:" @ NexgenClient.GetPropertyText("badConnectionSince"));
			Sender.ClientMessage("bBadConnectionDetected:" @ NexgenClient.GetPropertyText("bBadConnectionDetected"));
			Sender.ClientMessage("bMuted:" @ NexgenClient.GetPropertyText("bMuted"));
			Sender.ClientMessage("bNoTeamSwitch:" @ NexgenClient.GetPropertyText("bNoTeamSwitch"));
			Sender.ClientMessage("lastRespawnTime:" @ NexgenClient.GetPropertyText("lastRespawnTime"));
			Sender.ClientMessage("spawnProtectionTimeX:" @ NexgenClient.GetPropertyText("spawnProtectionTimeX"));
			
			Sender.ClientMessage("idleTime:" @ NexgenClient.GetPropertyText("idleTime"));
			Sender.ClientMessage("idleTimeCP:" @ NexgenClient.GetPropertyText("idleTimeCP"));
			Sender.ClientMessage("idleTimeRemaining:" @ NexgenClient.GetPropertyText("idleTimeRemaining"));
			Sender.ClientMessage("bUseNexgenMessageHUD:" @ NexgenClient.GetPropertyText("bUseNexgenMessageHUD"));
			Sender.ClientMessage("bIsReadyToPlay:" @ NexgenClient.GetPropertyText("bIsReadyToPlay"));
			Sender.ClientMessage("lastAliveCheck:" @ NexgenClient.GetPropertyText("lastAliveCheck"));
			Sender.ClientMessage("spawnProtectionTimeX:" @ NexgenClient.GetPropertyText("spawnProtectionTimeX"));
		}
	}
}

static function Info GetNexgenClient(PlayerPawn P) {
	local Info NexgenClient;

	ForEach P.AllActors(class'Info', NexgenClient) {
		if (NexgenClient.Class.Name == 'NexgenClient')
			if (string(P.PlayerReplicationInfo.PlayerID) == NexgenClient.GetPropertyText("playerNum"))
				return NexgenClient;
	}
	return None;
}

Code: Select all

> mutate ni
For Buggie found NexgenClient1
bNetLogin: False
bNetWait: False
loginComplete: True
ipAddress: 192.168.1.0
playerID: 68A33A864C91B20DAE42A391F9D65CA5
playerNum: 1
bHasAccount: True
loginOptions: ClientKey=Q3R8Y-MP9KD-3M6KB-383YB-7PK9Q
playerName: Buggie
team: 0
rights: A,B,C,D,E,F,G,H,I,J,K,L,M
title: Root Admin
country: 
bSpectator: False
bFirePressed: False
bInitialized: True
badConnectionSince: 0.000000
bBadConnectionDetected: False
bMuted: False
bNoTeamSwitch: False
lastRespawnTime: 0.000000
spawnProtectionTimeX: 0.000000
idleTime: 0.000000
idleTimeCP: 0.000000
idleTimeRemaining: 0
bUseNexgenMessageHUD: False
bIsReadyToPlay: False
lastAliveCheck: 0.000000
spawnProtectionTimeX: 0.000000
You do not have the required permissions to view the files attached to this post.

User avatar
Barbie
Godlike
Posts: 2393
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Retrieving NexGen player's account type

Post by Barbie » Mon May 16, 2022 10:24 am

Buggie wrote:
Mon May 16, 2022 3:51 am
What exactly "nexgen player's information" you need?
1) That thing that identifies a player. IMO it is "ClientKey" or " ClientID" in USER.INI, section [NexgenCC.GeneralConfig].

2) Nice to have would be the following:

Code: Select all

function bool PlayerIsNexgenAdmin(Pawn P) {
  // something like InStr(Caps(atTypeName[i]), "ADMIN") would be enough, no check for given rights needed
(atTypeName is defined in Nexgen.ini, section [Nexgen112N.NexgenConfigExt])
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett

Buggie
Godlike
Posts: 1483
Joined: Sat Mar 21, 2020 5:32 am

Re: Retrieving NexGen player's account type

Post by Buggie » Mon May 16, 2022 10:26 am

Also

Code: Select all

	// Add default right definitions.
	addRightDefiniton("A", control.lng.allowedToPlayRightDesc);
	addRightDefiniton("B", control.lng.vipSlotAccessRightDesc);
	addRightDefiniton("C", control.lng.adminSlotAccessRightDesc);
	addRightDefiniton("D", control.lng.needsNoPWRightDesc);
	addRightDefiniton("E", control.lng.canBeIdleRightDesc);
	addRightDefiniton("F", control.lng.matchAdminRightDesc);
	addRightDefiniton("G", control.lng.moderatorRightDesc);
	addRightDefiniton("K", control.lng.matchSetRightDesc);
	addRightDefiniton("H", control.lng.banOpRightDesc);
	addRightDefiniton("I", control.lng.accountMngrRightDesc);
	addRightDefiniton("J", control.lng.serverAdminRightDesc);
	addRightDefiniton("L", control.lng.canBanAccountsRightDesc);
	addRightDefiniton("M", control.lng.hiddenAdminRightDesc, true);
So you can check rights via:

Code: Select all

if (InStr("," $ NexgenClient.GetPropertyText("rights") $ ",", ",J,") != -1)
	// do some stuff which allowed only for serverAdminRight priveledge.

Automatically merged

Barbie wrote:
Mon May 16, 2022 10:24 am
1) That thing that identifies a player. IMO it is "ClientKey" or " ClientID" in USER.INI, section [NexgenCC.GeneralConfig].
In code above:
Sender.ClientMessage("playerID:" @ NexgenClient.GetPropertyText("playerID"));
playerID: 68A33A864C91B20DAE42A391F9D65CA5
Barbie wrote:
Mon May 16, 2022 10:24 am
2) Nice to have would be the following:

Code: Select all

function bool PlayerIsNexgenAdmin(Pawn P) {
  // something like InStr(Caps(atTypeName[i]), "ADMIN") would be enough, no check for given rights needed
(atTypeName is defined in Nexgen.ini, section [Nexgen112N.NexgenConfigExt])
In code above:
Sender.ClientMessage("title:" @ NexgenClient.GetPropertyText("title"));
title: Root Admin

But this not really useful if used custom player titles (or hidden admin). Better use check again rights, as I show above.

Buggie
Godlike
Posts: 1483
Joined: Sat Mar 21, 2020 5:32 am

Re: Retrieving NexGen player's account type

Post by Buggie » Sun Jun 12, 2022 11:48 am

Proper code for get NextgenClient:

Code: Select all

var PlayerPawn TempPlayer;

function Info GetNexgenClient(PlayerPawn P) {
	local Info NexgenClient;
	local string TempStr;
	
	TempPlayer = P;
	TempStr = GetPropertyText("TempPlayer");

	ForEach P.AllActors(class'Info', NexgenClient) {
		if (NexgenClient.Class.Name == 'NexgenClient')
			if (TempStr == NexgenClient.GetPropertyText("player"))
				return NexgenClient;
	}
	return None;
}
As I suspect long time, PlayerReplicationInfo.PlayerID is not same as NexgenClient.playerNum. Possible it match in some cases (usually when test and run server for it), but in general it is not same.

User avatar
Barbie
Godlike
Posts: 2393
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Retrieving NexGen player's account type

Post by Barbie » Sun Jun 12, 2022 9:40 pm

This is also possible:

Code: Select all

static function bool NexgenClient_Find(PlayerReplicationInfo PRI, out Info NexgenClient) {
/******************************************************************************
Returns TRUE if a NexgenClient was found.

string(PRI.Owner) is something like
	MH-UM-Curse-Of-Pharao1.TFemale0
An instance of class'NexgenClient' returns something like
	TFemale1'MH-UM-Curse-Of-Pharao1.TFemale0'
with GetPropertyText("player").
So the right side of that string (without the ') must be equal to
string(PRI.Owner).
******************************************************************************/
local Info I;
local byte OwnerStrLen;

	if (PRI != None && PRI.Owner != None)
	{
		OwnerStrLen = len(PRI.Owner);
		ForEach PRI.Owner.AllActors(class'Info', I)
			if (I.Class.Name == 'NexgenClient') // NexgenClient.Tag is NONE, so not usable
				if (string(PRI.Owner) == left(right(I.GetPropertyText("player"), OwnerStrLen + 1), OwnerStrLen))
				{
					NexgenClient = I;
					return true;
				}
	}
	return false;
}
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett