Author |
Message |
Hakaku Server Help Squatter
Joined: Apr 07 2006 Posts: 299 Location: Canada Offline
|
Posted: Thu Feb 26, 2009 12:47 pm Post subject: Fakes & chat |
|
|
|
|
At the moment in Deva we currently have the server forward messages to a bot in order to be able to send messages on a ?chat channel. In our attempt to make the zone eventually bot-free, would it technically be possible for the server or a fake player to send messages on a chat channel? If so, how could this be done? |
|
Back to top |
|
|
Chambahs Power attack
Joined: Jun 19 2005 Posts: 820 Offline
|
Posted: Thu Feb 26, 2009 1:58 pm Post subject: |
|
|
|
|
I know for sure it is. But do you want to keep the bot on a certain chat channel, or do you want the bot just relaying messages to different chat channels? |
|
Back to top |
|
|
Hakaku Server Help Squatter
Joined: Apr 07 2006 Posts: 299 Location: Canada Offline
|
Posted: Thu Feb 26, 2009 2:23 pm Post subject: |
|
|
|
|
Chambahs wrote: | I know for sure it is. But do you want to keep the bot on a certain chat channel, or do you want the bot just relaying messages to different chat channels? |
I think you misunderstood. Right now we already have a bot relaying messages from the server to a ?chat channel. What I'd like to be able to do is get rid of the bot entirely and just have the server/fake player send messages to the channel. So I'm asking if this is even possible? |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Thu Feb 26, 2009 3:07 pm Post subject: |
|
|
|
|
It's possible. You'd have to create a module to log a player into the billing server, and send ?chat=...
I don't know how much trouble that will be, though. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Thu Feb 26, 2009 5:25 pm Post subject: |
|
|
|
|
ive been meaning to do an asss chat mod, ill look into it... _________________ SSC Distension Owner
SSCU Trench Wars Developer |
|
Back to top |
|
|
Initrd.gz Seasoned Helper
Joined: Sep 18 2008 Posts: 134 Location: Over there ---> Offline
|
Posted: Fri Feb 27, 2009 8:25 pm Post subject: |
|
|
|
|
For fakes "speaking":
A ) You can use chat->SendAnyMessage
B ) You can add "Fake>" to the beginning of a message and send it like any other, though it would be green
Look at the Color module for how to "spoof" the color of chat->SendAnyMessage to make it look like a public/team/priv. message |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Fri Feb 27, 2009 9:33 pm Post subject: |
|
|
|
|
None of that will help with speaking on a ?chat channel. |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Sat Feb 28, 2009 12:50 am Post subject: |
|
|
|
|
because it only sends to those inside the zone
yeah, you could fake an entire chat session, but it wouldnt do anything for those in other zones... |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Thu Mar 05, 2009 2:17 am Post subject: |
|
|
|
|
in chat.c, it uses
local void v_send_msg(LinkedList *set, char type, char sound, Player *from, const char *str, va_list ap)
{
int size;
char _buf[256];
const char *ctype = get_chat_type(type);
struct ChatPacket *cp = (struct ChatPacket*)_buf;
size = vsnprintf(cp->text, 250, str, ap) + 6;
if (type == MSG_MODCHAT)
type = MSG_SYSOPWARNING;
cp->pktype = S2C_CHAT;
cp->type = type;
cp->sound = sound;
cp->pid = from ? from->pid : -1;
if (net) net->SendToSet(set, (byte*)cp, size, NET_RELIABLE);
if (chatnet && ctype)
{
if (from)
chatnet->SendToSet(set, "MSG:%s:%s:%s", ctype, from->name, cp->text);
else
chatnet->SendToSet(set, "MSG:%s:%s", ctype, cp->text);
}
}
|
i notice it uses
struct ChatPacket *cp = (struct ChatPacket*)_buf;
|
which is basically inline structure declaration.
why does this work?
i tried throwing this into my code, but it died with a "dereferencing pointer to incomplete type" error every time i tried to do cp->pktype = S2C_CHAT; or something...
--edit--
i got this to compile without error by tweaking the code.
however, the curent ChatPacket struct expects char text[0], which i know wants the pointer to a char array...
how do i pass char buf[256] to cp.text without getting an incompatible types error? |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Thu Mar 05, 2009 6:43 am Post subject: |
|
|
|
|
It works because it doesn't do what you think it's doing. It declares the chat packet as pointing to the buffer, it doesn't create a new chat packet. It's not an inline structure declaration. |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Thu Mar 05, 2009 10:10 am Post subject: |
|
|
|
|
Yeah, it just typecasts _buf (a char*) to a Chatpacket* _________________ (Insert a bunch of dead links here) |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Thu Mar 05, 2009 10:54 am Post subject: |
|
|
|
|
thats what i figured, but how do i pass char buf[256] to cp.text (buf[0]) without getting an incompatible types error?
im not so great at this if you cant tell |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Thu Mar 05, 2009 4:48 pm Post subject: |
|
|
|
|
cp->text (not cp.text) already occupies some of the same memory as the buffer. Assigning the buffer to it is not what you want, since the packet IS the buffer. If you're looking to better understand it, I'd suggest you brush up on pointers and arrays. Specifically the part where they talk about the similarities between the two. |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Thu Mar 05, 2009 5:00 pm Post subject: |
|
|
|
|
strcpy? |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Sat Mar 07, 2009 6:14 pm Post subject: |
|
|
|
|
so i connected this to a command
local void aCmd(const char *params, const char *params2, Player *p, const Target *target)
{
chat->SendMessage(p,"net cmd sending...");
//cpp=&cp;
char buf[256];
struct ChatPacket *cpp=(struct ChatPacket*)buf;
int size;
//cpp->text=buf;
size=snprintf(cpp->text,250,"%s","weeeeeeeeeeeeeeee")+6;
cpp->pktype=S2C_CHAT;
cpp->type=MSG_PUB;//79;//type;
cpp->sound=0;//sound;
cpp->pid=p->pid;//-1;//from ? from->pid : -1;
//net->SendToSet(set,(byte*)cp,size,NET_RELIABLE);
//void (*SendToOne)(Player *p, byte *data, int length, int flags);
net->SendToOne(p,(byte*)cpp,size,NET_RELIABLE);
chat->SendMessage(p,"net cmd sent");
return;
} |
compiled fine, but the zone crashes somewhere between 'sending' and 'sent'...
i have no idea why
after this works, ill figure out how to log a fake player into the biller. |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Sat Mar 07, 2009 6:54 pm Post subject: |
|
|
|
|
Run it in a debugger (gdb if you're running on linux). If you don't know how to use a debugger, then it's time to learn. You'll never regret any amount of time spent learning to use your debugger. It's easily your most powerful programming tool.
Oh, if you do try to log fake players into a biller, make sure you don't test it on SSC while you're developing. Try it on something like subbill or catid's biller. |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Sat Mar 07, 2009 7:47 pm Post subject: |
|
|
|
|
good thing i dont own a ssc connected zone then, right? =D
never used a debugger, and how would i debug a dll? :S
i installed one, but i have no idea how to use it...
unrelated: why does
chat->SendMessage(p,"| %-15c | %-80c |","string","string");
output wierd chars instead? |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Sat Mar 07, 2009 8:56 pm Post subject: |
|
|
|
|
Cheese wrote: | never used a debugger, and how would i debug a dll? :S |
Debug the entire program. It'll treat the dll as part of the whole.
Cheese wrote: | unrelated: why does
chat->SendMessage(p,"| %-15c | %-80c |","string","string");
output wierd chars instead? |
Because %c is for a char. You want %s for a string. |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Sun Mar 08, 2009 3:44 am Post subject: |
|
|
|
|
oh duh, thanks |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Tue Mar 10, 2009 11:31 pm Post subject: |
|
|
|
|
do i need a just in time debugger, or will any work?
know any good ones? |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Wed Mar 11, 2009 6:32 am Post subject: |
|
|
|
|
Use gdb on Linux. Dev-C++ and MSVC++ both have built in debuggers. |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Sat Mar 14, 2009 4:30 pm Post subject: |
|
|
|
|
i dont know assembly, and i dont want to go through the hell of trying to get the core to compile.
im about to give up on this |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Sat Mar 14, 2009 4:53 pm Post subject: |
|
|
|
|
Compile the core. That should have been your very first step when working with asss programming. |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Sat Mar 14, 2009 5:45 pm Post subject: |
|
|
|
|
:(
also,
Unknown exit code: -1073741819.
and the core will not compile if you dont have python
error 2:
CreateProcess((null), uname -s, ...) failed.
\src\Makefile ../build/deps.mk: No such file or directory.
\src\Makefile CreateProcess((null), ../windeps/python.exe ../scripts/makedeps.py -I. -Iinclude -I../build -I../windeps -D_REENTRANT -D_GNU_SOURCE -I../windeps -I../windeps/mysqlinc -I../windeps/pythoninc */*.c -P $(BUILDDIR)/ -o ../build/deps.mk, ...) failed.
\src\Makefile The system cannot find the file specified. |
|
Back to top |
|
|
|