iFoReX Posted April 26, 2012 Share Posted April 26, 2012 @tittle I put colorcodes to my script and it doesnt work function obtenerName() obtenerNombre = getPlayerName( source ) outputChatBox(" #00FF00 "..obtenerNombre.." , Tu nombre se te cambiara por tu nombre de cuenta cuando te desconectes te regresaremos tu nombre ", source, 255, 0, 0, true) end addEventHandler("onPlayerJoin", getRootElement(), obtenerName) function setearName() accountName = getAccountName( getPlayerAccount ( source ) ) outputChatBox(" #00FF00"..obtenerNombre.." , Ahora tu Nombre se cambio al Nombre de tu cuenta ("..accountName..") ", source, 255, 0, 0, true) setPlayerName( source, accountName ) end addEventHandler("onPlayerLogin", getRootElement(), setearName) function debolberName() setPlayerName( source, obtenerNombre ) end addEventHandler("onPlayerQuit", getRootElement(), debolberName) please help me Link to comment
Axel Posted April 26, 2012 Share Posted April 26, 2012 This should work: function obtenerName() obtenerNombre = getPlayerName( source ) outputChatBox(" #00FF00 "..obtenerNombre.." , Tu nombre se te cambiara por tu nombre de cuenta cuando te desconectes te regresaremos tu nombre ", source, 255, 0, 0, true) end addEventHandler("onPlayerJoin", getRootElement(), obtenerName) function setearName() accountName = getAccountName( getPlayerAccount ( source ) ) obtenerNombre = getPlayerName( source ) outputChatBox(" #00FF00"..obtenerNombre.." , Ahora tu Nombre se cambio al Nombre de tu cuenta ("..accountName..") ", source, 255, 0, 0, true) setPlayerName( source, accountName ) end addEventHandler("onPlayerLogin", getRootElement(), setearName) function debolberName() setPlayerName( source, obtenerNombre ) end addEventHandler("onPlayerQuit", getRootElement(), debolberName) (tested) Link to comment
iFoReX Posted April 26, 2012 Author Share Posted April 26, 2012 I edited , But now when I login the chatbox message doesnt appear function obtenerName() obtenerNombre = getPlayerName( source ) outputChatBox(" #00FF00 "..obtenerNombre.." , #00FF00Tu nombre se te cambiara por tu nombre de cuenta cuando te desconectes te regresaremos tu nombre ", source, 255, 0, 0, true) end addEventHandler("onPlayerJoin", getRootElement(), obtenerName) function setearName() accountName = getAccountName( getPlayerAccount ( source ) ) outputChatBox(" #00FF00"..obtenerNombre.." , #FF0000Ahora tu Nombre se cambio al Nombre de tu cuenta #00FF00( "..accountName.." ) ", source, 255, 0, 0, true) setPlayerName( source, accountName ) end addEventHandler("onPlayerLogin", getRootElement(), setearName) function debolberName() setPlayerName( source, obtenerNombre ) end addEventHandler("onPlayerQuit", getRootElement(), debolberName) Link to comment
Axel Posted April 26, 2012 Share Posted April 26, 2012 That's becouse obtenerNombre is not specified there, you have to insert obtenerNombre = getPlayerName( source ) there too. Copy again my code. Link to comment
iFoReX Posted April 26, 2012 Author Share Posted April 26, 2012 I copyed ur code again but when I join to my server doesnt appear the message in chatbox only when I login Link to comment
DNL291 Posted April 26, 2012 Share Posted April 26, 2012 The variable 'obtenerNombre' is not a global variable Link to comment
iFoReX Posted April 26, 2012 Author Share Posted April 26, 2012 and how I put it variable Global ? Link to comment
DNL291 Posted April 27, 2012 Share Posted April 27, 2012 local obtenerNombre = getPlayerName(source) function obtenerName() outputChatBox(" #00FF00 "..obtenerNombre.." , Tu nombre se te cambiara por tu nombre de cuenta cuando te desconectes te regresaremos tu nombre ", source, 255, 0, 0, true) end addEventHandler("onPlayerJoin", getRootElement(), obtenerName) function setearName() accountName = getAccountName( getPlayerAccount ( source ) ) outputChatBox(" #00FF00"..obtenerNombre.." , Ahora tu Nombre se cambio al Nombre de tu cuenta ("..accountName..") ", source, 255, 0, 0, true) setPlayerName( source, accountName ) end addEventHandler("onPlayerLogin", getRootElement(), setearName) function debolberName() setPlayerName( source, obtenerNombre ) end addEventHandler("onPlayerQuit", getRootElement(), debolberName) Link to comment
KenXeiko Posted April 27, 2012 Share Posted April 27, 2012 You can use this instead.. playerName = string.gsub (getPlayerName(source), "#x%x%x%x%x%x%", "") -- Replace player name color code to nothing outputChatBox (playerName.." bla bla bla", source, 255, 0, 0, false) Link to comment
iFoReX Posted April 27, 2012 Author Share Posted April 27, 2012 I dont want get the Colours of the Player I want put colours to my Message in chatboxes Link to comment
Castillo Posted April 28, 2012 Share Posted April 28, 2012 function obtenerName ( account ) local accountName accountName = getAccountName ( account ) local nombre = getPlayerName ( source ) -- You're calling the variable the same as the function name. outputChatBox ( " #00FF00 ".. nombre .." , Tu nombre se te cambiara por tu nombre de cuenta cuando te desconectes te regresaremos tu nombre ", source, 255, 0, 0, true ) outputChatBox(" #00FF00".. nombre .." , Ahora tu Nombre se cambio al Nombre de tu cuenta (".. accountName ..") ", source, 255, 0, 0, true ) setPlayerName ( source, accountName ) end addEventHandler ( "onPlayerJoin", root, obtenerName ) Link to comment
KenXeiko Posted April 28, 2012 Share Posted April 28, 2012 I dont want get the Colours of the Player I want put colours to my Message in chatboxes Nah, It doesn't mean like that. With string.gsub, It will replace any color code on player name, so you don't really need to put #FF0000 to your outputChatBox (Probably most people use it to make color code from player name will not appear if they set colorCoded to be false. So most people set colorCoded to be true and put color code at the outputChatBox to handle it). I'm not sure it's your problem, but that's my idea. At least try it. 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