Hex codes

Everything else about resources.

Moderators: Scripting Moderators, Moderators, MTA Team

Hex codes

Postby krYshuT on Sat Nov 27, 2010 8:13 am

Is there any way to hide hex codes in player's names?

Nobody want it look like this:

Image

But what is odd - when you finish the race, the killmessages resource shows it without the hex code as "ESE|krYshuT". However, when i kill myself it shows as "ESE|#ff00ffkrYshuT
krYshuT
Civilian
 
Posts: 27
Joined: Sun Sep 26, 2010 5:11 am

Re: Hex codes

Postby Aibo on Sat Nov 27, 2010 8:17 am

playerName = string.gsub(playerName, '#%x%x%x%x%x%x', '')
?
User avatar
Aibo
Russian Section Moderator & Scripting Section Moderator
 
Posts: 1115
Joined: Sun Jul 29, 2007 12:23 am
Location: Soviet Russia

Re: Hex codes

Postby dzek (varez) on Sat Nov 27, 2010 8:58 am

you will have to edit every resource that is displaying it "wrong"
Multi theft auto tools - replace cars and peds, move your map or compile your lua files online!
programista php rzeszów
Do not ask me for help with scripting via pm!
Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
User avatar
dzek (varez)
Global Moderator
 
Posts: 4265
Joined: Sun Jan 04, 2009 1:37 pm
Location: Poland

Re: Hex codes

Postby krYshuT on Sat Nov 27, 2010 9:26 am

Well, there is this line in delay indicator resource:

delayDisplayBehind:text("+"..msToTimeStr(delayTime).." "..cps..getPlayerName(source))

I have no experience in coding, so I don't know how to make it work fine. I tried to edit it like:

delayDisplayBehind:text("+"..msToTimeStr(delayTime).." "..cps..string.gsub(playerName, '#%x%x%x%x%x%x', ''))

But it didn't work.

How it's correct?

Else in the killmessages resource I have no idea where to paste it to make it work. Can you help me with this?
krYshuT
Civilian
 
Posts: 27
Joined: Sun Sep 26, 2010 5:11 am

Re: Hex codes

Postby dzek (varez) on Sat Nov 27, 2010 10:05 am

  1.  
  2. delayDisplayBehind:text("+"..msToTimeStr(delayTime).." "..cps..string.gsub(getPlayerName(source), '#%x%x%x%x%x%x', ''))
  3.  
Multi theft auto tools - replace cars and peds, move your map or compile your lua files online!
programista php rzeszów
Do not ask me for help with scripting via pm!
Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
User avatar
dzek (varez)
Global Moderator
 
Posts: 4265
Joined: Sun Jan 04, 2009 1:37 pm
Location: Poland

Re: Hex codes

Postby krYshuT on Sat Nov 27, 2010 11:42 am

Works perfect, thanks much.

Just one more question. Is there a way to make color text else then in the chatbox? I've got one resources which generates text elsewhere.
krYshuT
Civilian
 
Posts: 27
Joined: Sun Sep 26, 2010 5:11 am

Re: Hex codes

Postby dzek (varez) on Sat Nov 27, 2010 1:16 pm

depends of the way the text is displayed.
Multi theft auto tools - replace cars and peds, move your map or compile your lua files online!
programista php rzeszów
Do not ask me for help with scripting via pm!
Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
User avatar
dzek (varez)
Global Moderator
 
Posts: 4265
Joined: Sun Jan 04, 2009 1:37 pm
Location: Poland

Re: Hex codes

Postby krYshuT on Sat Nov 27, 2010 2:08 pm

Ingame it looks like this:

Image

Lua file:

  1. local messagesList = {
  2.     "19.11.: ESE #00ff0013:3 TPT",
  3.     "ingame cycling text shows here",
  4.     "ingame cycling text shows here",
  5.     "ingame cycling text shows here",
  6.     "ingame cycling text shows here",
  7.     "ingame cycling text shows here",
  8.  
  9. }
  10. local currentMessage = 0
  11.  
  12. addEventHandler("onClientPreRender", getRootElement(),
  13.     function()
  14.         local screenWidth, screenHeight = guiGetScreenSize()
  15.  
  16.         -- Draw the news sticker.
  17.         dxDrawRectangle(screenWidth - 249, 4, 0, 20, tocolor(0, 0, 0, 192), false)
  18.        
  19.         -- Draw all strings.
  20.         dxDrawText(messagesList[currentMessage + 1], screenWidth - 246, 6, screenWidth - 6, 16, tocolor(255, 255, 255, 255), 1, "default-bold", "center", "top", false, false, false)
  21.     end
  22. )
  23.  
  24. function updateMessage()
  25.     if (currentMessage == 5) then
  26.         currentMessage = 0
  27.     else
  28.         currentMessage = currentMessage + 1
  29.     end
  30. end
  31. setTimer(updateMessage, 5000, 0)
krYshuT
Civilian
 
Posts: 27
Joined: Sun Sep 26, 2010 5:11 am

Re: Hex codes

Postby dzek (varez) on Sat Nov 27, 2010 2:29 pm

take a look here.
Multi theft auto tools - replace cars and peds, move your map or compile your lua files online!
programista php rzeszów
Do not ask me for help with scripting via pm!
Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
User avatar
dzek (varez)
Global Moderator
 
Posts: 4265
Joined: Sun Jan 04, 2009 1:37 pm
Location: Poland

Re: Hex codes

Postby krYshuT on Sat Nov 27, 2010 5:07 pm

Thanks varez, it took me like 2 hours to make it working, but it works :D
krYshuT
Civilian
 
Posts: 27
Joined: Sun Sep 26, 2010 5:11 am

Re: Hex codes

Postby dzek (varez) on Sat Nov 27, 2010 5:11 pm

your welcome, it's nice of you that you actually tried :)
Multi theft auto tools - replace cars and peds, move your map or compile your lua files online!
programista php rzeszów
Do not ask me for help with scripting via pm!
Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
User avatar
dzek (varez)
Global Moderator
 
Posts: 4265
Joined: Sun Jan 04, 2009 1:37 pm
Location: Poland


Return to Resources

Who is online

Users browsing this forum: No registered users and 9 guests