Page 1 of 1

Error for what seems like no reason

Posted: June 15th, 2011, 10:59 pm
by F |Madness| U
Okay so I have been using code (such as below) to show messages in my mod for a while, and now for some reason I am getting errors with it. The error is: pair `undefined` and `2` has unmatching types `undefined` and `int` maps\mp\gametypes\_hud_util line 266.

The code I am using is below, and the code in _hud_util is below that.

But I just don't understand, I am using the exact same code but it is now giving these errors and I don't know why.

Code: Select all

AuthorText = createServerFontString( "Objective", 2 );
        AuthorText setPoint( "CENTER", "TOP", 0, 0 );
        AuthorText setText("^1My Mod ^31.00 by ^5Madness");

Code: Select all

createServerFontString( font, fontScale, team )
{
        if ( isDefined( team ) )
                fontElem = newTeamHudElem( team );
        else
                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);  ---- line 266
        fontElem.xOffset = 0;
        fontElem.yOffset = 0;
        fontElem.children = [];
        fontElem setParent( level.uiParent );
        fontElem.hidden = false;
        
        return fontElem;
}
I would love anyhelp with this.. it is really annoying me I just don't understand why I am suddenly getting this error.

Re: Error for what seems like no reason

Posted: June 15th, 2011, 11:20 pm
by F |Madness| U
Okay this is what I really don't understand. I have 2 pieces of code :

Code: Select all

AuthorText = createServerFontString( "extrabig", 2 );
        AuthorText setPoint( "CENTER", "CENTER", 0, -180 );
        AuthorText.sort = 1001;
        AuthorText setText("^1Mymod ^31.00 by ^5Madness");
and

Code: Select all

        gametypeswitchText = createServerFontString( "extrabig", 2 );
        gametypeswitchText setPoint( "CENTER", "CENTER", 0, -80 );
        gametypeswitchText.sort = 1001;
        gametypeswitchText setText("^2Incorrect Gametype Loaded. ^5Switching Gametype In 5");
The first piece of code gives the error mentioned above, the second code works fine, yet I'm sure there is no difference between them. Help please.

Re: Error for what seems like no reason

Posted: June 15th, 2011, 11:42 pm
by Rezil
Last line in code 1: you have an extra ].

Re: Error for what seems like no reason

Posted: June 15th, 2011, 11:57 pm
by F |Madness| U
Thats not in my code, that was just an error when inputting the code into these forums :P So yeah still got this problem.. I really don't understand it.

Re: Error for what seems like no reason

Posted: June 16th, 2011, 1:01 am
by IzNoGoD
Lemme guess where the star under the error is in this line:
fontElem.height = int(level.fontHeight * fontScale);
Its under the level.fontheight right? (or the L of level.fontheight for that matter)

This means your level.fontheight is undefined. Define it somewhere.

Edit: some more stuff that should be different if this were cod2:

fontElem = newHudElem( self );
should be
fontElem = newClientHudElem( self );

and the text should be a (semi) localized string that needs precaching.

I dont know about these issues in cod4, but i would look into it nonetheless

Re: Error for what seems like no reason

Posted: June 16th, 2011, 7:39 pm
by F |Madness| U
Seems to be because I was calling the thread on init(), rather than onPlayerConnect() or something else.