--
[ Picked text/plain from multipart/alternative ]
Joel: Glad to be of assistance! Good luck with the mod.
Dest: Let's start with the simplest solution. Have you specified your class
in scripts/HudLayout.res file? Our classname is CH5UI_PlayerNames, here's
what we have in our HudLayout.res file. This sets your hud element to be
visible, positioned at 0,0 and sizes it to fit the whole screen.
CH5UI_PlayerNames
{
"fieldName" "CH5UI_PlayerNames"
"xpos" "0"
"ypos" "0"
"wide" "640"
"tall" "480"
"visible" "1"
"enabled" "1"
}
If you have already done this, we'll keep troubleshooting from there.
On 4/16/07, Joel R. <[EMAIL PROTECTED]> wrote:
>
> --
> [ Picked text/plain from multipart/alternative ]
> Hey Oliver I borrowed your method for the OffsetZ which saved me time
> perfecting it to be the right distance over the players head. We're using
> it in our mod for Mario Kart Source and you'll receive appropriate credit
> for it. Thanks.
>
> Dest Romano: The font's you can use are listed in ClientScheme.res. You
> can
> get them in ApplySchemeSettings and just do.
> m_hFont = pScheme->GetFont( "Trebuchet24" );
> Or whatever custom font you want just add it to ClientScheme.res and at
> the
> bottom is where you link to the filename of the .ttf file. Make sure the
> name you use for the custom font is the exact same as when you open the
> font
> up at the top.
>
> On 4/16/07, Oliver <[EMAIL PROTECTED]> wrote:
> >
> > --
> > [ Picked text/plain from multipart/alternative ]
> > 1) Declare as a private variable for the class:
> > vgui::HFont m_hFont;
> >
> > Be sure to set it to a font in the constructor, we set to trebuchet:
> > m_hFont = g_hFontTrebuchet24;
> >
> > 2) Declare as a private variable for the class:
> > wchar_t sIDString[256];
> >
> > 3) You're right, code could be cleaned by moving variable declaration
> out
> > of
> > Paint method.
> >
> > Good luck!
> >
> > On 4/16/07, Dest Romano <[EMAIL PROTECTED]> wrote:
> > >
> > > Hello, That looks like a really great method of drawing text so I
> coded
> > it
> > > in. I have three questions
> > >
> > > 1) Where is m_hFont declared and how could I access m_hFont
> > > 2) Where is sIDString declared and what type of variable is it (char*
> > > dosen't seem to work)
> > > 3) Why do you declare so many variables in a class that will run every
> > > frame, why not just storing them on the player under public?
> > >
> > > Thanks for the method Oliver!
> > > -Dest
> > >
> > >
> > > >From: Oliver <[EMAIL PROTECTED]>
> > > >Reply-To: [email protected]
> > > >To: [email protected]
> > > >Subject: Re: [hlcoders] Client Side Text
> > > >Date: Sun, 15 Apr 2007 23:11:22 -0400
> > > >
> > > >--
> > > >[ Picked text/plain from multipart/alternative ]
> > > >Here's how we did it:
> > > >
> > > >Create a client-side class that extends CHudElement and vgui::Panel
> > > >
> > > >The Paint method is used to draw the text (fade as distance
> increases).
> > > >The
> > > >InView method determines if the other player is in view of the local
> > > >player.
> > > >
> > > >I make no claims to the elegance of this code, but it does work. :)
> > > >
> > > >void YourClassName::Paint()
> > > >{
> > > > C_HL2MP_Player *pLocalPlayer =
> > > C_HL2MP_Player::GetLocalHL2MPPlayer();
> > > >
> > > > if ( !pLocalPlayer )
> > > > return;
> > > >
> > > > Vector origin;
> > > > int x, y, length, wide, tall, offsetZ, alpha;
> > > > for ( int iEntIndex = 0; iEntIndex <
> > > >cl_entitylist->NumberOfEntities();
> > > >iEntIndex++ )
> > > > {
> > > > if ( IsPlayerIndex( iEntIndex ) )
> > > > {
> > > > C_BasePlayer *pPlayer =
> > > >static_cast<C_BasePlayer*>(cl_entitylist->GetEnt( iEntIndex ));
> > > >
> > > > if( pPlayer && !pPlayer->IsLocalPlayer() )
> > > > {
> > > > if(InView(pLocalPlayer, pPlayer))
> > > > {
> > > > sIDString[0] = 0;
> > > >
> > > >vgui::localize()->ConvertANSIToUnicode(pPlayer->GetPlayerName(),
> > > sIDString,
> > > >sizeof(sIDString));
> > > >
> > > > length = (pPlayer->GetAbsOrigin() -
> > > >pLocalPlayer->GetAbsOrigin()).Length();
> > > > offsetZ = 72;
> > > > offsetZ += (length - 80)/12.6;
> > > > if(length <= 400) alpha = 255;
> > > > else
> > > > {
> > > > alpha = 655 - length;
> > > > if(alpha < 0) alpha = 0;
> > > > }
> > > >
> > > >
> > > > vgui::surface()->GetTextSize( m_hFont,
> sIDString,
> > > >wide,
> > > >tall );
> > > >
> > > > Vector offset = Vector(0,0,offsetZ);
> > > > GetVectorInScreenSpace(pPlayer->GetAbsOrigin(),
> x,
> > > y,
> > > >&offset);
> > > > x -= wide/2;
> > > >
> > > > vgui::surface()->DrawSetTextFont(m_hFont);
> > > > vgui::surface()->DrawSetTextPos(x, y);
> > > >
> > > >vgui::surface()->DrawSetTextColor(Color(255,255,255,alpha));
> > > > vgui::surface()->DrawPrintText(sIDString,
> > > >wcslen(sIDString));
> > > > }
> > > > }
> > > > }
> > > > }
> > > >}
> > > >
> > > >bool YourClassName::InView(C_BasePlayer *pLocalPlayer, C_BasePlayer
> > > >*pPlayer)
> > > >{
> > > > // Clip text that is far away
> > > > if((pLocalPlayer->GetAbsOrigin() -
> > > >pPlayer->GetAbsOrigin()).LengthSqr()
> > > > > 90000000) return false;
> > > >
> > > > // Clip text that is behind the client
> > > > Vector clientForward;
> > > > pLocalPlayer->EyeVectors( &clientForward );
> > > >
> > > > Vector toText = pPlayer->GetAbsOrigin() -
> > > >pLocalPlayer->GetAbsOrigin();
> > > > float dotPr = DotProduct(clientForward,toText);
> > > >
> > > > if (dotPr < 0) return false;
> > > >
> > > > //Clip text that is obscured
> > > > trace_t tr;
> > > > Vector forward = pPlayer->GetAbsOrigin() -
> > > >pLocalPlayer->GetAbsOrigin();
> > > > int length = forward.Length();
> > > > forward.NormalizeInPlace();
> > > > UTIL_TraceLine(pLocalPlayer->Weapon_ShootPosition(), forward *
> > > >MAX_TRACE_LENGTH, (MASK_SHOT & ~CONTENTS_WINDOW), pLocalPlayer,
> > > >COLLISION_GROUP_NONE, &tr);
> > > >
> > > > if((tr.endpos - pLocalPlayer->GetAbsOrigin()).Length() < length)
> > > > {
> > > > return false;
> > > > }
> > > > return true;
> > > >}
> > > >
> > > >On 4/15/07, Dest Romano <[EMAIL PROTECTED]> wrote:
> > > > >
> > > > > Hello everyone,
> > > > >
> > > > > I am attempting to draw text over other players' heads.
> > > > >
> > > > > Serverside, NDebugOverlay::Text works perfectly fine
> > > > > However, I don't want to draw text over myself, so I am going to
> > draw
> > > it
> > > > > client side.
> > > > >
> > > > > When I do NDebugOverlay::Text clientside, it gives me an
> unresolved
> > > > > external
> > > > > symbol.
> > > > >
> > > > > I do have debugoverlay_shared.h included, and it is in
> game_shared,
> > so
> > > I
> > > > > don't see what is wrong.
> > > > >
> > > > > baseplayer_shared.obj : error LNK2019: unresolved external symbol
> > > "void
> > > > > __cdecl NDebugOverlay::Text(class Vector const &,char const
> > > >*,bool,float)"
> > > > > ([EMAIL PROTECTED]@@YAXABVVector@@[EMAIL PROTECTED]) referenced in
> function
> > > > > "public: virtual void __thiscall
> > C_BasePlayer::DrawJumbleNames(void)"
> > > > > ([EMAIL PROTECTED]@@UAEXXZ)
> > > > > 1>Release HL2MP/client.dll : fatal error LNK1120: 1 unresolved
> > > externals
> > > > >
> > > > > If anyone has another more flexible method of drawing text over
> > > entities
> > > > > client side, or a solution to this error, I would love to hear it!
> > > > >
> > > > > Thanks,
> > > > > Dest
> > > > >
> > >
> > > _________________________________________________________________
> > > MSN is giving away a trip to Vegas to see Elton John. Enter to win
> > today.
> > > http://msnconcertcontest.com?icid-nceltontagline
> > >
> > >
> > > _______________________________________________
> > > To unsubscribe, edit your list preferences, or view the list archives,
> > > please visit:
> > > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> > >
> > >
> > --
> >
> > _______________________________________________
> > To unsubscribe, edit your list preferences, or view the list archives,
> > please visit:
> > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> >
> >
> --
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>
>
--
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders