Author Topic: Ingame Killcounter  (Read 6095 times)

Offline PatmanSan

  • Administrator
  • Rank: Private
  • *****
  • Posts: 2527
Re: Ingame Killcounter
« Reply #15 on: August 16, 2009, 10:03:06 am »
You don't have to count anything. The mod is already doing that for you:

self.pers["conseckill"]

Enough suffering LOL.
Give me a minute. I'll fix you something.

EDIT: here ya go...

Offline TGX-SpIkE

  • Rank: Private
  • *
  • Posts: 144
Re: Ingame Killcounter
« Reply #16 on: August 16, 2009, 11:46:04 am »
Wow, nice work, man i love u, its time for my next donation :)

Offline TGX-SpIkE

  • Rank: Private
  • *
  • Posts: 144
Re: Ingame Killcounter
« Reply #17 on: August 17, 2009, 07:44:19 am »
Hehe, now i have a new idea^^

I copyed ur script, And use it now for a second counter "headshots" works fine :D i love this script^^ but how can replace the text with the headshot icon? My idea was this, but dont works Oo


showHeadshotsHUD()
{
   if(!isDefined(self.pers["headshotkill"])) self.pers["headshotkill"] = 0;

   if(!isdefined(self.hud_headshots))
   {
      self.hud_headshots = newClientHudElem(self);
      self.hud_headshots.archived = false;
      self.hud_headshots.horzAlign = "left";
      self.hud_headshots.vertAlign = "top";
      self.hud_headshots.x = 16;
      self.hud_headshots.y = 48;
      self.hud_headshots.sort = 1;
      self.hud_headshots.alpha = 1;
      self.hud_headshots.fontscale = 1;
      self.hud_headshots.archived = false;
      self.hud_headshots.color = (1, 1, 1);
      self.hud_headshots setShader = (game["death_headshot"];   <-- what is wrong?
   }

Offline PatmanSan

  • Administrator
  • Rank: Private
  • *****
  • Posts: 2527
Re: Ingame Killcounter
« Reply #18 on: August 17, 2009, 09:01:45 am »
game["death_headshot"], that is wrong.

You can not make up a variable, and expect it to work automatically. The one you invented is not even linked to a specific player. This is a one-for-all variable.

You need a variable like the one for the kill streak (self.pers["conseckill"])... personalized. A variable that is incremented, decremented, or reset when necessary.

You are still running v1.6 I think, so you have two options to replace your invalid var:

1. Keep track of headshot deaths
self.pers["headshotdeath"]

2. Keep track of headshot kills
self.pers["headshotkill"]

Offline TGX-SpIkE

  • Rank: Private
  • *
  • Posts: 144
Re: Ingame Killcounter
« Reply #19 on: August 17, 2009, 09:46:28 am »
Quote from: "PatmanSan";p="29655"
game["death_headshot"], that is wrong.

You can not make up a variable, and expect it to work automatically. The one you invented is not even linked to a specific player. This is a one-for-all variable.

You need a variable like the one for the kill streak (self.pers["conseckill"])... personalized. A variable that is incremented, decremented, or reset when necessary.

You are still running v1.6 I think, so you have two options to replace your invalid var:

1. Keep track of headshot deaths
self.pers["headshotdeath"]

2. Keep track of headshot kills
self.pers["headshotkill"]

I know^^


U misunderstand me^^ my script already run, but i want the "death-headshot" ICON as the Hud.

I saw, that in firstaid files, same variable used for the icons. And the "deaht_headshot" icon is a standart icon from cod2^^ thtas what i want^^

Offline PatmanSan

  • Administrator
  • Rank: Private
  • *****
  • Posts: 2527
Re: Ingame Killcounter
« Reply #20 on: August 17, 2009, 10:21:19 am »
If death_headshot is a proper shader, and you make sure it's being precached, you can use something like this:

self.hud_headshots setShader("death_headshot", 32, 32);

Where the first 32 is the width and the second 32 is the height.

Offline TGX-SpIkE

  • Rank: Private
  • *
  • Posts: 144
Re: Ingame Killcounter
« Reply #21 on: August 17, 2009, 10:33:07 am »
what u mean with precached? Add it to varcache? Like the firstaidicon?

Offline PatmanSan

  • Administrator
  • Rank: Private
  • *****
  • Posts: 2527
Re: Ingame Killcounter
« Reply #22 on: August 17, 2009, 12:00:30 pm »
Before you can use a shader, it has to be precached:

precacheShader("death_headshot");

You can first try without precaching it explicitly. Maybe the game engine already precaches it because of the stock obituaries. If needed, you can stick that in the init() procedure.

Offline TGX-SpIkE

  • Rank: Private
  • *
  • Posts: 144
Re: Ingame Killcounter
« Reply #23 on: August 18, 2009, 05:33:01 am »
Hmm, dont works

Code: [Select]
init()
{
precacheShader("death_headshot");    <--- precache
level thread onPlayerConnect();    
}
onPlayerConnect()
{
for(;;)
{
level waittill("connecting", player);
player thread onJoinedTeam();
player thread onJoinedSpectators();
player thread onPlayerKilled();
player thread onPlayerSpawned();
}
}

onJoinedTeam()
{
self endon("disconnect");

for(;;)
{
self waittill("joined_team");
self thread removeHeadshotsHUD();
}
}

onJoinedSpectators()
{
self endon("disconnect");

for(;;)
{
self waittill("joined_spectators");
self thread removeHeadshotsHUD();
}
}

onPlayerKilled()
{
self endon("disconnect");

for(;;)
{
self waittill("killed_player");
}
}

onPlayerSpawned()
{
self endon("disconnect");

for(;;)
{
self waittill("spawned_player");
self thread showHeadshotsHUD();
self thread onPlayerScore();
}
}

onPlayerScore()
{
self endon("disconnect");

for(;;)
{
self waittill("update_playerscore_hud");
self thread updateHeadshotsHUD();
}
}

showHeadshotsHUD()
{
if(!isDefined(self.pers["headshotkill"])) self.pers["headshotkill"] = 0;

if(!isdefined(self.hud_headshots))
{
self.hud_headshots = newClientHudElem(self);
self.hud_headshots.archived = false;
self.hud_headshots.horzAlign = "left";
self.hud_headshots.vertAlign = "top";
self.hud_headshots.x = 16;
self.hud_headshots.y = 80;
self.hud_headshots.sort = 1;
self.hud_headshots.alpha = 1;
self.hud_headshots.fontscale = 1;
self.hud_headshots.archived = false;
self.hud_headshots.color = (1, 1, 1);
self.hud_headshots setShader("death_headshot", 32, 32);  <--- ]dont works :( but why?
}
self.hud_headshots setValue(self.pers["headshotkill"]);
}

updateHeadshotsHUD()
{
if(isDefined(self.hud_headshots)) self.hud_headshots setValue(self.pers["headshotkill"]);
}
removeHeadshotsHUD()
{
if(isdefined(self.hud_headshots)) self.hud_headshots destroy();
}

Offline PatmanSan

  • Administrator
  • Rank: Private
  • *****
  • Posts: 2527
Re: Ingame Killcounter
« Reply #24 on: August 18, 2009, 10:06:37 am »
Quote from: "PatmanSan";p="29659"
If death_headshot is a proper shader ...

I guess it's not.

Offline TGX-SpIkE

  • Rank: Private
  • *
  • Posts: 144
Re: Ingame Killcounter
« Reply #25 on: August 18, 2009, 11:54:35 am »
hmmm i found it in main folder iwds in images.

Offline PatmanSan

  • Administrator
  • Rank: Private
  • *****
  • Posts: 2527
Re: Ingame Killcounter
« Reply #26 on: August 18, 2009, 12:28:32 pm »
You don't reference images directly. You need the material file linked to that image (in materials folder).

killiconheadshot

Offline TGX-SpIkE

  • Rank: Private
  • *
  • Posts: 144
Re: Ingame Killcounter
« Reply #27 on: August 19, 2009, 05:36:50 am »
Ok, i added it, but it dont works, i dont get a error, but the icont isnt in the game

init part of my file:

init()
{
   precacheShader("killiconheadshot");
   level thread onPlayerConnect();
}

Hudpart

showHeadshotsHUD()
{
   if(!isDefined(self.pers["headshotkill"])) self.pers["headshotkill"] = 0;

   if(!isdefined(self.hud_headshots))
   {
self.hud_headshots = newClientHudElem(self);
self.hud_headshots.archived = false;
self.hud_headshots.horzAlign = "left";
self.hud_headshots.vertAlign = "top";
self.hud_headshots.x = 50;
self.hud_headshots.y = 80;
self.hud_headshots.sort = 1;
self.hud_headshots.alpha = 1;
self.hud_headshots.fontscale = 1;
self.hud_headshots.archived = false;
self.hud_headshots.color = (1, 1, 1);
self.hud_headshots setShader ("killiconheadshot", 7, 7);

Do u know what is wrong?

Offline PatmanSan

  • Administrator
  • Rank: Private
  • *****
  • Posts: 2527
Re: Ingame Killcounter
« Reply #28 on: August 19, 2009, 11:19:04 am »
I can see the icon, so I guess you are doing a setShader and a setValue on the same HUD element, which makes the shader disappear.
If you want to set a shader AND a value, you have to use two HUD elements.

Offline TGX-SpIkE

  • Rank: Private
  • *
  • Posts: 144
Re: Ingame Killcounter
« Reply #29 on: August 20, 2009, 04:56:12 am »
Ok, i create a second hud elm. It works perfect now :), but im not sure that this code is correct. Would u make it the same Pat?


showHeadshotsHUD()
{
   if(!isDefined(self.pers["headshotkill"])) self.pers["headshotkill"] = 0;

   if(!isdefined(self.hud_headshots))
   {
self.hud_headshots = newClientHudElem(self);
self.hud_headshots.archived = false;
self.hud_headshots.horzAlign = "left";
self.hud_headshots.vertAlign = "top";
self.hud_headshots.x = 40;
self.hud_headshots.y = 55;
self.hud_headshots.sort = 1;
self.hud_headshots.alpha = 1;
self.hud_headshots.fontscale = 1;
self.hud_headshots.archived = false;
self.hud_headshots.color = (1, 1, 1);
}
if(!isdefined(self.hud_headshoticon))
{
self.hud_headshotsicon = newClientHudElem(self);
self.hud_headshotsicon.archived = false;
self.hud_headshotsicon.horzAlign = "left";
self.hud_headshotsicon.vertAlign = "top";
self.hud_headshots.sort = 1;
self.hud_headshots.alpha = 1;
self.hud_headshotsicon.x = 11.5;
self.hud_headshotsicon.y = 55;
self.hud_headshotsicon setShader("killiconheadshot");
   }
self.hud_headshots setValue(self.pers["headshotkill"]);