如何解决用与打开它的键相同的方式关闭GUI的最佳选择是什么jQuery
因此,我正在尝试对现有的FiveM库存脚本进行一些编辑,以打开GUI并使用Javascript将其关闭
打开库存时部分lua代码:
if not IsPlayerDead(PlayerId()) then
disableControlAction(0,37,true)
if IsdisabledControlJustpressed(1,Config.OpenControl) and GetLastInputMethod(0) then
-- Config.OpenControl here is the same as the closing key which is ( TAB ↹ )
openInventory()
JavaScript代码段:
// var inventoryOpen = true;
window.addEventListener("message",function (event) {
if (event.data.action == "display") {
// inventoryOpen = true;
type = event.data.type
disabled = false;
(尝试在调用closeinventory()函数时将变量设置为false
function closeInventory() {
$(".ui").fadeOut();
$.post("http://pb-inventory/NUIFocusOff",JSON.stringify({}));
// inventoryOpen = false;
}
(这是按下“关闭”键的时间)
$("body").on("keyup",function (key) {
if (Config.closeKeys.includes(key.which)) { // Config.closeKeys here is 9 which is the TAB key ↹
// if (inventoryOpen == true) {
closeInventory();
// }
}
});
因此,当我尝试上面的注释代码时,Gui开始出现毛刺,并在打开后保持关闭状态。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。