RaceUnit Posted January 26, 2013 Share Posted January 26, 2013 Hello, I'm new to MTA servers. i have a couple of questions:" #1: I want to change the textcolour of the map name, in the left-bottom. I did see race_client.lua but i don't understeand that #2: Can i place 2 labels up the mapname in the left-bottom corners, one for the FPS and one for the spectators. I Hope you can help me. Link to comment
Ab-47 Posted January 26, 2013 Share Posted January 26, 2013 Simply use: dxDrawText And please post your script, would be easier to understand your problem and think of a solution to your problem. Link to comment
RaceUnit Posted January 26, 2013 Author Share Posted January 26, 2013 Simply use: dxDrawText And please post your script, would be easier to understand your problem and think of a solution to your problem. I know that, but how to change the colour, here is part off my code: g_dxGUI = { ranknum = dxText:create('1', screenWidth - 60, screenHeight - 95, false, 'bankgothic', 2, 'right'), ranksuffix = dxText:create('st', screenWidth - 40, screenHeight - 86, false, 'bankgothic', 1), checkpoint = dxText:create('0/0', screenWidth - 15, screenHeight - 54, false, 'bankgothic', 0.8, 'right'), timepassed = dxText:create('0:00:00', screenWidth - 10, screenHeight - 25, false, 'bankgothic', 0.7, 'right'), mapdisplay = dxText:create('Map: none', 2, screenHeight - dxGetFontHeight(0.7, 'bankgothic')/2, false, 'bankgothic', 0.5, 'left') } And i want 2 more lines; one with the FPS off the player and one with the spectators. Link to comment
Ab-47 Posted January 26, 2013 Share Posted January 26, 2013 for the color use; tocolor ( r, g, b, 255 ) Within your function. See more here: dxDrawText Link to comment
RaceUnit Posted January 26, 2013 Author Share Posted January 26, 2013 Now i cant see anything; i have this: g_dxGUI = { ranknum = dxText:create('1', screenWidth - 60, screenHeight - 95, false, 'bankgothic', 2, 'right'), ranksuffix = dxText:create('st', screenWidth - 40, screenHeight - 86, false, 'bankgothic', 1), checkpoint = dxText:create('0/0', screenWidth - 15, screenHeight - 54, false, 'bankgothic', 0.8, 'right'), timepassed = dxText:create('0:00:00', screenWidth - 10, screenHeight - 25, false, 'bankgothic', 0.7, 'right'), mapdisplay = dxText:create('Map: none', 2, screenHeight - dxGetFontHeight(0.7, 'bankgothic')/2, false, 'bankgothic', tocolor ( 255, 0, 0, 255 ), 0.5, 'left') } Link to comment
Anderl Posted January 26, 2013 Share Posted January 26, 2013 Because Race gamemode uses a library for DirectX texts different from dxDrawText. There's no color parameter in "create" method. Link to comment
RaceUnit Posted January 26, 2013 Author Share Posted January 26, 2013 But i have seen some servers that have map name coloured. Link to comment
Castillo Posted January 26, 2013 Share Posted January 26, 2013 Most of servers draw the text without the DirectX library provided by race author. You can still edit the library to add color coded. Link to comment
RaceUnit Posted January 26, 2013 Author Share Posted January 26, 2013 Most of servers draw the text without the DirectX library provided by race author.You can still edit the library to add color coded. Can you say how i do that? Link to comment
csiguusz Posted January 26, 2013 Share Posted January 26, 2013 I checked this library, and there is a dxText:color(r,g,b,a) function. I think you can change the color with it. Link to comment
Castillo Posted January 26, 2013 Share Posted January 26, 2013 Go to line 262 of the file at: "race/textlib.lua" and replace it with: dxDrawText ( self.strText, l, t, r, b, tocolor(unpack(self.tColor)), self.fScale, self.strFont, self.bHorizontalAlign, self.bVerticalAlign, self.bClip, self.bWordWrap, self.bPostGUI, true ) @csiguusz: He wants HEX color codes. Link to comment
RaceUnit Posted January 26, 2013 Author Share Posted January 26, 2013 Thanks, it worked! But can someone explain my how to show the FPS and spectators above the mapname? Link to comment
Castillo Posted January 26, 2013 Share Posted January 26, 2013 Well, you can download a FPS script, create a new text above the map name, and use the FPS script you downloaded to update it. Link to comment
RaceUnit Posted January 26, 2013 Author Share Posted January 26, 2013 I did make two labels, but i don't know how to parse the FPS in the label, i already have a FPS scoreboard resource. Link to comment
Castillo Posted January 26, 2013 Share Posted January 26, 2013 You can update the text when the element data of the FPS resource changes I think, or make something else to update it. Link to comment
Anderl Posted January 26, 2013 Share Posted January 26, 2013 You can also implement this in the script to get the FPS: viewtopic.php?f=91&t=47788 Then you call the function "getFPS". Link to comment
RaceUnit Posted January 27, 2013 Author Share Posted January 27, 2013 You can also implement this in the script to get the FPS: viewtopic.php?f=91&t=47788Then you call the function "getFPS". I have try that, but i don't know how to inplent in my label, this is what i have: g_dxGUI = { ranknum = dxText:create('', screenWidth - 60, screenHeight - 95, false, 'bankgothic', 2, 'right'), ranksuffix = dxText:create('', screenWidth - 40, screenHeight - 86, false, 'bankgothic', 1), checkpoint = dxText:create('', screenWidth - 15, screenHeight - 54, false, 'bankgothic', 0.8, 'right'), timepassed = dxText:create('0:00:00', screenWidth - 10, screenHeight - 25, false, 'bankgothic', 0.7, 'right'), mapdisplay = dxText:create('SPECTATORS: null', 2, screenHeight - dxGetFontHeight(2.3, 'bankgothic')/2, false, 'bankgothic', 0.55, 'left'), mapdisplay = dxText:create('FPS: null', 2, screenHeight - dxGetFontHeight(1.5, 'bankgothic')/2, false, 'bankgothic', 0.55, 'left'), mapdisplay = dxText:create('MAP: none', 2, screenHeight - dxGetFontHeight(0.7, 'bankgothic')/2, false, 'bankgothic', 0.55, 'left') } I want to change the "null" into the FPS. Link to comment
Anderl Posted January 27, 2013 Share Posted January 27, 2013 (edited) Read: http://lua-users.org/wiki/FunctionCallTutorial And use "dxText:text" and "getFPS" function, example: textObj:text ( getFPS() ); Also, you're creating three text objects with the same variable, you can't do it ( well, you can, but you won't be able to control them all ). Edited January 27, 2013 by Guest Link to comment
RaceUnit Posted January 27, 2013 Author Share Posted January 27, 2013 Read: http://lua-users.org/wiki/FunctionCallTutorialAnd use "dxText:text" and "getFPS" function, example: textObj:text ( getFPS() ); Also, you're creating three text objects with the same variable, you can't do it ( well, you can, but you won't be able to control them all ). Thanks! I'll will try it; iknow i use three same variables, but it was to test. edit: I'll tryd this code; but then the FPS won't work.. local iFPS = 0 local iFrames = 0 local iStartTick = getTickCount() function GetFPS( ) return iFPS end addEventHandler( 'onClientRender', root, function() iFrames = iFrames + 1 if getTickCount() - iStartTick >= 1000 then iFPS = iFrames iFrames = 0 iStartTick = getTickCount() end end ) addEventHandler('onClientResourceStart', g_ResRoot, function() g_Players = getElementsByType('player') fadeCamera(false,0.0) -- create GUI local screenWidth, screenHeight = guiGetScreenSize() g_dxGUI = { ranknum = dxText:create('', screenWidth - 60, screenHeight - 95, false, 'bankgothic', 2, 'right'), ranksuffix = dxText:create('', screenWidth - 40, screenHeight - 86, false, 'bankgothic', 1), checkpoint = dxText:create('', screenWidth - 15, screenHeight - 54, false, 'bankgothic', 0.8, 'right'), timepassed = dxText:create('0:00:00', screenWidth - 10, screenHeight - 25, false, 'bankgothic', 0.7, 'right'), mapdisplay = dxText:create('SPECTATORS: null', 2, screenHeight - dxGetFontHeight(2.3, 'bankgothic')/2, false, 'bankgothic', 0.55, 'left'), fpsdisplay = dxText:create('FPS: 0', 2, screenHeight - dxGetFontHeight(1.5, 'bankgothic')/2, false, 'bankgothic', 0.55, 'left'), mapdisplay = dxText:create('MAP: none', 2, screenHeight - dxGetFontHeight(0.7, 'bankgothic')/2, false, 'bankgothic', 0.55, 'left') } g_dxGUI.fpsdisplay:text(GetFPS()) Link to comment
Castillo Posted January 27, 2013 Share Posted January 27, 2013 local iFPS = 0 local iFrames = 0 local iStartTick = getTickCount() function GetFPS( ) return iFPS end addEventHandler('onClientResourceStart', g_ResRoot, function() g_Players = getElementsByType('player') fadeCamera(false,0.0) -- create GUI local screenWidth, screenHeight = guiGetScreenSize() g_dxGUI = { ranknum = dxText:create('', screenWidth - 60, screenHeight - 95, false, 'bankgothic', 2, 'right'), ranksuffix = dxText:create('', screenWidth - 40, screenHeight - 86, false, 'bankgothic', 1), checkpoint = dxText:create('', screenWidth - 15, screenHeight - 54, false, 'bankgothic', 0.8, 'right'), timepassed = dxText:create('0:00:00', screenWidth - 10, screenHeight - 25, false, 'bankgothic', 0.7, 'right'), mapdisplay = dxText:create('SPECTATORS: null', 2, screenHeight - dxGetFontHeight(2.3, 'bankgothic')/2, false, 'bankgothic', 0.55, 'left'), fpsdisplay = dxText:create('FPS: 0', 2, screenHeight - dxGetFontHeight(1.5, 'bankgothic')/2, false, 'bankgothic', 0.55, 'left'), mapdisplay = dxText:create('MAP: none', 2, screenHeight - dxGetFontHeight(0.7, 'bankgothic')/2, false, 'bankgothic', 0.55, 'left') } g_dxGUI.fpsdisplay:text(GetFPS()) addEventHandler( 'onClientRender', root, function() iFrames = iFrames + 1 if getTickCount() - iStartTick >= 1000 then iFPS = iFrames iFrames = 0 iStartTick = getTickCount() end g_dxGUI.fpsdisplay:text(GetFPS()) end ) 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