CanPlayerUseFunction: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
{{Server function}} | {{Server function}} | ||
{{Deprecated}} | {{Deprecated}} | ||
Please use [[hasObjectPermissionTo]] | |||
This function can be used to check if the player can use a function, based on their current access level. Access levels for functions are stored in the server's config file. Use this if you want to prevent a player using a function unless they are logged in with enough rights. | This function can be used to check if the player can use a function, based on their current access level. Access levels for functions are stored in the server's config file. Use this if you want to prevent a player using a function unless they are logged in with enough rights. | ||
==Syntax== | ==Syntax== |
Revision as of 21:10, 20 April 2011
This article needs checking. | |
Reason(s): Should the function still be string? --Talidan2 15:44, 15 July 2007 (CDT) If this is supposed to take a console command, it'd better be renamed to canPlayerUseCommand. --jbeta 19:58, 11 September 2007 (CDT) ChrML This function doesn't work. It's not coded at all with the ACL system. Remove? |
This function is deprecated. This means that its use is discouraged and that it might not exist in future versions, but there should be a more generic way to perform what it does. | |
Please use hasObjectPermissionTo
This function can be used to check if the player can use a function, based on their current access level. Access levels for functions are stored in the server's config file. Use this if you want to prevent a player using a function unless they are logged in with enough rights.
Syntax
bool canPlayerUseFunction ( player thePlayer, string functionName )
Required Arguments
- thePlayer: The player who you consider is running the function.
- functionName The name of the function which you want to check.
Returns
Returns true if the player specified can use the function specified, false otherwise.
Example
This example adds a console function called kill_player that can only be used by players with enough access rights. These access rights can be specified in the server's config file.
function adminKillPlayer ( source, commandName, killPlayerName ) if ( canPlayerUseFunction ( source, "kill_player" ) ) then -- if the player can use the "kill_player" function local playerToKill = getPlayerFromNick ( killPlayerName ) -- look up the player to kill if ( playerToKill ~= false ) then -- check if we found him killPlayer ( playerToKill ) -- if so, kill him outputConsole ( killPlayerName .. " has been killed!", source ) -- and notify the admin else outputConsole ( "Couldn't find a player called '" .. killPlayerName .. "'", source ) -- otherwise tell him the player was not found end else outputConsole ( "You do not have access to this function!", source ) -- if he isn't allowed to use the function, tell him so end end addCommandHandler ( "kill_player", adminKillPlayer )
See Also
- getPlayerTeam
- getPlayerBlurLevel
- setPlayerBlurLevel
- getPlayerSerial
- forcePlayerMap
- getPlayerScriptDebugLevel
- getPlayerFromName
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
- getPlayerWantedLevel
- givePlayerMoney
- isPlayerMapForced
- isPlayerNametagShowing
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
- takePlayerMoney
- countPlayersInTeam
- getPlayersInTeam
- isVoiceEnabled
- setControlState
- getControlState