Can't give players custom weapons (dedicated server)

  • 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/

Benjamin

Grizzled Veteran
May 17, 2009
3,631
635
113
France
Simple problem, but I can't seem to find a solution. It works fine in single player, but when using it on a dedicated server the player never gets the weapon (and for some reason the key associated with that category of weapon disables). I can give players standard weapons without problems.

KFGeneric (mutator file)
Code:
class KFGeneric extends Mutator;

function PostBeginPlay()
{
	SetTimer(5, true);
}

function Timer()
{
	local KFHumanPawn player;

	foreach AllActors(class'KFHumanPawn', player)
	{
		player.GiveWeapon("KFGeneric.KFNewWeapon");
		Log("Given weapon to player");
	}
}

defaultproperties
{
    GroupName="KF-Generic"
    FriendlyName="Generic mutator"
    Description=""
}

KFNewWeapon.uc (weapon file)
Code:
class KFNewWeapon extends KFMod.Deagle;

As you can see all I'm doing is extending from an existing weapon and not modifying it anyway, yet while giving the original weapon works this does not.

Any ideas?

Solved: Add bAddToServerPackages=True to the defaultproperties of the mutator.
 
Last edited:

Yomommassis

FNG / Fresh Meat
Sep 24, 2009
705
233
0
Palmdale, CA USA
Try this, i dont code i tweak existing code.
This will replace the starting load out of the players to whatever you set it to be, as long as its within the weight limit
Code:
class KFGeneric extends Mutator;
config(KFGeneric);
 
var() config bool bReplaceInitWeps;
 
function PostBeginPlay()
{
 if( bReplaceInitWeps )
  SetTimer(0.1,False);
}
 
function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
{
 if( bReplaceInitWeps && KFHumanPawn(Other)!=None )
 {
  KFHumanPawn(Other).RequiredEquipment[0] = "KFMod.Knife";
  KFHumanPawn(Other).RequiredEquipment[1] = "KFMod.Single";
  KFHumanPawn(Other).RequiredEquipment[2] = "KFMod.Frag";
  KFHumanPawn(Other).RequiredEquipment[3] = "KFMod.Syringe";
  KFHumanPawn(Other).RequiredEquipment[4] = "KFMod.Welder";
  KFHumanPawn(Other).RequiredEquipment[5] = string(Class'[I]Custom[/I]W[I]eaponNameNoKFModPrefixNeeded[/I]');
 }
 if ( string(Other.Class) ~= "KFMod.[I]Weapon[/I]Pickup" )
  {
   ReplaceWith( Other, "KFMod[I]orAnyCustomMod.Weapon[/I]Pickup" );
   return false;
  }
 return true;
}
 
static function FillPlayInfo(PlayInfo PlayInfo)
{
 Super.FillPlayInfo(PlayInfo);
 PlayInfo.AddSetting(default.RulesGroup, "bReplaceInitWeps", "Replace initial weapons:", 0, 0, "Check");
}
static event string GetDescriptionText(string PropName)
{
 switch(PropName)
 {
  case "bReplaceInitWeps":
   return "Should replace initial weapons with the custom weapons.";
  default:
   return Super.GetDescriptionText(PropName);
 }
}
 
defaultproperties
{
    bReplaceInitWeps=True
    GroupName="KF-Generic"
    FriendlyName="Generic mutator"
    Description=""
}
 
Last edited:

Benjamin

Grizzled Veteran
May 17, 2009
3,631
635
113
France
Thanks for taking the time to reply (it's nice to know about that RequiredEquipment array), but it's the same deal:

Works fine if adding standard weapons to the loadout.
Works fine if using custom weapons in single player (or as host on a listen server).

Doesn't when using a dedicated server.

It's most bizarre. :eek:
 
Last edited:

Yomommassis

FNG / Fresh Meat
Sep 24, 2009
705
233
0
Palmdale, CA USA
maybe this will help
whenever i add a custom weapon it looks like this

im working on a custom 9mm, the regular one is called "Single" and my version is called "SingleMed" so when i go to add it in the code it looks EXACTLY like this:

Code:
  KFHumanPawn(Other).RequiredEquipment[4] = "KFMod.Welder";
  KFHumanPawn(Other).RequiredEquipment[5] = string(Class'SingleMed')

when adding a custom weapon dont put a prefix like KFGeneric.blahblah
 

Benjamin

Grizzled Veteran
May 17, 2009
3,631
635
113
France
Actually, that's pretty much the same thing since if you take a look at the result it will be <pkgname>.<classname>. So no luck there. :(

Does your mutator work correctly for you when you run it on a dedicated (not listen) server?
 

Benjamin

Grizzled Veteran
May 17, 2009
3,631
635
113
France
I'll give that a try, that last line in particular makes me think it might work since it's only giving custom (stored in the mutator) weapons that is the problem, and that could be since the client doesn't have the weapon class itself. I'm not sure if the other lines are necessary (as the server dictates what weapons the players have) but I'll give them a try at the same time.

At the moment I'm reinstalling since I may have messed something up (in the past I somehow managed to stop Siren screams from damaging me when working on a completely unrelated project...) so I'll try it out later and tell you how it goes. Thanks!