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

Code [Help] Mutator not working Online/Multiplayer!

Josko

Grizzled Veteran
Nov 2, 2012
107
0
Hi, I have been working on this mutator, It's purpose is to change a few stats to different weapons, like Damage, clipsize and so on.

However, strange thing is it dosn't work at all online on my gameserver, but in solo it works flawlessly. I have no clue what could be wrong.

Any idea what could be wrong? Something that's missing? Something that shouldn't be there? Ofcourse, I'm a total newbie in coding so I have no idea, Benjamin has written all the code by the way and I wouldn't be even close without his help, thanks Benjamin! However the problem still stands. For some reason, it's not working online.

Here's the code:


Code:
class MutAlteredWeaponsPack extends Mutator; 

simulated function PostBeginPlay() 

{ 

KFGameType(Level.Game).default.LoadedSkills[1] = class'MutAlteredWeaponsPack.CustomKFVetSupportSpec';

KFGameType(Level.Game).default.LoadedSkills[2] =

class'MutAlteredWeaponsPack.CustomKFVetSharpshooter';

KFGameType(Level.Game).default.LoadedSkills[3] =

class'MutAlteredWeaponsPack.CustomKFVetCommando';

KFGameType(Level.Game).default.LoadedSkills[6] =

class'MutAlteredWeaponsPack.CustomKFVetDemolitions';

KFGameType(Level.Game).default.LoadedSkills[4] =

class'MutAlteredWeaponsPack.CustomKFVetBerserker';

KFGameType(Level.Game).default.LoadedSkills[0] =

class'MutAlteredWeaponsPack.CustomKFVetFieldMedic';

KFGameType(Level.Game).default.LoadedSkills[5] =

class'MutAlteredWeaponsPack.CustomKFVetFirebug';

//M249Mut

    class'M249Mut'.default.ItemName = "M249 SAW";

    class'M249Pickup'.default.ItemName = "M249 SAW";

    class'M249Pickup'.default.ItemShortName = "M249 SAW";

    class'M249Pickup'.default.PickupMessage = "You got the M249 SAW!";

// Set timer since info probably won't be available on the client yet 

SetTimer(0.1, false); 

} 

simulated function Timer() 

