Resource:Dxscoreboard: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 11: Line 11:
<section name="Server" class="server" show="true">
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool scoreboardAddColumn ( string name, [ element forElement = getRootElement(), int width = 70, string friendlyName = name, int pos = scoreboardGetColumnCount() + 1 ] )
bool scoreboardAddColumn ( string name, [ element forElement = getRootElement(), int width = 70, string friendlyName = name, int priority = slot after "name" column ] )
</syntaxhighlight>
</syntaxhighlight>
*'''name:''' The column name (also the element data name used to get information from).
*'''name:''' The column name (also the element data name used to get information from).
Line 17: Line 17:
*'''width:''' Width of the column in pixels.
*'''width:''' Width of the column in pixels.
*'''friendlyName:''' Friendly name (displayed in the scoreboard) of the column.
*'''friendlyName:''' Friendly name (displayed in the scoreboard) of the column.
*'''pos:''' Position of the column.
*'''priority:''' The priority slot of the column (1-500). If slot isn't free, the column in that slot will be pushed forward.
<br>
<br>


Line 55: Line 55:


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int scoreboardGetColumnPos ( string name )
int scoreboardGetColumnPriority ( string name )
</syntaxhighlight>
</syntaxhighlight>
*'''name:''' The column name.
*'''name:''' The column name.
'''Returns the column position.'''
'''Returns the column priority (1-500).'''
<br>
<br>


<syntaxhighlight lang="lua">
bool scoreboardSetColumnPriority ( string name, int priority, [ element forElement = getRootElement() ] )
</syntaxhighlight>
*'''name:''' The column name.
*'''priority:''' The priority slot of the column (1-500). If slot isn't free, the column in that slot will be pushed forward.
*'''forElement:''' The player to who the column should be added for.
<br>


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 67: Line 75:
*''No arguments.''
*''No arguments.''
'''Returns scoreboard column count.'''
'''Returns scoreboard column count.'''
<br>
<syntaxhighlight lang="lua">
bool scoreboardForceTeamsVisible( bool enabled )
</syntaxhighlight>
*'''enabled:''' Should the team header be always visible in the scoreboard (client's setting will be ignored)?
<br>
<syntaxhighlight lang="lua">
bool scoreboardForceTeamsHidden( bool enabled )
</syntaxhighlight>
*'''enabled:''' Should the team header be always hidden in the scoreboard (client's setting will be ignored)?
<br>
<syntaxhighlight lang="lua">
bool isPrioritySlotFree( int slot )
</syntaxhighlight>
*'''slot:''' The priority slot that should be checked.
'''Checks if the specified priority slot is free.'''
<br>
<syntaxhighlight lang="lua">
int getNextFreePrioritySlot( [ int startAt = 1 ] )
</syntaxhighlight>
*'''startAt:''' At which point should we start looking for free slots.
'''Finds the next free priority slot.'''
<br>
<br>


Line 80: Line 116:
<section name="Client" class="client" show="true">
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool scoreboardAddColumn ( string name, [ int width = 70, string friendlyName = name, int pos = scoreboardGetColumnCount() + 1, function textFunction = nil ] )
bool scoreboardAddColumn ( string name, [ int width = 70, string friendlyName = name, int priority = slot after "name" column, function textFunction = nil ] )
</syntaxhighlight>
</syntaxhighlight>
*'''name:''' The column name (also the element data name used to get information from).
*'''name:''' The column name (also the element data name used to get information from).
*'''width:''' Width of the column in pixels.
*'''width:''' Width of the column in pixels.
*'''friendlyName:''' Friendly name (displayed in the scoreboard) of the column.
*'''friendlyName:''' Friendly name (displayed in the scoreboard) of the column.
*'''pos:''' Position of the column.
*'''priority:''' The priority slot of the column (1-500). If slot isn't free, the column in that slot will be pushed forward.
*'''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.
*'''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.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 138: Line 174:


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int scoreboardGetColumnPos ( string name )
int scoreboardGetColumnPriority ( string name )
</syntaxhighlight>
</syntaxhighlight>
*'''name:''' The column name.
*'''name:''' The column name.
'''Returns the column position.'''
'''Returns the column priority (1-500).'''
<br>
<br>


<syntaxhighlight lang="lua">
bool scoreboardSetColumnPriority ( string name, int priority )
</syntaxhighlight>
*'''name:''' The column name.
*'''priority:''' The priority slot of the column (1-500). If slot isn't free, the column in that slot will be pushed forward.
*'''forElement:''' The player to who the column should be added for.
<br>


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 151: Line 195:
'''Returns scoreboard column count.'''
'''Returns scoreboard column count.'''
<br>
<br>
<syntaxhighlight lang="lua">
bool isPrioritySlotFree( int slot )
</syntaxhighlight>
*'''slot:''' The priority slot that should be checked.
'''Checks if the specified priority slot is free.'''
<br>
<syntaxhighlight lang="lua">
int getNextFreePrioritySlot( [ int startAt = 1 ] )
</syntaxhighlight>
*'''startAt:''' At which point should we start looking for free slots.
'''Finds the next free priority slot.'''
<br>
<syntaxhighlight lang="lua">
int, int scoreboardGetTopCornerPosition ()
</syntaxhighlight>
'''Returns the absolute position of the scoreboards top corner if it's drawn, ''false'' otherwise.'''
<br>
<syntaxhighlight lang="lua">
int, int scoreboardGetSize ()
</syntaxhighlight>
'''Returns the absolute size (width, height) of the scoreboard if it's drawn, ''false'' otherwise.'''
<br>





Revision as of 19:05, 16 September 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 priority = slot after "name" column ] )
  • 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.
  • priority: The priority slot of the column (1-500). If slot isn't free, the column in that slot will be pushed forward.


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 scoreboardGetColumnPriority ( string name )
  • name: The column name.

