Hello all,
James here, I had a question.
I am using using scanf_s
Code:
char trigg[255];
char alert[255];
i=0;
for(i=0; i <500; i++)
scanf_s("%s",&trigg[i]);
scanf_s("%s",&alert[i]);
i++;
Trying to read a text file with contents:
"trigger for the bot to see" "alert for the bot to make for trigger"
"LOL" "Laughing Out Loud"
"Hello" "Hello world!"
"Hi there" "Hello, how are you?"
Into arrays trigg and alert so I can use them for this function
Code:
void bot_manager_item::on_push_event(bot_exchange_format f)
{
switch (f.pid)
{
case BOT_EVENT_IM:
{
std::string nickname = std::string(f[0x01]);
int feedback = (int)f[0x02];
u_char age = (u_char)f[0x03];
std::string text = std::string(f[0x04]);
u_char attributes = (u_char)f[0x05];
u_char size = (u_char)f[0x06];
u_long color = (u_long)f[0x07];
u_long effects = (u_long)f[0x08];
u_char charset = (u_char)f[0x09];
u_char pitch = (u_char)f[0x0A];
std::string font = (std::string)f[0x0B];
if (!text.empty())
{
transform(text.begin(), text.end(), text.begin(), toupper);
if (!strcmp(text.c_str(), "/VER"))
{
bot_exchange_format p(PLUGIN_EVENT_IM);
p << bot_value(0x01, nickname);
std::string text = ("James' Camfrog Bot 5.1 Sample Plugin");
p << bot_value(0x02, text.c_str() );
p << bot_value(0x03, attributes);
p << bot_value(0x04, size);
p << bot_value(0x05, color);
p << bot_value(0x06, effects);
p << bot_value(0x07, charset);
p << bot_value(0x08, pitch);
p << bot_value(0x09, font);
std::string d = p.data();
_mngr->deliver_event(_name.c_str(), d.c_str(), (int)d.size());
}
}
} break;
case BOT_EVENT_ROOM_TEXT:
{
std::string nickname = std::string(f[0x01]);
std::string text = std::string(f[0x02]);
u_char attributes = (u_char)f[0x03];
u_char size = (u_char)f[0x04];
u_long color = (u_long)f[0x05];
u_long effects = (u_long)f[0x06];
u_char charset = (u_char)f[0x07];
u_char pitch = (u_char)f[0x08];
std::string font = (std::string)f[0x09];
if (!text.empty())
{
transform(text.begin(), text.end(), text.begin(), toupper);
if (!strcmp(text.c_str(), ".&trigg[0]."))
{
bot_exchange_format p(PLUGIN_EVENT_ROOM_TEXT);
p << bot_value(0x01, ".&alert[0].");
p << bot_value(0x02, attributes);
p << bot_value(0x03, size);
p << bot_value(0x04, color);
p << bot_value(0x05, effects);
p << bot_value(0x06, charset);
p << bot_value(0x07, pitch);
p << bot_value(0x08, font);
std::string d = p.data();
_mngr->deliver_event(_name.c_str(), d.c_str(), (int)d.size());
}
}
} break;
I thought I had the right idea. Any pointers would be great.