mirror of
https://github.com/fedddddd/iw5-gsc-utils.git
synced 2025-04-22 05:35:43 +00:00
Add tell, say functions
This commit is contained in:
parent
ee109d622a
commit
d0d31e5d06
@ -330,6 +330,29 @@ namespace gsc
|
||||
return {};
|
||||
});
|
||||
|
||||
function::add("say", [](function_args args) -> scripting::script_value
|
||||
{
|
||||
const auto message = args[0].as<std::string>();
|
||||
game::SV_GameSendServerCommand(-1, 0, utils::string::va("%c \"%s\"", 84, message.data()));
|
||||
|
||||
return {};
|
||||
});
|
||||
|
||||
method::add("tell", [](game::scr_entref_t ent, function_args args) -> scripting::script_value
|
||||
{
|
||||
if (ent.classnum != 0)
|
||||
{
|
||||
throw std::runtime_error("Invalid type");
|
||||
}
|
||||
|
||||
const auto client = ent.entnum;
|
||||
const auto message = args[0].as<std::string>();
|
||||
|
||||
game::SV_GameSendServerCommand(client, 0, utils::string::va("%c \"%s\"", 84, message.data()));
|
||||
|
||||
return {};
|
||||
});
|
||||
|
||||
utils::hook::jump(0x56C8EB, call_builtin_stub);
|
||||
utils::hook::jump(0x56CBDC, call_builtin_method_stub);
|
||||
utils::hook::jump(0x56B726, vm_execute_stub);
|
||||
|
@ -26,19 +26,11 @@ namespace notifies
|
||||
std::string message = game::ConcatArgs(1);
|
||||
message.erase(0, 1);
|
||||
|
||||
scheduler::once([message, clientNum]()
|
||||
{
|
||||
const scripting::entity level{*game::levelEntityId};
|
||||
const auto _player = scripting::call("getEntByNum", {clientNum});
|
||||
const scripting::entity level{*game::levelEntityId};
|
||||
const auto player = scripting::call("getEntByNum", {clientNum}).as<scripting::entity>();
|
||||
|
||||
if (_player.get_raw().type == game::SCRIPT_OBJECT)
|
||||
{
|
||||
const auto player = _player.as<scripting::entity>();
|
||||
|
||||
scripting::notify(level, "say", {player, message});
|
||||
scripting::notify(player, "say", {message});
|
||||
}
|
||||
});
|
||||
scripting::notify(level, "say", {player, message});
|
||||
scripting::notify(player, "say", {message});
|
||||
}
|
||||
|
||||
return client_command_hook.invoke<void>(clientNum);
|
||||
|
Loading…
x
Reference in New Issue
Block a user