Returns the column priority (1-500).


bool scoreboardSetColumnPriority ( string name, int priority, [ element forElement = getRootElement() ] )
  • name: The column name.
  • priority: The priority slot of the column (1-500). If slot isn't free, the column in that slot will be pushed forward.
  • forElement: The player to who the column should be added for.


int scoreboardGetColumnCount ()
  • No arguments.

Returns scoreboard column count.


bool scoreboardForceTeamsVisible( bool enabled )
  • enabled: Should the team header be always visible in the scoreboard (client's setting will be ignored)?


bool scoreboardForceTeamsHidden( bool enabled )
  • enabled: Should the team header be always hidden in the scoreboard (client's setting will be ignored)?


bool isPrioritySlotFree( int slot )
  • slot: The priority slot that should be checked.

Checks if the specified priority slot is free.


int getNextFreePrioritySlot( [ int startAt = 1 ] )
  • startAt: At which point should we start looking for free slots.

Finds the next free priority slot.


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 priority = slot after "name" column, 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.
  • priority: The priority slot of the column (1-500). If slot isn't free, the column in that slot will be pushed forward.
  • 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 scoreboardGetColumnPriority ( string name )
  • name: The column name.

Returns the column priority (1-500).


bool scoreboardSetColumnPriority ( string name, int priority )
  • name: The column name.
  • priority: The priority slot of the column (1-500). If slot isn't free, the column in that slot will be pushed forward.
  • forElement: The player to who the column should be added for.


int scoreboardGetColumnCount ()
  • No arguments.

Returns scoreboard column count.


bool isPrioritySlotFree( int slot )
  • slot: The priority slot that should be checked.

Checks if the specified priority slot is free.


int getNextFreePrioritySlot( [ int startAt = 1 ] )
  • startAt: At which point should we start looking for free slots.

Finds the next free priority slot.


int, int scoreboardGetTopCornerPosition ()

Returns the absolute position of the scoreboards top corner if it's drawn, false otherwise.


int, int scoreboardGetSize ()

Returns the absolute size (width, height) of the scoreboard if it's drawn, false otherwise.


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 )