TheDeftGamer Posted May 22, 2010 Share Posted May 22, 2010 okay so ive made a gui window and i created a label which makes text show up which says UserNameHere So, this is where i want a persons user name to show up. So when you press a key, the window opens, and you see your name on the very top left. Label_PlayerName = guiCreateLabel(14,8,428,53,"UserNameHere",false,GUIEditor_Tab[1]) guiLabelSetColor(Label_PlayerName,255,255,255) guiLabelSetVerticalAlign(Label_Playername,"top") guiLabelSetHorizontalAlign(Label_Playername,"left",false) guiSetFont(Label_PlayerName,"sa-header") So how do i do this? I've been making alot of progress with learning to code but the wiki is not very helpful here. If anyone can help it would be highly appreciated. Link to comment
Xierra Posted May 22, 2010 Share Posted May 22, 2010 Here we go! Time for my GUI test! All right, to get player names, you can use getPlayerName function. If you want to get local player, it's good to use it client-side. local Localplayer = getPlayerName(getLocalPlayer()) Label_PlayerName = guiCreateLabel(14,8,428,53,LocalPlayer,false,GUIEditor_Tab[1]) guiLabelSetColor(Label_PlayerName,255,255,255) guiLabelSetVerticalAlign(Label_Playername,"top"). guiLabelSetHorizontalAlign(Label_Playername,"left",false) guiSetFont(Label_PlayerName,"sa-header") So the trick is that the text part (which you put quotes), you can change it into a variable OR a function. Note that getting output from a variable / function doesn't need a quote. Just see the difference in the Label text. I hope this helps. PS: Use [lua] if you wanna post codes with lua language, like mine. Link to comment
TheDeftGamer Posted May 22, 2010 Author Share Posted May 22, 2010 Sadly that did not work. I also had to remove the . because that made the entire window screw up lol. so now it looks like this: local Localplayer = getPlayerName(getLocalPlayer()) Label_PlayerName = guiCreateLabel(14,8,428,53,LocalPlayer,false,GUIEditor_Tab[1]) guiLabelSetColor(Label_PlayerName,255,255,255) guiLabelSetVerticalAlign(Label_Playername,"top") guiLabelSetHorizontalAlign(Label_Playername,"left",false) guiSetFont(Label_PlayerName,"sa-header") still isnt working.. this is hard to understand. all the wiki tutorials do is tell you how to get teh name output on the chatbox and theres nothing about displaying a playername using a label or anything for gui's. ;( EDIT: that first line gave me a debug error: failed to index a booleon variable Link to comment
Xierra Posted May 22, 2010 Share Posted May 22, 2010 Oh yeah I forgot something! Add this on the top. LocalPlayer = "" --I forgot this, please put this on line 1 Link to comment
Taalasmaa Posted May 22, 2010 Share Posted May 22, 2010 local Localplayer = getPlayerName(getLocalPlayer()) Label_PlayerName = guiCreateLabel(14,8,428,53,Localplayer,false,GUIEditor_Tab[1]) guiLabelSetColor(Label_PlayerName,255,255,255) guiLabelSetVerticalAlign(Label_Playername,"top") guiLabelSetHorizontalAlign(Label_Playername,"left",false) guiSetFont(Label_PlayerName,"sa-header") This should work.. No needed any LocalPlayer = "" XX3, you falied at "Localplayer = getPlayerName(getLocalPlayer())" and you put to label "LocalPlayer", insted of Localplayer Link to comment
TheDeftGamer Posted May 22, 2010 Author Share Posted May 22, 2010 taalasma, that was perfect! local Localplayer = getPlayerName(getLocalPlayer()) Label_PlayerName = guiCreateLabel(15,8,428,53,Localplayer,false,GUIEditor_Tab[1]) guiLabelSetColor(Label_PlayerName,255,255,255) guiLabelSetVerticalAlign(Label_Playername,"top") guiLabelSetHorizontalAlign(Label_Playername,"left",false) guiSetFont(Label_PlayerName,"sa-header") Thank you guys very much for the help, stop by the alw race server and see your help in action sometime! Link to comment
Xierra Posted May 23, 2010 Share Posted May 23, 2010 Awww. My mistake. Thanks Talasma. I'll be more careful next time. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now