Custom Basic HUD with CSQC

Need help with a tutorial found on InsideQC.com? Post here.
Post Reply
EMR
Posts: 13
Joined: Mon Oct 11, 2010 8:08 pm

Custom Basic HUD with CSQC

Post by EMR »

Working through http://www.inside3d.com/showtutorial.php?id=245.

This tutorial is very cool, but leaves the reader to guess about what they should do with some of the files, and I can't get it to compile.

Has anyone gotten this to work? If so, what file did they put

Code: Select all

void DrawHealth()
{
	local string text;
	
	vid_size_x = cvar(\"vid_conwidth\");
        vid_size_y = cvar(\"vid_conheight\");
        vid_res_x = cvar(\"vid_width\");
        vid_res_y = cvar(\"vid_height\");
	
	currenthealth = getstati(STAT_HEALTH);
	
	pos_x = vid_size_x*0.050 - hud_width*0.050;
	pos_y= vid_size_y*0.83 - hud_height*0.83;
	
	text = strcat(ftos(currenthealth), \": HEALTH\"); 
	drawstring(pos, text, \'5 10 0\', \'1 1 1\', 3, 1);
};

void DrawArmor()
{
	local string text;
	vid_size_x = cvar(\"vid_conwidth\");
        vid_size_y = cvar(\"vid_conheight\");
        vid_res_x = cvar(\"vid_width\");
        vid_res_y = cvar(\"vid_height\");
	
	currentarmor = getstati(STAT_ARMOR);
	pos_x = vid_size_x*0.05 - hud_width*0.05;
	pos_y= vid_size_y*0.85 - hud_height*0.85;
	text = strcat(ftos(currentarmor), \": ARMOR\"); 
	drawstring(pos, text, \'5 10 0\', \'1 1 1\', 3, 1);
};


void DrawHud()
{
        vid_size_x = cvar(\"vid_conwidth\");
        vid_size_y = cvar(\"vid_conheight\");
        vid_res_x = cvar(\"vid_width\");
        vid_res_y = cvar(\"vid_height\");
	pos2_y= vid_size_y*0.77 - hud_height*0.77;
	pos2_x = vid_size_x*0.0 - hud_width*0.0;
	drawpic(pos2, \"progs/hud4.tga\", \'128 110 0\', \'1 1 1\', 1, 0);
};
inside? Gamedefs.qc?

Can someone smart say if the code in the tutorial can be made to compile?
The suggested compiler gives me this:
Source file: progs.src
outputfile: ../csprogs.dat
compiling Defs.qc
compiling csqc_constants.qc
compiling csqc_builtins.qc
compiling Main.qc
compiling gamedefs.qc
in function DrawHealth (line 2),
gamedefs.qc:23: error: newline inside quote
gamedefs.qc:23: error: newline inside quote
gamedefs.qc:23: error: newline inside quote
gamedefs.qc:23: error: newline inside quote
gamedefs.qc:29: error: newline inside quote
gamedefs.qc:29: error: Bad vector
gamedefs.qc:29: error: Bad vector
in function DrawArmor (line 3),
gamedefs.qc:35: error: "\" - not a name
gamedefs.qc:35: error: newline inside quote
gamedefs.qc:35: error: newline inside quote
gamedefs.qc:35: error: newline inside quote

************ ERROR ************
Errors have occured

Error in gamedefs.qc on line 35
Finally, what engines have you made it work with?
Arkage
Posts: 66
Joined: Thu Nov 19, 2009 4:17 pm

Post by Arkage »

Remove the \ before the quotes, I don't know why they are being escaped.
Post Reply