ZH-CN/aclGroupAddObjectServer: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(One intermediate revision by one other user not shown)
Line 31: Line 31:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function giveAdminRights (playerSource, commandName, accountName) --添加函数giveAdminRights并指定其参数
function giveAdminRights (playerSource, commandName, accountName) --添加函数giveAdminRights并指定其参数
if accountName then --if there was an accountName entered then
if accountName then --如果输入了accountName
aclGroupAddObject (aclGetGroup("Admin"), "user."..accountName) --使用“user.[accountName]”格式将ACL对象添加到ACL组“Admin”
aclGroupAddObject (aclGetGroup("Admin"), "user."..accountName) --使用“user.[accountName]”格式将ACL对象添加到ACL组“Admin”
outputChatBox ("Account '"..accountName.."' succesfully added to the admin group", playerSource) --向输入命令的玩家输出一个通知,通知其账户已成功添加
outputChatBox ("Account '"..accountName.."' succesfully added to the admin group", playerSource) --向输入命令的玩家输出一个通知,通知其账户已成功添加
Line 46: Line 46:
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc -->
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc -->
{{ACL_functions}}
{{ACL_functions}}
[[en:aclGroupAddObjectServer]]
 
[[ar:aclGroupAddObjectServer]]
[[en:AclGroupAddObjectServer]]
[[zh-cn:aclGroupAddObjectServer]]

Latest revision as of 18:29, 21 February 2021

此函数用于将对象添加到给定的ACL组。对象可以是玩家的帐户,指定为:

 user.<accountname>

或者是资源,指定为:

 resource.<resourcename>

对象被指定为字符串。ACL组用于用户帐户和其中指定的资源.

语法

bool aclGroupAddObject ( aclgroup theGroup, string theObjectName )

OOP Syntax Help! I don't understand this!

Method: aclgroup:addObject(...)


必填参数

  • theGroup: 要添加对象名称字符串的组.
  • theObjectName: 要添加到给定ACL的对象字符串.

返回值

如果对象已成功添加到ACL,则返回“true”;如果对象已存在于列表中,则返回“false”.

示例

这个例子使每个玩家都能使用一个名为“giveAccountAdminRights”的命令,这个命令会将一个特定的帐户名作为ACL对象添加到“Admin”组中.

function giveAdminRights (playerSource, commandName, accountName) --添加函数giveAdminRights并指定其参数
	if accountName then --如果输入了accountName
		aclGroupAddObject (aclGetGroup("Admin"), "user."..accountName) --使用“user.[accountName]”格式将ACL对象添加到ACL组“Admin”
		outputChatBox ("Account '"..accountName.."' succesfully added to the admin group", playerSource) --向输入命令的玩家输出一个通知,通知其账户已成功添加
	else --否则,将错误消息和命令的正确语法输出给输入它的玩家
		outputChatBox ("No account name specified.", playerSource)
		outputChatBox ("Correct syntax: /giveAccountAdminRights [accountName]", playerSource)
	end
end

addCommandHandler ("giveAccountAdminRights", giveAdminRights) --添加一个命令“giveAccountAdminRights”并将函数“giveAdminRights”添加到其中

See Also