Author |
Message |
JaqMs14 Guest
Offline
|
Posted: Fri Jul 16, 2004 9:44 pm Post subject: String help |
 |
|
|
|
Ok for mervbot, I made a command that will say something when the play enters, and what is says is customizeable (ex. !message [message]).
But all it did was PM the player with a blank message. Here is my code>
In command.cpp:
if (c->check("message"))
{
String themessage = c->final;
if (c->checkParam(themessage))
{
message_enabled = true;
if (themessage.IsEmpty())
{
message_enabled = false;
}
}
}
And in spawn.ccp:
case EVENT_PlayerEntering:
{
Player *p = (Player*)event.p[0];
if(p->ship!=
{gotEvent(makePlayerShip(p,p->ship, );}
if(message_enabled)
{
sendPrivate(p, themessage);
}
}
And in spawn.h, I defined:
bool message_enabled;
String themessage;[/code] |
|
Back to top |
|
 |
JaqMs14 Guest
Offline
|
Posted: Fri Jul 16, 2004 9:45 pm Post subject: |
 |
|
|
|
Oops that got messed up a bit. |
|
Back to top |
|
 |
50% Packetloss Server Help Squatter

Age:40 Gender: Joined: Sep 09 2003 Posts: 561 Location: Santa Clarita, California Offline
|
|
Back to top |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Sat Jul 17, 2004 8:42 am Post subject: |
 |
|
|
|
Quote: | strncpy(c->final,256); |
I must be missing something _________________
 |
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Sat Jul 17, 2004 9:24 am Post subject: |
 |
|
|
|
try changing, in commands.cpp:
if (c->check("message"))
{
String themessage = c->final;
to:
if (c->check("message"))
{
themessage = c->final;
It will always use the local variable whever it can, so if you redefine it locally it won't affect the global one, save you doing this.themessage |
|
Back to top |
|
 |
50% Packetloss Server Help Squatter

Age:40 Gender: Joined: Sep 09 2003 Posts: 561 Location: Santa Clarita, California Offline
|
Posted: Sat Jul 17, 2004 1:36 pm Post subject: |
 |
|
|
|
haters, lol, i corrected it. There is no need for a class, just use a regular char |
|
Back to top |
|
 |
|