GetPlayerStat: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
{{Server client function}}
__NOTOC__
__NOTOC__
==Description==
==Description==
Line 5: Line 6:
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
float getPlayerStat ( player player, stat )
float getPlayerStat ( player thePlayer, int stat )
</syntaxhighlight>
</syntaxhighlight>


===Required Arguments===
===Required Arguments===
*'''player''': The [[player]] whose stat you want to retrieve.
*'''thePlayer''': The [[player]] whose stat you want to retrieve.
*'''stat''': A whole number determining the stat ID.
*'''stat''': A whole number determining the stat ID.


Line 16: Line 17:


==Example==
==Example==
This example outputs a players stat.
<section name="Server" class="server" show="true">
This example outputs a player's stat in the chat box.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function onPlayerSpawn ( player )
function onPlayerSpawn ( spawnedPlayer )
  stat = getPlayerStat ( player, 102 )
    local stat = getPlayerStat ( spawnedPlayer, 102 )
  -- Check that getPlayerStat returned a value
    -- Check that getPlayerStat returned a value
  if ( stat ) then
    if ( stat ) then
-- Output the stat in the chat text
        -- Output the stat in the chat box
    outputChatBox ( "The player's stat for 102 is: " .. stat )
        outputChatBox ( "The value for " .. getClientName ( spawnedPlayer ) .. "'s 102 stat is " .. stat )
    end
end
end
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Player functions}}
{{Player functions}}

Revision as of 13:40, 19 August 2007

Description

This function returns a float that contains the value of the specified statistic, for a specific player.

Syntax

float getPlayerStat ( player thePlayer, int stat )

Required Arguments

  • thePlayer: The player whose stat you want to retrieve.
  • stat: A whole number determining the stat ID.

Returns

Returns a float indicating the statistic value.

Example

Click to collapse [-]
Server

This example outputs a player's stat in the chat box.

function onPlayerSpawn ( spawnedPlayer )
    local stat = getPlayerStat ( spawnedPlayer, 102 )
    -- Check that getPlayerStat returned a value
    if ( stat ) then
        -- Output the stat in the chat box
        outputChatBox ( "The value for " .. getClientName ( spawnedPlayer ) .. "'s 102 stat is " .. stat )
    end
end

See Also