iprintln & setexpfog

Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!

Moderator: Core Staff

Post Reply
bSun Lynx
CJ Wannabe
CJ Wannabe
Posts: 10
Joined: October 1st, 2011, 10:10 pm

iprintln & setexpfog

Post by bSun Lynx » October 1st, 2011, 10:13 pm

i'm a former pawn coder and recently moved to cod, so here's my questions:

can iprintln's position be changed? i'm trying to create an advertisement that never fades away, is there any other method besides using an endless loop to fix this?
setexpfog doesn't seem to affect the skybox, am i able to change the skybox color or?

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: iprintln & setexpfog

Post by IzNoGoD » October 1st, 2011, 11:19 pm

Use huds instead of iprintlnbolds
LMGTFY!

Its not a glitch... Its the future!

bSun Lynx
CJ Wannabe
CJ Wannabe
Posts: 10
Joined: October 1st, 2011, 10:10 pm

Re: iprintln & setexpfog

Post by bSun Lynx » October 1st, 2011, 11:41 pm

IzNoGoD wrote:Use huds instead of iprintlnbolds
i've found some usefull shit..

Code: Select all

static const char *g_he_font[] =
{
	"default",		// HE_FONT_DEFAULT
	"bigfixed",		// HE_FONT_BIGFIXED
	"smallfixed",	// HE_FONT_SMALLFIXED
	"objective",	// HE_FONT_OBJECTIVE
};


// These values correspond to the defines in q_shared.h
static const char *g_he_alignx[] =
{
	"left",   // HE_ALIGN_LEFT
	"center", // HE_ALIGN_CENTER
	"right",  // HE_ALIGN_RIGHT
};


static const char *g_he_aligny[] =
{
	"top",    // HE_ALIGN_TOP
	"middle", // HE_ALIGN_MIDDLE
	"bottom", // HE_ALIGN_BOTTOM
};


// These values correspond to the defines in menudefinition.h
static const char *g_he_horzalign[] =
{
	"subleft",			// HORIZONTAL_ALIGN_SUBLEFT
	"left",				// HORIZONTAL_ALIGN_LEFT
	"center",			// HORIZONTAL_ALIGN_CENTER
	"right",			// HORIZONTAL_ALIGN_RIGHT
	"fullscreen",		// HORIZONTAL_ALIGN_FULLSCREEN
	"noscale",			// HORIZONTAL_ALIGN_NOSCALE
	"alignto640",		// HORIZONTAL_ALIGN_TO640
	"center_safearea",	// HORIZONTAL_ALIGN_CENTER_SAFEAREA
};
cassert( ARRAY_COUNT( g_he_horzalign ) == HORIZONTAL_ALIGN_MAX + 1 );


static const char *g_he_vertalign[] =
{
	"subtop",			// VERTICAL_ALIGN_SUBTOP
	"top",				// VERTICAL_ALIGN_TOP
	"middle",			// VERTICAL_ALIGN_CENTER
	"bottom",			// VERTICAL_ALIGN_BOTTOM
	"fullscreen",		// VERTICAL_ALIGN_FULLSCREEN
	"noscale",			// VERTICAL_ALIGN_NOSCALE
	"alignto480",		// VERTICAL_ALIGN_TO480
	"center_safearea",	// VERTICAL_ALIGN_CENTER_SAFEAREA
};
cassert( ARRAY_COUNT( g_he_vertalign ) == VERTICAL_ALIGN_MAX + 1 );


init()
{
	level.uiParent = spawnstruct();
	level.uiParent.horzAlign = "left";
	level.uiParent.vertAlign = "top";
	level.uiParent.alignX = "left";
	level.uiParent.alignY = "top";
	level.uiParent.x = 0;
	level.uiParent.y = 0;
	level.uiParent.width = 0;
	level.uiParent.height = 0;
	level.uiParent.children = [];
	
	if ( level.console )
		level.fontHeight = 12;
	else
		level.fontHeight = 12;
}

Code: Select all

