KF [Help] Server Perks Custom Weapon Categories

  • Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Denilson

FNG / Fresh Meat
Dec 2, 2014
1
0
0
hello, I'm trying to create a 'WeaponCategories' specific for members of my server, nothing special, just who is on the list of members can buy weapons that category.

I'm not an experienced programmer, but I always try, I beheld several codes and got this:

Code:
Class MyMut extends ServerPerksMut;

struct FMemberEntry
{
	var() config string ID,Name;
};
var() config array<FMemberEntry> Members;
var() config array<string> MemberInventory;
var array< class<Pickup> > LoadMInventory;

function PostBeginPlay()
{
	local int i,j;
	local class<Pickup> P;
	local string S;
	local byte Cat;
	
	// Load up Member trader inventory
	for( i=0; i<MemberInventory.Length; i++ )
	{
		S = MemberInventory[i];
		j = InStr(S,":");
		if( j>0 )
		{
			Cat = Min(int(Left(S,j)),LoadedCategories.Length-1);
			S = Mid(S,j+1);
		}
		else Cat = 0;
		P = class<Pickup>(DynamicLoadObject(S,Class'Class'));
		if( P!=None )
		{
			// Inform bots.
			/*if( R!=None )
				R.MediItemForSale[R.MediItemForSale.Length] = P;*/

			LoadMInventory[LoadMInventory.Length] = P;
			LoadInvCategory[LoadInvCategory.Length] = Cat;
			if( P.Outer.Name!='KFMod' )
				ImplementPackage(P);
		}
	}
	Super.PostBeginPlay();
}
final function CheckMember( PlayerController PC )
{
	local ClientPerkRepLink R;
	local int i,j;
	local string S;
	
	// Log("Checking for member"@PC.PlayerReplicationInfo.PlayerName);
	S = PC.GetPlayerIDHash();
	for( i=(Members.Length-1); i>=0; --i )
	{
		if( Members[i].ID~=S )
		{
			// Log("...was a member.");
			R = ServerStStats(PC.SteamStatsAndAchievements).Rep;
			if( R==None )
				return;
				
			j = R.ShopInventory.Length;
			R.ShopInventory.Length = j+LoadMInventory.Length;
			for( i=(LoadMInventory.Length-1); i>=0; --i )
			{
				R.ShopInventory[j+i].PC = LoadMInventory[i];
				R.ShopInventory[j+i].CatNum = LoadInvCategory[i];
			}
			
			return;
		}
	}
}
function Timer()
{
	while( PendingPlayers.Length>0 )
	{
		if( PendingPlayers[0]!=None && PendingPlayers[0].Player!=None && ServerStStats(PendingPlayers[0].SteamStatsAndAchievements)==None )
		{
			if( PendingPlayers[0].SteamStatsAndAchievements!=None )
				PendingPlayers[0].SteamStatsAndAchievements.Destroy();
			PendingPlayers[0].SteamStatsAndAchievements = Spawn(Class'ServerStStats',PendingPlayers[0]);
		}
		if( PendingPlayers[0]!=None && PendingPlayers[0].Player!=None )
			CheckMember(PendingPlayers[0]);
		PendingPlayers.Remove(0,1);
	}
}

defaultproperties
{
}

my serverperks.ini
Code:
[ServerPerksMut.ServerPerksMut]
...
TraderInventory=6:KFMod.LAWPickup
WeaponCategories=4:Melee
WeaponCategories=2:Pistol
WeaponCategories=1:Shotgun
WeaponCategories=2:Sniper
WeaponCategories=3:Machine Gun
WeaponCategories=0:Medic Gun
WeaponCategories=6:Explosive
WeaponCategories=5:Flame Thrower
WeaponCategories=7:Misc
WeaponCategories=Members
....

[MyMut.MyMut]
; Default ID only for test
Members=(id="20b300195d48c2ccc2651885cfea1a2f",Name="KFPlayer")
; Standard Weapons only for test
MemberInventory=9:KFMod.CamoM4Pickup
MemberInventory=9:KFMod.CamoM32Pickup

it compiles correctly, does not appear errors in the logs or Warnning, but does not work.

if anyone could help,

ps: Sorry for my English

Att
Denilson