Some fixes
This commit is contained in:
parent
87dcfaf91b
commit
a8537ed67b
@ -303,18 +303,25 @@ namespace command
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string arg = params.get(1);
|
||||||
|
const std::string arg2 = params.get(2);
|
||||||
|
const auto count = params.size();
|
||||||
|
|
||||||
|
scheduler::once([=]()
|
||||||
|
{
|
||||||
|
printf("%i\n", game::Sys_IsMainThread());
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto arg = params.get(1);
|
|
||||||
const scripting::entity player = scripting::call("getentbynum", {0}).as<scripting::entity>();
|
const scripting::entity player = scripting::call("getentbynum", {0}).as<scripting::entity>();
|
||||||
auto ps = game::g_entities[0].client;
|
auto ps = game::g_entities[0].client;
|
||||||
|
|
||||||
if (arg == "ammo"s)
|
if (arg == "ammo")
|
||||||
{
|
{
|
||||||
const auto weapon = player.call("getcurrentweapon").as<std::string>();
|
const auto weapon = player.call("getcurrentweapon").as<std::string>();
|
||||||
player.call("givemaxammo", {weapon});
|
player.call("givemaxammo", {weapon});
|
||||||
}
|
}
|
||||||
else if (arg == "allammo"s)
|
else if (arg == "allammo")
|
||||||
{
|
{
|
||||||
const auto weapons = player.call("getweaponslist").as<scripting::array>();
|
const auto weapons = player.call("getweaponslist").as<scripting::array>();
|
||||||
for (auto i = 0; i < weapons.size(); i++)
|
for (auto i = 0; i < weapons.size(); i++)
|
||||||
@ -322,11 +329,11 @@ namespace command
|
|||||||
player.call("givemaxammo", {weapons[i]});
|
player.call("givemaxammo", {weapons[i]});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (arg == "health"s)
|
else if (arg == "health")
|
||||||
{
|
{
|
||||||
if (params.size() > 2)
|
if (count > 2)
|
||||||
{
|
{
|
||||||
const auto amount = atoi(params.get(2));
|
const auto amount = atoi(arg2.data());
|
||||||
const auto health = player.get("health").as<int>();
|
const auto health = player.get("health").as<int>();
|
||||||
player.set("health", {health + amount});
|
player.set("health", {health + amount});
|
||||||
}
|
}
|
||||||
@ -336,20 +343,19 @@ namespace command
|
|||||||
player.set("health", {amount});
|
player.set("health", {amount});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (arg == "all"s)
|
else if (arg == "all")
|
||||||
{
|
{
|
||||||
const auto type = game::XAssetType::ASSET_TYPE_WEAPON;
|
const auto type = game::XAssetType::ASSET_TYPE_WEAPON;
|
||||||
fastfiles::enum_assets(type, [&player, type](const game::XAssetHeader header)
|
fastfiles::enum_assets(type, [&player, type](const game::XAssetHeader header)
|
||||||
{
|
{
|
||||||
const auto asset = game::XAsset{type, header};
|
const auto asset = game::XAsset{type, header};
|
||||||
const auto* const asset_name = game::DB_GetXAssetName(&asset);
|
const auto* const asset_name = game::DB_GetXAssetName(&asset);
|
||||||
|
|
||||||
player.call("giveweapon", {asset_name});
|
player.call("giveweapon", {asset_name});
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto wp = game::G_GetWeaponForName(arg);
|
const auto wp = game::G_GetWeaponForName(arg.data());
|
||||||
if (wp)
|
if (wp)
|
||||||
{
|
{
|
||||||
if (game::G_GivePlayerWeapon(ps, wp, 0, 0, 0, 0))
|
if (game::G_GivePlayerWeapon(ps, wp, 0, 0, 0, 0))
|
||||||
@ -367,6 +373,7 @@ namespace command
|
|||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
}, scheduler::pipeline::server);
|
||||||
});
|
});
|
||||||
|
|
||||||
add("dropweapon", [](const params& params)
|
add("dropweapon", [](const params& params)
|
||||||
@ -376,6 +383,8 @@ namespace command
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scheduler::once([]()
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const scripting::entity player = scripting::call("getentbynum", {0}).as<scripting::entity>();
|
const scripting::entity player = scripting::call("getentbynum", {0}).as<scripting::entity>();
|
||||||
@ -385,6 +394,7 @@ namespace command
|
|||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
}, scheduler::pipeline::server);
|
||||||
});
|
});
|
||||||
|
|
||||||
add("take", [](const params& params)
|
add("take", [](const params& params)
|
||||||
@ -400,8 +410,10 @@ namespace command
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto weapon = params.get(1);
|
const std::string weapon = params.get(1);
|
||||||
|
|
||||||
|
scheduler::once([=]()
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto player = scripting::call("getentbynum", {0}).as<scripting::entity>();
|
const auto player = scripting::call("getentbynum", {0}).as<scripting::entity>();
|
||||||
@ -417,6 +429,7 @@ namespace command
|
|||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
}, scheduler::pipeline::server);
|
||||||
});
|
});
|
||||||
|
|
||||||
add("kill", [](const params& params)
|
add("kill", [](const params& params)
|
||||||
|
@ -68,8 +68,15 @@ namespace gui
|
|||||||
|
|
||||||
void new_gui_frame()
|
void new_gui_frame()
|
||||||
{
|
{
|
||||||
ImGui::GetIO().MouseDrawCursor = toggled || *game::keyCatchers & 0x1;
|
ImGui::GetIO().MouseDrawCursor = toggled;
|
||||||
*game::keyCatchers |= 0x10 * toggled;
|
if (toggled)
|
||||||
|
{
|
||||||
|
*game::keyCatchers |= 0x10;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*game::keyCatchers &= ~0x10;
|
||||||
|
}
|
||||||
|
|
||||||
ImGui_ImplDX11_NewFrame();
|
ImGui_ImplDX11_NewFrame();
|
||||||
ImGui_ImplWin32_NewFrame();
|
ImGui_ImplWin32_NewFrame();
|
||||||
|
@ -26,41 +26,44 @@ namespace input
|
|||||||
|
|
||||||
void cl_char_event_stub(const int local_client_num, const int key)
|
void cl_char_event_stub(const int local_client_num, const int key)
|
||||||
{
|
{
|
||||||
ui_scripting::notify("keypress",
|
if (!gui::gui_char_event(local_client_num, key))
|
||||||
{
|
{
|
||||||
{"keynum", key},
|
return;
|
||||||
{"key", game::Key_KeynumToString(key, 0, 1)},
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if (!game_console::console_char_event(local_client_num, key))
|
if (!game_console::console_char_event(local_client_num, key))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gui::gui_char_event(local_client_num, key))
|
ui_scripting::notify("keypress",
|
||||||
{
|
{
|
||||||
return;
|
{"keynum", key},
|
||||||
}
|
{"key", game::Key_KeynumToString(key, 0, 1)},
|
||||||
|
});
|
||||||
|
|
||||||
cl_char_event_hook.invoke<void>(local_client_num, key);
|
cl_char_event_hook.invoke<void>(local_client_num, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cl_key_event_stub(const int local_client_num, const int key, const int down)
|
void cl_key_event_stub(const int local_client_num, const int key, const int down)
|
||||||
{
|
{
|
||||||
ui_scripting::notify(down ? "keydown" : "keyup",
|
if (!gui::gui_key_event(local_client_num, key, down))
|
||||||
{
|
{
|
||||||
{"keynum", key},
|
return;
|
||||||
{"key", game::Key_KeynumToString(key, 0, 1)},
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if (!game_console::console_key_event(local_client_num, key, down))
|
if (!game_console::console_key_event(local_client_num, key, down))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gui::gui_key_event(local_client_num, key, down))
|
if (!(*game::keyCatchers & 1) && !(*game::keyCatchers & 0x10))
|
||||||
{
|
{
|
||||||
return;
|
ui_scripting::notify(down ? "keydown" : "keyup",
|
||||||
|
{
|
||||||
|
{"keynum", key},
|
||||||
|
{"key", game::Key_KeynumToString(key, 0, 1)},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_key_event_hook.invoke<void>(local_client_num, key, down);
|
cl_key_event_hook.invoke<void>(local_client_num, key, down);
|
||||||
|
@ -57,6 +57,7 @@ namespace ui_scripting
|
|||||||
|
|
||||||
table event{};
|
table event{};
|
||||||
event.set("name", name);
|
event.set("name", name);
|
||||||
|
event.set("dispatchChildren", true);
|
||||||
|
|
||||||
for (const auto& arg : arguments)
|
for (const auto& arg : arguments)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user