goodiewarrior Posted July 12, 2016 Posted July 12, 2016 Hello, I want to shorten a string like, if one string (nickname from player) is too long, shorten it. Like this: -> original string: Nickname -> remove it untill it is only 4 length. -> returns Nick
G-Stefan Posted July 12, 2016 Posted July 12, 2016 One way is to split it in letters then create a new variable which will contain the four chars in a string The function is here https://wiki.multitheftauto.com/wiki/RemoveHex NOT CREATED BY ME Multi Theft Auto : Racers Land 10%
Walid Posted July 12, 2016 Posted July 12, 2016 One way is to split it in letters then create a new variable which will contain the four chars in a stringThe function is here https://wiki.multitheftauto.com/wiki/RemoveHex NOT CREATED BY ME I think you need to read his question again. RemoveHex(created By me) : This function is used to remove hex color codes from strings. Hello, I want to shorten a string like, if one string (nickname from player) is too long, shorten it.Like this: -> original string: Nickname -> remove it untill it is only 4 length. -> returns Nick All what you need string.len if (string.len (name) > 4) then -- change the player name end For more information about strings check my tuto Lua Strings Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
John Smith Posted July 12, 2016 Posted July 12, 2016 Generally to shorten a string, you should use string.sub e.g: local myString = "Nickname" outputChatBox( string.sub(myString, 1, 4) ) -- Returns 'Nick' Number 1 in there indicates where you want to shorten the string from, in case it's from N ( Nickname ) and Number 4 indicates where to you want to shorten the string, in this case to k ( Nickname ) If you find my post useful or if it helped you, please like my post Ingame name: ZoeN
G-Stefan Posted July 12, 2016 Posted July 12, 2016 Wrong function lol I searched for string. Split ) Multi Theft Auto : Racers Land 10%
Voltex'GNR Posted July 13, 2016 Posted July 13, 2016 One way is to split it in letters then create a new variable which will contain the four chars in a stringThe function is here https://wiki.multitheftauto.com/wiki/RemoveHex NOT CREATED BY ME I think you need to read his question again. RemoveHex(created By me) : This function is used to remove hex color codes from strings. Hello, I want to shorten a string like, if one string (nickname from player) is too long, shorten it.Like this: -> original string: Nickname -> remove it untill it is only 4 length. -> returns Nick All what you need string.len if (string.len (name) > 4) then -- change the player name end For more information about strings check my tuto Lua Strings removeHex, isn't removing the Hexs Today These Days the only Solution to remove hexs, is to remove the Color of The Player When he chats.
Walid Posted July 13, 2016 Posted July 13, 2016 removeHex, isn't removing the Hexs TodayThese Days the only Solution to remove hexs, is to remove the Color of The Player When he chats. Really lol ? simply to prevent players from using hex codes you can use it on: onPlayerJoin onPlayerChangeNick Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
TorNix~|nR Posted July 13, 2016 Posted July 13, 2016 if you need to remove the colors in chat and in server use this addEventHandler ( "onPlayerConnect", getRootElement(),function(nick) if(string.find(nick,"#%x%x%x%x%x%x"))then cancelEvent(true,"Remove your name colors for join the IP") end end) addEventHandler ( "onPlayerConnect", getRootElement(),function(nick) if(string.find(nick,"##%x%x%x%x%x%x"))then cancelEvent(true,"Remove your name colors for join the IP") end end) addEventHandler ( "onPlayerChat", getRootElement(),function(nick) if(string.find(nick,"#%x%x%x%x%x%x"))then kickPlayer(source, getRootElement(), "Do not use colors in Chat!") end end) addEventHandler ( "onPlayerChat", getRootElement(),function(nick) if(string.find(nick,"##%x%x%x%x%x%x"))then kickPlayer(source, getRootElement(), "Do not use colors in Chat!") end end) ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003
TorNix~|nR Posted July 15, 2016 Posted July 15, 2016 You're welcome. ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003
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