Resource:Dxscoreboard: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with '{{Resource page}} __NOTOC__ The DirectX scoreboard displays connected players, teams, pings and other data for players ingame. It also has a javascript-enabled web interface, so …')
 

Revision as of 13:24, 27 August 2009

The DirectX scoreboard displays connected players, teams, pings and other data for players ingame. It also has a javascript-enabled web interface, so it can be viewed from a browser. It's created as a replacement for the old scoreboard resource created by jbeta.

The biggest difference to the old resource is that it is created fully using MTA's DirectX drawing functions. When you add a column to the scoreboard, it's linked to the element data field of the same name, so if you add the "score" column, element data in the field "score" will be shown for all players and teams.

Download can be found at the MTA community page.

Exported functions

Click to collapse [-]
Server
bool scoreboardAddColumn ( string name, [ element forElement = getRootElement(), int width = 70, string friendlyName = name, int pos = scoreboardGetColumnCount() ] )
  • name: The column name (also the element data name used to get information from).
  • forElement: The player to who the column should be added for.
  • width: Width of the column in pixels.
  • friendlyName: Friendly name (displayed in the scoreboard) of the column.
  • pos: Position of the column.


bool scoreboardRemoveColumn ( string name, [ element forElement = getRootElement() ] )
  • name: The column name.
  • forElement: The player from who the column should be removed.


bool scoreboardClearColumns ( [ element forElement = getRootElement() ] )
  • forElement: The player whose scoreboard's columns should be cleared.


bool scoreboardResetColumns ( [ element forElement = getRootElement() ] )
  • forElement: The player whose scoreboard's columns should be reset (only leaves name and ping).


bool scoreboardSetForced ( bool forced, [ element forElement = getRootElement() ] )
  • forced: Should scoreboard be forced.
  • forElement: The player whose scoreboard should be forced.


bool scoreboardSetSortBy ( string name, [ bool descending = true, element forElement = getRootElement() ] )
  • name: The column name. Can also be nil making the sorting be disabled.
  • descending: Use descending sort.
  • forElement: The player whose scoreboard should be sorted.


int scoreboardGetColumnPos ( string name )
  • name: The column name.

Returns the column position.


int scoreboardGetColumnCount ()
  • No arguments.

Returns scoreboard column count.


Note: These functions used in scoreboard resource do also work in dxscoreboard.

bool addScoreboardColumn ( string columnName, element visibleToElement, int columnPosition, float columnSize )
bool removeScoreboardColumn ( string columnName )
bool setPlayerScoreboardForced ( player thePlayer, bool forced )
bool resetScoreboardColumns ()
Click to collapse [-]
Client
bool scoreboardAddColumn ( string name, [ int width = 70, string friendlyName = name, int pos = scoreboardGetColumnCount(), function textFunction = nil ] )
  • name: The column name (also the element data name used to get information from).
  • width: Width of the column in pixels.
  • friendlyName: Friendly name (displayed in the scoreboard) of the column.
  • pos: Position of the column.
  • textFunction: The text function used to process before displaying the content in the column. For example, this function would replace the "_"'s in player names with a space, if added to the "name" column.
function fixName( playerName )
    return playerName:gsub( "_", " " )
end


bool scoreboardRemoveColumn ( string name )
  • name: The column name.


bool scoreboardClearColumns ()
  • No arguments.


bool scoreboardResetColumns ()
  • No arguments.


bool scoreboardSetForced ( bool forced )
  • forced: Should scoreboard be forced.


bool scoreboardSetColumnTextFunction ( string name, function textFunction )
  • name: The column name.
  • textFunction: The text function used to process before displaying the content in the column. For example, this function would replace the "_"'s in player names with a space, if added to the "name" column.
function fixName( playerName )
    return playerName:gsub( "_", " " )
end


bool scoreboardSetSortBy ( string name, [ bool descending = true ] )
  • name: The column name. Can also be nil making the sorting be disabled.
  • descending: Use descending sort.


int scoreboardGetColumnPos ( string name )
  • name: The column name.

Returns the column position.


int scoreboardGetColumnCount ()
  • No arguments.

Returns scoreboard column count.


Note: These functions used in scoreboard resource do also work in dxscoreboard.

bool setScoreboardForced ( bool forced )

You can call them from another resource using call()

call ( getResourceFromName ( "dxscoreboard" ), "scoreboardAddColumn", "Wanted level" )

-- Note that this syntax is also valid
exports.dxscoreboard:scoreboardAddColumn( "Wanted level" )

You can set the scoreboard data with setElementData:

-- 3 is inserted in the player's wanted level column, if column
-- called "Wanted level" has been added in the scoreboard
setElementData ( player, "Wanted level", 3 )