HALP!

Laughing-Stork

Veteran XV
I'm trying to create a scriptgl killhud. I've copied the scriptgl chathud method of creating lines but I can't quite get it to work.

It creates the first line perfectly, but the next kill event only bumps the first line up and fails to create another line. This happens until the line reaches the top of the hud. Then the line starts showing old kill messages after each kill event.

Code:
// Stork vKillHUD

$pref::KillHUD::Lines = 5;
$KillHud::Width = "300";
$KillHUD::Line = 0;

function killHUD::onClientKilled(%killer, %victim, %damagetype)
{
                  %kname = String::escape(Client::GetName(%killer));
	%vname = String::escape(Client::GetName(%victim));
                  $dmg = killhud::getname(%damageType);

	if((%killer == %victim) || (%kname == ""))
                  $killline = %vname@"  "@$dmg;
                  else
                  $killline = %kname@"  "@$dmg@"  "@%vname;

                  $KillHud::Line++;
	$KillHud::Line[$KillHud::Line, line] = $killline;
}

function killhud::getname(%damageType) {
	if (%damagetype == "Blaster") { return "blaster"; }
	if (%damagetype == "Chaingun") { return "chaingun"; }
	if (%damagetype == "Disc") { return "disc"; }
	if (%damagetype == "ELF") { return "elf"; }
	if (%damagetype == "Explosive") { return "grenade"; }
	if (%damagetype == "Explosives") { return "grenade"; }
	if (%damagetype == "Laser Rifle") { return "sniper"; }
	if (%damagetype == "Mortar") { return "mortar"; }
	if (%damagetype == "Plasma") { return "plasma"; }
	if (%damagetype == "Turret") { return "turret"; }
	if (%damagetype == "Suicide") { return "suicide"; }
	return "suicide";
}

function vKillHUD::onrender()
{
	if($Scriptgl::CurrentGui != "playGui")
		return;
	
	if(!Control::getVisible("ScriptGL::vKillHUD"))
		return;

	%position = Control::GetPosition("ScriptGL::vKillHUD");
	%position[x] = getWord(%position,0);
	%position[y] = getWord(%position,1);
	%dx = $KillHud::Width;

	Control::setExtent("ScriptGL::vKillHud", getWord(Control::getExtent("ScriptGL::vKillHud"),0), -5 +($pref::KillHud::Lines+1) * 15);

	glDisable($GL_TEXTURE_2D);
	glDisable($GL_SCISSOR_TEST);
	glEnable($GL_ALPHA_TEST);
	glBlendFunc($GL_SRC_ALPHA,$GL_ONE_MINUS_SRC_ALPHA);	
	glAlphaFunc($GL_GREATER,$GL_ZERO);
	glColor4ub( 0, 0, 0, 95 );
	glLoadIdentity();

	glBegin($GL_QUADS);
		glVertex2f(%position[x],%position[y]);			
		glVertex2f(%position[x] + %dx, %position[y]);
		glVertex2f(%position[x] + %dx, %position[y] - 5 + ($pref::KillHud::Lines+1) * 15);
		glVertex2f(%position[x], %position[y] - 5 + ($pref::KillHud::Lines+1) * 15);
	glEnd();

	glSetFont( "tahoma", 12, 0, 9 );

	glColor4ub(255,255,255,255);

	for(%i = 0; %i < $pref::KillHud::Lines && %i < $KillHud::Line; %i++)
{
                  %lines = $KillHud::Line-%i;
	%textslot = %i;
	%textpos[x] = %position[x] + 3;
	%textpos[y] = %position[y] + 5 + ($pref::KillHud::Lines - %textslot - 1)*15;
}
                  %display = $KillHud::Line[%lines, line];
                  glDrawString(%textpos[x],%textpos[y], %display);
}

function vKillHUD::create() 
{
	if ( $vKillHUD::Loaded )
		return;
		
	$vKillHUD::Loaded = true;
	
	vhud::create( "ScriptGL::vKillHUD", "0% 0%", "0% 0%", vKillHUD::onrender );
	HUD::New("ScriptGL::vKillHUD", 0, 25, $KillHud::Width, 10+($pref::KillHud::Lines-%i-1)*13);
}


event::Attach(eventClientKilled, killHUD::onClientKilled);
event::Attach(eventClientTeamKilled, killHUD::onClientKilled );
event::Attach(eventClientSuicided, killHUD::onClientKilled );

vKillHUD::create();

I've fooled around with various different things and had various results but not what I'm looking for.

WHAT IS WRONG??
 
Well, it's been awhile, but what is this?

Code:
$KillHud::Line++;
$KillHud::Line[$KillHud::Line, line] = $killline;

I mean if $KillHud::Line is storing the kill string then why are you ++ing it? I also don't understand why you are using a 2d array? Shouldn't it be something like:
Code:
function killHUD::onClientKilled(%killer, %victim, %damagetype) {
...
   //Re-order the array (push whats @ index 0 out)
   for (%i=0 ; %i<=$KillHud::TotalLines-1; %i++) {
      $KillHud::Line[%i] = $KillHud::Line[%i+1];
   }
   //Put our new kill line at TotalLines
   $KillHud::Line[$KillHud::TotalLines] = $killline;
}

Then in onRender you just print what is in the $KillHud::Line array
 
Last edited:
Well after trying a billion different things, I copied the chathud and converted it into a killhud. This is the closest I've gotten to success. I'll try this out when I get home.
 
Yeah, I've known that was the problem, but nothing else worked. I guess the chathud has something that figures out the array better that I'm missing.

Maybe its time I actually learn how to write my own scripts.
 
Well, it's been awhile, but what is this?

Code:
$KillHud::Line++;
$KillHud::Line[$KillHud::Line, line] = $killline;

I mean if $KillHud::Line is storing the kill string then why are you ++ing it? I also don't understand why you are using a 2d array? Shouldn't it be something like:
Code:
function killHUD::onClientKilled(%killer, %victim, %damagetype) {
...
   //Re-order the array (push whats @ index 0 out)
   for (%i=0 ; %i<=$KillHud::TotalLines-1; %i++) {
      $KillHud::Line[%i] = $KillHud::Line[%i+1];
   }
   //Put our new kill line at TotalLines
   $KillHud::Line[$KillHud::TotalLines] = $killline;
}

Then in onRender you just print what is in the $KillHud::Line array

No luck with this.

I am having trouble creating multiple lines from gldrawstring function.

I've tried copying the methods of the 1.30 scriptgl vhud and my own regular tribes default killhud. But NOTHING works. I've had many different results but can't quite get it. It's frustrating as hell. :/
 
Back
Top