PDA

View Full Version : Using iprintln(); to display an image?



filthy_freak_
4th January 2014, 13:46
I'm currently working on creating my own obituary/killfeed and am having trouble figuring out how I can display the headshot image using iprintln();

Can iprintln(); be used to display anything other than strings? If so, any example?

If not, I will probably seek a different way to achieve what I need.

Cheers

Tally
4th January 2014, 14:00
I'm currently working on creating my own obituary/killfeed and am having trouble figuring out how I can display the headshot image using iprintln();

Can iprintln(); be used to display anything other than strings? If so, any example?

If not, I will probably seek a different way to achieve what I need.

Cheers

No, iprintln() cannot display images - only strings. You will have to create a hud element to display images and position it where the obits are displayed.

filthy_freak_
4th January 2014, 14:05
No, iprintln() cannot display images - only strings. You will have to create a hud element to display images and position it where the obits are displayed.

Yeah I thought that was the case.

Ty.

php
4th January 2014, 14:10
If you were looking to change the headshot icon in the killfeed you'd just simple add a texture for that; I believe it's hud_, also I think you meant the obituary function instead of iprintln?


Obituary( self, attacker, sWeapon, sMeansOfDeath );

serthy
4th January 2014, 14:15
if you want some extra icons, you can use MOD_CRUSH as sMeansOfDeath and change this image (its unused in CoD2).
or youcould reuse the smokegrenades icons or the binocular one.
if you want to change all, you have to do it with HUDs or menu's (would prefer menus)

Tally
4th January 2014, 14:58
If you were looking to change the headshot icon in the killfeed you'd just simple add a texture for that; I believe it's hud_, also I think you meant the obituary function instead of iprintln?


Obituary( self, attacker, sWeapon, sMeansOfDeath );


As he clearly states in his opening post, he is working on his OWN obituary. He is not using the stock one.

filthy_freak_
28th January 2014, 04:46
Small update:

Managed to combine iprintln() and huds to come up with something like this;
http://tinypic.com/view.php?pic=yjuoo&s=5#.Uuc1dxBe5hF

My next problem is coming up with an easy way to calculate where the hud image X needs to be so it will place itself in the middle of each name. My only idea is to somehow manually grab the pixel length of each letter and add them up. Wondering if anyone has any other ideas?

Edit: Would be easier to do my idea if the font was mono-spaced, any way I can do this? I believe console font is mono-spaced, but only know how to use the font in menus.

IzNoGoD
28th January 2014, 10:58
console font is mono-spaced.

hud.font = "console"; iirc.

filthy_freak_
28th January 2014, 13:23
^.^ thankyou.

Ni3ls
28th January 2014, 16:03
Can you post your script? Very curious how you did this

filthy_freak_
28th January 2014, 16:13
Starting to look finished;

http://i.imgur.com/WS0YWIN.png

filthy_freak_
28th January 2014, 16:23
Having trouble editing posts atm so thats why the double post.


Can you post your script? Very curious how you did this
It's nowhere near ready to be released. Once it is I might. I have much bigger plans for this.

IzNoGoD
28th January 2014, 17:49
Use my version, adapt it a bit so it spawns 3 huds instead of 1:


doline(loc_say, time)
{
if(!isdefined(self.vo_hud))
{
self.vo_hud = [];
}
//any reusable line?
hud = undefined;
for(i = 0; i < self.vo_hud.size; i++)
{
if(self.vo_hud[i].removetime < gettime())
{
//reuse this one
hud = self.vo_hud[i];
break;
}
}
if(!isdefined(hud))
{
hud = newclienthudelem(self);
hud.alignx = "left";
hud.aligny = "top";
hud.horzalign = "left";
hud.vertalign = "bottom";
hud.sort = 1000;
hud.font = "default";
hud.fontscale = 1;
self.vo_hud[self.vo_hud.size] = hud;
}
hud.x = 125;
hud.y = -95;
hud.alpha = 1;
hud settext(loc_say);
for(i = 0; i < self.vo_hud.size; i++)
{
if(hud == self.vo_hud[i])
continue;
if(self.vo_hud[i].removetime < gettime())
continue;
self.vo_hud[i] moveovertime(.25);
self.vo_hud[i].y -= 10; //line-spacing
}
hud.removetime = gettime() + time * 1000 + 1000; //fadeovertime in 1 second
hud moveovertime(.25);
hud.y -= 10;
wait time;
hud fadeovertime(1);
hud.alpha = 0;
}

Is an already adapted version of a rewrite of the jm_pier_2 scripts

filthy_freak_
30th January 2014, 19:37
I'v hit another roadblock.

I'm trying to completely disable the stock iprintln/obituary/killfeed so that it will not overlay the new obituary but having trouble stopping the message it prints when changing names.

I have been editing the localized string for it without much luck. If I give it a blank string, it will still display your new and old name. I can hide the old name by adding a few "/n" to the string but it will still display your new name.

I also tried hex editing the .exe file and was able to make it all disappear but other clients require the modified .exe for it to work.


Was wondering if anyone has any ideas? I'v run out of things to try and starting to think it will not be possible... is this something that libcod could fix?

YuriJurek
30th January 2014, 20:00
Did you try to set some sort of shader over the original iprintln ? I mean a shader that would completely cover the old iPrintln and instead show your own, well it would need to be some kind fancy shader so that it doesn't distract people, but I think it would be best to just go for it and see how will it look like.

kung foo man
30th January 2014, 20:08
You can hook and call the original function only when not "print": void SV_SendServerCommand(/*client_t*/int *client, int bla, const char *fmt, ...)

Addresses are already in here: https://github.com/kungfooman/libcod/blob/master/libcod.cpp

IzNoGoD
30th January 2014, 22:25
You can just comment the obituary out in the callback_playerkilled

filthy_freak_
31st January 2014, 03:55
You can just comment the obituary out in the callback_playerkilled

That won't stop showing a message if a player changes name/get kicked/timed out etc.

Any other ideas? Would prefer not to use libcod because of no experience.

Tally
31st January 2014, 10:43
That won't stop showing a message if a player changes name/get kicked/timed out etc.

Any other ideas? Would prefer not to use libcod because of no experience.

I believe it's possible to stop all messages showing by force setting client dvars on players in a loop (to stop players going in and resetting the dvar back). I don't remember off hand exactly what the dvars were, but PAM (competitive) mod did it like that.

filthy_freak_
31st January 2014, 11:52
I believe it's possible to stop all messages showing by force setting client dvars on players in a loop (to stop players going in and resetting the dvar back). I don't remember off hand exactly what the dvars were, but PAM (competitive) mod did it like that.

I must find the source of this sorcery!

EDIT: Yep found the command;
setClientNameMode("manual_change");

=D tyvm