https://wiki.multitheftauto.com/api.php?action=feedcontributions&user=Qwe7769611&feedformat=atomMulti Theft Auto: Wiki - User contributions [en]2024-03-29T00:38:35ZUser contributionsMediaWiki 1.39.3https://wiki.multitheftauto.com/index.php?title=ZH-CN/guiCreateWindow&diff=68845ZH-CN/guiCreateWindow2021-02-07T11:06:34Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Client function}}<br />
此函数用于创建新的GUI窗口. This provides a base for other gui elements to be created within. However, windows do not have a parent and cannot be created in any GUI elements.<br />
<br />
==语法== <br />
<syntaxhighlight lang="lua"><br />
element guiCreateWindow ( float x, float y, float width, float height, string titleBarText, bool relative )<br />
</syntaxhighlight><br />
{{OOP_ZH-CN||[[Element/GUI/Window|GuiWindow]]||}}<br />
<br />
===必填参数===<br />
[[Image:gui-window.png|frame|Example Window.]]<br />
*'''x:''' 玩家屏幕上图形用户界面窗口的2D x 位置的浮动. This is affected by the ''relative'' argument.<br />
*'''y:''' 玩家屏幕上GUI窗口的2D y 位置的浮动. This is affected by the ''relative'' argument.<br />
*'''width:''' GUI窗口宽度的浮动. This is affected by the ''relative'' argument.<br />
*'''height:''' GUI窗口高度的浮动. This is affected by the ''relative'' argument.<br />
*'''titleBarText:''' 将显示在窗口标题栏中的文本字符串.<br />
*'''relative:''' 尺寸和位置是否是相对的. 如果这是“true”,则所有x、y、width和height浮动必须介于0和1之间, 将 大小/位置 表示为屏幕大小的一部分. 如果“false”,则大小和坐标基于客户端的分辨率,可使用[[guiGetScreenSize]]访问.<br />
<br />
===返回值===<br />
如果gui窗口元素创建成功,则返回该元素,否则返回false.<br />
<br />
==示例== <br />
'''示例 1:''' 本例创建了一个信息窗口,并向“tabPanel”tabPanel添加了两个选项卡,并向其中添加了一些其他gui元素<br />
<syntaxhighlight lang="lua"><br />
local myWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Information", true ) -- 创建一个在标题栏中有“信息”的窗口.<br />
local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, myWindow ) -- 创建一个填充整个窗口的选项卡面板<br />
local tabMap = guiCreateTab( "Map Information", tabPanel ) -- 在“tabPanel”上创建一个名为“Map Information”的选项卡<br />
local tabHelp = guiCreateTab( "Help", tabPanel ) -- 在“tabPanel”上创建另一个名为“Help”的选项卡<br />
<br />
-- 向每个选项卡添加标签(文本)<br />
guiCreateLabel(0.02, 0.04, 0.94, 0.2, "这是有关当前地图的信息", true, tabMap)<br />
guiCreateLabel(0.02, 0.04, 0.94, 0.92, "这是帮助文本.", true, tabHelp)<br />
</syntaxhighlight><br />
<br />
'''示例 2:''' 这个例子创建了一个武器选择屏幕,包括一个窗口、网格列表和一个按钮. 用户可以选择猎枪或机枪. 窗口不能移动,也不能调整大小.<br />
<syntaxhighlight lang="lua"><br />
--设置一些表格<br />
<br />
shotguns = {<br />
"chrome",<br />
"sawn-off",<br />
"combat"<br />
}<br />
<br />
machineGun = {<br />
"m4",<br />
"ak-47"<br />
}<br />
<br />
function setupWeaponSelection ( theResource )<br />
-- getResourceRootElement(getThisResource()) at the bottom means it will only create the gui on this resource start<br />
-- 为我们的屏幕创建一个窗口,标题为“选择你的武器”.<br />
spawnScreenMenu = guiCreateWindow ( 0.15, 0.33, 0.7, 0.34, "Select your weapons", true )<br />
-- 创建一个OK按钮,允许用户确认他们的选择,并将其附加到confirmSelection函数<br />
spawnScreenOKButton = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "OK", true, spawnScreenMenu )<br />
-- 确保用户不能移动或调整屏幕大小.<br />
guiWindowSetMovable ( spawnScreenMenu, false )<br />
guiWindowSetSizable ( spawnScreenMenu, false )<br />
-- 创建我们的gridlist,它占据了大部分窗口.<br />
spawnScreenGridList = guiCreateGridList ( 0, 0.1, 1, 0.9, true, spawnScreenMenu )<br />
guiGridListSetSelectionMode ( spawnScreenGridList, 2 ) -- ensure the selection mode is one per column<br />
-- 既然我们有两套武器,就为散弹枪和机关枪创建一个纵队<br />
guiGridListAddColumn ( spawnScreenGridList, "Shotguns", 0.3 )<br />
guiGridListAddColumn ( spawnScreenGridList, "Machine guns", 0.3 )<br />
-- 接下来,我们循环遍历handguns表,将handgun项添加到gridlist中<br />
for key,weaponName in pairs(shotguns) do<br />
-- 每次向我们的gridlist添加一个新行<br />
local row = guiGridListAddRow ( spawnScreenGridList )<br />
-- 接下来,我们将该行的文本设置为武器名称。列是1,因为“Shotguns”列是首先创建的.<br />
guiGridListSetItemText ( spawnScreenGridList, row, 1, weaponName, false, false )<br />
end<br />
-- 我们对其他武器列表重复这个过程,改变列号<br />
row = 0<br />
for key,weaponName in pairs(machineGun) do<br />
-- 我们不需要像在上一个循环中那样创建新行<br />
-- 我们只是将行的文本设置为武器名称.列是2,因为“机枪”列是第二个创建的.<br />
guiGridListSetItemText ( spawnScreenGridList, row, 2, weaponName, false, false )<br />
row = row + 1 -- 增加行号<br />
end<br />
end<br />
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), setupWeaponSelection )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{GUI_functions}}<br />
[[ru:guiCreateWindow]]<br />
[[pl:guiCreateWindow]]<br />
[[en:guiCreateWindow]]<br />
{{GUI_events}}</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/guiCreateWindow&diff=68844ZH-CN/guiCreateWindow2021-02-07T10:06:33Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Client function}}<br />
此函数用于创建新的GUI窗口. This provides a base for other gui elements to be created within. However, windows do not have a parent and cannot be created in any GUI elements.<br />
<br />
==语法== <br />
<syntaxhighlight lang="lua"><br />
element guiCreateWindow ( float x, float y, float width, float height, string titleBarText, bool relative )<br />
</syntaxhighlight><br />
{{OOP_ZH-CN||[[Element/GUI/Window|GuiWindow]]||}}<br />
<br />
===必填参数===<br />
[[Image:gui-window.png|frame|Example Window.]]<br />
*'''x:''' A float of the 2D x position of the GUI window on a player's screen. This is affected by the ''relative'' argument.<br />
*'''y:''' A float of the 2D y position of the GUI window on a player's screen. This is affected by the ''relative'' argument.<br />
*'''width:''' A float of the width of the GUI window. This is affected by the ''relative'' argument.<br />
*'''height:''' A float of the height of the GUI window. This is affected by the ''relative'' argument.<br />
*'''titleBarText:''' A string of the text that will be displayed in the title bar of the window.<br />
*'''relative:''' This is whether sizes and positioning are relative. If this is ''true'', then all x,y,width,height floats must be between 0 and 1, representing sizes/positions as a fraction of the screen size. If ''false'', then the size and co-ordinates are based on client's resolution, accessible using [[guiGetScreenSize]].<br />
<br />
===返回值===<br />
Returns a gui window element if it was created successfully, false otherwise.<br />
<br />
==示例== <br />
'''示例 1:''' This example creates a information window and adds two tabs to a "tabPanel" tabpanel, and adds some other gui elements to it.<br />
<syntaxhighlight lang="lua"><br />
local myWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Information", true ) -- create a window which has "Information" in the title bar.<br />
local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, myWindow ) -- create a tab panel which fills the whole window<br />
local tabMap = guiCreateTab( "Map Information", tabPanel ) -- create a tab named "Map Information" on 'tabPanel'<br />
local tabHelp = guiCreateTab( "Help", tabPanel ) -- create another tab named "Help" on 'tabPanel'<br />
<br />
-- adds a label (text) to each tab<br />
guiCreateLabel(0.02, 0.04, 0.94, 0.2, "This is information about the current map", true, tabMap)<br />
guiCreateLabel(0.02, 0.04, 0.94, 0.92, "This is help text.", true, tabHelp)<br />
</syntaxhighlight><br />
<br />
'''示例 2:''' This example creates a weapon selection screen, complete with a window, gridlist and a button. Users can select a shotgun or a machine gun. The window is not movable or sizable.<br />
<syntaxhighlight lang="lua"><br />
--Setup some tables<br />
<br />
shotguns = {<br />
"chrome",<br />
"sawn-off",<br />
"combat"<br />
}<br />
<br />
machineGun = {<br />
"m4",<br />
"ak-47"<br />
}<br />
<br />
function setupWeaponSelection ( theResource )<br />
-- getResourceRootElement(getThisResource()) at the bottom means it will only create the gui on this resource start<br />
-- Create a window for our spawnscreen, with the title "Select your weapons".<br />
spawnScreenMenu = guiCreateWindow ( 0.15, 0.33, 0.7, 0.34, "Select your weapons", true )<br />
-- create an OK button to allow the user to confirm their selections, and attach it to the confirmSelection function<br />
spawnScreenOKButton = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "OK", true, spawnScreenMenu )<br />
-- ensure the user can't move or resize our spawnscreen.<br />
guiWindowSetMovable ( spawnScreenMenu, false )<br />
guiWindowSetSizable ( spawnScreenMenu, false )<br />
-- create our gridlist, which fills up most of the window.<br />
spawnScreenGridList = guiCreateGridList ( 0, 0.1, 1, 0.9, true, spawnScreenMenu )<br />
guiGridListSetSelectionMode ( spawnScreenGridList, 2 ) -- ensure the selection mode is one per column<br />
-- Since we have 2 sets of weapons, create a column for shotguns and one for machine guns<br />
guiGridListAddColumn ( spawnScreenGridList, "Shotguns", 0.3 )<br />
guiGridListAddColumn ( spawnScreenGridList, "Machine guns", 0.3 )<br />
-- next, we loop through our handguns table to add handgun items to the gridlist<br />
for key,weaponName in pairs(shotguns) do<br />
-- add a new row to our gridlist each time<br />
local row = guiGridListAddRow ( spawnScreenGridList )<br />
-- next, we set that row's text to the weapon name. Column is 1 since the "Shotguns" column was created first.<br />
guiGridListSetItemText ( spawnScreenGridList, row, 1, weaponName, false, false )<br />
end<br />
-- we repeat the process for other weapon list, changing the column number<br />
row = 0<br />
for key,weaponName in pairs(machineGun) do<br />
-- we don't need to create new rows as that was done in the previous loop<br />
-- we just set the row's text to the weapon name. Column is 2 since the "Machine guns" column was created second.<br />
guiGridListSetItemText ( spawnScreenGridList, row, 2, weaponName, false, false )<br />
row = row + 1 -- increase the row number<br />
end<br />
end<br />
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), setupWeaponSelection )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{GUI_functions}}<br />
[[ru:guiCreateWindow]]<br />
[[pl:guiCreateWindow]]<br />
[[en:guiCreateWindow]]<br />
{{GUI_events}}</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/guiCreateWindow&diff=68843ZH-CN/guiCreateWindow2021-02-07T10:04:26Z<p>Qwe7769611: Created page with "__NOTOC__ {{Client function}} This function is for creating a new GUI window. This provides a base for other gui elements to be created within. However, windows do not have..."</p>
<hr />
<div>__NOTOC__ <br />
{{Client function}}<br />
This function is for creating a new GUI window. This provides a base for other gui elements to be created within. However, windows do not have a parent and cannot be created in any GUI elements.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
element guiCreateWindow ( float x, float y, float width, float height, string titleBarText, bool relative )<br />
</syntaxhighlight><br />
{{OOP||[[Element/GUI/Window|GuiWindow]]||}}<br />
<br />
===Required Arguments===<br />
[[Image:gui-window.png|frame|Example Window.]]<br />
*'''x:''' A float of the 2D x position of the GUI window on a player's screen. This is affected by the ''relative'' argument.<br />
*'''y:''' A float of the 2D y position of the GUI window on a player's screen. This is affected by the ''relative'' argument.<br />
*'''width:''' A float of the width of the GUI window. This is affected by the ''relative'' argument.<br />
*'''height:''' A float of the height of the GUI window. This is affected by the ''relative'' argument.<br />
*'''titleBarText:''' A string of the text that will be displayed in the title bar of the window.<br />
*'''relative:''' This is whether sizes and positioning are relative. If this is ''true'', then all x,y,width,height floats must be between 0 and 1, representing sizes/positions as a fraction of the screen size. If ''false'', then the size and co-ordinates are based on client's resolution, accessible using [[guiGetScreenSize]].<br />
<br />
===Returns===<br />
Returns a gui window element if it was created successfully, false otherwise.<br />
<br />
==Example== <br />
'''Example 1:''' This example creates a information window and adds two tabs to a "tabPanel" tabpanel, and adds some other gui elements to it.<br />
<syntaxhighlight lang="lua"><br />
local myWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Information", true ) -- create a window which has "Information" in the title bar.<br />
local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, myWindow ) -- create a tab panel which fills the whole window<br />
local tabMap = guiCreateTab( "Map Information", tabPanel ) -- create a tab named "Map Information" on 'tabPanel'<br />
local tabHelp = guiCreateTab( "Help", tabPanel ) -- create another tab named "Help" on 'tabPanel'<br />
<br />
-- adds a label (text) to each tab<br />
guiCreateLabel(0.02, 0.04, 0.94, 0.2, "This is information about the current map", true, tabMap)<br />
guiCreateLabel(0.02, 0.04, 0.94, 0.92, "This is help text.", true, tabHelp)<br />
</syntaxhighlight><br />
<br />
'''Example 2:''' This example creates a weapon selection screen, complete with a window, gridlist and a button. Users can select a shotgun or a machine gun. The window is not movable or sizable.<br />
<syntaxhighlight lang="lua"><br />
--Setup some tables<br />
<br />
shotguns = {<br />
"chrome",<br />
"sawn-off",<br />
"combat"<br />
}<br />
<br />
machineGun = {<br />
"m4",<br />
"ak-47"<br />
}<br />
<br />
function setupWeaponSelection ( theResource )<br />
-- getResourceRootElement(getThisResource()) at the bottom means it will only create the gui on this resource start<br />
-- Create a window for our spawnscreen, with the title "Select your weapons".<br />
spawnScreenMenu = guiCreateWindow ( 0.15, 0.33, 0.7, 0.34, "Select your weapons", true )<br />
-- create an OK button to allow the user to confirm their selections, and attach it to the confirmSelection function<br />
spawnScreenOKButton = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "OK", true, spawnScreenMenu )<br />
-- ensure the user can't move or resize our spawnscreen.<br />
guiWindowSetMovable ( spawnScreenMenu, false )<br />
guiWindowSetSizable ( spawnScreenMenu, false )<br />
-- create our gridlist, which fills up most of the window.<br />
spawnScreenGridList = guiCreateGridList ( 0, 0.1, 1, 0.9, true, spawnScreenMenu )<br />
guiGridListSetSelectionMode ( spawnScreenGridList, 2 ) -- ensure the selection mode is one per column<br />
-- Since we have 2 sets of weapons, create a column for shotguns and one for machine guns<br />
guiGridListAddColumn ( spawnScreenGridList, "Shotguns", 0.3 )<br />
guiGridListAddColumn ( spawnScreenGridList, "Machine guns", 0.3 )<br />
-- next, we loop through our handguns table to add handgun items to the gridlist<br />
for key,weaponName in pairs(shotguns) do<br />
-- add a new row to our gridlist each time<br />
local row = guiGridListAddRow ( spawnScreenGridList )<br />
-- next, we set that row's text to the weapon name. Column is 1 since the "Shotguns" column was created first.<br />
guiGridListSetItemText ( spawnScreenGridList, row, 1, weaponName, false, false )<br />
end<br />
-- we repeat the process for other weapon list, changing the column number<br />
row = 0<br />
for key,weaponName in pairs(machineGun) do<br />
-- we don't need to create new rows as that was done in the previous loop<br />
-- we just set the row's text to the weapon name. Column is 2 since the "Machine guns" column was created second.<br />
guiGridListSetItemText ( spawnScreenGridList, row, 2, weaponName, false, false )<br />
row = row + 1 -- increase the row number<br />
end<br />
end<br />
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), setupWeaponSelection )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{GUI_functions}}<br />
[[ru:guiCreateWindow]]<br />
[[pl:guiCreateWindow]]<br />
[[en:guiCreateWindow]]<br />
{{GUI_events}}</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=GuiCreateWindow&diff=68842GuiCreateWindow2021-02-07T10:04:13Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Client function}}<br />
This function is for creating a new GUI window. This provides a base for other gui elements to be created within. However, windows do not have a parent and cannot be created in any GUI elements.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
element guiCreateWindow ( float x, float y, float width, float height, string titleBarText, bool relative )<br />
</syntaxhighlight><br />
{{OOP||[[Element/GUI/Window|GuiWindow]]||}}<br />
<br />
===Required Arguments===<br />
[[Image:gui-window.png|frame|Example Window.]]<br />
*'''x:''' A float of the 2D x position of the GUI window on a player's screen. This is affected by the ''relative'' argument.<br />
*'''y:''' A float of the 2D y position of the GUI window on a player's screen. This is affected by the ''relative'' argument.<br />
*'''width:''' A float of the width of the GUI window. This is affected by the ''relative'' argument.<br />
*'''height:''' A float of the height of the GUI window. This is affected by the ''relative'' argument.<br />
*'''titleBarText:''' A string of the text that will be displayed in the title bar of the window.<br />
*'''relative:''' This is whether sizes and positioning are relative. If this is ''true'', then all x,y,width,height floats must be between 0 and 1, representing sizes/positions as a fraction of the screen size. If ''false'', then the size and co-ordinates are based on client's resolution, accessible using [[guiGetScreenSize]].<br />
<br />
===Returns===<br />
Returns a gui window element if it was created successfully, false otherwise.<br />
<br />
==Example== <br />
'''Example 1:''' This example creates a information window and adds two tabs to a "tabPanel" tabpanel, and adds some other gui elements to it.<br />
<syntaxhighlight lang="lua"><br />
local myWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Information", true ) -- create a window which has "Information" in the title bar.<br />
local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, myWindow ) -- create a tab panel which fills the whole window<br />
local tabMap = guiCreateTab( "Map Information", tabPanel ) -- create a tab named "Map Information" on 'tabPanel'<br />
local tabHelp = guiCreateTab( "Help", tabPanel ) -- create another tab named "Help" on 'tabPanel'<br />
<br />
-- adds a label (text) to each tab<br />
guiCreateLabel(0.02, 0.04, 0.94, 0.2, "This is information about the current map", true, tabMap)<br />
guiCreateLabel(0.02, 0.04, 0.94, 0.92, "This is help text.", true, tabHelp)<br />
</syntaxhighlight><br />
<br />
'''Example 2:''' This example creates a weapon selection screen, complete with a window, gridlist and a button. Users can select a shotgun or a machine gun. The window is not movable or sizable.<br />
<syntaxhighlight lang="lua"><br />
--Setup some tables<br />
<br />
shotguns = {<br />
"chrome",<br />
"sawn-off",<br />
"combat"<br />
}<br />
<br />
machineGun = {<br />
"m4",<br />
"ak-47"<br />
}<br />
<br />
function setupWeaponSelection ( theResource )<br />
-- getResourceRootElement(getThisResource()) at the bottom means it will only create the gui on this resource start<br />
-- Create a window for our spawnscreen, with the title "Select your weapons".<br />
spawnScreenMenu = guiCreateWindow ( 0.15, 0.33, 0.7, 0.34, "Select your weapons", true )<br />
-- create an OK button to allow the user to confirm their selections, and attach it to the confirmSelection function<br />
spawnScreenOKButton = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "OK", true, spawnScreenMenu )<br />
-- ensure the user can't move or resize our spawnscreen.<br />
guiWindowSetMovable ( spawnScreenMenu, false )<br />
guiWindowSetSizable ( spawnScreenMenu, false )<br />
-- create our gridlist, which fills up most of the window.<br />
spawnScreenGridList = guiCreateGridList ( 0, 0.1, 1, 0.9, true, spawnScreenMenu )<br />
guiGridListSetSelectionMode ( spawnScreenGridList, 2 ) -- ensure the selection mode is one per column<br />
-- Since we have 2 sets of weapons, create a column for shotguns and one for machine guns<br />
guiGridListAddColumn ( spawnScreenGridList, "Shotguns", 0.3 )<br />
guiGridListAddColumn ( spawnScreenGridList, "Machine guns", 0.3 )<br />
-- next, we loop through our handguns table to add handgun items to the gridlist<br />
for key,weaponName in pairs(shotguns) do<br />
-- add a new row to our gridlist each time<br />
local row = guiGridListAddRow ( spawnScreenGridList )<br />
-- next, we set that row's text to the weapon name. Column is 1 since the "Shotguns" column was created first.<br />
guiGridListSetItemText ( spawnScreenGridList, row, 1, weaponName, false, false )<br />
end<br />
-- we repeat the process for other weapon list, changing the column number<br />
row = 0<br />
for key,weaponName in pairs(machineGun) do<br />
-- we don't need to create new rows as that was done in the previous loop<br />
-- we just set the row's text to the weapon name. Column is 2 since the "Machine guns" column was created second.<br />
guiGridListSetItemText ( spawnScreenGridList, row, 2, weaponName, false, false )<br />
row = row + 1 -- increase the row number<br />
end<br />
end<br />
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), setupWeaponSelection )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{GUI_functions}}<br />
[[ru:guiCreateWindow]]<br />
[[pl:guiCreateWindow]]<br />
[[zh-cn:guiCreateWindow]]<br />
{{GUI_events}}</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/IsObjectInACLGroup&diff=68832ZH-CN/IsObjectInACLGroup2021-02-06T07:34:33Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
{{Important Note|You must '''NOT''' to use this function to limit features to users that belong to specific groups. Instead you '''MUST''' use [[hasObjectPermissionTo]]. Using this function forces the server owner to name their group a certain way, whereas using hasObjectPermissionTo allows the owner to give permission for whatever features you restrict to whatever groups they have set up in their ACL.}}<br />
此函数用于确定对象是否在组中.<br />
<br />
==语法== <br />
<syntaxhighlight lang="lua"><br />
bool isObjectInACLGroup ( string theObject, aclgroup theGroup )<br />
</syntaxhighlight> <br />
{{New feature/item|3.0141|1.4.0|6994|{{OOP_ZH-CN||[[aclgroup]]:doesContainObject||}}}}<br />
===必填参数=== <br />
*'''theObject:''' 要检查的对象的名称. 示例: "resource.ctf", "user.Jim".<br />
*'''theGroup:''' 应该从中找到对象的组的[[ACL group]]指针函数.<br />
<br />
===返回值===<br />
如果对象在指定的组中,则返回“true”,否则返回“false”.<br />
<br />
==示例== <br />
''' 示例 1:''' 此示例添加了一个仅对管理员可用的“jetpack”命令.当输入命令时,它将切换玩家的喷气背包.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "jetpack",<br />
function ( thePlayer )<br />
if doesPedHaveJetPack ( thePlayer ) then -- 如果玩家已经有一个喷气背包,移除它<br />
removePedJetPack ( thePlayer ) -- 移除喷气背包<br />
return -- 在这里停止函数<br />
end<br />
<br />
-- Otherwise, 给她一个 if he has access<br />
<br />
local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- 获取他的帐户名<br />
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then -- 他有权限使用管理功能吗<br />
if not doesPedHaveJetPack ( thePlayer ) then -- 如果玩家没有喷气背包,就给他.<br />
givePedJetPack ( thePlayer ) -- 给予喷气背包<br />
end<br />
end<br />
end<br />
)<br />
</syntaxhighlight><br />
<br />
'''示例2:''' 此示例显示聊天框中所有联机管理员的列表(假设ACL中的管理员组名为“admin”):<br />
<syntaxhighlight lang="lua"><br />
players = getElementsByType ( "player" )<br />
admins = ""<br />
for k,v in ipairs(players) do<br />
local accountname = ""<br />
if (isGuestAccount(getPlayerAccount(v)) == false) then<br />
accountname = getAccountName (getPlayerAccount(v))<br />
if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "admin" ) ) then<br />
if (admins == "") then<br />
admins = getPlayerName(v)<br />
else<br />
admins = admins .. ", " .. getPlayerName(v)<br />
end<br />
end<br />
end<br />
end<br />
outputChatBox( "Online Admins:", getRootElement(), 255, 255, 0)<br />
outputChatBox( " " .. tostring ( admins ), getRootElement(), 255, 255, 0)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{ACL_functions}}<br />
[[en:IsObjectInACLGroup]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/IsObjectInACLGroup&diff=68831ZH-CN/IsObjectInACLGroup2021-02-06T07:34:19Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
{{Important Note|You must '''NOT''' to use this function to limit features to users that belong to specific groups. Instead you '''MUST''' use [[hasObjectPermissionTo]]. Using this function forces the server owner to name their group a certain way, whereas using hasObjectPermissionTo allows the owner to give permission for whatever features you restrict to whatever groups they have set up in their ACL.}}<br />
此函数用于确定对象是否在组中.<br />
<br />
==语法== <br />
<syntaxhighlight lang="lua"><br />
bool isObjectInACLGroup ( string theObject, aclgroup theGroup )<br />
</syntaxhighlight> <br />
{{New feature/item|3.0141|1.4.0|6994|{{OOP||[[aclgroup]]:doesContainObject||}}}}<br />
===必填参数=== <br />
*'''theObject:''' 要检查的对象的名称. 示例: "resource.ctf", "user.Jim".<br />
*'''theGroup:''' 应该从中找到对象的组的[[ACL group]]指针函数.<br />
<br />
===返回值===<br />
如果对象在指定的组中,则返回“true”,否则返回“false”.<br />
<br />
==示例== <br />
''' 示例 1:''' 此示例添加了一个仅对管理员可用的“jetpack”命令.当输入命令时,它将切换玩家的喷气背包.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "jetpack",<br />
function ( thePlayer )<br />
if doesPedHaveJetPack ( thePlayer ) then -- 如果玩家已经有一个喷气背包,移除它<br />
removePedJetPack ( thePlayer ) -- 移除喷气背包<br />
return -- 在这里停止函数<br />
end<br />
<br />
-- Otherwise, 给她一个 if he has access<br />
<br />
local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- 获取他的帐户名<br />
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then -- 他有权限使用管理功能吗<br />
if not doesPedHaveJetPack ( thePlayer ) then -- 如果玩家没有喷气背包,就给他.<br />
givePedJetPack ( thePlayer ) -- 给予喷气背包<br />
end<br />
end<br />
end<br />
)<br />
</syntaxhighlight><br />
<br />
'''示例2:''' 此示例显示聊天框中所有联机管理员的列表(假设ACL中的管理员组名为“admin”):<br />
<syntaxhighlight lang="lua"><br />
players = getElementsByType ( "player" )<br />
admins = ""<br />
for k,v in ipairs(players) do<br />
local accountname = ""<br />
if (isGuestAccount(getPlayerAccount(v)) == false) then<br />
accountname = getAccountName (getPlayerAccount(v))<br />
if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "admin" ) ) then<br />
if (admins == "") then<br />
admins = getPlayerName(v)<br />
else<br />
admins = admins .. ", " .. getPlayerName(v)<br />
end<br />
end<br />
end<br />
end<br />
outputChatBox( "Online Admins:", getRootElement(), 255, 255, 0)<br />
outputChatBox( " " .. tostring ( admins ), getRootElement(), 255, 255, 0)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{ACL_functions}}<br />
[[en:IsObjectInACLGroup]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/IsObjectInACLGroup&diff=68830ZH-CN/IsObjectInACLGroup2021-02-06T07:34:08Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
{{Important Note|You must '''NOT''' to use this function to limit features to users that belong to specific groups. Instead you '''MUST''' use [[hasObjectPermissionTo]]. Using this function forces the server owner to name their group a certain way, whereas using hasObjectPermissionTo allows the owner to give permission for whatever features you restrict to whatever groups they have set up in their ACL.}}<br />
此函数用于确定对象是否在组中.<br />
<br />
==语法== <br />
<syntaxhighlight lang="lua"><br />
bool isObjectInACLGroup ( string theObject, aclgroup theGroup )<br />
</syntaxhighlight> <br />
{{New feature/item|3.0141|1.4.0|6994|{{OOP||[[aclgroup]]:doesContainObject||}}}}<br />
===必填参数=== <br />
*'''theObject:''' 要检查的对象的名称. 示例: "resource.ctf", "user.Jim".<br />
*'''theGroup:''' 应该从中找到对象的组的[[ACL group]]指针函数.<br />
<br />
===Returns===<br />
如果对象在指定的组中,则返回“true”,否则返回“false”.<br />
<br />
==示例== <br />
''' 示例 1:''' 此示例添加了一个仅对管理员可用的“jetpack”命令.当输入命令时,它将切换玩家的喷气背包.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "jetpack",<br />
function ( thePlayer )<br />
if doesPedHaveJetPack ( thePlayer ) then -- 如果玩家已经有一个喷气背包,移除它<br />
removePedJetPack ( thePlayer ) -- 移除喷气背包<br />
return -- 在这里停止函数<br />
end<br />
<br />
-- Otherwise, 给她一个 if he has access<br />
<br />
local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- 获取他的帐户名<br />
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then -- 他有权限使用管理功能吗<br />
if not doesPedHaveJetPack ( thePlayer ) then -- 如果玩家没有喷气背包,就给他.<br />
givePedJetPack ( thePlayer ) -- 给予喷气背包<br />
end<br />
end<br />
end<br />
)<br />
</syntaxhighlight><br />
<br />
'''示例2:''' 此示例显示聊天框中所有联机管理员的列表(假设ACL中的管理员组名为“admin”):<br />
<syntaxhighlight lang="lua"><br />
players = getElementsByType ( "player" )<br />
admins = ""<br />
for k,v in ipairs(players) do<br />
local accountname = ""<br />
if (isGuestAccount(getPlayerAccount(v)) == false) then<br />
accountname = getAccountName (getPlayerAccount(v))<br />
if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "admin" ) ) then<br />
if (admins == "") then<br />
admins = getPlayerName(v)<br />
else<br />
admins = admins .. ", " .. getPlayerName(v)<br />
end<br />
end<br />
end<br />
end<br />
outputChatBox( "Online Admins:", getRootElement(), 255, 255, 0)<br />
outputChatBox( " " .. tostring ( admins ), getRootElement(), 255, 255, 0)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{ACL_functions}}<br />
[[en:IsObjectInACLGroup]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/hasObjectPermissionTo&diff=68829ZH-CN/hasObjectPermissionTo2021-02-06T07:28:37Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
此函数返回给定对象是否有权执行给定操作. <br />
{{Note|Only certain action names work. This function seems to return ''nil'' and output a bad argument error when checking if an object has rights for an action which doesn't start with ''function.'', ''command.'' or ''resource.'' keywords.}}<br />
<br />
脚本经常希望限制特定用户对函数的访问.最简单的方法是检查试图执行某个操作的玩家是否在特定的组(通常是Admin组)中.这样做的主要问题是管理组不能保证存在.它也没有给服务器管理员任何灵活性.他可能希望允许他的“moderators”访问您限制访问的功能,或者他可能希望完全禁用该功能.<br />
<br />
这就是正确使用ACL的地方,幸运的是这非常容易。归根结底就是使用这个函数.这个名称有些混乱的函数允许您检查ACL对象(player或source)是否具有特定的ACL权限。在这种情况下,我们只关心玩家们.<br />
<br />
所以,首先,为你的“right”想个名字。假设我们想要一个只有某些人才能进入的私人区域,我们会称之为我们的right accessPrivateArea.然后,您只需在代码中添加一个“if”语句:<br />
<syntaxhighlight lang="lua">if hasObjectPermissionTo ( player, "resource.YourResourceName.accessPrivateArea", false ) then<br />
-- 如果他们被允许进来,你想发生什么都可以<br />
else<br />
-- 不管你想发生什么,如果他们不是<br />
end<br />
</syntaxhighlight><br />
<br />
请注意,我们使用“right”来命名“right”resource.YourResourceName.accessPrivateArea''-这只是为了整洁,以便管理员知道权限属于什么资源. 强烈建议你遵守这个惯例. “false”参数指定“defaultPermission”, false表示如果用户没有被允许或不允许的权限(即管理员没有将其添加到配置中),它应该默认为不被允许.<br />
<br />
使用此方法的唯一缺点是管理员必须修改其配置。好处是管理员有更多的控制权,您的脚本可以在任何服务器上运行,不管管理员如何配置它.<br />
<br />
==语法== <br />
<syntaxhighlight lang="lua"><br />
bool hasObjectPermissionTo ( string / element theObject, string theAction [, bool defaultPermission = true ] )<br />
</syntaxhighlight> <br />
<!-- Yes! This is actually correct this time ^^ notice theObject can be a string! --><br />
{{OOP_ZH-CN|This function is also a static function underneath the ACL class.|[[ACL]].hasObjectPermissionTo||}}<br />
===必填参数=== <br />
*'''theObject:''' 要测试的对象是否有访问的权限。它可以是客户端元素(即player)、resource或“user.<name>”或“resource.<name>”形式的字符串.<br />
*'''theAction:''' 测试给定对象是否有权访问的操作. 就是说. "function.kickPlayer".<br />
<br />
==选填参数=== <br />
{{OptionalArg}} <br />
*'''defaultPermission:''' 如果在给定对象所属的任何组中都未指定任何权限,则为默认权限. 如果将其保留为true,则给定对象将具有执行该操作的权限,除非在[[ACL]]中显式指定了相反的权限. 如果为false,除非[[Access Control List]]明确批准,否则默认情况下将拒绝该操作.<br />
<br />
===返回值===<br />
如果给定对象具有执行给定操作的权限,则返回“true”,否则返回“false”。如果函数因参数错误而失败,则返回“nil”.<br />
<br />
==示例== <br />
如果使用它的用户可以访问kickPlayer函数,那么这个示例将踢出一个玩家.<br />
<syntaxhighlight lang="lua"><br />
-- 踢出指令<br />
function onKickCommandHandler ( playerSource, commandName, playerToKick, stringReason )<br />
-- 呼叫用户是否有权踢球员?违约<br />
-- 出于安全原因而伪造.我们这样做是为了任何用户都不能使用我们<br />
-- 踢出玩家.<br />
if ( hasObjectPermissionTo ( playerSource, "function.kickPlayer", false ) ) then<br />
<br />
-- 我们有权限踢出那个玩家吗? We do this so we can fail<br />
-- 如果这个资源不能调用这个函数.<br />
if ( hasObjectPermissionTo ( getThisResource (), "function.kickPlayer", true ) ) then<br />
-- 踢出他<br />
kickPlayer ( playerToKick, playerSource, stringReason )<br />
else<br />
-- 资源没有任何权限,抱歉<br />
outputChatBox ( "kick: The admin resource is not able to kick players. Please give this resource access to 'function.kickPlayer' in the ACL to use this function.", playerSource )<br />
end<br />
else<br />
-- 用户没有任何权限<br />
outputChatBox ( "kick: You don't have permissions to use this command.", playerSource )<br />
end<br />
end<br />
addCommandHandler ( "kick", onKickCommandHandler )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:hasObjectPermissionTo]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/hasObjectPermissionTo&diff=68828ZH-CN/hasObjectPermissionTo2021-02-06T07:26:56Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
此函数返回给定对象是否有权执行给定操作. <br />
{{Note|Only certain action names work. This function seems to return ''nil'' and output a bad argument error when checking if an object has rights for an action which doesn't start with ''function.'', ''command.'' or ''resource.'' keywords.}}<br />
<br />
脚本经常希望限制特定用户对函数的访问.最简单的方法是检查试图执行某个操作的玩家是否在特定的组(通常是Admin组)中.这样做的主要问题是管理组不能保证存在.它也没有给服务器管理员任何灵活性.他可能希望允许他的“moderators”访问您限制访问的功能,或者他可能希望完全禁用该功能.<br />
<br />
这就是正确使用ACL的地方,幸运的是这非常容易。归根结底就是使用这个函数.这个名称有些混乱的函数允许您检查ACL对象(player或source)是否具有特定的ACL权限。在这种情况下,我们只关心玩家们.<br />
<br />
所以,首先,为你的“right”想个名字。假设我们想要一个只有某些人才能进入的私人区域,我们会称之为我们的right accessPrivateArea.然后,您只需在代码中添加一个“if”语句:<br />
<syntaxhighlight lang="lua">if hasObjectPermissionTo ( player, "resource.YourResourceName.accessPrivateArea", false ) then<br />
-- 如果他们被允许进来,你想发生什么都可以<br />
else<br />
-- 不管你想发生什么,如果他们不是<br />
end<br />
</syntaxhighlight><br />
<br />
请注意,我们使用“right”来命名“right”resource.YourResourceName.accessPrivateArea''-这只是为了整洁,以便管理员知道权限属于什么资源. 强烈建议你遵守这个惯例. “false”参数指定“defaultPermission”, false表示如果用户没有被允许或不允许的权限(即管理员没有将其添加到配置中),它应该默认为不被允许.<br />
<br />
使用此方法的唯一缺点是管理员必须修改其配置。好处是管理员有更多的控制权,您的脚本可以在任何服务器上运行,不管管理员如何配置它.<br />
<br />
==语法== <br />
<syntaxhighlight lang="lua"><br />
bool hasObjectPermissionTo ( string / element theObject, string theAction [, bool defaultPermission = true ] )<br />
</syntaxhighlight> <br />
<!-- Yes! This is actually correct this time ^^ notice theObject can be a string! --><br />
{{OOP_ZH-CN|This function is also a static function underneath the ACL class.|[[ACL]].hasObjectPermissionTo||}}<br />
===必填参数=== <br />
*'''theObject:''' 要测试的对象是否有访问的权限。它可以是客户端元素(即player)、resource或“user.<name>”或“resource.<name>”形式的字符串.<br />
*'''theAction:''' 测试给定对象是否有权访问的操作. 就是说. "function.kickPlayer".<br />
<br />
==选填参数=== <br />
{{OptionalArg}} <br />
*'''defaultPermission:''' The default permission if none is specified in either of the groups the given object is a member of. If this is left to true, the given object will have permissions to perform the action unless the opposite is explicitly specified in the [[ACL]]. If false, the action will be denied by default unless explicitly approved by the [[Access Control List]].<br />
<br />
===返回值===<br />
如果给定对象具有执行给定操作的权限,则返回“true”,否则返回“false”。如果函数因参数错误而失败,则返回“nil”.<br />
<br />
==示例== <br />
如果使用它的用户可以访问kickPlayer函数,那么这个示例将踢出一个玩家.<br />
<syntaxhighlight lang="lua"><br />
-- 踢出指令<br />
function onKickCommandHandler ( playerSource, commandName, playerToKick, stringReason )<br />
-- 呼叫用户是否有权踢球员?违约<br />
-- 出于安全原因而伪造.我们这样做是为了任何用户都不能使用我们<br />
-- 踢出玩家.<br />
if ( hasObjectPermissionTo ( playerSource, "function.kickPlayer", false ) ) then<br />
<br />
-- 我们有权限踢出那个玩家吗? We do this so we can fail<br />
-- 如果这个资源不能调用这个函数.<br />
if ( hasObjectPermissionTo ( getThisResource (), "function.kickPlayer", true ) ) then<br />
-- 踢出他<br />
kickPlayer ( playerToKick, playerSource, stringReason )<br />
else<br />
-- 资源没有任何权限,抱歉<br />
outputChatBox ( "kick: The admin resource is not able to kick players. Please give this resource access to 'function.kickPlayer' in the ACL to use this function.", playerSource )<br />
end<br />
else<br />
-- 用户没有任何权限<br />
outputChatBox ( "kick: You don't have permissions to use this command.", playerSource )<br />
end<br />
end<br />
addCommandHandler ( "kick", onKickCommandHandler )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:hasObjectPermissionTo]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/hasObjectPermissionTo&diff=68827ZH-CN/hasObjectPermissionTo2021-02-06T07:16:49Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
此函数返回给定对象是否有权执行给定操作. <br />
{{Note|Only certain action names work. This function seems to return ''nil'' and output a bad argument error when checking if an object has rights for an action which doesn't start with ''function.'', ''command.'' or ''resource.'' keywords.}}<br />
<br />
Scripts frequently wish to limit access to features to particular users. The naïve way to do this would be to check if the player who is attempting to perform an action is in a particular group (usually the Admin group). The main issue with doing this is that the Admin group is not guaranteed to exist. It also doesn't give the server admin any flexibility. He might want to allow his 'moderators' access to the function you're limiting access to, or he may want it disabled entirely. <br />
<br />
This is where using the ACL properly comes in, and luckily this is very easy. It all comes down to using this function. This, somewhat confusingly named function lets you check if an ACL object (a player or a resource) has a particular ACL right. In this case, we just care about players.<br />
<br />
So, first of all, think of a name for your 'right'. Let's say we want a private area only certain people can go in, we'll call our right accessPrivateArea. Then, all you need to do is add one 'if' statement to your code:<br />
<syntaxhighlight lang="lua">if hasObjectPermissionTo ( player, "resource.YourResourceName.accessPrivateArea", false ) then<br />
-- Whatever you want to happen if they're allowed in<br />
else<br />
-- Whatever you want to happen if they aren't<br />
end<br />
</syntaxhighlight><br />
<br />
Notice that we've named the ''right'' using ''resource.YourResourceName.accessPrivateArea'' - this is just for neatness, so that the admin knows what resource the right belongs to. It's strongly advised you follow this convention. The ''false'' argument specifies the 'defaultPermission', false indicating that if the user hasn't had the right allowed or dissallowed (i.e. the admin hasn't added it to the config), that it should default to being not allowed.<br />
<br />
The only downside of using this method is that the admin has to modify his config. The upsides are that the admin has much more control and your script will work for any server, however the admin has configured it.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool hasObjectPermissionTo ( string / element theObject, string theAction [, bool defaultPermission = true ] )<br />
</syntaxhighlight> <br />
<!-- Yes! This is actually correct this time ^^ notice theObject can be a string! --><br />
{{OOP|This function is also a static function underneath the ACL class.|[[ACL]].hasObjectPermissionTo||}}<br />
===Required Arguments=== <br />
*'''theObject:''' The object to test if has permission to. This can be a client element (ie. a player), a resource or a string in the form "user.<name>" or "resource.<name>".<br />
*'''theAction:''' The action to test if the given object has access to. Ie. "function.kickPlayer".<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''defaultPermission:''' The default permission if none is specified in either of the groups the given object is a member of. If this is left to true, the given object will have permissions to perform the action unless the opposite is explicitly specified in the [[ACL]]. If false, the action will be denied by default unless explicitly approved by the [[Access Control List]].<br />
<br />
===Returns===<br />
Returns ''true'' if the given object has permission to perform the given action, ''false'' otherwise. Returns ''nil'' if the function failed because of bad arguments.<br />
<br />
==Example== <br />
This example kicks a player if the user using it has access to the kickPlayer function.<br />
<syntaxhighlight lang="lua"><br />
-- Kick command<br />
function onKickCommandHandler ( playerSource, commandName, playerToKick, stringReason )<br />
-- Does the calling user have permission to kick the player? Default<br />
-- to false for safety reasons. We do this so any user can't use us to<br />
-- kick players.<br />
if ( hasObjectPermissionTo ( playerSource, "function.kickPlayer", false ) ) then<br />
<br />
-- Do we have permission to kick the player? We do this so we can fail<br />
-- nicely if this resource doesn't have access to call that function.<br />
if ( hasObjectPermissionTo ( getThisResource (), "function.kickPlayer", true ) ) then<br />
-- Kick him<br />
kickPlayer ( playerToKick, playerSource, stringReason )<br />
else<br />
-- Resource doesn't have any permissions, sorry<br />
outputChatBox ( "kick: The admin resource is not able to kick players. Please give this resource access to 'function.kickPlayer' in the ACL to use this function.", playerSource )<br />
end<br />
else<br />
-- User doesn't have any permissions<br />
outputChatBox ( "kick: You don't have permissions to use this command.", playerSource )<br />
end<br />
end<br />
addCommandHandler ( "kick", onKickCommandHandler )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:hasObjectPermissionTo]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclSetRight&diff=68826ZH-CN/aclSetRight2021-02-06T07:16:03Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
此函数用于更改或添加给定ACL中的给定权限。访问可以是“true”或“false”,并指定ACL是否允许访问权限.<br />
<br />
==语法== <br />
<syntaxhighlight lang="lua"><br />
bool aclSetRight ( acl theAcl, string rightName, bool hasAccess )<br />
</syntaxhighlight> <br />
{{OOP_ZH-CN||[[acl]]:setRight||aclGetRight}}<br />
===必填参数=== <br />
*'''theAcl:''' 要更改其权限的ACL<br />
*'''rightName:''' 添加/更改的访问属性的权限<br />
*'''hasAccess:''' 访问是否应设置为true或false<br />
<br />
===返回值===<br />
如果访问已成功更改,则返回“true”;如果由于某种原因(例如无效的ACL或rightname无效)而失败,则返回“false”或“nil”.<br />
<br />
==示例== <br />
此示例添加了命令“setaclright”,使用该命令可以轻松地向指定的访问控制列表添加新权限.<br />
<syntaxhighlight lang="lua"><br />
function setACLRight ( thePlayer, commandName, aclName, rightName, access )<br />
local ourACL = aclGet ( aclName )<br />
-- 如果以前没有具有此名称的ACL,则需要创建一个<br />
if not ourACL then<br />
ourACL = aclCreate ( aclName )<br />
end<br />
<br />
-- 将布尔字符串转换为小写<br />
access = string.lower ( access )<br />
-- 访问必须是true或false(布尔值)<br />
if not (access == "true" or access == "false") then<br />
-- 将错误消息发送到调试窗口<br />
return outputDebugString ( "Invalid access; true and false are only accepted", 1 )<br />
end<br />
<br />
-- 将访问权限更改为布尔值<br />
if access == "true" then<br />
access = true<br />
else <br />
access = false<br />
end<br />
<br />
-- 最后让我们确定正确的方向<br />
aclSetRight ( ourACL, rightName, access )<br />
-- 不要忘记在修改ACL后保存它<br />
aclSave ()<br />
end<br />
addCommandHandler ( "setaclright", setACLRight )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{ACL_functions}}<br />
[[en:aclSetRight]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclSave&diff=68825ZH-CN/aclSave2021-02-06T07:13:33Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
每当修改ACL时,ACL XML文件都会自动保存,但出于性能原因,自动保存最多可延迟10秒。调用此函数将强制立即保存. <br />
<br />
==语法== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool aclSave ()<br />
</syntaxhighlight> <br />
{{OOP_ZH-CN|This function is a static function underneath the ACL class.|[[ACL]].save||}}<br />
===返回值===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
如果ACL已成功更改,则返回“true”;如果由于某种原因(如文件正在使用)无法保存,则返回“false”或“nil”.<br />
<br />
==示例== <br />
<!-- Explain what the example is in a single sentance --><br />
此示例在有人键入“/save ACL”时保存ACL.<br />
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --><br />
<syntaxhighlight lang="lua"><br />
function saveACL ( thePlayer, command ) -- 函数标题.也是定义图层的地方<br />
local saved = aclSave() -- 保存ACL<br />
if ( saved ) then -- 如果成功保存,则...<br />
outputChatBox ( "ACL was successfully saved.", thePlayer, 255, 0, 0 ) -- 输出已保存<br />
else -- If it wasn't saved for whatever reason then...<br />
outputChatBox ( "An unexpected error occured.", thePlayer, 255, 0, 0 ) -- 输出它没有保存输出<br />
end<br />
end<br />
addCommandHandler ( "save-acl", saveACL ) -- 使其触发“/save-acl”<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:aclSave]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclRemoveRight&diff=68824ZH-CN/aclRemoveRight2021-02-06T07:10:46Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数用于从给定ACL中删除给定的权限(字符串).<br />
<br />
==语法== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool aclRemoveRight ( acl theAcl, string rightName ) <br />
</syntaxhighlight> <br />
{{OOP_ZH-CN||[[acl]]:removeRight||}}<br />
===必填参数=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''theAcl:''' 要从中移除右侧的ACL<br />
*'''rightName:''' 要从右侧删除的ACL名称<br />
<br />
===返回值===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
如果给定的权限已成功从给定的ACL中删除,则返回“true”;如果由于某种原因无法删除,即ACL中不存在该权限,则返回“false”或“nil”.<br />
<br />
==示例== <br />
此示例在资源启动时删除acl权限.<br />
<syntaxhighlight lang="lua"><br />
addEventHandler("onResourceStart",resourceRoot,function()<br />
aclRemoveRight(aclGet("Admin"),"function.setServerPassword")<br />
end)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:aclRemoveRight]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclReload&diff=68823ZH-CN/aclReload2021-02-06T07:08:45Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数用于从ACL XML文件重新加载ACL和ACL组。所有ACL和ACL组元素在调用后都无效,不应再使用.<br />
<br />
==语法== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool aclReload ()<br />
</syntaxhighlight> <br />
{{OOP_ZH-CN|This function is a static function underneath the ACL class.|[[ACL]].reload||}}<br />
===返回值===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
如果XML已成功从文件中重新加载,则返回“true”;如果XML无效、不存在或由于其他原因无法加载,则返回“false”或“nil”.<br />
<br />
==示例== <br />
<!-- Explain what the example is in a single sentance --><br />
此示例允许管理员通过键入“/reloadACL”来重新加载ACL.<br />
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --><br />
<syntaxhighlight lang="lua"><br />
function reloadACL ( source, command )<br />
-- 检查他们是不是管理员...<br />
if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( source )), aclGetGroup ( "Admin" ) ) ) then<br />
local reload = aclReload() -- 重新加载ACL<br />
if ( reload ) then -- 检查是否已成功重新加载<br />
outputChatBox ( "ACL was successfully reloaded.", source, 255, 0, 0 ) -- If so, output it<br />
else -- 如果没有,输出下面一行↓<br />
outputChatBox ( "An unknown error occured. Please check the ACL file exists.", source, 255, 0, 0 )<br />
end<br />
else -- 如果他们不是管理员,输出下面一行↓<br />
outputChatBox ( "You must be an admin to use this command!", source, 255, 0, 0 )<br />
end<br />
end<br />
addCommandHandler ( "reloadACL", reloadACL )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:aclReload]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclListRights&diff=68822ZH-CN/aclListRights2021-02-06T07:05:06Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
此函数返回给定ACL拥有的所有权限的表.<br />
<br />
==语法== <br />
<syntaxhighlight lang="lua"><br />
table aclListRights ( acl theACL, string allowedType )<br />
</syntaxhighlight> <br />
{{OOP_ZH-CN||[[acl]]:listRights||}}<br />
===必填参数=== <br />
*'''theACL:''' 要从中获取权限的ACL<br />
*'''allowedType:''' 允许的正确类型.可能的值为 ''general'', ''function'', ''resource'' and ''command''<br />
<br />
===返回值===<br />
在给定ACL中以字符串形式返回权限上的表。这张表子可能是空的。如果acl无效或由于其他原因失败,则返回“false”或“nil”.<br />
<br />
==示例== <br />
本例输出给定acl的权限.(已测试!)<br />
<syntaxhighlight lang="lua">addCommandHandler("aclRights",function(player,command,theAcl)<br />
if(theAcl~="")then<br />
rights = aclListRights(aclGet(theAcl))<br />
count = 0<br />
for acl,list in pairs(rights)do<br />
outputChatBox("ACL List: "..theAcl.." #"..tostring(count).." Right: "..list..".",player)<br />
count = count + 1<br />
end<br />
else<br />
outputChatBox("Please type in a acl that you want to retrieve the rights from.",player)<br />
outputChatBox("Please use this Syntax: /aclRights theACL ",player)<br />
end<br />
end)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:aclListRights]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclList&diff=68821ZH-CN/aclList2021-02-06T07:02:20Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
此函数返回所有ACL的列表.<br />
<br />
==语法== <br />
<syntaxhighlight lang="lua"><br />
table aclList ()<br />
</syntaxhighlight> <br />
{{OOP_ZH-CN|This function is a static function underneath the ACL class.|[[ACL]].list||}}<br />
===返回值===<br />
返回所有ACL的表。如果不存在ACL,则此表可以为空。如果由于某种原因失败,它还可以返回“false”/“nil”.<br />
<br />
==示例== <br />
此示例添加了一个命令“listacls”,它将所有acl的名称列表打印到控制台.<br />
<syntaxhighlight lang="lua"><br />
function printOutAllACLs ( thePlayer )<br />
-- 在所有ACL上建立一个表<br />
local allACLs = aclList()<br />
-- 如果表为空(没有ACL)<br />
if #allACLs == 0 then<br />
-- 发送消息到控制台并退出功能<br />
return outputConsole ( "There are no ACLs!", thePlayer )<br />
else<br />
-- 发送名单列表<br />
outputConsole ( "List of all ACLs:", thePlayer )<br />
for key, singleACL in ipairs ( allACLs ) do<br />
local ACLName = aclGetName ( singleACL )<br />
outputConsole ( "- " .. tostring ( ACLName ), thePlayer )<br />
end<br />
end<br />
end<br />
addCommandHandler ( "listacls", printOutAllACLs )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{ACL_functions}}<br />
[[en:aclList]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/AclCreateGroup&diff=68820ZH-CN/AclCreateGroup2021-02-06T06:57:39Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
此函数用于在ACL中创建组。ACL组可以包含玩家和资源等对象.它们指定谁有权访问此组中的ACL<br />
<br />
==语法== <br />
<syntaxhighlight lang="lua"><br />
aclgroup aclCreateGroup ( string groupName )<br />
</syntaxhighlight> <br />
{{OOP_ZH-CN||[[aclgroup|ACLGroup]]||}}<br />
===必填参数=== <br />
*'''groupName:''' 要创建的组的名称<br />
<br />
===返回值===<br />
如果成功,则返回指向已创建aclgroup的指针函数。如果失败,则返回false.<br />
<br />
==示例== <br />
此示例添加了一个命令''addobjecttogroup'',使用该命令可以轻松地将新对象添加到指定的访问控制列表组中.<br />
<syntaxhighlight lang="lua"><br />
function addACLGroupObject ( thePlayer, commandName, groupName, objectName )<br />
local ourGroup = aclGetGroup ( groupName )<br />
-- 如果以前没有使用此名称的组,则需要创建一个<br />
if not ourGroup then<br />
ourGroup = aclCreateGroup ( groupName )<br />
end<br />
<br />
-- 如果没有给出对象名<br />
if not objectName then<br />
-- 将消息发送到聊天室<br />
return outputChatBox ( "You need to specify the object!", thePlayer )<br />
end<br />
<br />
-- 最后,让我们将对象添加到它的组中<br />
aclGroupAddObject ( ourGroup, objectName )<br />
-- 不要忘记在修改ACL后保存它<br />
aclSave ()<br />
end<br />
addCommandHandler ( "addobjecttogroup", addACLGroupObject )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{ACL_functions}}<br />
[[en:AclCreateGroup]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclGroupListObjects&diff=68819ZH-CN/aclGroupListObjects2021-02-06T06:47:30Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
<!-- Change this to "Client function" or "Server function" appropriately--><br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数用于返回给定ACL组中存在的所有对象的表。这些都是像玩家和资源这样的对象.<br />
<br />
==语法== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
table aclGroupListObjects ( aclgroup theGroup )<br />
</syntaxhighlight> <br />
{{OOP_ZH-CN||[[aclgroup]]:listObjects|objects|}}<br />
===必填参数=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''theGroup:''' 要从中获取对象的ACL组<br />
<br />
===返回值===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
返回给定ACL组中的字符串表。这张表子可能是空的。如果组无效或由于其他原因失败,则返回“false”或“nil”.<br />
<br />
==示例== <br />
如果给定了ACL组,本例将输出对象列表.(已测试!)<br />
<section name="Example 1: Server" class="server" show="true"><br />
<syntaxhighlight lang="lua">addCommandHandler("aclObjectList",function(player,command,aclGroup)<br />
if(aclGroup~="")then<br />
table = aclGroupListObjects(aclGetGroup(aclGroup))<br />
count = 0<br />
for objects,name in pairs(table)do<br />
outputChatBox("ACL LIST: "..aclGroup.." #"..tostring(count).." Object: "..name..".",player)<br />
count = count + 1<br />
end<br />
else<br />
outputChatBox("Please add the aclGroup you want the list of.",player)<br />
outputChatBox("Syntax: /aclObjectList aclGroup",player)<br />
end<br />
end)<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
本例通过命令“getadmincounts”输出添加到“Admin”组的所有帐户.<br />
<section name="Example 2: Server" class="server" show="true"><br />
<syntaxhighlight lang="lua" >function outputAdminGroupAccounts( player )<br />
local admins = {} -- 创建将在其中添加“Admin”组帐户的表<br />
local group = aclGetGroup( "Admin" )<br />
-- 如果在ACL中找到“Admin”组,则应返回“aclgroup”<br />
if (group) then<br />
for _, object in ipairs(aclGroupListObjects(group) or {}) do<br />
local objType = gettok( object, 1, string.byte('.') )<br />
-- objType:只获取对象类型,可以是“user”或“resource”<br />
if (objType == "user") then -- 检查是否是玩家帐户<br />
local _name = gettok( object, 2, string.byte('.') ) -- 忽略“user.”,将其与帐户名分开<br />
table.insert( admins, _name ) -- 将帐户名添加到“admins”表中<br />
end<br />
end<br />
end<br />
for i, name in ipairs(admins) do -- 在“admins”表中循环<br />
outputChatBox(tostring(i).." : "..tostring(name), player, 140, 220, 140)<br />
-- 输出如下:“1:John”<br />
end<br />
end<br />
addCommandHandler("getAdminAccounts", outputAdminGroupAccounts)<br />
-- 添加命令“getAdminAccounts”并将其附加到函数“outputAdminGroupAccounts”<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:aclGroupListObjects]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclGroupListObjects&diff=68818ZH-CN/aclGroupListObjects2021-02-06T06:46:45Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
<!-- Change this to "Client function" or "Server function" appropriately--><br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数用于返回给定ACL组中存在的所有对象的表。这些都是像玩家和资源这样的对象.<br />
<br />
==语法== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
table aclGroupListObjects ( aclgroup theGroup )<br />
</syntaxhighlight> <br />
{{OOP_ZH-CN||[[aclgroup]]:listObjects|objects|}}<br />
===必填参数=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''theGroup:''' 要从中获取对象的ACL组<br />
<br />
===返回值===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
返回给定ACL组中的字符串表。这张表子可能是空的。如果组无效或由于其他原因失败,则返回“false”或“nil”.<br />
<br />
==示例== <br />
如果给定了ACL组,本例将输出对象列表.(已测试!)<br />
<section name="Example 1: Server" class="server" show="true"><br />
<syntaxhighlight lang="lua">addCommandHandler("aclObjectList",function(player,command,aclGroup)<br />
if(aclGroup~="")then<br />
table = aclGroupListObjects(aclGetGroup(aclGroup))<br />
count = 0<br />
for objects,name in pairs(table)do<br />
outputChatBox("ACL LIST: "..aclGroup.." #"..tostring(count).." Object: "..name..".",player)<br />
count = count + 1<br />
end<br />
else<br />
outputChatBox("Please add the aclGroup you want the list of.",player)<br />
outputChatBox("Syntax: /aclObjectList aclGroup",player)<br />
end<br />
end)<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
This example outputs through the command "getAdminAccounts" all accounts added to the "Admin" group.<br />
<section name="Example 2: Server" class="server" show="true"><br />
<syntaxhighlight lang="lua" >function outputAdminGroupAccounts( player )<br />
local admins = {} -- 创建将在其中添加“Admin”组帐户的表<br />
local group = aclGetGroup( "Admin" )<br />
-- 如果在ACL中找到“Admin”组,则应返回“aclgroup”<br />
if (group) then<br />
for _, object in ipairs(aclGroupListObjects(group) or {}) do<br />
local objType = gettok( object, 1, string.byte('.') )<br />
-- objType:只获取对象类型,可以是“user”或“resource”<br />
if (objType == "user") then -- 检查是否是玩家帐户<br />
local _name = gettok( object, 2, string.byte('.') ) -- 忽略“user.”,将其与帐户名分开<br />
table.insert( admins, _name ) -- 将帐户名添加到“admins”表中<br />
end<br />
end<br />
end<br />
for i, name in ipairs(admins) do -- 在“admins”表中循环<br />
outputChatBox(tostring(i).." : "..tostring(name), player, 140, 220, 140)<br />
-- 输出如下:“1:John”<br />
end<br />
end<br />
addCommandHandler("getAdminAccounts", outputAdminGroupAccounts)<br />
-- 添加命令“getAdminAccounts”并将其附加到函数“outputAdminGroupAccounts”<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:aclGroupListObjects]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclGroupListObjects&diff=68817ZH-CN/aclGroupListObjects2021-02-06T06:43:48Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
<!-- Change this to "Client function" or "Server function" appropriately--><br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数用于返回给定ACL组中存在的所有对象的表。这些都是像玩家和资源这样的对象.<br />
<br />
==Syntax== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
table aclGroupListObjects ( aclgroup theGroup )<br />
</syntaxhighlight> <br />
{{OOP||[[aclgroup]]:listObjects|objects|}}<br />
===Required Arguments=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''theGroup:''' 要从中获取对象的ACL组<br />
<br />
===Returns===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
Returns a table of strings in the given ACL group. This table might be empty. Returns ''false'' or ''nil'' if theGroup is invalid or it fails for some other reason.<br />
<br />
==Examples== <br />
This example outputs a list of Objects if the ACL Group is given. (TESTED!)<br />
<section name="Example 1: Server" class="server" show="true"><br />
<syntaxhighlight lang="lua">addCommandHandler("aclObjectList",function(player,command,aclGroup)<br />
if(aclGroup~="")then<br />
table = aclGroupListObjects(aclGetGroup(aclGroup))<br />
count = 0<br />
for objects,name in pairs(table)do<br />
outputChatBox("ACL LIST: "..aclGroup.." #"..tostring(count).." Object: "..name..".",player)<br />
count = count + 1<br />
end<br />
else<br />
outputChatBox("Please add the aclGroup you want the list of.",player)<br />
outputChatBox("Syntax: /aclObjectList aclGroup",player)<br />
end<br />
end)<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
This example outputs through the command "getAdminAccounts" all accounts added to the "Admin" group.<br />
<section name="Example 2: Server" class="server" show="true"><br />
<syntaxhighlight lang="lua" >function outputAdminGroupAccounts( player )<br />
local admins = {} -- creates the table in which will be added the accounts of "Admin" group<br />
local group = aclGetGroup( "Admin" )<br />
-- should return the "aclgroup" if the "Admin" group be found in ACL<br />
if (group) then<br />
for _, object in ipairs(aclGroupListObjects(group) or {}) do<br />
local objType = gettok( object, 1, string.byte('.') )<br />
-- objType: gets the object type only, which can be either "user" or "resource"<br />
if (objType == "user") then -- checks if it's a player account<br />
local _name = gettok( object, 2, string.byte('.') ) -- ignores "user." by separating that from the account name<br />
table.insert( admins, _name ) -- adds the account name to the "admins" table<br />
end<br />
end<br />
end<br />
for i, name in ipairs(admins) do -- loop through the table "admins"<br />
outputChatBox(tostring(i).." : "..tostring(name), player, 140, 220, 140)<br />
-- output will look like this: "1 : John"<br />
end<br />
end<br />
addCommandHandler("getAdminAccounts", outputAdminGroupAccounts)<br />
-- adds the command "getAdminAccounts" and attaches it to the function "outputAdminGroupAccounts"<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:aclGroupListObjects]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclGroupListObjects&diff=68816ZH-CN/aclGroupListObjects2021-02-06T06:43:38Z<p>Qwe7769611: Created page with "__NOTOC__ {{Server function}} <!-- Change this to "Client function" or "Server function" appropriately--> <!-- Describe in plain english what this function does. Don't go int..."</p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
<!-- Change this to "Client function" or "Server function" appropriately--><br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数用于返回给定ACL组中存在的所有对象的表。这些都是像玩家和资源这样的对象.<br />
<br />
==Syntax== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
table aclGroupListObjects ( aclgroup theGroup )<br />
</syntaxhighlight> <br />
{{OOP||[[aclgroup]]:listObjects|objects|}}<br />
===Required Arguments=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''theGroup:''' 要从中获取对象的ACL组<br />
<br />
===Returns===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
Returns a table of strings in the given ACL group. This table might be empty. Returns ''false'' or ''nil'' if theGroup is invalid or it fails for some other reason.<br />
<br />
==Examples== <br />
This example outputs a list of Objects if the ACL Group is given. (TESTED!)<br />
<section name="Example 1: Server" class="server" show="true"><br />
<syntaxhighlight lang="lua">addCommandHandler("aclObjectList",function(player,command,aclGroup)<br />
if(aclGroup~="")then<br />
table = aclGroupListObjects(aclGetGroup(aclGroup))<br />
count = 0<br />
for objects,name in pairs(table)do<br />
outputChatBox("ACL LIST: "..aclGroup.." #"..tostring(count).." Object: "..name..".",player)<br />
count = count + 1<br />
end<br />
else<br />
outputChatBox("Please add the aclGroup you want the list of.",player)<br />
outputChatBox("Syntax: /aclObjectList aclGroup",player)<br />
end<br />
end)<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
This example outputs through the command "getAdminAccounts" all accounts added to the "Admin" group.<br />
<section name="Example 2: Server" class="server" show="true"><br />
<syntaxhighlight lang="lua" >function outputAdminGroupAccounts( player )<br />
local admins = {} -- creates the table in which will be added the accounts of "Admin" group<br />
local group = aclGetGroup( "Admin" )<br />
-- should return the "aclgroup" if the "Admin" group be found in ACL<br />
if (group) then<br />
for _, object in ipairs(aclGroupListObjects(group) or {}) do<br />
local objType = gettok( object, 1, string.byte('.') )<br />
-- objType: gets the object type only, which can be either "user" or "resource"<br />
if (objType == "user") then -- checks if it's a player account<br />
local _name = gettok( object, 2, string.byte('.') ) -- ignores "user." by separating that from the account name<br />
table.insert( admins, _name ) -- adds the account name to the "admins" table<br />
end<br />
end<br />
end<br />
for i, name in ipairs(admins) do -- loop through the table "admins"<br />
outputChatBox(tostring(i).." : "..tostring(name), player, 140, 220, 140)<br />
-- output will look like this: "1 : John"<br />
end<br />
end<br />
addCommandHandler("getAdminAccounts", outputAdminGroupAccounts)<br />
-- adds the command "getAdminAccounts" and attaches it to the function "outputAdminGroupAccounts"<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[zh-cn:aclGroupListObjects]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/AclGroupListACL&diff=68815ZH-CN/AclGroupListACL2021-02-06T06:42:41Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<!-- Change this to "Client function" or "Server function" appropriately--><br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数返回给定ACL组中存在的所有ACL的表.<br />
<br />
==语法== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
table aclGroupListACL ( aclgroup theGroup )<br />
</syntaxhighlight> <br />
{{OOP_ZH-CN||[[aclgroup]]:listACL|aclList|}}<br />
===必填参数=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''theGroup:''' 要从中获取ACL元素的ACL组<br />
<br />
===返回值===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
返回给定ACL组中ACL元素的表。这张表子可能是空的。如果组无效或由于其他原因失败,则返回“false”或“nil”.<br />
<br />
==示例== <br />
如果给定了ACL组名称,本例将输出ACL的列表.(已测试!)<br />
<syntaxhighlight lang="lua">addCommandHandler("aclList",function(player,command,aclGroup)<br />
if(aclGroup~="")then<br />
tables = aclGroupListACL(aclGetGroup(aclGroup))<br />
count = 0<br />
for list,nam in pairs(tables) do<br />
outputChatBox("ACL LIST: "..aclGroup.."Line: "..tostring(count).." ACL: "..aclGetName(nam)..".",player)<br />
count = count + 1<br />
end<br />
else<br />
outputChatBox("Please add the aclGroup you want the list of.",player)<br />
outputChatBox("Syntax: /aclList aclGroup",player)<br />
end<br />
end)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:AclGroupListACL]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/AclGroupListACL&diff=68814ZH-CN/AclGroupListACL2021-02-06T06:42:01Z<p>Qwe7769611: Created page with "__NOTOC__ {{Server function}}<!-- Change this to "Client function" or "Server function" appropriately--> <!-- Describe in plain english what this function does. Don't go into..."</p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<!-- Change this to "Client function" or "Server function" appropriately--><br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数返回给定ACL组中存在的所有ACL的表.<br />
<br />
==语法== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
table aclGroupListACL ( aclgroup theGroup )<br />
</syntaxhighlight> <br />
{{OOP_ZH-CN||[[aclgroup]]:listACL|aclList|}}<br />
===必填参数=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''theGroup:''' 要从中获取ACL元素的ACL组<br />
<br />
===返回值===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
返回给定ACL组中ACL元素的表。这张表子可能是空的。如果组无效或由于其他原因失败,则返回“false”或“nil”.<br />
<br />
==示例== <br />
如果给定了ACL组名称,本例将输出ACL的列表.(已测试!)<br />
<syntaxhighlight lang="lua">addCommandHandler("aclList",function(player,command,aclGroup)<br />
if(aclGroup~="")then<br />
tables = aclGroupListACL(aclGetGroup(aclGroup))<br />
count = 0<br />
for list,nam in pairs(tables) do<br />
outputChatBox("ACL LIST: "..aclGroup.."Line: "..tostring(count).." ACL: "..aclGetName(nam)..".",player)<br />
count = count + 1<br />
end<br />
else<br />
outputChatBox("Please add the aclGroup you want the list of.",player)<br />
outputChatBox("Syntax: /aclList aclGroup",player)<br />
end<br />
end)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[zh-cn:AclGroupListACL]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/AclGroupList&diff=68813ZH-CN/AclGroupList2021-02-06T06:38:49Z<p>Qwe7769611: Created page with "__NOTOC__ {{Server function}} 此函数返回所有ACL组的表. ==语法== <syntaxhighlight lang="lua"> table aclGroupList () </syntaxhighlight> {{OOP_ZH-CN|This functio..."</p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
此函数返回所有ACL组的表.<br />
<br />
==语法== <br />
<syntaxhighlight lang="lua"><br />
table aclGroupList ()<br />
</syntaxhighlight> <br />
{{OOP_ZH-CN|This function is a static function underneath the ACL Group class.|[[aclgroup|ACLGroup]].list||}}<br />
===Returns===<br />
如果成功,则返回所有ACL组的表;如果不存在ACL组,则返回空表.如果此函数因其他原因失败,则可以返回"false"/"nil".<br />
<br />
==示例== <br />
<!-- Explain what the example is in a single sentance --><br />
此示例显示如何按“showAclGroups”输出所有ACL组名<br />
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --><br />
<syntaxhighlight lang="lua"><br />
function showGroups(player)<br />
local groups = {}<br />
groups = aclGroupList()<br />
for i,v in ipairs(groups) do<br />
local name = aclGroupGetName(v)<br />
outputChatBox(tostring(name),player)<br />
end<br />
end<br />
addCommandHandler("showAclGroups",showGroups)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:AclGroupList]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclGroupGetName&diff=68812ZH-CN/aclGroupGetName2021-02-06T06:36:03Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数用于获取给定ACL组的名称.<br />
<br />
==语法== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
string aclGroupGetName ( aclgroup aclGroup )<br />
</syntaxhighlight> <br />
{{OOP||[[aclgroup]]:getName|name|}}<br />
===必填参数=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''aclGroup:''' 要获取其名称的ACL组<br />
<br />
===返回值===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
如果成功,则以字符串形式返回给定ACL组的名称;如果ACL组无效或由于其他原因失败,则返回“false”或“nil”.<br />
<br />
==示例== <br />
这个例子输出到控制台,"管理员已经准备好监视:)"<br />
<syntaxhighlight lang="lua">addEventHandler("onResourceStart", resourceRoot, function()<br />
outputConsole(aclGroupGetName(aclGetGroup("Admin")).."'s are ready to watch :)",root)<br />
end)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:aclGroupGetName]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclGroupGetName&diff=68811ZH-CN/aclGroupGetName2021-02-06T06:35:39Z<p>Qwe7769611: Created page with "__NOTOC__ {{Server function}} <!-- Describe in plain english what this function does. Don't go into details, just give an overview --> 此函数用于获取给定ACL组的名..."</p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数用于获取给定ACL组的名称.<br />
<br />
==语法== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
string aclGroupGetName ( aclgroup aclGroup )<br />
</syntaxhighlight> <br />
{{OOP||[[aclgroup]]:getName|name|}}<br />
===必填参数=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''aclGroup:''' 要获取其名称的ACL组<br />
<br />
===返回值===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
如果成功,则以字符串形式返回给定ACL组的名称;如果ACL组无效或由于其他原因失败,则返回“false”或“nil”.<br />
<br />
==示例== <br />
这个例子输出到控制台,"管理员已经准备好监视:)"<br />
<syntaxhighlight lang="lua">addEventHandler("onResourceStart", resourceRoot, function()<br />
outputConsole(aclGroupGetName(aclGetGroup("Admin")).."'s are ready to watch :)",root)<br />
end)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[zh-cn:aclGroupGetNameServer]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=AclGroupGetName&diff=68810AclGroupGetName2021-02-06T06:35:26Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
This function is used to get the name of the given ACL group.<br />
<br />
==Syntax== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
string aclGroupGetName ( aclgroup aclGroup )<br />
</syntaxhighlight> <br />
{{OOP||[[aclgroup]]:getName|name|}}<br />
===Required Arguments=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''aclGroup:''' The ACL group to get the name of<br />
<br />
===Returns===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
Returns the name of the given ACL group as a string if successful, otherwise ''false'' or ''nil'' if the aclGroup is invalid or it fails for some other reason.<br />
<br />
==Example== <br />
This example outputs to the console that "Admin's are ready to watch :)". <br />
<syntaxhighlight lang="lua">addEventHandler("onResourceStart", resourceRoot, function()<br />
outputConsole(aclGroupGetName(aclGetGroup("Admin")).."'s are ready to watch :)",root)<br />
end)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[zh-cn:aclGroupGetName]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclGroupAddObjectServer&diff=68804ZH-CN/aclGroupAddObjectServer2021-02-06T06:30:10Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数用于将对象添加到给定的ACL组。对象可以是玩家的帐户,指定为:<br />
''user.<accountname>''<br />
<br />
或者是资源,指定为:<br />
''resource.<resourcename>''<br />
<br />
对象被指定为字符串。ACL组用于用户帐户和其中指定的资源.<br />
<br />
==语法== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool aclGroupAddObject ( aclgroup theGroup, string theObjectName )<br />
</syntaxhighlight> <br />
{{OOP||[[aclgroup]]:addObject||}}<br />
===必填参数=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''theGroup:''' 要添加对象名称字符串的组.<br />
*'''theObjectName:''' 要添加到给定ACL的对象字符串.<br />
<br />
===返回值===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
如果对象已成功添加到ACL,则返回“true”;如果对象已存在于列表中,则返回“false”.<br />
<br />
==示例== <br />
<!-- Explain what the example is in a single sentance --><br />
这个例子使每个玩家都能使用一个名为“giveAccountAdminRights”的命令,这个命令会将一个特定的帐户名作为ACL对象添加到“Admin”组中.<br />
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --><br />
<syntaxhighlight lang="lua"><br />
function giveAdminRights (playerSource, commandName, accountName) --添加函数giveAdminRights并指定其参数<br />
if accountName then --如果输入了accountName<br />
aclGroupAddObject (aclGetGroup("Admin"), "user."..accountName) --使用“user.[accountName]”格式将ACL对象添加到ACL组“Admin”<br />
outputChatBox ("Account '"..accountName.."' succesfully added to the admin group", playerSource) --向输入命令的玩家输出一个通知,通知其账户已成功添加<br />
else --否则,将错误消息和命令的正确语法输出给输入它的玩家<br />
outputChatBox ("No account name specified.", playerSource)<br />
outputChatBox ("Correct syntax: /giveAccountAdminRights [accountName]", playerSource)<br />
end<br />
end<br />
<br />
addCommandHandler ("giveAccountAdminRights", giveAdminRights) --添加一个命令“giveAccountAdminRights”并将函数“giveAdminRights”添加到其中<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:aclGroupAddObjectServer]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclGroupAddObjectServer&diff=68803ZH-CN/aclGroupAddObjectServer2021-02-06T06:29:19Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数用于将对象添加到给定的ACL组。对象可以是玩家的帐户,指定为:<br />
''user.<accountname>''<br />
<br />
或者是资源,指定为:<br />
''resource.<resourcename>''<br />
<br />
对象被指定为字符串。ACL组用于用户帐户和其中指定的资源.<br />
<br />
==语法== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool aclGroupAddObject ( aclgroup theGroup, string theObjectName )<br />
</syntaxhighlight> <br />
{{OOP||[[aclgroup]]:addObject||}}<br />
===必填参数=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''theGroup:''' 要添加对象名称字符串的组.<br />
*'''theObjectName:''' 要添加到给定ACL的对象字符串.<br />
<br />
===返回值===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
如果对象已成功添加到ACL,则返回“true”;如果对象已存在于列表中,则返回“false”.<br />
<br />
==示例== <br />
<!-- Explain what the example is in a single sentance --><br />
这个例子使每个玩家都能使用一个名为“giveAccountAdminRights”的命令,这个命令会将一个特定的帐户名作为ACL对象添加到“Admin”组中.<br />
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --><br />
<syntaxhighlight lang="lua"><br />
function giveAdminRights (playerSource, commandName, accountName) --添加函数giveAdminRights并指定其参数<br />
if accountName then --if there was an accountName entered then<br />
aclGroupAddObject (aclGetGroup("Admin"), "user."..accountName) --使用“user.[accountName]”格式将ACL对象添加到ACL组“Admin”<br />
outputChatBox ("Account '"..accountName.."' succesfully added to the admin group", playerSource) --向输入命令的玩家输出一个通知,通知其账户已成功添加<br />
else --否则,将错误消息和命令的正确语法输出给输入它的玩家<br />
outputChatBox ("No account name specified.", playerSource)<br />
outputChatBox ("Correct syntax: /giveAccountAdminRights [accountName]", playerSource)<br />
end<br />
end<br />
<br />
addCommandHandler ("giveAccountAdminRights", giveAdminRights) --添加一个命令“giveAccountAdminRights”并将函数“giveAdminRights”添加到其中<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:aclGroupAddObjectServer]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclGroupAddObjectServer&diff=68802ZH-CN/aclGroupAddObjectServer2021-02-06T06:29:09Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数用于将对象添加到给定的ACL组。对象可以是玩家的帐户,指定为:<br />
''user.<accountname>''<br />
<br />
或者是资源,指定为:<br />
''resource.<resourcename>''<br />
<br />
对象被指定为字符串。ACL组用于用户帐户和其中指定的资源.<br />
<br />
==语法== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool aclGroupAddObject ( aclgroup theGroup, string theObjectName )<br />
</syntaxhighlight> <br />
{{OOP||[[aclgroup]]:addObject||}}<br />
===必填参数=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''theGroup:''' 要添加对象名称字符串的组.<br />
*'''theObjectName:''' 要添加到给定ACL的对象字符串.<br />
<br />
===返回值===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
如果对象已成功添加到ACL,则返回“true”;如果对象已存在于列表中,则返回“false”.<br />
<br />
==Example== <br />
<!-- Explain what the example is in a single sentance --><br />
这个例子使每个玩家都能使用一个名为“giveAccountAdminRights”的命令,这个命令会将一个特定的帐户名作为ACL对象添加到“Admin”组中.<br />
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --><br />
<syntaxhighlight lang="lua"><br />
function giveAdminRights (playerSource, commandName, accountName) --添加函数giveAdminRights并指定其参数<br />
if accountName then --if there was an accountName entered then<br />
aclGroupAddObject (aclGetGroup("Admin"), "user."..accountName) --使用“user.[accountName]”格式将ACL对象添加到ACL组“Admin”<br />
outputChatBox ("Account '"..accountName.."' succesfully added to the admin group", playerSource) --向输入命令的玩家输出一个通知,通知其账户已成功添加<br />
else --否则,将错误消息和命令的正确语法输出给输入它的玩家<br />
outputChatBox ("No account name specified.", playerSource)<br />
outputChatBox ("Correct syntax: /giveAccountAdminRights [accountName]", playerSource)<br />
end<br />
end<br />
<br />
addCommandHandler ("giveAccountAdminRights", giveAdminRights) --添加一个命令“giveAccountAdminRights”并将函数“giveAdminRights”添加到其中<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:aclGroupAddObjectServer]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclGroupAddObjectServer&diff=68801ZH-CN/aclGroupAddObjectServer2021-02-06T06:25:32Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数用于将对象添加到给定的ACL组。对象可以是玩家的帐户,指定为:<br />
''user.<accountname>''<br />
<br />
或者是资源,指定为:<br />
''resource.<resourcename>''<br />
<br />
Objects are specified as strings. The ACL groups work for the user accounts and the resources that are specified in them.<br />
<br />
==Syntax== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool aclGroupAddObject ( aclgroup theGroup, string theObjectName )<br />
</syntaxhighlight> <br />
{{OOP||[[aclgroup]]:addObject||}}<br />
===Required Arguments=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''theGroup:''' The group to add the object name string too.<br />
*'''theObjectName:''' The object string to add to the given ACL.<br />
<br />
===Returns===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
Returns ''true'' if the object was successfully added to the ACL, ''false'' if it already existed in the list.<br />
<br />
==Example== <br />
<!-- Explain what the example is in a single sentance --><br />
This example makes every player able to use a command named "giveAccountAdminRights" that will add a specific accountname as an ACL object to the "Admin" group.<br />
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --><br />
<syntaxhighlight lang="lua"><br />
function giveAdminRights (playerSource, commandName, accountName) --add the function giveAdminRights and specify its arguments<br />
if accountName then --if there was an accountName entered then<br />
aclGroupAddObject (aclGetGroup("Admin"), "user."..accountName) --add an ACL object using the form "user.[accountName]" to the ACL group "Admin"<br />
outputChatBox ("Account '"..accountName.."' succesfully added to the admin group", playerSource) --output a notification to the player who entered the command that the acocunt was successfully added<br />
else --else output an error message and the correct syntax of the command to the player who entered it<br />
outputChatBox ("No account name specified.", playerSource)<br />
outputChatBox ("Correct syntax: /giveAccountAdminRights [accountName]", playerSource)<br />
end<br />
end<br />
<br />
addCommandHandler ("giveAccountAdminRights", giveAdminRights) --add a command "giveAccountAdminRights" and attch the function "giveAdminRights" to it <br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:aclGroupAddObjectServer]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclGroupAddACL&diff=68800ZH-CN/aclGroupAddACL2021-02-06T06:23:40Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数用于将给定ACL添加到给定ACL组。这使得给定ACL组中的资源和玩家可以访问给定ACL中指定的内容.一个组中不同ACL中的某个内容的权限被合并在一起,这意味着如果一个ACL允许访问某个内容,那么这个ACL组将有权访问该内容.<br />
<br />
==语法== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool aclGroupAddACL ( aclgroup theGroup, acl theACL )<br />
</syntaxhighlight> <br />
{{OOP_ZH-CN||[[aclgroup]]:addACL||}}<br />
===必填参数=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''theGroup:''' 要将ACL添加到的组<br />
*'''theACL:''' 要添加到组的ACL<br />
<br />
===返回值===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
如果ACL可以成功添加到ACL组,则返回“true”;如果其中任何一个元素无效,则返回“false”/“nil”;如果ACL已在该组中,或出现其他错误,则返回“true”.<br />
<br />
==示例==<br />
此示例添加了一个命令“addAclGroup”,使用该命令可以轻松地将新的访问控制列表添加到指定的acl组.<br />
<syntaxhighlight lang="lua"><br />
function addAclGroup ( thePlayer, commandName, aclName )<br />
if(aclName) then<br />
acl = aclCreate ( aclName )<br />
else<br />
acl = aclCreate("myName")<br />
end<br />
aclGroup = aclGetGroup("Admin")<br />
aclGroupAddACL(aclGroup,acl) -- 现在所有的管理员都有acl的权限了<br />
aclSave () <br />
addCommandHandler ( "addAclGroup", addAclGroup)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:aclGroupAddACL]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclGetRight&diff=68798ZH-CN/aclGetRight2021-02-06T03:49:35Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数返回ACL中给定权限的访问权限设置为true还是false.<br />
<br />
==语法== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool aclGetRight ( acl theAcl, string rightName )<br />
</syntaxhighlight> <br />
{{OOP_ZH-CN||[[acl]]:getRight||aclSetRight}}<br />
===必填参数=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''theAcl:''' 要从中获取权限的ACL<br />
*'''rightName:''' 返回的访问值的正确名称.<br />
<br />
===返回值===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
如果ACL允许或不允许访问给定函数,则返回“true”或“false”。如果由于某种原因失败,例如指定了无效的ACL或ACL中不存在指定的权限,则返回“nil”.<br />
<br />
==示例== <br />
这个例子允许玩家检查ACL组是否有权访问某些东西.<br />
<syntaxhighlight lang="lua"><br />
--theACL examples: Admin, Default, Moderator<br />
--theRight examples: command.debugscript, function.banPlayer<br />
<br />
function aclRightCheck(player, command, theACL, theRight)<br />
if (theACL and theRight) then -- Make sure atleast two arguments were entered.<br />
local theACL = aclGet(theACL) -- 如果ACL存在,则将其从字符串转换为ACL指针变量(pointer).<br />
if (theACL) then -- 如果找到ACL.<br />
local theReturn = aclGetRight(theACL, theRight) -- 如果在ACL中找到,则返回true.<br />
outputChatBox("The ACL right was found and returned: "..tostring(theReturn), player, 0, 255, 0)<br />
else<br />
outputChatBox("The ACL you entered was not found to exist in the ACL file.", player, 255, 0, 0) -- 当未找到ACL时.<br />
end<br />
else<br />
outputChatBox("You need to enter an ACL, and a right name.", player, 255, 0, 0) -- 当两个参数(argument)没有被输入时.<br />
end<br />
end<br />
addCommandHandler("aclgetright", aclRightCheck) -- 当玩家执行aclgetright命令时,它会调用上面的aclRightCheck函数.<br />
-- Example of use: /aclgetright Admin command.debugscript (this should return true)<br />
-- Example of use: /aclgetright Default command.debugscript (this should return false)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:aclGetRight]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/AclGetName&diff=68797ZH-CN/AclGetName2021-02-06T03:41:27Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
获取给定ACL的名称.<br />
<br />
==语法== <br />
<syntaxhighlight lang="lua"><br />
string aclGetName ( acl theAcl )<br />
</syntaxhighlight> <br />
{{OOP_ZH-CN||[[acl]]:getName|name|}}<br />
===必填参数=== <br />
*'''theACL:''' 要获取其名称的ACL<br />
<br />
===返回值===<br />
如果成功,则以字符串形式返回给定ACL的名称。如果不成功,则返回“false”/“nil”,即ACL无效.<br />
<br />
==示例== <br />
此示例添加命令“listacls”,该命令将所有acl的名称列表打印到控制台.<br />
<syntaxhighlight lang="lua"><br />
function printOutAllACLs ( thePlayer )<br />
-- 在所有ACL上建立一个表<br />
local allACLs = aclList()<br />
-- 如果表里是空白的(代表没有ACL)<br />
if #allACLs == 0 then<br />
-- 发送消息到控制台并退出函数<br />
return outputConsole ( "There are no ACLs!", thePlayer )<br />
else<br />
-- 发送名单列表<br />
outputConsole ( "List of all ACLs:", thePlayer )<br />
for key, singleACL in ipairs ( allACLs ) do<br />
local ACLName = aclGetName ( singleACL )<br />
outputConsole ( "- " .. tostring ( ACLName ), thePlayer )<br />
end<br />
end<br />
end<br />
addCommandHandler ( "listacls", printOutAllACLs )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{ACL_functions}}<br />
[[en:AclGetName]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/AclGetGroup&diff=68796ZH-CN/AclGetGroup2021-02-06T03:35:19Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数用于获取具有给定名称的ACL组.如果需要大多数组,应该考虑使用[[aclGroupList]]来获得包含所有组的表.<br />
<br />
==语法== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
aclgroup aclGetGroup ( string groupName )<br />
</syntaxhighlight> <br />
{{OOP_ZH-CN|This function is a static function underneath the ACL Group class.|[[aclgroup|ACLGroup]].get||}}<br />
===必填参数=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''groupName:''' 从中获取ACL组的名称<br />
<br />
===返回值===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
返回ACL组(如果可以找到).如果它不存在或由于某种原因失败,则返回false/nil.<br />
<br />
==示例== <br />
<br />
'''例子 1:''' 这个例子使每个玩家都能使用一个名为“giveAccountAdminRights”的命令,该命令会将一个特定的账户名作为ACL对象添加到“Admin”组中.<br />
<syntaxhighlight lang="lua"><br />
function giveAdminRights (playerSource, commandName, accountName) --添加函数giveAdminRights并指定其参数<br />
if accountName then --if there was an accountName entered then<br />
aclGroupAddObject (aclGetGroup("Admin"), "user."..accountName)) --使用“user.[accountName]”格式将ACL对象添加到ACL组“Admin”<br />
outputChatBox ("Account '"..accountName.."' succesfully added to the admin group", playerSource) --向输入命令的玩家输出一个通知,通知其acocunt已成功添加<br />
else --否则,将错误消息和命令的正确语法输出给输入它的玩家<br />
outputChatBox ("No account name specified.", playerSource)<br />
outputChatBox ("Correct syntax: /giveAccountAdminRights [accountName]", playerSource)<br />
end<br />
end<br />
<br />
addCommandHandler ("giveAccountAdminRights", giveAdminRights) --添加一个命令“giveAccountAdminRights”并将函数“giveAdminRights”添加到其中<br />
</syntaxhighlight><br />
<br />
'''例子 2:''' 此示例显示聊天框中所有在线管理员的列表(假设ACL中的管理员组名为“admin”):<br />
<syntaxhighlight lang="lua"><br />
players = getElementsByType ( "player" )<br />
admins = ""<br />
for k,v in ipairs(players) do<br />
local accountname = ""<br />
if (isGuestAccount(getPlayerAccount(v)) == false) then<br />
accountname = getAccountName (getPlayerAccount(v))<br />
if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "admin" ) ) then<br />
if (admins == "") then<br />
admins = getPlayerName(v)<br />
else<br />
admins = admins .. ", " .. getPlayerName(v)<br />
end<br />
end<br />
end<br />
end<br />
outputChatBox( "Online Admins:", getRootElement(), 255, 255, 0)<br />
outputChatBox( " " .. tostring ( admins ), getRootElement(), 255, 255, 0)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:AclGetGroup]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/AclGet&diff=68795ZH-CN/AclGet2021-02-06T03:27:27Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
获取具有给定名称的ACL。如果需要获取大多数ACL,您应该考虑使用[[aclist]]来获取所有ACL的表.<br />
<br />
==语法== <br />
<syntaxhighlight lang="lua"><br />
acl aclGet ( string aclName )<br />
</syntaxhighlight> <br />
{{OOP_ZH-CN|This function is a static function underneath the ACL class.|[[ACL]].get||}}<br />
===必填参数=== <br />
*'''aclName:''' 获取ACL所属的名称<br />
<br />
===返回值===<br />
如果可以检索,则返回具有该名称的ACL;如果ACL不存在或由于其他原因失败,则返回“false”/“nil”.<br />
<br />
==示例== <br />
此示例添加了命令“setaclright”,使用该命令可以轻松地向指定的访问控制列表添加新权限.<br />
<syntaxhighlight lang="lua"><br />
function setACLRight ( thePlayer, commandName, aclName, rightName, access )<br />
local ourACL = aclGet ( aclName )<br />
-- 如果以前没有具有此名称的ACL,则需要创建一个<br />
if not ourACL then<br />
ourACL = aclCreate ( aclName )<br />
end<br />
<br />
-- 将布尔字符串转换为小写<br />
access = string.lower ( access )<br />
-- 访问必须是true或false(布尔值)<br />
if not (access == "true" or access == "false") then<br />
-- 将错误消息打印到调试窗口<br />
return outputDebugString ( "Invalid access; true and false are only accepted", 1 )<br />
end<br />
<br />
-- 将访问权限更改为布尔值<br />
if access == "true" then<br />
access = true<br />
else <br />
access = false<br />
end<br />
<br />
-- 最后让我们确定正确的方向<br />
aclSetRight ( ourACL, rightName, access )<br />
-- 不要忘记在修改ACL后保存它<br />
aclSave ()<br />
end<br />
addCommandHandler ( "setaclright", setACLRight )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{ACL_functions}}<br />
[[en:AclGet]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/AclDestroyGroup&diff=68794ZH-CN/AclDestroyGroup2021-02-06T02:05:45Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数将销毁给定的ACL组.销毁的ACL组将不再有效.<br />
<br />
==语法== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool aclDestroyGroup ( aclgroup aclGroup )<br />
</syntaxhighlight> <br />
{{OOP_ZH-CN||[[aclgroup]]:destroy||}}<br />
===必填参数=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''aclGroup:''' 要销毁的ACL组元素<br />
<br />
===返回值===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
如果ACL组已成功删除,则返回“true”;如果由于某种原因(即无效参数)无法删除,则返回“false”.<br />
<br />
==示例== <br />
<!-- Explain what the example is in a single sentance --><br />
此示例允许管理员删除他们指定的ACL组.<br />
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --><br />
<syntaxhighlight lang="lua"><br />
function removeACLGroup ( source, command, groupName )<br />
-- 检查他们是不是管理员...<br />
if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( source )), aclGetGroup ( "Admin" ) ) ) then<br />
if ( groupName ) then -- 检查他们是否指定了组名<br />
local group = aclGetGroup ( groupName ) -- 返回与名称匹配的任何组<br />
if ( group ) then -- If any were returned then...<br />
aclDestroyGroup ( group ) -- 删除这个组<br />
else<br />
-- 告诉他们是否找不到具有该名称的组...<br />
outputChatBox ( "No group with that name was found.", source, 255, 0, 0 )<br />
end<br />
<br />
else -- 如果他们没有指定组<br />
outputChatBox ( "Please specify the group name.", source, 255, 0, 0 ) -- Tell them that they must<br />
end<br />
else -- 如果他们不是管理员....<br />
outputChatBox ( "You must be an admin to use this command", source, 255, 0, 0 ) -- Tell them it's restricted<br />
end<br />
end<br />
addCommandHandler ( "removeACL", removeACLGroup ) -- 当玩家输入 "/removeACL"时触发的事件<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:AclDestroyGroup]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/AclDestroy&diff=68793ZH-CN/AclDestroy2021-02-06T01:59:53Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数将销毁传递的ACL.销毁的ACL将不再有效.<br />
<br />
==语法== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool aclDestroy ( acl theACL )<br />
</syntaxhighlight> <br />
{{OOP||[[acl]]:destroy||}}<br />
===必填参数=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''theACL:''' 要销毁的ACL<br />
<br />
===返回值===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
如果成功销毁,则返回“true”;如果无法删除,则返回“false”(意思就是它是一个空值).<br />
<br />
==示例== <br />
<!-- Explain what the example is in a single sentance --><br />
此示例显示了删除ACL的命令:<br />
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --><br />
<syntaxhighlight lang="lua"><br />
function deleteSomeACL ( thePlayer, cmdname, theACL )<br />
if aclGet ( theACL ) then --检查指定的ACL是否存在<br />
--If it does<br />
local deleted = aclDestroy ( theACL ) --尝试删除ACL<br />
if deleted then --如果ACL已被删除<br />
--我们会发送给玩家一个成功删除的消息<br />
outputChatBox ( "ACL " ..theACL.. " Succesfully removed!", thePlayer )<br />
else --如果删除时出错<br />
--我们向玩家发送一条错误消息<br />
outputChatBox ( "Error while removing ACL " ..theACL.. "!", thePlayer )<br />
end<br />
else --如果ACL不存在<br />
outputChatBox ( "Error: Invalid ACL Name specified, or the ACL doesn't exist.", thePlayer )<br />
end<br />
end<br />
addCommandHandler ( "deleteACL", deleteSomeACL ) --添加命令处理程序<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:AclDestroy]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/AclDestroy&diff=68792ZH-CN/AclDestroy2021-02-06T01:56:00Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数将销毁传递的ACL.销毁的ACL将不再有效.<br />
<br />
==语法== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool aclDestroy ( acl theACL )<br />
</syntaxhighlight> <br />
{{OOP||[[acl]]:destroy||}}<br />
===必填参数=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''theACL:''' The ACL to destroy<br />
<br />
===返回值===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
Returns ''true'' if successfully destroyed and ''false'' if it could not be deleted (ie. it's not valid).<br />
<br />
==示例== <br />
<!-- Explain what the example is in a single sentance --><br />
This example shows you a command to delete an ACL:<br />
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --><br />
<syntaxhighlight lang="lua"><br />
function deleteSomeACL ( thePlayer, cmdname, theACL )<br />
if aclGet ( theACL ) then --Check if the specified ACL exists<br />
--If it does<br />
local deleted = aclDestroy ( theACL ) --Try to delete the ACL<br />
if deleted then --If the ACL has been deleted<br />
--We will give the player a succes-message<br />
outputChatBox ( "ACL " ..theACL.. " Succesfully removed!", thePlayer )<br />
else --If there was something wrong while deleting<br />
--We send the player an error message<br />
outputChatBox ( "Error while removing ACL " ..theACL.. "!", thePlayer )<br />
end<br />
else --If the ACL doesn't exists<br />
outputChatBox ( "Error: Invalid ACL Name specified, or the ACL doesn't exist.", thePlayer )<br />
end<br />
end<br />
addCommandHandler ( "deleteACL", deleteSomeACL ) --Add the commandhandler<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:AclDestroy]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/AclDestroy&diff=68791ZH-CN/AclDestroy2021-02-06T01:55:48Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
此函数将销毁传递的ACL。销毁的ACL将不再有效.<br />
<br />
==语法== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool aclDestroy ( acl theACL )<br />
</syntaxhighlight> <br />
{{OOP||[[acl]]:destroy||}}<br />
===必填参数=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''theACL:''' The ACL to destroy<br />
<br />
===返回值===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
Returns ''true'' if successfully destroyed and ''false'' if it could not be deleted (ie. it's not valid).<br />
<br />
==示例== <br />
<!-- Explain what the example is in a single sentance --><br />
This example shows you a command to delete an ACL:<br />
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --><br />
<syntaxhighlight lang="lua"><br />
function deleteSomeACL ( thePlayer, cmdname, theACL )<br />
if aclGet ( theACL ) then --Check if the specified ACL exists<br />
--If it does<br />
local deleted = aclDestroy ( theACL ) --Try to delete the ACL<br />
if deleted then --If the ACL has been deleted<br />
--We will give the player a succes-message<br />
outputChatBox ( "ACL " ..theACL.. " Succesfully removed!", thePlayer )<br />
else --If there was something wrong while deleting<br />
--We send the player an error message<br />
outputChatBox ( "Error while removing ACL " ..theACL.. "!", thePlayer )<br />
end<br />
else --If the ACL doesn't exists<br />
outputChatBox ( "Error: Invalid ACL Name specified, or the ACL doesn't exist.", thePlayer )<br />
end<br />
end<br />
addCommandHandler ( "deleteACL", deleteSomeACL ) --Add the commandhandler<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:AclDestroy]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/AclCreateGroup&diff=68789ZH-CN/AclCreateGroup2021-02-05T09:49:30Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
此函数用于在ACL中创建组。ACL组可以包含玩家和资源等对象.它们指定谁有权访问此组中的ACL<br />
<br />
==语法== <br />
<syntaxhighlight lang="lua"><br />
aclgroup aclCreateGroup ( string groupName )<br />
</syntaxhighlight> <br />
{{OOP_ZH-CN||[[aclgroup|ACLGroup]]||}}<br />
===必填参数=== <br />
*'''groupName:''' 要创建的组的名称<br />
<br />
===返回值===<br />
Returns the pointer to the created aclgroup if successful. Returns false if failed.<br />
<br />
==示例== <br />
此示例添加了一个命令''addobjecttogroup'',使用该命令可以轻松地将新对象添加到指定的访问控制列表组中.<br />
<syntaxhighlight lang="lua"><br />
function addACLGroupObject ( thePlayer, commandName, groupName, objectName )<br />
local ourGroup = aclGetGroup ( groupName )<br />
-- 如果以前没有使用此名称的组,则需要创建一个<br />
if not ourGroup then<br />
ourGroup = aclCreateGroup ( groupName )<br />
end<br />
<br />
-- 如果没有给出对象名<br />
if not objectName then<br />
-- 将消息发送到聊天室<br />
return outputChatBox ( "You need to specify the object!", thePlayer )<br />
end<br />
<br />
-- 最后,让我们将对象添加到它的组中<br />
aclGroupAddObject ( ourGroup, objectName )<br />
-- 不要忘记在修改ACL后保存它<br />
aclSave ()<br />
end<br />
addCommandHandler ( "addobjecttogroup", addACLGroupObject )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{ACL_functions}}<br />
[[en:AclCreateGroup]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/AclCreate&diff=68788ZH-CN/AclCreate2021-02-05T09:31:15Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
此函数用于在访问控制列表系统中创建具有指定名称的ACL条目.<br />
<br />
==语法== <br />
<syntaxhighlight lang="lua"><br />
acl aclCreate ( string aclName )<br />
</syntaxhighlight> <br />
{{OOP_ZH-CN||[[ACL]]||}}<br />
===必填函数=== <br />
*'''aclName:''' 要添加的ACL条目的名称.<br />
<br />
===返回值===<br />
如果成功,返回创建的ACL对象.如果无法创建给定名称的ACL,则返回false.<br />
<br />
==示例==<br />
此示例添加了命令 ''setaclright'',使用该命令可以轻松地向指定的访问控制列表添加新权限.<br />
<syntaxhighlight lang="lua"><br />
function setACLRight ( thePlayer, commandName, aclName, rightName, access )<br />
-- 将布尔字符串转换为小写<br />
access = string.lower ( access )<br />
-- 访问必须是true或false(布尔值)<br />
if not (access == "true" or access == "false") then<br />
-- 将错误消息发送到调试窗口<br />
return outputDebugString ( "Invalid access; true and false are only accepted", 1 )<br />
end<br />
<br />
-- 将访问权限更改为布尔值<br />
if access == "true" then<br />
access = true<br />
else <br />
access = false<br />
end<br />
<br />
local ourACL = aclGet ( aclName )<br />
-- 如果以前没有具有此名称的ACL,则需要创建一个<br />
if not ourACL then<br />
ourACL = aclCreate ( aclName )<br />
end<br />
<br />
-- and finally let's set the right<br />
aclSetRight ( ourACL, rightName, access )<br />
-- 不要忘记在修改ACL后保存它<br />
aclSave ()<br />
end<br />
addCommandHandler ( "setaclright", setACLRight )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{ACL_functions}}<br />
[[zh-cn:AclCreate]]<br />
[[en:AclCreate]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/IsObjectInACLGroup&diff=68787ZH-CN/IsObjectInACLGroup2021-02-05T09:11:09Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
{{Important Note|You must '''NOT''' to use this function to limit features to users that belong to specific groups. Instead you '''MUST''' use [[hasObjectPermissionTo]]. Using this function forces the server owner to name their group a certain way, whereas using hasObjectPermissionTo allows the owner to give permission for whatever features you restrict to whatever groups they have set up in their ACL.}}<br />
This function is used to determine if an object is in a group.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool isObjectInACLGroup ( string theObject, aclgroup theGroup )<br />
</syntaxhighlight> <br />
{{New feature/item|3.0141|1.4.0|6994|{{OOP||[[aclgroup]]:doesContainObject||}}}}<br />
===Required Arguments=== <br />
*'''theObject:''' the name of the object to check. Examples: "resource.ctf", "user.Jim".<br />
*'''theGroup:''' the [[ACL group]] pointer of the group from which the object should be found.<br />
<br />
===Returns===<br />
Returns ''true'' if the object is in the specified group, ''false'' otherwise.<br />
<br />
==Example== <br />
''' Example 1:''' This example adds a ''jetpack'' command that is only available to admins. When entering the command, it will toggle the player's jetpack.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "jetpack",<br />
function ( thePlayer )<br />
if doesPedHaveJetPack ( thePlayer ) then -- If the player have a jetpack already, remove it<br />
removePedJetPack ( thePlayer ) -- Remove the jetpack<br />
return -- And stop the function here<br />
end<br />
<br />
-- Otherwise, give him one if he has access<br />
<br />
local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- get his account name<br />
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then -- Does he have access to Admin functions?<br />
if not doesPedHaveJetPack ( thePlayer ) then -- If the player doesn't have a jetpack give it.<br />
givePedJetPack ( thePlayer ) -- Give the jetpack<br />
end<br />
end<br />
end<br />
)<br />
</syntaxhighlight><br />
<br />
'''Example 2:''' This example displays a list of all the online admins in the chat box (assuming your administrator's group in your ACL is called 'admin'):<br />
<syntaxhighlight lang="lua"><br />
players = getElementsByType ( "player" )<br />
admins = ""<br />
for k,v in ipairs(players) do<br />
local accountname = ""<br />
if (isGuestAccount(getPlayerAccount(v)) == false) then<br />
accountname = getAccountName (getPlayerAccount(v))<br />
if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "admin" ) ) then<br />
if (admins == "") then<br />
admins = getPlayerName(v)<br />
else<br />
admins = admins .. ", " .. getPlayerName(v)<br />
end<br />
end<br />
end<br />
end<br />
outputChatBox( "Online Admins:", getRootElement(), 255, 255, 0)<br />
outputChatBox( " " .. tostring ( admins ), getRootElement(), 255, 255, 0)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{ACL_functions}}<br />
[[en:IsObjectInACLGroup]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/hasObjectPermissionTo&diff=68786ZH-CN/hasObjectPermissionTo2021-02-05T09:10:31Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
This function returns whether or not the given object has access to perform the given action. <br />
{{Note|Only certain action names work. This function seems to return ''nil'' and output a bad argument error when checking if an object has rights for an action which doesn't start with ''function.'', ''command.'' or ''resource.'' keywords.}}<br />
<br />
Scripts frequently wish to limit access to features to particular users. The naïve way to do this would be to check if the player who is attempting to perform an action is in a particular group (usually the Admin group). The main issue with doing this is that the Admin group is not guaranteed to exist. It also doesn't give the server admin any flexibility. He might want to allow his 'moderators' access to the function you're limiting access to, or he may want it disabled entirely. <br />
<br />
This is where using the ACL properly comes in, and luckily this is very easy. It all comes down to using this function. This, somewhat confusingly named function lets you check if an ACL object (a player or a resource) has a particular ACL right. In this case, we just care about players.<br />
<br />
So, first of all, think of a name for your 'right'. Let's say we want a private area only certain people can go in, we'll call our right accessPrivateArea. Then, all you need to do is add one 'if' statement to your code:<br />
<syntaxhighlight lang="lua">if hasObjectPermissionTo ( player, "resource.YourResourceName.accessPrivateArea", false ) then<br />
-- Whatever you want to happen if they're allowed in<br />
else<br />
-- Whatever you want to happen if they aren't<br />
end<br />
</syntaxhighlight><br />
<br />
Notice that we've named the ''right'' using ''resource.YourResourceName.accessPrivateArea'' - this is just for neatness, so that the admin knows what resource the right belongs to. It's strongly advised you follow this convention. The ''false'' argument specifies the 'defaultPermission', false indicating that if the user hasn't had the right allowed or dissallowed (i.e. the admin hasn't added it to the config), that it should default to being not allowed.<br />
<br />
The only downside of using this method is that the admin has to modify his config. The upsides are that the admin has much more control and your script will work for any server, however the admin has configured it.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool hasObjectPermissionTo ( string / element theObject, string theAction [, bool defaultPermission = true ] )<br />
</syntaxhighlight> <br />
<!-- Yes! This is actually correct this time ^^ notice theObject can be a string! --><br />
{{OOP|This function is also a static function underneath the ACL class.|[[ACL]].hasObjectPermissionTo||}}<br />
===Required Arguments=== <br />
*'''theObject:''' The object to test if has permission to. This can be a client element (ie. a player), a resource or a string in the form "user.<name>" or "resource.<name>".<br />
*'''theAction:''' The action to test if the given object has access to. Ie. "function.kickPlayer".<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''defaultPermission:''' The default permission if none is specified in either of the groups the given object is a member of. If this is left to true, the given object will have permissions to perform the action unless the opposite is explicitly specified in the [[ACL]]. If false, the action will be denied by default unless explicitly approved by the [[Access Control List]].<br />
<br />
===Returns===<br />
Returns ''true'' if the given object has permission to perform the given action, ''false'' otherwise. Returns ''nil'' if the function failed because of bad arguments.<br />
<br />
==Example== <br />
This example kicks a player if the user using it has access to the kickPlayer function.<br />
<syntaxhighlight lang="lua"><br />
-- Kick command<br />
function onKickCommandHandler ( playerSource, commandName, playerToKick, stringReason )<br />
-- Does the calling user have permission to kick the player? Default<br />
-- to false for safety reasons. We do this so any user can't use us to<br />
-- kick players.<br />
if ( hasObjectPermissionTo ( playerSource, "function.kickPlayer", false ) ) then<br />
<br />
-- Do we have permission to kick the player? We do this so we can fail<br />
-- nicely if this resource doesn't have access to call that function.<br />
if ( hasObjectPermissionTo ( getThisResource (), "function.kickPlayer", true ) ) then<br />
-- Kick him<br />
kickPlayer ( playerToKick, playerSource, stringReason )<br />
else<br />
-- Resource doesn't have any permissions, sorry<br />
outputChatBox ( "kick: The admin resource is not able to kick players. Please give this resource access to 'function.kickPlayer' in the ACL to use this function.", playerSource )<br />
end<br />
else<br />
-- User doesn't have any permissions<br />
outputChatBox ( "kick: You don't have permissions to use this command.", playerSource )<br />
end<br />
end<br />
addCommandHandler ( "kick", onKickCommandHandler )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:hasObjectPermissionTo]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=HasObjectPermissionTo&diff=68785HasObjectPermissionTo2021-02-05T09:10:20Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
This function returns whether or not the given object has access to perform the given action. <br />
{{Note|Only certain action names work. This function seems to return ''nil'' and output a bad argument error when checking if an object has rights for an action which doesn't start with ''function.'', ''command.'' or ''resource.'' keywords.}}<br />
<br />
Scripts frequently wish to limit access to features to particular users. The naïve way to do this would be to check if the player who is attempting to perform an action is in a particular group (usually the Admin group). The main issue with doing this is that the Admin group is not guaranteed to exist. It also doesn't give the server admin any flexibility. He might want to allow his 'moderators' access to the function you're limiting access to, or he may want it disabled entirely. <br />
<br />
This is where using the ACL properly comes in, and luckily this is very easy. It all comes down to using this function. This, somewhat confusingly named function lets you check if an ACL object (a player or a resource) has a particular ACL right. In this case, we just care about players.<br />
<br />
So, first of all, think of a name for your 'right'. Let's say we want a private area only certain people can go in, we'll call our right accessPrivateArea. Then, all you need to do is add one 'if' statement to your code:<br />
<syntaxhighlight lang="lua">if hasObjectPermissionTo ( player, "resource.YourResourceName.accessPrivateArea", false ) then<br />
-- Whatever you want to happen if they're allowed in<br />
else<br />
-- Whatever you want to happen if they aren't<br />
end<br />
</syntaxhighlight><br />
<br />
Notice that we've named the ''right'' using ''resource.YourResourceName.accessPrivateArea'' - this is just for neatness, so that the admin knows what resource the right belongs to. It's strongly advised you follow this convention. The ''false'' argument specifies the 'defaultPermission', false indicating that if the user hasn't had the right allowed or dissallowed (i.e. the admin hasn't added it to the config), that it should default to being not allowed.<br />
<br />
The only downside of using this method is that the admin has to modify his config. The upsides are that the admin has much more control and your script will work for any server, however the admin has configured it.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool hasObjectPermissionTo ( string / element theObject, string theAction [, bool defaultPermission = true ] )<br />
</syntaxhighlight> <br />
<!-- Yes! This is actually correct this time ^^ notice theObject can be a string! --><br />
{{OOP|This function is also a static function underneath the ACL class.|[[ACL]].hasObjectPermissionTo||}}<br />
===Required Arguments=== <br />
*'''theObject:''' The object to test if has permission to. This can be a client element (ie. a player), a resource or a string in the form "user.<name>" or "resource.<name>".<br />
*'''theAction:''' The action to test if the given object has access to. Ie. "function.kickPlayer".<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''defaultPermission:''' The default permission if none is specified in either of the groups the given object is a member of. If this is left to true, the given object will have permissions to perform the action unless the opposite is explicitly specified in the [[ACL]]. If false, the action will be denied by default unless explicitly approved by the [[Access Control List]].<br />
<br />
===Returns===<br />
Returns ''true'' if the given object has permission to perform the given action, ''false'' otherwise. Returns ''nil'' if the function failed because of bad arguments.<br />
<br />
==Example== <br />
This example kicks a player if the user using it has access to the kickPlayer function.<br />
<syntaxhighlight lang="lua"><br />
-- Kick command<br />
function onKickCommandHandler ( playerSource, commandName, playerToKick, stringReason )<br />
-- Does the calling user have permission to kick the player? Default<br />
-- to false for safety reasons. We do this so any user can't use us to<br />
-- kick players.<br />
if ( hasObjectPermissionTo ( playerSource, "function.kickPlayer", false ) ) then<br />
<br />
-- Do we have permission to kick the player? We do this so we can fail<br />
-- nicely if this resource doesn't have access to call that function.<br />
if ( hasObjectPermissionTo ( getThisResource (), "function.kickPlayer", true ) ) then<br />
-- Kick him<br />
kickPlayer ( playerToKick, playerSource, stringReason )<br />
else<br />
-- Resource doesn't have any permissions, sorry<br />
outputChatBox ( "kick: The admin resource is not able to kick players. Please give this resource access to 'function.kickPlayer' in the ACL to use this function.", playerSource )<br />
end<br />
else<br />
-- User doesn't have any permissions<br />
outputChatBox ( "kick: You don't have permissions to use this command.", playerSource )<br />
end<br />
end<br />
addCommandHandler ( "kick", onKickCommandHandler )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[zh-cn:hasObjectPermissionTo]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=HasObjectPermissionTo&diff=68784HasObjectPermissionTo2021-02-05T09:10:01Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
This function returns whether or not the given object has access to perform the given action. <br />
{{Note|Only certain action names work. This function seems to return ''nil'' and output a bad argument error when checking if an object has rights for an action which doesn't start with ''function.'', ''command.'' or ''resource.'' keywords.}}<br />
<br />
Scripts frequently wish to limit access to features to particular users. The naïve way to do this would be to check if the player who is attempting to perform an action is in a particular group (usually the Admin group). The main issue with doing this is that the Admin group is not guaranteed to exist. It also doesn't give the server admin any flexibility. He might want to allow his 'moderators' access to the function you're limiting access to, or he may want it disabled entirely. <br />
<br />
This is where using the ACL properly comes in, and luckily this is very easy. It all comes down to using this function. This, somewhat confusingly named function lets you check if an ACL object (a player or a resource) has a particular ACL right. In this case, we just care about players.<br />
<br />
So, first of all, think of a name for your 'right'. Let's say we want a private area only certain people can go in, we'll call our right accessPrivateArea. Then, all you need to do is add one 'if' statement to your code:<br />
<syntaxhighlight lang="lua">if hasObjectPermissionTo ( player, "resource.YourResourceName.accessPrivateArea", false ) then<br />
-- Whatever you want to happen if they're allowed in<br />
else<br />
-- Whatever you want to happen if they aren't<br />
end<br />
</syntaxhighlight><br />
<br />
Notice that we've named the ''right'' using ''resource.YourResourceName.accessPrivateArea'' - this is just for neatness, so that the admin knows what resource the right belongs to. It's strongly advised you follow this convention. The ''false'' argument specifies the 'defaultPermission', false indicating that if the user hasn't had the right allowed or dissallowed (i.e. the admin hasn't added it to the config), that it should default to being not allowed.<br />
<br />
The only downside of using this method is that the admin has to modify his config. The upsides are that the admin has much more control and your script will work for any server, however the admin has configured it.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool hasObjectPermissionTo ( string / element theObject, string theAction [, bool defaultPermission = true ] )<br />
</syntaxhighlight> <br />
<!-- Yes! This is actually correct this time ^^ notice theObject can be a string! --><br />
{{OOP|This function is also a static function underneath the ACL class.|[[ACL]].hasObjectPermissionTo||}}<br />
===Required Arguments=== <br />
*'''theObject:''' The object to test if has permission to. This can be a client element (ie. a player), a resource or a string in the form "user.<name>" or "resource.<name>".<br />
*'''theAction:''' The action to test if the given object has access to. Ie. "function.kickPlayer".<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''defaultPermission:''' The default permission if none is specified in either of the groups the given object is a member of. If this is left to true, the given object will have permissions to perform the action unless the opposite is explicitly specified in the [[ACL]]. If false, the action will be denied by default unless explicitly approved by the [[Access Control List]].<br />
<br />
===Returns===<br />
Returns ''true'' if the given object has permission to perform the given action, ''false'' otherwise. Returns ''nil'' if the function failed because of bad arguments.<br />
<br />
==Example== <br />
This example kicks a player if the user using it has access to the kickPlayer function.<br />
<syntaxhighlight lang="lua"><br />
-- Kick command<br />
function onKickCommandHandler ( playerSource, commandName, playerToKick, stringReason )<br />
-- Does the calling user have permission to kick the player? Default<br />
-- to false for safety reasons. We do this so any user can't use us to<br />
-- kick players.<br />
if ( hasObjectPermissionTo ( playerSource, "function.kickPlayer", false ) ) then<br />
<br />
-- Do we have permission to kick the player? We do this so we can fail<br />
-- nicely if this resource doesn't have access to call that function.<br />
if ( hasObjectPermissionTo ( getThisResource (), "function.kickPlayer", true ) ) then<br />
-- Kick him<br />
kickPlayer ( playerToKick, playerSource, stringReason )<br />
else<br />
-- Resource doesn't have any permissions, sorry<br />
outputChatBox ( "kick: The admin resource is not able to kick players. Please give this resource access to 'function.kickPlayer' in the ACL to use this function.", playerSource )<br />
end<br />
else<br />
-- User doesn't have any permissions<br />
outputChatBox ( "kick: You don't have permissions to use this command.", playerSource )<br />
end<br />
end<br />
addCommandHandler ( "kick", onKickCommandHandler )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:hasObjectPermissionTo]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclSetRight&diff=68783ZH-CN/aclSetRight2021-02-05T09:09:38Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
This functions changes or adds the given right in the given ACL. The access can be ''true'' or ''false'' and specifies whether the ACL gives access to the right or not.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool aclSetRight ( acl theAcl, string rightName, bool hasAccess )<br />
</syntaxhighlight> <br />
{{OOP||[[acl]]:setRight||aclGetRight}}<br />
===Required Arguments=== <br />
*'''theAcl:''' The ACL to change the right of<br />
*'''rightName:''' The right to add/change the access property of<br />
*'''hasAccess:''' Whether the access should be set to true or false<br />
<br />
===Returns===<br />
Returns ''true'' if the access was successfully changed, ''false'' or ''nil'' if it failed for some reason, ie. invalid ACL or the rightname is invalid.<br />
<br />
==Example== <br />
This example adds a command ''setaclright'' with which you can easily add new rights to specified access control lists.<br />
<syntaxhighlight lang="lua"><br />
function setACLRight ( thePlayer, commandName, aclName, rightName, access )<br />
local ourACL = aclGet ( aclName )<br />
-- if there is no previous ACL with this name, we need to create one<br />
if not ourACL then<br />
ourACL = aclCreate ( aclName )<br />
end<br />
<br />
-- turn the boolean string to lower case<br />
access = string.lower ( access )<br />
-- access has to be either true or false (booleans)<br />
if not (access == "true" or access == "false") then<br />
-- print out error message to debug window<br />
return outputDebugString ( "Invalid access; true and false are only accepted", 1 )<br />
end<br />
<br />
-- change the access to boolean<br />
if access == "true" then<br />
access = true<br />
else <br />
access = false<br />
end<br />
<br />
-- and finally let's set the right<br />
aclSetRight ( ourACL, rightName, access )<br />
-- don't forget to save the ACL after it has been modified<br />
aclSave ()<br />
end<br />
addCommandHandler ( "setaclright", setACLRight )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{ACL_functions}}<br />
[[en:aclSetRight]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclSave&diff=68782ZH-CN/aclSave2021-02-05T09:09:24Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
The ACL XML file is automatically saved whenever the ACL is modified, but the automatic save can be delayed by up to 10 seconds for performance reasons. Calling this function will force an immediate save. <br />
<br />
==Syntax== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool aclSave ()<br />
</syntaxhighlight> <br />
{{OOP|This function is a static function underneath the ACL class.|[[ACL]].save||}}<br />
===Returns===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
Returns ''true'' if the ACL was successfully changed, ''false'' or ''nil'' if it could not be saved for some reason, ie. file in use.<br />
<br />
==Example== <br />
<!-- Explain what the example is in a single sentance --><br />
This example saves the ACL when somebody types "/save-acl".<br />
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --><br />
<syntaxhighlight lang="lua"><br />
function saveACL ( thePlayer, command ) -- Function header. Also where thePlayer is defined.<br />
local saved = aclSave() -- Save the ACL<br />
if ( saved ) then -- If it was successfully saved then...<br />
outputChatBox ( "ACL was successfully saved.", thePlayer, 255, 0, 0 ) -- Output it saved<br />
else -- If it wasn't saved for whatever reason then...<br />
outputChatBox ( "An unexpected error occured.", thePlayer, 255, 0, 0 ) -- Output it didn't save<br />
end<br />
end<br />
addCommandHandler ( "save-acl", saveACL ) -- Make it trigger for "/save-acl".<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:aclSave]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclRemoveRight&diff=68781ZH-CN/aclRemoveRight2021-02-05T09:09:08Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
This function removes the given right (string) from the given ACL.<br />
<br />
==Syntax== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool aclRemoveRight ( acl theAcl, string rightName ) <br />
</syntaxhighlight> <br />
{{OOP||[[acl]]:removeRight||}}<br />
===Required Arguments=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''theAcl:''' The ACL to remove the right from<br />
*'''rightName:''' The ACL name to remove from the right from<br />
<br />
===Returns===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
Returns ''true'' if the given right was successfully removed from the given ACL, ''false'' or ''nil'' if it could not be removed for some reason, ie. it didn't exist in the ACL.<br />
<br />
==Example== <br />
This example removes an acl right on resource start.<br />
<syntaxhighlight lang="lua"><br />
addEventHandler("onResourceStart",resourceRoot,function()<br />
aclRemoveRight(aclGet("Admin"),"function.setServerPassword")<br />
end)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:aclRemoveRight]]</div>Qwe7769611https://wiki.multitheftauto.com/index.php?title=ZH-CN/aclReload&diff=68780ZH-CN/aclReload2021-02-05T09:08:39Z<p>Qwe7769611: </p>
<hr />
<div>__NOTOC__ <br />
{{Server function}} <br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
This function reloads the ACL's and the ACL groups from the ACL XML file. All ACL and ACL group elements are invalid after a call to this and should not be used anymore.<br />
<br />
==Syntax== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool aclReload ()<br />
</syntaxhighlight> <br />
{{OOP|This function is a static function underneath the ACL class.|[[ACL]].reload||}}<br />
===Returns===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
Returns ''true'' if the XML was successfully reloaded from the file, ''false'' or ''nil'' if the XML was invalid, didn't exist or could not be loaded for some other reason.<br />
<br />
==Example== <br />
<!-- Explain what the example is in a single sentance --><br />
This example allows an admin to reload the ACL by typing "/reloadACL".<br />
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --><br />
<syntaxhighlight lang="lua"><br />
function reloadACL ( source, command )<br />
-- Check if they're an admin...<br />
if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( source )), aclGetGroup ( "Admin" ) ) ) then<br />
local reload = aclReload() -- Reload the ACL<br />
if ( reload ) then -- Check it was reloaded successfully<br />
outputChatBox ( "ACL was successfully reloaded.", source, 255, 0, 0 ) -- If so, output it<br />
else -- If not, output it (line below)<br />
outputChatBox ( "An unknown error occured. Please check the ACL file exists.", source, 255, 0, 0 )<br />
end<br />
else -- If they're not an admin, output it (below)<br />
outputChatBox ( "You must be an admin to use this command!", source, 255, 0, 0 )<br />
end<br />
end<br />
addCommandHandler ( "reloadACL", reloadACL )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{ACL_functions}}<br />
[[en:aclReload]]</div>Qwe7769611