Jump to content

[HELP] Some questions


RaceUnit

Recommended Posts

Posted

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.

Posted

Simply use:

dxDrawText 

And please post your script, would be easier to understand your problem and think of a solution to your problem.

And now Aurora is back again, pm for more info.

Ex. Lead dev & L6 Staff at AUR, NGC, MTA RP & SAA.

Ex. Developer at Community of Social Gamers - CSG

Ex Founder of International Gaming Community - IGC and Union of Individual Players- UIP

9o6E8.png Ab-47

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

Posted

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') 
        } 

Posted

Because Race gamemode uses a library for DirectX texts different from dxDrawText. There's no color parameter in "create" method.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

Most of servers draw the text without the DirectX library provided by race author.

You can still edit the library to add color coded.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Posted

I checked this library, and there is a dxText:color(r,g,b,a) function. I think you can change the color with it.

Owner of [HUN]Magyar Play Szerver 1.4, IP: 31.220.43.153:22003

Posted

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You can update the text when the element data of the FPS resource changes I think, or make something else to update it.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Posted (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 by Guest

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted
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()) 

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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