add say/tell + update submodules

This commit is contained in:
m
2022-10-22 23:21:05 -05:00
parent 8aa10c7dc5
commit 4893a44954
5 changed files with 32 additions and 4 deletions

View File

@ -464,6 +464,34 @@ namespace gsc
// return 0 so the game doesn't override the cfg
return 0;
});
function::add("say", [](const function_args& args)
{
const auto message = args[0].as<std::string>();
game::SV_GameSendServerCommand(-1, game::SV_CMD_CAN_IGNORE, utils::string::va("%c \"%s\"", 84, message.data()));
return scripting::script_value{};
});
method::add("tell", [](const game::scr_entref_t ent, const function_args& args)
{
if (ent.classnum != 0)
{
throw std::runtime_error("Invalid entity");
}
const auto client = ent.entnum;
if (game::mp::g_entities[client].client == nullptr)
{
throw std::runtime_error("Not a player entity");
}
const auto message = args[0].as<std::string>();
game::SV_GameSendServerCommand(client, game::SV_CMD_CAN_IGNORE, utils::string::va("%c \"%s\"", 84, message.data()));
return scripting::script_value{};
});
}
};
}