Thread Tools Display Modes
02-14-10, 12:33 PM   #1
ShetiPhian
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 23
Can you get the servers name?

I use Stuf Unit Frames and would like to replace the (*) that appears after a players name with the server name.

I'm sure I need to use the Custom Lua option but don't know the script
  Reply With Quote
02-14-10, 12:43 PM   #2
Cralor
Mmm... cookies!!!
 
Cralor's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 772
Try this:

GetServerName();

Code:
local serverName = GetServerName();
__________________
Never be satisfied with satisfactory.
  Reply With Quote
02-14-10, 02:17 PM   #3
ShetiPhian
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 23
so simple, now I feel dumb

Thankyou
  Reply With Quote
02-14-10, 03:21 PM   #4
ShetiPhian
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 23
um.. I must need something inside of the ()


This returns nothing:
Code:
function(unit, cache, textframe) local servername = GetServerName() return servername end

This returns Server
Code:
function(unit, cache, textframe) local servername = "Server" return servername end

now to find whats missing
  Reply With Quote
02-14-10, 03:25 PM   #5
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
Are you looking for UnitName?
Code:
local name, realm = UnitName(unit)
I've never come across GetServerName(), I only know GetRealmName()
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
02-14-10, 03:28 PM   #6
Cralor
Mmm... cookies!!!
 
Cralor's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 772
Hmm... you know, I thought the same thing. Looks like I'll have to delete that WoWWiki article with false information.
__________________
Never be satisfied with satisfactory.
  Reply With Quote
02-14-10, 04:07 PM   #7
Shadowed
...
Premium Member
Featured
Join Date: Feb 2006
Posts: 387
You can just use the function Blizzard adds in UnitFrame.lua:

Code:
function GetUnitName(unit, showServerName)
	local name, server = UnitName(unit);
	if ( server and server ~= "" ) then
		if ( showServerName ) then
			return name.." - "..server;
		else
			return name..FOREIGN_SERVER_LABEL;
		end
	else
		return name;
	end
end
So GetUnitName("target", true) will show the full name and server if they target is from a different one.
  Reply With Quote
02-14-10, 05:33 PM   #8
ShetiPhian
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 23
So I think changing the code in core.lua will work better then trying the built in custom lua box.

I found this in core.lua
Code:
local function GetUnitName(unit)
	local name, server = UnitName(unit)
	if server and server ~= "" then
		return name..FOREIGN_SERVER_LABEL
	else
		return name
	end
end
and I changed it to this:
Code:
local function GetUnitName(unit)
	local name, server = UnitName(unit)
	if server and server ~= "" then
		return name.." - "..server
	else
		return name
	end
end
I'm sitting in queue now, hope it works.
  Reply With Quote
02-14-10, 06:39 PM   #9
ShetiPhian
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 23
That worked, Thank you for all the help!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Can you get the servers name?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off