Resource:Exp system

From Multi Theft Auto: Wiki
Revision as of 04:21, 17 April 2012 by Castillo (talk | contribs)
Jump to navigation Jump to search

A level/experience system made from scratch by Castillo.
It uses SQLite to save level and experience.

Exported Functions

Click to collapse [-]
Server

This function is used to get a player level.

Syntax

bool getPlayerLevel ( player thePlayer )

Required Arguments

  • thePlayer: The player element you wish you get the level.

Returns

Returns a number with with the level of the player. <syntaxhighlight lang="lua"> addCommandHandler ( "mylevel", function ( thePlayer )

               local myExp = exports.exp_system:getPlayerLevel ( thePlayer )

outputChatBox ( "Your level is: ".. myLevel, thePlayer ) end )

Click to collapse [-]
Server

This function is used to set a player level.

Syntax

bool setPlayerLevel ( player thePlayer, int theLevel )

Required Arguments

  • thePlayer: The player element you wish you set the level.
  • theLevel: The level you want to set.

Returns

Returns a bool, whether the level was set successfully or not. <syntaxhighlight lang="lua"> addCommandHandler ( "setmylevel", function ( thePlayer, commandName, theLevel )

               local theLevel = tonumber ( theLevel ) or 1

exports.exp_system:setPlayerLevel ( thePlayer, theLEvel ) end )

Click to collapse [-]
Server

This function is used to get a player experience.

Syntax

bool getPlayerEXP ( player thePlayer )

Required Arguments

  • thePlayer: The player element you wish you get the experience.

Returns

Returns a number with with the experience of the player.

Example

<syntaxhighlight lang="lua"> addCommandHandler ( "myexp", function ( thePlayer )

               local myExp = exports.exp_system:getPlayerEXP ( thePlayer )

outputChatBox ( "Your experience is: ".. myExp, thePlayer ) end )

Click to collapse [-]
Server

This function is used to set a player experience.

Syntax

bool setPlayerEXP ( player thePlayer, int theExperience )

Required Arguments

  • thePlayer: The player element you wish you set the experience.
  • theExperience: The exprience you want to set.

Returns

Returns a bool, whether the experience was set successfully or not.

Example

<syntaxhighlight lang="lua"> addCommandHandler ( "setmyexp", function ( thePlayer, commandName, theExp )

               local theExp = tonumber ( theExp ) or 0

exports.exp_system:setPlayerEXP ( thePlayer, theExp ) end )

Click to collapse [-]
Server

This function is used to give a player experience.

Syntax

bool addPlayerEXP ( player thePlayer, int theExperience )

Required Arguments

  • thePlayer: The player element you wish you to give the experience.
  • theExperience: The exprience you want to give.

Returns

Returns a bool, whether the experience was given successfully or not.

Example

<syntaxhighlight lang="lua"> addEvent ( "onZombieWasted", true ) addEventHandler ( "onZombieWasted", root, function ( theKiller ) exports.exp_system:addPlayerEXP ( theKiller, 5 ) end )

Click to collapse [-]
Server

This function is used to get a account level.

Syntax

bool getAccountLevel ( account theAccount )

Required Arguments

  • theAccount: The player element you wish you get the level.

Returns

Returns a number with with the level of the player. <syntaxhighlight lang="lua"> addCommandHandler ( "mylevel", function ( thePlayer ) local account = getPlayerAccount ( thePlayer )

               local myExp = exports.exp_system:getAccountLevel ( account )

outputChatBox ( "Your account level is: ".. myLevel, thePlayer ) end )

Click to collapse [-]
Server

This function is used to set a player level.

Syntax

bool setAccountLevel ( account theAccount, int theLevel )

Required Arguments

  • theAccount: The player element you wish you set the level.
  • theLevel: The level you want to set.

Returns

Returns a bool, whether the level was set successfully or not. <syntaxhighlight lang="lua"> addCommandHandler ( "setmylevel", function ( thePlayer, commandName, theLevel ) local account = getPlayerAccount ( thePlayer )

               local theLevel = tonumber ( theLevel ) or 1

exports.exp_system:setAccountLevel ( account, theLEvel ) end )

Click to collapse [-]
Server

This function is used to get a player experience.

Syntax

bool getAccountEXP ( account theAccount )

Required Arguments

  • theAccount: The player element you wish you get the experience.

Returns

Returns a number with with the experience of the player.

Example

<syntaxhighlight lang="lua"> addCommandHandler ( "myexp", function ( thePlayer ) local account = getPlayerAccount ( thePlayer )

               local myExp = exports.exp_system:getAccountEXP ( account )

outputChatBox ( "Your account experience is: ".. myExp, thePlayer ) end )

Click to collapse [-]
Server

This function is used to set a player experience.

Syntax

bool setAccountEXP ( account theAccount, int theExperience )

Required Arguments

  • theAccount: The player element you wish you set the experience.
  • theExperience: The exprience you want to set.

Returns

Returns a bool, whether the experience was set successfully or not.

Example

<syntaxhighlight lang="lua"> addCommandHandler ( "setmyexp", function ( thePlayer, commandName, theExp ) local account = getPlayerAccount ( thePlayer )

               local theExp = tonumber ( theExp ) or 0

exports.exp_system:setAccountEXP ( account, theExp ) end )

See also

Download page