• k,v pairs stuff
    4 replies, posted
I understand the title is not the best but i don't know what else to say, i need to make a table holding ranks and colors assigned to them then lay them out and assign the color to a draw.DrawText() [CODE] AHUD.RankColors = { ["owner"] = Color( 0, 255, 255, 255 ), ["coowner"] = Color( 0, 255, 255, 255 ), ["admin"] = Color( 0, 255, 255, 255 ), ["superadmin"] = Color( 0, 255, 255, 255 ), } [/CODE] For example, a table like this and have them read in a function like this [CODE] local g = self:GetNWString( "usergroup" ) draw.DrawText( "Rank: " .. string.upper( g ), "AHudFont_20", x, y-h+69, COLOR GOES HERE, 1 ) [/CODE] but the color should only go their if the rank is the same in AHUD.RankColors["HERE"]
Just do this: [CODE] AHUD.RankColors[ self:GetNWString( "usergroup" ) ] [/CODE] But you might want to add a default color, for example, white: [CODE] AHUD.RankColors[ self:GetNWString( "usergroup" ) ] or Color( 255, 255, 255 ) [/CODE] In the original code it'd look like this: [CODE] local g = self:GetNWString( "usergroup" ) draw.DrawText( "Rank: " .. string.upper( g ), "AHudFont_20", x, y-h+69, AHUD.RankColors[ g ] or Color( 255, 255, 255 ), 1 ) [/CODE] Also, you can use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/GetUserGroup]Player:GetUserGroup[/url] instead of GetNWString (I think)
[QUOTE=MPan1;52193055]Just do this: [CODE] AHUD.RankColors[ self:GetNWString( "usergroup" ) ] [/CODE] But you might want to add a default color, for example, white: [CODE] AHUD.RankColors[ self:GetNWString( "usergroup" ) ] or Color( 255, 255, 255 ) [/CODE] In the original code it'd look like this: [CODE] local g = self:GetNWString( "usergroup" ) draw.DrawText( "Rank: " .. string.upper( g ), "AHudFont_20", x, y-h+69, AHUD.RankColors[ g ] or Color( 255, 255, 255 ), 1 ) [/CODE] Also, you can just use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/GetUserGroup]Player:GetUserGroup[/url] instead of GetNWString (I think)[/QUOTE] Yea Player:GetUserGroup() is a 10x better method than GetNWString. some admin mods use a different method of getting a players user group ;)
[QUOTE=Tupac;52193782]Yea Player:GetUserGroup() is a 10x better method than GetNWString. some admin mods use a different method of getting a players user group ;)[/QUOTE] How is GetUserGroup 10 times better? It literally just calls GetNWString. [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/includes/extensions/player_auth.lua#L34-L40[/url]
[QUOTE=Sean Bean;52195107]How is GetUserGroup 10 times better? It literally just calls GetNWString. [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/includes/extensions/player_auth.lua#L34-L40[/url][/QUOTE] Because it allows the admin mod to overwrite the function.
Sorry, you need to Log In to post a reply to this thread.