关于 Advanced Status
一个有用的 API 插件,可模拟游戏中的状态栏并允许添加自定义状态栏。
注: AdvancedStatus 本身不显示任何条形。这是由使用它的其他插件完成的。
一个示例插件,演示了与 AdvancedStatus 的交互。
- 能够指定计算柱数的频率;
- 指定柱线顺序的能力;
- 更改条形高度的能力;
- 自定义 background 的颜色和透明度的能力;
- 为背景设置材质的能力;
- 在图像的 CuiRawImageComponent 和 CuiImageComponent 之间切换的能力;
- 从本地文件夹获取图像的能力 (*SERVER*\oxide\data\AdvancedStatus\Images);
- 设置自己的图像并自定义图像的颜色和透明度的能力;
- 设置 sprite 而不是图像的能力;
- 指定自定义文本的能力;
- 自定义文本颜色、大小和字体的能力;
- 无需传递所有参数;
- 卸载插件时无需手动删除您的酒吧。
- advancedstatus.admin – 授予对聊天命令的访问权限(默认为 /bar)。
{
"Chat command": "bar",
"Is it worth enabling console notifications for the successful loading of local images?": false,
"Interval(in seconds) for counting in-game status bars": 0.5,
"Interval(in seconds) for counting Building Privilege status bars. Note: Calculating Building Privilege is significantly more resource-intensive than other counts": 1.0,
"Bar - Display Layer. If you have button bars, it's advisable to use Hud(https://umod.org/guides/rust/basic-concepts-of-gui#layers)": "Under",
"Bar - Left to Right": true,
"Bar - Offset between status bars": 2,
"Bar - Default Height": 26,
"Main - Default Color": "#505F75",
"Main - Default Transparency": 0.7,
"Main - Default Material(empty to disable)": "",
"Image - Default Image": "AdvancedStatus_Default",
"Image - Default Color": "#6B7E95",
"Image - Default Transparency": 1.0,
"Image - Outline Default Color": "#000000",
"Image - Outline Default Transparency": 1.0,
"Image - Outline Default Distance": "0.75 0.75",
"Text - Default Size": 12,
"Text - Default Color": "#FFFFFF",
"Text - Default Transparency": 1.0,
"Text - Default Font(https://umod.org/guides/rust/basic-concepts-of-gui#fonts)": "RobotoCondensed-Bold.ttf",
"Text - Default Offset Horizontal": 0,
"Text - Outline Default Color": "#000000",
"Text - Outline Default Transparency": 1.0,
"Text - Outline Default Distance": "0.75 0.75",
"SubText - Default Size": 12,
"SubText - Default Color": "#FFFFFF",
"SubText - Default Transparency": 1.0,
"SubText - Default Font": "RobotoCondensed-Bold.ttf",
"SubText - Outline Default Color": "#000000",
"SubText - Outline Default Transparency": 1.0,
"SubText - Outline Default Distance": "0.75 0.75",
"Progress - Default Color": "#89B840",
"Progress - Default Transparency": 0.7,
"Progress - Default OffsetMin": "25 2.5",
"Progress - Default OffsetMax": "-3.5 -3.5",
"Version": {
"Major": 0,
"Minor": 1,
"Patch": 21
}
}
EN:
{
"MsgDays": "d",
"MsgHours": "h",
"MsgMinutes": "m",
"MsgSeconds": "s"
}
RU:
{
"MsgDays": "д",
"MsgHours": "ч",
"MsgMinutes": "м",
"MsgSeconds": "я"
}
- 图片重新加载
- ImageName – 从图像文件夹中重新加载指定的图像;
- all – 重新加载 image 文件夹中的所有本地图像。
示例:/bar images reload all
注意:要访问这些命令,玩家必须是管理员(控制台或所有者)或具有 advancedstatus.admin 权限。
- OnAdvancedStatusLoaded 上:
- 在 AdvancedStatus 插件完全加载并准备就绪后调用。
- OnPlayerGainedBuildingPrivilege 的
- 在玩家进入其建筑权限后调用。
- OnPlayerLostBuildingPrivilege 的
- 在玩家退出其构建权限后调用。
void OnAdvancedStatusLoaded() { Puts("The AdvancedStatus plugin is loaded and ready to go!"); } void OnPlayerGainedBuildingPrivilege(BasePlayer player) { Puts($"{player.displayName} entered the authorized building privilege zone."); } void OnPlayerLostBuildingPrivilege(BasePlayer player) { Puts($"{player.displayName} exited the authorized building privilege zone."); }
[PluginReference] private Plugin AdvancedStatus;
共有 15 种方法:
- 已准备就绪
- 创建栏
- 更新内容
- 删除栏
- 删除类别
- 删除所有栏
- GetTotalClientBars
- GetTotalPlayerBars
- 加载图像
- 加载图像
- 复制图像
- 删除图像
- 删除图像
- BarExists
- InBuildingPrivilege
有 5 种类型的酒吧:
- Default (默认) – 显示所提供信息的简单栏。本身不更新 SubText 的值;
- 定时 – 与默认条类似,但它会在 TimeStamp 参数中的指定时间后自动消失;
- TimeCounter – SubText 显示 TimeStamp 之前的剩余时间。TimeStamp 到期时也会自动删除;
- TimeProgress – 类似于 Timed 进度条,但还具有自动填充进度条;
- TimeProgressCounter – 类似于 TimeCounter 栏,但还具有自动填充进度条。
IsReady:
用于检查 AdvancedStatus 插件是否已加载并准备好工作。
IsReady 方法如果准备就绪,则返回 true,如果尚未准备就绪,则返回 null。
(bool)AdvancedStatus?.Call("IsReady");//Calling the IsReady method. If the result is not null(bool true), the plugin is ready.
CreateBar:
用于创建条形或更新玩家的条形值。
调用 CreateBar 方法需要传入 2 个参数。第一个是 BasePlayer 或 <ulong>playerID。第二个是包含所需参数的字典。
在 CreateBar 方法中,除两个参数外,所有参数都是可选的:
- ID;
- 插件。
创建新柱线时未指定的参数将使用 AdvancedStatus 插件配置文件中设置的值。
在柱线更新期间未指定的参数将保留它们在更新之前的值。
注意:该插件不会自动更新值,您需要手动发送新值。
Dictionary<string, object> parameters = new Dictionary<string, object> { { "Id", "AdvancedStatusDemo_1" }, //<string>Unique identifier for the bar in your plugin. ***This is a required field. { "BarType", "Default" }, //<string>Type of the bar. There are 4 types: Default, Timed, TimeCounter and TimeProgress. { "Plugin", "AdvancedStatusDemo" }, //<string>Name of your plugin. ***This is a required field. { "Category", "Default" }, //<string>Internal plugin category of the bar. { "Order", 10 }, //<int>The position of your bar relative to others. Order is determined by increasing values(ASC). { "Height", 26 }, //<int>The height of your bar. A standard bar is 26 pixels. { "Main_Color", "#505F75" }, //<string>HTML Hex color of the bar background. { "Main_Transparency", 0.7f }, //<float>Transparency of the bar background. { "Main_Material", "assets/content/ui/uibackgroundblur.mat" }, //<string>Material of the bar background(empty to disable). { "Image", "scrap" }, //<string>Name of the image saved in the ImageLibrary or a direct link to the image if ImageLibrary is not used. { "Image_Local", "AdvancedStatusDemo_Scrap" }, //<string>The name of the image file(without its extension) located in *SERVER*\data\AdvancedStatus\Images. Leave empty to use Image. { "Image_Sprite", "" }, //<string>Sprite image of the bar. Leave empty to use Image_Local or Image. { "Is_RawImage", true }, //<bool>Which type of image will be used? True - CuiRawImageComponent. False - CuiImageComponent. { "Image_Color", "#6B7E95" }, //<string>HTML Hex color of the bar image. { "Image_Transparency", 1.0f }, //<float>Transparency of the image. { "Text", "Scrap" }, //<string>Main text. { "Text_Size", 12 }, //<int>Size of the main text. { "Text_Color", "#FFFFFF" }, //<string>HTML Hex color of the main text. { "Text_Font", "RobotoCondensed-Bold.ttf" }, //<string>Font of the main text. { "Text_Offset_Horizontal", 0 }, //<int>Horizontal offset for the main text. { "SubText", "35" }, //<string>Sub text. { "SubText_Size", 12 }, //<int>Size of the sub text. { "SubText_Color", "#FFFFFF" }, //<string>HTML Hex color of the sub text. { "SubText_Font", "RobotoCondensed-Bold.ttf" }, //<string>Font of the sub text. { "TimeStampStart", Network.TimeEx.currentTimestamp }, //<double>Responsible for specifying the start point of the time reference and 0% for TimeProgress and TimeProgressCounter bars. Used if the bar type is Timed, TimeCounter, TimeProgress or TimeProgressCounter. { "TimeStamp", Network.TimeEx.currentTimestamp + 6 }, //<double>Specifies the end time point after which the bar will be destroyed and 100% for TimeProgress and TimeProgressCounter bars. Used if the bar type is Timed, TimeCounter, TimeProgress or TimeProgressCounter. { "TimeStampDestroy", Network.TimeEx.currentTimestamp + 3 }, //<double>If TimeStampDestroy is specified and it is less than TimeStamp, the bar will be destroyed by TimeStampDestroy. Used if the bar type is Timed, TimeCounter, TimeProgress or TimeProgressCounter. { "Progress", (float)35 / 100f }, //<float>Progress. From 0.0 to 1.0. { "Progress_Reverse", false }, //<bool>Progress reverse. A value of false means that the progress will increase. Used if the bar type is TimeProgress or TimeProgressCounter. { "Progress_Color", "#89B840" }, //<string>Progress color. { "Progress_Transparency", 1f }, //<float>Progress transparency. { "Progress_OffsetMin", "25 2.5" }, //<string>Progress OffsetMin: "*left* *bottom*". { "Progress_OffsetMax", "-3.5 -3.5" }, //<string>Progress OffsetMax: "*right* *top*". { "Command", "kit" } //<string>If the field is not empty, the bar becomes clickable, and the specified command is executed upon clicking. Note: the command must be covalence. }; AdvancedStatus?.Call("CreateBar", player.userID.Get(), parameters); //Calling the CreateBar method with the passing of BasePlayer/playerID and a dictionary containing the required parameters.
UpdateContent:
用于仅更新现有状态栏的内容。
若要调用 UpdateContent 方法,需要传递 2 个参数。第一个是 BasePlayer 或 <ulong>playerID。第二个是包含所需参数的字典。
在 UpdateBar 方法中,除两个参数外,所有参数都是可选的:
- ID;
- 插件。
var parameters = new Dictionary<string, object> { { "Id", "MyID" }, //<string>Unique identifier for the bar in your plugin. ***This is a required field. { "Plugin", Name }, //<string>Name of your plugin. ***This is a required field. { "Text", "MyText" }, //<string>Main text. { "SubText", "MyText" }, //<string>Sub text. { "Progress", (float)amount / 100f }, //<float>Progress. From 0.0 to 1.0. }; AdvancedStatus?.Call("UpdateContent", player.userID.Get(), parameters); //Calling the UpdateContent method with the passing of BasePlayer/playerID and a dictionary containing the required parameters.
DeleteBar:
用于删除玩家的栏。
有两种方法可以按 ID 删除条形图:
- 指定特定玩家;
- 调用该方法需要传入 3 个参数。第一个是 BasePlayer 或 <ulong>playerID。第二个是你的栏的 ID,第三个是你的插件的名称。
- 而不指定特定播放器(这将为所有播放器删除它)
- 调用该方法需要传入 2 个参数。第一个是你的栏的 ID,第二个是你的插件的名称。
AdvancedStatus?.Call("DeleteBar", player.userID.Get(), barID, Name); //Calling the DeleteBar method with the passing of BasePlayer/playerID, ID of the bar and the name of your plugin. AdvancedStatus?.Call("DeleteBar", barID, Name); //Calling the DeleteBar method with the passing of ID of the bar and the name of your plugin.
如果您尝试删除不存在的条形图,则不会发生任何不良情况。因此,请随意删除该栏,而无需检查其存在。
附言卸载插件时,无需手动删除玩家的进度条,AdvancedStatus 会自动处理。
DeleteCategory:
用于删除与插件类别关联的所有条形。
若要调用 DeleteCategory 方法,需要传递 2 个参数。第一个是类别,第二个是插件的名称。
AdvancedStatus?.Call("DeleteCategory", "Default", Name);//Calling the DeleteCategory method by passing the category and name of your plugin
DeleteAllBars:
Used to remove all bars associated with the plugin.
To call the DeleteAllBars method, you need to pass only 1 parameter. It is name of your plugin.
AdvancedStatus?.Call("DeleteAllBars", Name);//Calling the DeleteAllBars method, passing the name of your plugin
GetTotalClientBars:
Used to get the number of client bars for the player.
To call the GetTotalClientBars method, you need to pass only 1 parameter. It is BasePlayer or <ulong>playerID.
(int)AdvancedStatus?.Call("GetTotalClientBars", player.userID.Get());//Calling the GetTotalClientBars method, passing the name of BasePlayer/playerID
GetTotalPlayerBars:
Used to get the number of active custom bars for the player.
To call the GetTotalPlayerBars method, you need to pass only 1 parameter. It is BasePlayer or <ulong>playerID.
(int)AdvancedStatus?.Call("GetTotalPlayerBars", player.userID.Get());//Calling the GetTotalPlayerBars method, passing the name of BasePlayer/playerID
LoadImages:
Used to check if the local images specified in the list are loaded.
If any of the images are not loaded but their files exist in the images folder, the plugin will load them.
To call the LoadImages method, you need to pass only 2 parameters. The first one is the <List<string>>list of image’s name and the second one(optional) is <bool>force, which, if set to true, will force reload the image even if it already exists.
AdvancedStatus?.Call("LoadImages", list, false);//Calling the LoadImages method, passing a list of image names
LoadImage:
Used to check if the local image is loaded.
If the file is not loaded and exists in the images folder, the plugin will load it.
To call the LoadImage method, you need to pass 2 parameters. The first one is the <string>image’s name and the second one(optional) is <bool>force, which, if set to true, will force reload the image even if it already exists.
AdvancedStatus?.Call("LoadImage", imgName, false);//Calling the LoadImage method, passing an image's name
CopyImage:
Used to create and load a copy of an existing image.
To call the CopyImage method, you need to pass 3 parameters. The first parameter is the <string>source image’s name, the second parameter is the <string>new image’s name and the third one(optional) is <bool>force, which, if set to true, will force copy and reload the image even if it already exists.
AdvancedStatus?.Call("CopyImage", "ZoneStatus_Default", "ZoneStatus_NewZone", false);//Calling CopyImage, passing the source image name and the new image name.
DeleteImages:
用于删除图像及其文件的列表。
若要调用 DeleteImages 方法,需要传递 2 个参数。第一个是图像名称的 <List<string>>list,第二个(可选)参数是 <bool>deleteFile,如果设置为 true,也会删除图像的文件。
AdvancedStatus?.Call("DeleteImages", list, true);//Calling DeleteImages, passing a list of image names.
DeleteImage:
用于删除图片和图片文件。
要调用 DeleteImage 方法,您需要传递 2 个参数。第一个参数是 <string>image 的名称,第二个(可选)参数是 <bool>deleteFile,如果设置为 true,也会删除图像的文件。
AdvancedStatus?.Call("DeleteImage", "ZoneStatus_NewZone", true);//Calling DeleteImage, passing the image name.
BarExists:
用于检查指定的 bar 是否存在。
要调用 BarExists 方法,您需要传递 3 个参数。第一个是 BasePlayer 或 <ulong>playerID。第二个是 Id 的 Bar。第三个是你的插件名称。
(bool)AdvancedStatus?.Call("BarExists", player.userID.Get(), barID, Name);//Calling the BarExists method with the passing of BasePlayer/playerID, ID of the bar and name of your plugin.
InBuildingPrivilege:
用于检查玩家是否具有授权的构建权限。
调用 InBuildingPrivilege 方法需要传入 BasePlayer 或 <ulong>playerID。
(bool)AdvancedStatus?.Call("InBuildingPrivilege", player.userID.Get());//Checking if the player has Building Privilege.
暂无评论内容