/*
=============
///ScriptDocBegin
"Name: createFontString( <font>, <fontScale> )"
"Summary: Creates a hud element for font purposes"
"Module: Hud"
"MandatoryArg: <font>: Apparently this is always set to default."
"MandatoryArg: <fontScale>: The scale you want."
"Example: level.hintElem = createFontString( "default", 2.0 );"
"SPMP: singleplayer"
///ScriptDocEnd
=============
*/

createFontString( font, fontScale )
{
	fontElem = newHudElem( self );
	fontElem.elemType = "font";
	fontElem.font = font;
	fontElem.fontscale = fontScale;
	fontElem.x = 0;
	fontElem.y = 0;
	fontElem.width = 0;
	fontElem.height = int(level.fontHeight * fontScale);
	fontElem.xOffset = 0;
	fontElem.yOffset = 0;
	fontElem.children = [];
	fontElem setParent( level.uiParent );
	
	return fontElem;
}


createServerFontString( font, fontScale )
{
	fontElem = newHudElem( self );
	fontElem.elemType = "font";
	fontElem.font = font;
	fontElem.fontscale = fontScale;
	fontElem.x = 0;
	fontElem.y = 0;
	fontElem.width = 0;
	fontElem.height = int(level.fontHeight * fontScale);
	fontElem.xOffset = 0;
	fontElem.yOffset = 0;
	fontElem.children = [];
	fontElem setParent( level.uiParent );
	
	return fontElem;
}
what about the skybox?

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: iprintln & setexpfog

Post by Drofder2004 » October 2nd, 2011, 1:05 am

The skybox is formed with textures, not settings.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: iprintln & setexpfog

Post by IzNoGoD » October 2nd, 2011, 11:47 am

Code: Select all

 
        hud_sponsor=newhudelem();
        hud_sponsor.horzAlign = "left";
        hud_sponsor.vertAlign = "top";
        hud_sponsor.alignx = "left";
        hud_sponsor.aligny = "top";
        hud_sponsor.x = 8;
        hud_sponsor.y = 170;
        hud_sponsor settext("sponsored by IzNoGoD");
 
LMGTFY!

Its not a glitch... Its the future!

bSun Lynx
CJ Wannabe
CJ Wannabe
Posts: 10
Joined: October 1st, 2011, 10:10 pm

Re: iprintln & setexpfog

Post by bSun Lynx » October 2nd, 2011, 8:39 pm

IzNoGoD wrote:

Code: Select all

 
        hud_sponsor=newhudelem();
        hud_sponsor.horzAlign = "left";
        hud_sponsor.vertAlign = "top";
        hud_sponsor.alignx = "left";
        hud_sponsor.aligny = "top";
        hud_sponsor.x = 8;
        hud_sponsor.y = 170;
        hud_sponsor settext("sponsored by IzNoGoD");
 
pretty much what i've done yesterday, just a note; you missed the fontscale and the font itself, it does not work without them (atleast from what i've tried). thank you once again.

Code: Select all

	level.adv = NewHudElem();
	level.adv.horzAlign = "center_safearea";
	level.adv.vertAlign = "top";
	level.adv.alignX = "center";
	level.adv.alignY = "middle";
	level.adv.x = 0;
	level.adv.y = 70;
	level.adv.font = "objective";
	level.adv.fontscale = 2;
	level.adv SetText("^1insert your advertisement text here..");
there's just one major problem with the following code; i can't get it to work with the same font size as IPrintLn();, not even if font is set to "default".

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: iprintln & setexpfog

Post by IzNoGoD » October 2nd, 2011, 9:47 pm

Look through some menudefs to find all the possible fonts.
LMGTFY!

Its not a glitch... Its the future!

bSun Lynx
CJ Wannabe
CJ Wannabe
Posts: 10
Joined: October 1st, 2011, 10:10 pm

Re: iprintln & setexpfog

Post by bSun Lynx » October 3rd, 2011, 12:38 am

Code: Select all

 
level.adv = newHudElem();
level.adv.horzAlign = "right";
level.adv.vertAlign = "top";
level.adv.alignX = "right";
level.adv.alignY = "top";
level.adv.x -= 6;
level.adv.y += 6;
// level.adv.font = "objective";
level.adv.fontscale = 2;
level.adv setText("...");
whenever you change the fontscale to anything lower than 2 it fails (no draw).

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: iprintln & setexpfog

