May 26, 20241 yr Im still tryna understand whats problem inside of code, after sending custom notice ps_game crashed. *** AdminCmdNoticeAllOutgoing createNotice(const std::string& message) { AdminCmdNoticeAllOutgoing notice{}; notice.messageLength = message.length(); std::memcpy(¬ice.message, message.c_str(), message.length()); return notice; } *** std::string output; auto charId = std::stoi(args.at(0)); std::string Notice = args.at(1); CUser* user = CWorld::FindUser(charId); if (!user) { std::stringstream output_msg; output_msg << "Character not found !!"; output = output_msg.str(); return 0; } auto SendNotice = createNotice(Notice); SConnection::Send(&user->connection, &SendNotice, sizeof(SendNotice)); std::stringstream output_msg; output_msg << "notice send to player ok !"; output = output_msg.str();
May 26, 20241 yr Author notice packet struct like that #pragma pack(push, 1) struct AdminCmdNoticeAllOutgoing { UINT16 opcode{ 0xF90B }; // w/ null-terminator UINT8 messageLength; ChatMessage message; }; #pragma pack(pop)
Im still tryna understand whats problem inside of code, after sending custom notice ps_game crashed.
***
AdminCmdNoticeAllOutgoing createNotice(const std::string& message) {
AdminCmdNoticeAllOutgoing notice{};
notice.messageLength = message.length();
std::memcpy(¬ice.message, message.c_str(), message.length());
return notice;
}
***
std::string output;
auto charId = std::stoi(args.at(0));
std::string Notice = args.at(1);
CUser* user = CWorld::FindUser(charId);
if (!user)
{
std::stringstream output_msg;
output_msg << "Character not found !!";
output = output_msg.str();
return 0;
}
auto SendNotice = createNotice(Notice);
SConnection::Send(&user->connection, &SendNotice, sizeof(SendNotice));
std::stringstream output_msg;
output_msg << "notice send to player ok !";
output = output_msg.str();