CTF Scripting help

Xml V2.0

Veteran XV
Needing help setting the text opposite of what it is for enemy flag so that it reads "player name" (0). Just like it is set in Milk's mini config. Switching the enemy flag around and setting it to where i want it will be no problem. It's the text i am having a problem with. Your help is greatly appreciated.

UlnOQRs.png


Code:
$CtfHUD::Image[0, home] = "friendly.home.png";
$CtfHUD::Image[0, player] = "friendly.player.png";
$CtfHUD::Image[0, field] = "friendly.empty.png";

$CtfHUD::Image[1, home] = "enemy.home.png";
$CtfHUD::Image[1, player] = "enemy.player.png";
$CtfHUD::Image[1, field] = "enemy.empty.png";

function CtfHUD::Init() {
	if ( $CtfHUD::Loaded )
		return;
	$CtfHUD::Loaded = true;
	
	HUD::New("CtfHUD::Container", 500, 8, 1200, 49, CtfHUD::Wake, CtfHUD::Sleep);
	newObject("CtfHUD::Image0", FearGuiFormattedText, 0, 0, 23, 20); 
	newObject("CtfHUD::Image1", FearGuiFormattedText, 1000, 0, 0, 0);

	newObject("CtfHUD::Status0", FearGuiFormattedText, 35, 3, 150, 20); 
	newObject("CtfHUD::Status1", FearGuiFormattedText, 940, 3, 0, 0);

	HUD::Add("CtfHUD::Container", "CtfHUD::Image0");
	HUD::Add("CtfHUD::Container", "CtfHUD::Image1");
	
	HUD::Add("CtfHUD::Container", "CtfHUD::Status0");
	HUD::Add("CtfHUD::Container", "CtfHUD::Status1");

	CtfHUD::Reset();
}

function CtfHUD::Wake() { CtfHUD::Update(); }
function CtfHUD::Sleep() { }

function CtfHUD::Reset() {
	Control::SetValue("CtfHUD::Image0", "<b3,3:Modules/CTFHud/friendly.home.png>");
	Control::SetValue("CtfHUD::Image1", "<b3,4:Modules/CTFHud/enemy.home.png>");

	CtfHUD::Update();
}

function CtfHUD::Update() {
	//friendly team goes in slot 0
	CtfHUD::SetTeamValue( 0, Team::Friendly() );
	//enemy team goes in slot 0
	CtfHUD::SetTeamValue( 1, Team::Enemy() );
}


function CtfHUD::SetTeamValue( %slot, %team ) {
	%score = Team::Score(%team);
	%loc = Team::Flag::Location(%team);
	
	switch ( %loc ) {
		case "home":
			%loc = "<f3>Home";
			%bmp = $CtfHUD::Image[%slot, "home"];
			break;
		case "field":
			%loc = "<f3>Dropped-><f2>" ~ Team::Flag::Timer(%team);
			%bmp = $CtfHUD::Image[%slot, "field"];
			break;
		default:
			%loc = "<f2>" ~ String::escapeFormatting(Client::GetName(%loc));
			%bmp = $CtfHUD::Image[%slot, "player"];
			break;
	}
	
	Control::SetValue( "CtfHUD::Image"~%slot, "<b3,3:Modules/CTFHud/"~%bmp~">" );
	Control::SetValue( "CtfHUD::Status"~%slot, "<f3>(<f2>"~%score~"<f3>)  "~%loc );

}

// if we change teams, the sides may need to be updated
function CtfHUD::SelfUpdate( %client, %team ) {
	if ( %client == getManagerId() )
		CtfHUD::Update();
}

Event::Attach( EventFlagUpdate, CtfHUD::Update );
Event::Attach( EventFlagTimerUpdate, CtfHUD::Update );
Event::Attach( EventClientChangeTeam, CtfHUD::SelfUpdate );

CtfHUD::Init();
 
find this

Code:
Control::SetValue( "CtfHUD::Status"~%slot, "<f3>(<f2>"~%score~"<f3>)"~%loc );

make it this
Code:
if( %slot == 0 )
Control::SetValue( "CtfHUD::Status"~%slot, "<f3>(<f2>"~%score~"<f3>)"~%loc );
else
Control::SetValue( "CtfHUD::Status"~%slot, %loc~"  <f3>(<f2>"~%score~"<f3>)" );

edit: fixed
 
Last edited:
Thanks Lemon!



Edit: Working on this config. Should be up and running soon. Maybe some one will enjoy playing it.
 
Last edited:
Back
Top