Jump to content

[HELP] Some questions


RaceUnit

Recommended Posts

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
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

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

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
You can also implement this in the script to get the FPS: viewtopic.php?f=91&t=47788

Then 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
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 ).

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...