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

