Author Topic: Simple 3D Text Labels  (Read 5157 times)

Vortrex

  • Full Member
  • ***
  • Posts: 267
  • Karma: +54/-73
    • View Profile
Simple 3D Text Labels
« on: July 26, 2013, 07:23:29 am »
Okay, so after messing with some client features I found a neat and simple way to create 3D Text Labels. For those who don't know, this is a feature found in SA-MP that allows a server to create a label in the game world (instead of on the screen as HUD or something).

For the following snippet, and as far as LU goes, this is not limited to just labels. You could probably put images, windows of information and other things in the actual game world itself. This could be useful for putting clan logo's on top of player heads (which in my opinion, would make the word awesome an understatement). For now, I will just give you the snippet for labels and you can do the rest if you want.

To use this, just add the following snippet into a client script and use the following command:
/addlabel <text>

Keep in mind that the label disappears after you get too far away (15 units). It will reappear when you are in range.

This is tested as of a moment ago, and works smoothly on my PC.

Code: [Select]
function onClientCommand( command , params )
{
if( command.tolower( ) == "addlabel" )
{
if( params.len( ) > 0 )
{
local label = GUILabel( VectorScreen( 0 , 0 ) , ScreenSize( params.len( ) * 12 , 0 ) , params );
label.FontName = "Courier New";
label.FontSize = 12;
label.Colour = Colour( 255 , 255 , 255 );
AddGUILayer( label );
if( label )
{
Labels[ label.ID ] <- { };
Labels[ label.ID ].GamePos <- FindLocalPlayer( ).Pos;
Labels[ label.ID ].Label <- label;
Message( "[#00FF00]SUCCESS: [#FFFFFF]Label added!" );
}
else
{
Message( "[#00FF00]ERROR: [#FFFFFF]Could not add the label!" );
}
}
else
{
Message( "[#999999]USAGE: [#FFFFFF]/addlabel <message>" );
}
}
}

function onScriptLoad( )
{
Labels <- { };
}

function onClientRender( )
{
if( Labels.len( ) > 0 )
{
foreach( ii , vv in Labels )
{
if( GetDistance( FindLocalPlayer( ).Pos , vv.GamePos ) < 15 )
{
if( !vv.Label.Visible )
{
vv.Label.Visible = true;
}
vv.Label.Pos = WorldPosToScreen( vv.GamePos );
}
else
{
vv.Label.Visible = false;
}
}
}
}

Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: Simple 3D Text Labels
« Reply #1 on: July 26, 2013, 12:07:50 pm »
Screenshots?

Mido_Pop

  • Full Member
  • ***
  • Posts: 168
  • Karma: +6/-20
  • The_Pops ( War )
    • View Profile
Re: Simple 3D Text Labels
« Reply #2 on: July 26, 2013, 12:29:00 pm »
Nice One Vortrex  :)
« Last Edit: July 26, 2013, 12:31:07 pm by Mido_Pop »



Shadow.

  • Tester
  • Full Member
  • ****
  • Posts: 144
  • Karma: +16/-35
    • View Profile
Re: Simple 3D Text Labels
« Reply #3 on: July 26, 2013, 02:07:01 pm »
Pics:



My suggestion would be making the text labels bold and colourable :p
« Last Edit: July 26, 2013, 04:28:51 pm by Shadow. »

_TailS_

  • Newbie
  • *
  • Posts: 7
  • Karma: +2/-3
  • Who seeks shall find...
    • View Profile
Re: Simple 3D Text Labels
« Reply #4 on: July 26, 2013, 07:40:42 pm »
Good job !

Vortrex

  • Full Member
  • ***
  • Posts: 267
  • Karma: +54/-73
    • View Profile
Re: Simple 3D Text Labels
« Reply #5 on: July 26, 2013, 07:43:10 pm »
Thanks for the screenshots Shadow.

About the colors and bold fonts, I just wanted to say that this wasn't a full blown release or anything. I just wanted to show everybody how it worked (the basics). I think some developers could take it to the next level if they need to.

The only thing about it that I find weird is the line of sight. You can see the label through your player skin and stuff, which makes it a bit glitchy.

PatrikBr

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-1
  • Aaaah eu vo gozaaaar!
    • View Profile
Re: Simple 3D Text Labels
« Reply #6 on: June 12, 2014, 10:12:11 pm »
sorry man , but it's not work in my pc ,
If you don't like , dont fucking play it!
BUG RAGE 4 EVER : https://www.facebook.com/BugRageOProjeto?ref=bookmarks

 

© Liberty Unleashed Team.