[T1 Question]

SuperSlug

Contributor
Veteran X
The following code when I add "HUD::Display(SuperSlugScoreHUD);" makes my computer freeze until I exit tribes through task manager. Why does it do that? How can I fix that? The other problem is - when I have just capped and go into hud mover and exit - it adds five points to my score. Any ideas on either?

Code:
Include("presto\\HUD.cs");
Include("presto\\event.cs");

function SuperSlugScoreHUD::Create()
{
	$SuperSlugScoreHUD::Points = 0;
	$SuperSlugScoreHUD::add = 0;										
	HUD::NewFrame(SuperSlugScoreHUD, SuperSlugScoreHUD::Update, 500, 752, 40, 15);
	$SuperSlugScoreHUD::Text = object::getName(HUD::AddObject(SuperSlugScoreHUD, FearGuiFormattedText, 0, 0, 40, 40));
	
	// the following line freezes tribes for some reason
	//HUD::Display(SuperSlugScoreHUD);
	Control::setValue($SuperSlugScoreHUD::Text, "<JC><F1>Me: <F2>0");
}


function SuperSlugScoreHUD::onClientMessage(%client, %msg)
{
	if(String::FindSubStr(%msg, "You captured ") != -1)
	{
			$SuperSlugScoreHUD::add += 5;
			SuperSlugScoreHUD::Update();
	}
}

function SuperSlugScoreHUD::onKill(%killer, %victim, %weapon)
{
	if(%client)
		return;

	%me = getManagerID();

	if (%victim == %me && %weapon == "Suicide")
	{
		$SuperSlugScoreHUD::add = -1;
		SuperSlugSuperSlugScoreHUD::Update();		
	}
	else if (%killer == %me && %weapon == "Team Kill")
	{
		$SuperSlugScoreHUD::add = -1;
		SuperSlugSuperSlugScoreHUD::Update();	
	}
	else if (%killer == %me)	
	{
		$SuperSlugScoreHUD::add = 1;
		SuperSlugScoreHUD::Update();
	}
}

function SuperSlugScoreHUD::Update()
{
	
	$SuperSlugScoreHUD::Points += $SuperSlugScoreHUD::add;
	Control::setValue($SuperSlugScoreHUD::Text, "<JC><f1>Me:<F2> " @ $SuperSlugScoreHUD::Points);
}

function SuperSlugScoreHUD::Reset()
{	 
	$SuperSlugScoreHUD::Points = 0;
	$SuperSlugScoreHUD::add = 0;
	Control::setvalue($SuperSlugScoreHUD::Text, "<JC><F1>Me:<F2>0");
}


SuperSlugScoreHUD::Create();
Event::Attach(eventClientMessage, SuperSlugScoreHUD::onClientMessage);
Event::Attach(eventKillTrak, SuperSlugScoreHUD::onKill);
Event::Attach(eventChangeMission, SuperSlugScoreHUD::Reset);
 
well for one thing the container is only 15 pixels high and the text thing is 40 which is odd..and another is if you are using presto, which I'm assuming since thats presto hud code you are, why are you parsing messages for captures? try attaching to eventFlagCaptured or something like that.and Lastly it's 'HUD::Display(SuperSlugHud,true);'

I dunno if any of these things are actually causin crashes though but maybe:)
 
Last edited:
None of those work :/ When I go to into hud mover it displays it fine saying: "Me: 23" or whatever. I just can't get it to be displayed without freezing.
 
Why don't you try going back to the basics.
Comment out a whole heap of code and try first just to get the hud displaying, then some text, then some more code etc etc.
 
Back
Top