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.
I've fooled around with various different things and had various results but not what I'm looking for.
WHAT IS WRONG??
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??