papam77 Posted July 17, 2013 Share Posted July 17, 2013 function onlog (player) local g_Name = getPlayerName() Label = guiCreateLabel(0.35, 0.97, 0.29, 0.03,""..g_Name.." has been logged in !", true) guiLabelSetHorizontalAlign(Label, "center", false) guiLabelSetVerticalAlign(Label, "center") font = guiCreateFont( "lithos.ttf", 20 ) guiSetFont( Label, font ) end addEvent( "onlog", true ) addEventHandler( "onlog", getRootElement(), onlog ) Why it doesn't get my name in label? Link to comment
Castillo Posted July 17, 2013 Share Posted July 17, 2013 Because you aren't filling the argument for getPlayerName. Link to comment
papam77 Posted July 17, 2013 Author Share Posted July 17, 2013 function onlog ( thePlayer ) Label = guiCreateLabel(0.35, 0.97, 0.29, 0.03,"[LOGIN] "..getPlayerName( thePlayer )" has been logged in !", true) guiLabelSetHorizontalAlign(Label, "center", false) guiLabelSetVerticalAlign(Label, "center") font = guiCreateFont( "lithos.ttf", 20 ) guiSetFont( Label, font ) end addEvent( "onlog", true ) addEventHandler( "onlog", getRootElement(), onlog ) I've tryied this, and nothing. Link to comment
Castillo Posted July 17, 2013 Share Posted July 17, 2013 Show me how you trigger: "onlog". Link to comment
papam77 Posted July 17, 2013 Author Share Posted July 17, 2013 function onlog () triggerClientEvent ( "onlog", getRootElement()) end addEventHandler ("onPlayerLogin", getRootElement(), onlog) Link to comment
Castillo Posted July 17, 2013 Share Posted July 17, 2013 triggerClientEvent ( "onlog", getRootElement(), source ) Link to comment
papam77 Posted July 17, 2013 Author Share Posted July 17, 2013 And this please function onlog ( source ) Label = guiCreateLabel(0.00, 0.97, 1.00, 0.03,gsub("#%x%x%x%x%x%x"),getPlayerName( source ).." has been logged in !", true) guiLabelSetHorizontalAlign(Label, "center", false) guiLabelSetVerticalAlign(Label, "center") font = guiCreateFont( "lithos.ttf", 17 ) guiSetFont( Label, font ) end addEvent( "onlog", true ) addEventHandler( "onlog", getRootElement(), onlog ) Why doesn't work player's name hex color in label? Link to comment
Castillo Posted July 17, 2013 Share Posted July 17, 2013 Because you are doing it wrong. Label = guiCreateLabel(0.00, 0.97, 1.00, 0.03,getPlayerName( source ):gsub("#%x%x%x%x%x%x", "") .." has been logged in !", true) Link to comment
papam77 Posted July 17, 2013 Author Share Posted July 17, 2013 ERROR: JQ/join_c.lua:3: bad argument #2 to 'gsub' (string\function\table expected) Doesn't work. Link to comment
papam77 Posted July 17, 2013 Author Share Posted July 17, 2013 Work it. And how can destroy this text after 5sec ? Link to comment
papam77 Posted July 17, 2013 Author Share Posted July 17, 2013 function onlog ( source ) Label = guiCreateLabel(0.00, 0.97, 1.00, 0.03,getPlayerName( source ):gsub("#%x%x%x%x%x%x", "") .." has been logged in !", true) guiLabelSetHorizontalAlign(Label, "center", false) guiLabelSetVerticalAlign(Label, "center") font = guiCreateFont( "lithos.ttf", 17 ) guiSetFont( Label, font ) if ( Label ) then setTimer (destroyElement ( Label ), 5000, 1 ) end end I've tryied this and nothing. Link to comment
Castillo Posted July 17, 2013 Share Posted July 17, 2013 Because you did it wrong, arguments for destroyElement go after the setTimer arguments. setTimer ( destroyElement, 5000, 1, Label ) Link to comment
papam77 Posted July 17, 2013 Author Share Posted July 17, 2013 And last ask function onlog ( source ) Label = guiCreateLabel(0.00, 0.97, 1.00, 0.03,getPlayerName( source ):gsub("#%x%x%x%x%x%x", "") .." has been logged in !", true) guiLabelSetHorizontalAlign(Label, "center", false) guiLabelSetVerticalAlign(Label, "center") font = guiCreateFont( "lithos.ttf", 17 ) guiSetFont( Label, font ) if ( Label ) then setTimer ( destroyElement, 3000, 1, Label ) end end addEvent( "onlog", true ) addEventHandler( "onlog", getRootElement(), onlog ) function onlogout ( source ) Label2 = guiCreateLabel(0.00, 0.97, 1.00, 0.03,getPlayerName( source ):gsub("#%x%x%x%x%x%x", "") .." has been logged out !", true) guiLabelSetHorizontalAlign(Label2, "center", false) guiLabelSetVerticalAlign(Label2, "center") font = guiCreateFont( "lithos.ttf", 17 ) guiSetFont( Label2, font ) if ( Label2 ) then setTimer ( destroyElement, 3000, 1, Label2 ) end end addEvent( "onlogout", true ) addEventHandler( "onlogout", getRootElement(), onlogout ) function onjoin ( source ) Label1 = guiCreateLabel(0.00, 0.97, 1.00, 0.03,getPlayerName( source ):gsub("#%x%x%x%x%x%x", "") .." has been joined to server !", true) guiLabelSetHorizontalAlign(Label1, "center", false) guiLabelSetVerticalAlign(Label1, "center") font = guiCreateFont( "lithos.ttf", 17 ) guiSetFont( Label1, font ) if ( Label1 ) then setTimer ( destroyElement, 3000, 1, Label1 ) end end addEvent( "onjoin", true ) addEventHandler( "onjoin", getRootElement(), onjoin ) How can do this: When it show "Label" then destroy "Label1" if is on the screen. Because i made this: if ( Label ) then destroyElement ( Label1 ) end And it is making bugs. Link to comment
denny199 Posted July 17, 2013 Share Posted July 17, 2013 How can do this: When it show "Label" then destroy "Label1" if is on the screen. Because i made this: if ( Label ) then destroyElement ( Label1 ) end And it is making bugs. it cheks for "Label" instead of "Label1" 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