Post by Drofder2004 » October 3rd, 2011, 1:12 am

For CoD4.

Code: Select all

level.myhud = createServerFontString( "default", 1.4 );
level.myhud setPoint( <screenarea>, <relativearea>, <xoffset>, <yoffset>);
level.myhud setText("...");
areas = TOP / TOP LEFT / TOP RIGHT / LEFT / CENTER / RIGHT / BOTTOM / BOTTOM LEFT / BOTTOM RIGHT
1.4 is the smallest font size

fonts = "default", "bigfixed", "smallfixed", "objective"
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

bSun Lynx
CJ Wannabe
CJ Wannabe
Posts: 10
Joined: October 1st, 2011, 10:10 pm

Re: iprintln & setexpfog

Post by bSun Lynx » October 3rd, 2011, 2:41 am

Drofder2004 wrote:For CoD4.

Code: Select all

level.myhud = createServerFontString( "default", 1.4 );
level.myhud setPoint( <screenarea>, <relativearea>, <xoffset>, <yoffset>);
level.myhud setText("...");
areas = TOP / TOP LEFT / TOP RIGHT / LEFT / CENTER / RIGHT / BOTTOM / BOTTOM LEFT / BOTTOM RIGHT
1.4 is the smallest font size

fonts = "default", "bigfixed", "smallfixed", "objective"
thanks, now fontScale parametter works fine.
is there a way to skip to the next line or there's a need to draw the 2nd line separately?

Code: Select all

hudPlayersCount()
{
        level.adv = createFontString("default", 1.4);
        level.adv.horzAlign = "left";
        level.adv.vertAlign = "top";
        level.adv.alignX = "left";
        level.adv.alignY = "top";
        level.adv.x += 112;
        level.adv.y += 16;
        level.adv setText("^2Humans Left: ^3" + getPlayersCount(0) + " ^2Zombies Left: ^3" + getPlayersCount(1)); // skip anything after getPlayersCount(0); to the next line and keep the parametters.
}
yea, i'll probably need to draw the 2nd line separately, just asking around.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: iprintln & setexpfog

Post by Drofder2004 » October 3rd, 2011, 3:18 am

"\n"

Code: Select all

iprintln("Hello \nWorld!");
Hello
World!
I have not tested this in a HUD however, unsure of its behaviour, but should be fine.

Code: Select all

level.adv = createServerFontString( "default", 1.4 );
level.adv setPoint( "TOP LEFT", "TOP LEFT", 112, 16);
level.adv setText("^2Humans Left: ^3" + getPlayersCount(0) + "\n^2Zombies Left: ^3" + getPlayersCount(1));
Word of note, the variables "getplayercount" will NOT update automatically, you will need to call the "setText" each time it updates.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

bSun Lynx
CJ Wannabe
CJ Wannabe
Posts: 10
Joined: October 1st, 2011, 10:10 pm

Re: iprintln & setexpfog

Post by bSun Lynx » October 3rd, 2011, 3:34 am

Drofder2004 wrote:"\n"

Code: Select all

iprintln("Hello \nWorld!");
Hello
World!
I have not tested this in a HUD however, unsure of its behaviour, but should be fine.

Code: Select all

level.adv = createServerFontString( "default", 1.4 );
level.adv setPoint( "TOP LEFT", "TOP LEFT", 112, 16);
level.adv setText("^2Humans Left: ^3" + getPlayersCount(0) + "\n^2Zombies Left: ^3" + getPlayersCount(1));
Word of note, the variables "getplayercount" will NOT update automatically, you will need to call the "setText" each time it updates.
don't worry, i'm aware. i've moved to cod but i've been dealing with valve games since ages. i'm doing the update on the following events: disconnect & join spectator & spawn (which is when the gvar zomb changes).

i'm basing it off on my first mod anyways from hl2dm..
http://youtu.be/9vXvTbklrpA?t=14s

Post Reply

Who is online

Users browsing this forum: No registered users and 31 guests