{ 

local KFLevelRules KFLR; 

local int i; 

// Get KFLevelRules actor if it's available 

foreach DynamicActors(class'KFLevelRules', KFLR) 

break; 

// If not available, try again in a second 

if (KFLR == none) 

{ 

Log("Could not find KFLevelRules"); 

SetTimer(1.0, false); 

return; 

} 

// Search through shop list for original Weapons 

for (i = 0; i < ArrayCount(KFLR.ItemForSale); i++) 

{ 

if (KFLR.ItemForSale[i] == class'KFMod.AA12Pickup') 

{ 

KFLR.ItemForSale[i] = class'MutAlteredWeaponsPack.CustomAA12Pickup';

} 

else if (KFLR.ItemForSale[i] == class'KFMod.M99Pickup') 

{ 

KFLR.ItemForSale[i] = class'MutAlteredWeaponsPack.CustomM99Pickup';

} 

else if (KFLR.ItemForSale[i] == class'KFMod.M4Pickup') 

{ 

KFLR.ItemForSale[i] = class'MutAlteredWeaponsPack.CustomM4Pickup';

} 

else if (KFLR.ItemForSale[i] == class'KFMod.SCARMK17Pickup') 

{ 

KFLR.ItemForSale[i] = class'MutAlteredWeaponsPack.CustomSCARMK17Pickup';

} 

else if (KFLR.ItemForSale[i] == class'KFMod.FNFAL_ACOG_Pickup') 

{ 

KFLR.ItemForSale[i] = class'MutAlteredWeaponsPack.CustomFNFAL_ACOGPickup';

} 

else if (KFLR.ItemForSale[i] == class'KFMod.BenelliPickup') 

{ 

KFLR.ItemForSale[i] = class'MutAlteredWeaponsPack.CustomBenelliPickup';

} 

else if (KFLR.ItemForSale[i] == class'KFMod.M4203Pickup') 

{ 

KFLR.ItemForSale[i] = class'MutAlteredWeaponsPack.CustomM4203Pickup';

} 

else if (KFLR.ItemForSale[i] == class'KFMod.M14EBRPickup') 

{ 

KFLR.ItemForSale[i] = class'MutAlteredWeaponsPack.CustomM14EBRPickup';

}

else if (KFLR.ItemForSale[i] == class'KFMod.M32Pickup') 

{ 

KFLR.ItemForSale[i] = class'MutAlteredWeaponsPack.CustomM32Pickup';

}

else if (KFLR.ItemForSale[i] == class'KFMod.M79Pickup') 

{ 

KFLR.ItemForSale[i] = class'MutAlteredWeaponsPack.CustomM79Pickup';

}

else if (KFLR.ItemForSale[i] == class'KFMod.LAWPickup') 

{ 

KFLR.ItemForSale[i] = class'MutAlteredWeaponsPack.CustomLAWPickup';

}

else if (KFLR.ItemForSale[i] == class'KFMod.CrossbuzzsawPickup') 

{ 

KFLR.ItemForSale[i] = class'MutAlteredWeaponsPack.CustomBuzzPickup';

}

else if (KFLR.ItemForSale[i] == class'KFMod.M7A3MPickup') 

{ 

KFLR.ItemForSale[i] = class'MutAlteredWeaponsPack.CustomM7A3MPickup';

}

else if (KFLR.ItemForSale[i] == class'KFMod.TrenchgunPickup') 

{ 

KFLR.ItemForSale[i] = class'MutAlteredWeaponsPack.CustomTrenchPickup';

}

else if (KFLR.ItemForSale[i] == class'KFMod.MP5MPickup') 

{ 

KFLR.ItemForSale[i] = class'MutAlteredWeaponsPack.CustomMP5MPickup';

} 

} 

// Find a free slot and add the M249 to it 

for (i = 0; i < ArrayCount(KFLR.ItemForSale); i++) 

{ 

if (KFLR.ItemForSale[i] == none) 

{ 

KFLR.ItemForSale[i] = class'MutAlteredWeaponsPack.M249Pickup'; 

break; 

} 

}

// Exit mutator since it's no longer needed 

Destroy(); 

}

defaultproperties

{

     bAddToServerPackages=True

     GroupName="KFAlteredWeaponsPack"

     FriendlyName="Altered Weapons Pack"

     Description="Includes: AA12, M249 SAW, M4, Claymore, M14EBR, M4203, SCARMK17, FNFAL, M99 & Combat Shotgun"

     bAlwaysRelevant=True

     RemoteRole=ROLE_SimulatedProxy

}
 
How exactly did you install it to your server? Did you add the ServerPackages=TheMutFileName to the server KillingFloor.ini?


I use multiplay gameserver's and I upload the stuff I want and they add it, and I checked, it was added to ServerPackages. The server.log shows no error at all, neither does my KillingFloor.log.

So I have no idea why it's not working online on my server :p
 
Upvote 0
God that formatting is evil.

Also, you are running a timer, it runs after everything is loaded. So no need for that check. Although a simple check to ensure the game is using KFLevelRules woudln't go a miss.

Ok, as for the find free spot in the array, the FOR loop will only run the length of the array, it won't find an 'empty' slot.

Code:
	for (i = 0; i < KFLR.ItemForSale.Length; i++) 
	{ 
		if (i == KFLR.ItemForSale.Length) 
		{ 
			i += 1
			KFLR.ItemForSale[i] = class'MutAlteredWeaponsPack.M249Pickup'; 
			break; 
		} 
	}

Might have better luck with this.

http://pastebin.com/MKwSXnW0 if you want to see the whole thing, you'll have to compile it to see if it works.
 
Upvote 0