I search for solutions in this order: Past Code, Unreal Source, Wiki, BUF, groups.yahoo, google, screaming at monitor. – RegularX

Difference between revisions of "Unreal Wiki:Scratchpad"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
Line 6: Line 6:
  
 
<uscript>
 
<uscript>
class MyTriggerMessage extends Trigger placeable;
+
function Mutate(string MutateString, PlayerController Sender)
const NoOfMessages=5;
+
function PostBeginPlay()
+
 
{
 
{
        Super.PostBeginPlay();
+
local AIController AC;
        Message=GetMessage();
+
local int RawBotCount;
}
+
 
function Bump(actor Other)
+
if (Master == none || Sender == none)
{
+
{
Super.Bump(Other);
+
Super.Mutate(MutateString, Sender);
Message=GetMessage();
+
return;
}
+
}
function string GetMessage()
+
 
{
+
if (MutateString ~= "TTFVersion")
local string OutText[NoOfMessages];
+
{
OutText[0]="11";
+
Sender.ClientMessage("Running TitanTeamFix version:"@TTFVersion);
OutText[1]="22";
+
}
OutText[2]="33";
+
else if (MutateString ~= "TTFDebug")
OutText[3]="44";
+
{
OutText[4]="55";
+
Sender.ClientMessage("Team 0 size:"@WorldInfo.Game.GameReplicationInfo.Teams[0].Size$", Team 1 size:"@WorldInfo.Game.GameReplicationInfo.Teams[1].Size);
return OutText[Rand(NoOfMessages)];
+
}
 +
else if (MutateString ~= "TTFPlayerCount")
 +
{
 +
foreach WorldInfo.AllControllers(Class'AIController', AC)
 +
++RawBotCount;
 +
 
 +
Sender.ClientMessage("DesiredPlayerCount (i.e. MinPlayers):"@UTGame(WorldInfo.Game).DesiredPlayerCount$", NumPlayers:"@WorldInfo.Game.NumPlayers$", NumBots:"@WorldInfo.Game.NumBots);
 +
Sender.ClientMessage("RawBotCount:"@RawBotCount$", NumTravellingPlayers:"@WorldInfo.Game.NumTravellingPlayers);
 +
}
 +
else
 +
{
 +
Super.Mutate(MutateString, Sender);
 +
}
 
}
 
}
 
</uscript>
 
</uscript>

Revision as of 11:34, 24 April 2008

This page is for pasting code you want to show someone as an example or to get assistance with. This allows you to easily collaborate with someone to solve a problem, and allows easy comparisons of the edits.

You are free to remove any existing code from below, and paste your code between the <uscript> </uscript> tags. If the page hasn't been edited in 24 hours, you can assume it isn't needed anymore and can be removed. A full edit history will be available, so don't worry about losing anything.


function Mutate(string MutateString, PlayerController Sender)
{
	local AIController AC;
	local int RawBotCount;
 
	if (Master == none || Sender == none)
	{
		Super.Mutate(MutateString, Sender);
		return;
	}
 
	if (MutateString ~= "TTFVersion")
	{
		Sender.ClientMessage("Running TitanTeamFix version:"@TTFVersion);
	}
	else if (MutateString ~= "TTFDebug")
	{
		Sender.ClientMessage("Team 0 size:"@WorldInfo.Game.GameReplicationInfo.Teams[0].Size$", Team 1 size:"@WorldInfo.Game.GameReplicationInfo.Teams[1].Size);
	}
	else if (MutateString ~= "TTFPlayerCount")
	{
		foreach WorldInfo.AllControllers(Class'AIController', AC)
			++RawBotCount;
 
		Sender.ClientMessage("DesiredPlayerCount (i.e. MinPlayers):"@UTGame(WorldInfo.Game).DesiredPlayerCount$", NumPlayers:"@WorldInfo.Game.NumPlayers$", NumBots:"@WorldInfo.Game.NumBots);
		Sender.ClientMessage("RawBotCount:"@RawBotCount$", NumTravellingPlayers:"@WorldInfo.Game.NumTravellingPlayers);
	}
	else
	{
		Super.Mutate(MutateString, Sender);
	}
}