4651
static bool se_enableChatCommands = true;
4652
static tSettingItem<bool> se_enableChatCommandsConf( "CHAT_LOCAL_COMMANDS", se_enableChatCommands );
4654
//our local commands (should always be lowercase)
4655
static char const * const se_localChatCommands[] = {
4662
#endif //if not dedicated
4664
4639
void ePlayerNetID::Chat(const tString &s_orig)
4666
4641
tColoredString s( s_orig );
4669
4644
#ifndef DEDICATED
4671
std::string chatString(s_orig);
4672
std::istringstream passedString(chatString);
4676
passedString >> command;
4677
tToLower( command );
4678
tConfItemBase::EatWhitespace(passedString);
4680
bool isLocalCommand = false;
4682
for (int i = sizeof(se_localChatCommands)/sizeof(se_localChatCommands[0]) - 1; i >= 0; --i)
4684
if (command.StartsWith(se_localChatCommands[i]))
4686
isLocalCommand = true;
4690
if (isLocalCommand && se_enableChatCommands && (s_orig.StartsWith("/")))
4692
// check for direct console commands
4693
if (command == "/console")
4695
// direct commands are executed at owner level
4696
tCurrentAccessLevel level( tAccessLevel_Owner, true );
4699
if (s_orig.StrPos(" ") == -1)
4702
params = s_orig.SubStr(s_orig.StrPos(" ") + 1);
4704
if ( tRecorder::IsPlayingBack() )
4706
tConfItemBase::LoadPlayback();
4710
std::stringstream s(static_cast< char const * >( params ) );
4711
tConfItemBase::LoadAll(s);
4714
//Short handle for grabbing player colors.
4715
else if ((command == "/listcolors") || (command == "/colors"))
4717
listPlayerColors(tString(s_orig));
4719
//Short handle for grabbing player information.
4720
else if (command == "/info")
4722
listPlayerInfo(tString(s_orig));
4724
//Short handle for changing our RGB values.
4725
else if (command == "/rgb")
4727
currentPlayerRGB(tString(s_orig));
4645
// check for direct console commands
4646
if( s_orig.StartsWith("/console") )
4648
// direct commands are executed at owner level
4649
tCurrentAccessLevel level( tAccessLevel_Owner, true );
4652
if (s_orig.StrPos(" ") == -1)
4655
params = s_orig.SubStr(s_orig.StrPos(" ") + 1);
4657
if ( tRecorder::IsPlayingBack() )
4659
tConfItemBase::LoadPlayback();
4663
std::stringstream s(static_cast< char const * >( params ) );
4664
tConfItemBase::LoadAll(s);
4731
#endif //if not dedicated
4733
4670
tString retStr(s);
4734
4671
if (eBannedWords::BadWordTrigger(this, retStr))
8534
//Gather all the rgb colors and put them in a nice list.
8535
//Usage /colors with no parameters returns all players and their colors.
8536
// /colors playername returns that specific players color or more depending if the search term is found in other player names
8537
void ePlayerNetID::listPlayerColors(tString s_orig)
8540
if (se_PlayerNetIDs.Len()>0)
8542
if (s_orig.StrPos(" ") == -1)
8544
con << tOutput("$player_colors_text");
8546
for ( int i = 0; i <= se_PlayerNetIDs.Len()-1; i++ )
8548
ePlayerNetID *p=se_PlayerNetIDs(i);
8549
con << (i+1) << ": " << gatherPlayerColor(p);
8555
tArray<tString> msgsExt = s_orig.Split(" ");
8556
bool playerFound = false;
8558
con << tOutput("$player_colors_text");
8560
for(int i = 0; i < msgsExt.Len(); i++)
8562
tString word = msgsExt[i];
8564
for ( int i = 0; i <= se_PlayerNetIDs.Len()-1; i++ )
8566
ePlayerNetID *p=se_PlayerNetIDs(i);
8568
if (p->GetName().Filter().Contains(word.Filter()))
8572
con << (j+1) << ": " << gatherPlayerColor(p);
8581
con << tOutput("$player_not_found_text", msgsExt[1]);
8589
//Not sure if this is better / faster but better looking I guess?
8590
tColoredString ePlayerNetID::gatherPlayerColor(ePlayerNetID * p)
8592
tColoredString listColors;
8593
return listColors << p->GetColoredName() << "0xRESETT (" << p->r << ", " << p->g << ", " << p->b << ")\n";
8599
List player information.
8604
Used Rubber out of max
8606
Spectating / Playing
8608
Sometimes Alive / Dead
8609
Usage: /info - Returns own information
8610
/info playername - Returns that players name. (or more depending if the search word is found in more than one player)
8613
void ePlayerNetID::listPlayerInfo(tString s_orig)
8616
if (se_PlayerNetIDs.Len()>0)
8618
if (s_orig.StrPos(" ") == -1)
8620
con << tOutput("$player_info_text");
8621
ePlayerNetID *p = se_GetLocalPlayer();
8622
con << gatherPlayerInfo(p);
8626
tArray<tString> msgsExt = s_orig.Split(" ");
8627
tArray<ePlayerNetID *> foundPlayers;
8628
bool playerFound = false;
8629
con << tOutput("$player_info_text");
8630
for(int i = 0; i < msgsExt.Len(); i++)
8632
tString word = msgsExt[i];
8634
for(int i=0; i < se_PlayerNetIDs.Len(); i++)
8636
ePlayerNetID *p=se_PlayerNetIDs(i);
8638
if (p->GetName().Filter().Contains(word.Filter()))
8642
con << gatherPlayerInfo(p);
8650
con << tOutput("$player_not_found_text", msgsExt[1]);
8660
tColoredString ePlayerNetID::gatherPlayerInfo(ePlayerNetID * p)
8662
tColoredString listinfo;
8663
listinfo << "Results for " << p->GetColoredName() << "0xRESETT: \n";
8665
///Status. Includes player type, spectating or playing, and if the player is chatting.
8666
listinfo << "Status: ";
8667
(p->IsHuman()) ? listinfo << "Human" : listinfo << "Bot";
8669
//Oddly IsSpectating returned some confusing results.
8670
(!p->CurrentTeam()) ? listinfo << ", Spectating" : listinfo << ", Playing";
8672
//Are we chatting / out of focus? Calculating the time worked for our local player but didnt work too well for players who joined before us.
8673
(p->IsChatting()) ? listinfo << ", Chatting" : listinfo << ""; // ("<< fabs(p->TimeChatting()) << ") seconds\n" : listinfo << "\n";
8676
//Only grab this information if the player is an active object.
8677
if (p->Object() && p->currentTeam)
8679
//If the player is an active object, are they alive? Pretty sure we know this already but no harm in including it.
8680
(p->Object()->Alive()) ? listinfo << ", Alive\n" : listinfo << ", Dead\n";
8682
//Only grab this information if the player is an alive object.
8683
if (p->Object()->Alive())
8685
gCycle *pCycle = dynamic_cast<gCycle *>(p->Object());
8687
listinfo << "Position: x: " << pCycle->MapPosition().x << ", y: " << pCycle->MapPosition().y << "\n";
8689
//Had trouble converting the direction to an angle, will have to visit this later
8690
listinfo << "Map Direction: " << "x: " << pCycle->MapDirection().x << ", y: " << pCycle->MapDirection().y << "\n";
8691
listinfo << "Speed: " << pCycle->verletSpeed_ << "\n";
8692
listinfo << "Rubber: " << pCycle->GetRubber() << "/" << sg_rubberCycle << "\n";
8696
return listinfo << "\n";
8699
// Allow us to change our current RGB easily.
8700
// Usage: /rgb with no parameters displays current rgb.
8701
// /rgb 15 3 3 Would set player 1's RGB to R15 G3 B3.
8702
// /rgb unique gives all players unique colors.
8703
// /rgb random gives all players random colors.
8704
// /rgb 2 15 3 3 Will change player 2's colors to 15 3 3.
8705
void ePlayerNetID::currentPlayerRGB(tString s_orig)
8707
if (s_orig.StrPos(" ") == -1)
8709
con << tOutput("$player_colors_current_text");
8710
for(int i=0; i<MAX_PLAYERS; ++i )
8712
bool in_game=ePlayer::PlayerIsInGame(i);
8713
ePlayer *me=ePlayer::PlayerConfig(i);
8715
tCONTROLLED_PTR(ePlayerNetID) &p=me->netPlayer;
8716
if (bool(p) && in_game)
8718
tColoredString listColors;
8719
listColors << p->GetColoredName() << "0xRESETT (" << ePlayer::PlayerConfig(i)->rgb[0] << ", " << ePlayer::PlayerConfig(i)->rgb[1] << ", " << ePlayer::PlayerConfig(i)->rgb[2] << ")\n";
8726
tArray<tString> passedString = s_orig.Split(" ");
8727
bool correctParameters = false;
8728
bool random = false;
8729
bool unique = false;
8732
if (passedString[1] == "random")
8734
correctParameters = true;
8737
//For now everyone gets random colors.
8738
for(int i=0; i<MAX_PLAYERS; ++i )
8740
bool in_game = ePlayer::PlayerIsInGame(i);
8741
ePlayer *me = ePlayer::PlayerConfig(i);
8743
tCONTROLLED_PTR(ePlayerNetID) &p=me->netPlayer;
8745
if (bool(p) && in_game)
8747
se_RandomizeColor(me);
8752
else if(passedString[1] == "unique")
8754
correctParameters = true;
8756
//Also everyone gets unique colors if sent.
8757
for(int i=0; i<MAX_PLAYERS; ++i )
8759
bool in_game=ePlayer::PlayerIsInGame(i);
8760
ePlayer *me=ePlayer::PlayerConfig(i);
8762
tCONTROLLED_PTR(ePlayerNetID) &p=me->netPlayer;
8764
if (bool(p) && in_game)
8766
se_UniqueColor(me,p);
8771
//Not really checking if the strings passed parameters are numbers, but if someone did /rgb asd asd asd it would just make it 0 0 0.
8772
else if (passedString.Len() >= 4 && !(random || unique ))
8774
//Guess we must be ID 0?
8775
if (passedString.Len() == 4)
8777
correctParameters = true;
8779
unsigned short r = (unsigned short) strtoul(passedString[1], NULL, 0);
8780
unsigned short g = (unsigned short) strtoul(passedString[2], NULL, 0);
8781
unsigned short b = (unsigned short) strtoul(passedString[3], NULL, 0);
8783
ePlayer::PlayerConfig(0)->rgb[0] = r;
8784
ePlayer::PlayerConfig(0)->rgb[1] = g;
8785
ePlayer::PlayerConfig(0)->rgb[2] = b;
8788
else if (passedString.Len() == 5)
8790
ourID = (unsigned short) strtoul(passedString[1], NULL, 0);
8791
if ((ourID <= MAX_PLAYERS) && (ourID > 0))
8793
correctParameters = true;
8795
bool in_game=ePlayer::PlayerIsInGame(ourID-1);
8796
ePlayer *me=ePlayer::PlayerConfig(ourID-1);
8798
unsigned short r = (unsigned short) strtoul(passedString[2], NULL, 0);
8799
unsigned short g = (unsigned short) strtoul(passedString[3], NULL, 0);
8800
unsigned short b = (unsigned short) strtoul(passedString[4], NULL, 0);
8802
ePlayer::PlayerConfig(ourID-1)->rgb[0] = r;
8803
ePlayer::PlayerConfig(ourID-1)->rgb[1] = g;
8804
ePlayer::PlayerConfig(ourID-1)->rgb[2] = b;
8809
// If the correct parameters are passed, display the changes.
8810
if (correctParameters)
8812
con << tOutput("$player_colors_current_text");
8814
for(int i=0; i<MAX_PLAYERS; ++i )
8816
bool in_game=ePlayer::PlayerIsInGame(i);
8817
ePlayer *me=ePlayer::PlayerConfig(i);
8819
tCONTROLLED_PTR(ePlayerNetID) &p=me->netPlayer;
8820
if (bool(p) && in_game)
8821
{ tColoredString listColors;
8822
listColors << i+1 << ": " << p->GetColoredName() << "0xRESETT (" << ePlayer::PlayerConfig(i)->rgb[0] << ", " << ePlayer::PlayerConfig(i)->rgb[1] << ", " << ePlayer::PlayerConfig(i)->rgb[2] << ")\n";
8825
if(!(bool(p) && in_game) && ourID-1 == i)
8827
con << tOutput("$player_colors_changed_text", ourID, ePlayer::PlayerConfig(i)->rgb[0], ePlayer::PlayerConfig(i)->rgb[1], ePlayer::PlayerConfig(i)->rgb[2]);
8833
con << tOutput("$player_colors_changed_usage_error");
8841
8435
static nSettingItem<int> se_pingCharityServerConf("PING_CHARITY_SERVER",sn_pingCharityServer );
8842
8436
static nVersionFeature se_pingCharityServerControlled( 14 );
10670
10252
static void SilenceAll_conf(std::istream &s)
10672
if (se_PlayerNetIDs.Len() > 0)
10254
if ( se_NeedsServer( "SILENCE_ALL", s ) )
10259
if (se_PlayerNetIDs.Len()>0)
10674
10261
int max = se_PlayerNetIDs.Len();
10675
for (int i = 0; i < max; i++)
10677
ePlayerNetID *p = se_PlayerNetIDs(i);
10680
if ((sn_GetNetState() == nCLIENT) && (p && !p->IsSilenced()) && ((p->Owner() != ::sn_myNetID)))
10682
p->SetSilenced(true);
10687
if ((sn_GetNetState() == nSERVER) && (p && !p->IsSilenced()))
10689
p->SetSilenced(true);
10694
if (sn_GetNetState() == nCLIENT)
10696
sn_ConsoleOut(tOutput("$player_silenced_all_local"));
10699
if (sn_GetNetState() == nSERVER)
10701
sn_ConsoleOut(tOutput("$player_silenced_all"));
10262
for(int i=0; i<max; i++)
10264
ePlayerNetID *p=se_PlayerNetIDs(i);
10265
if ( p && !p->IsSilenced() )
10267
p->SetSilenced( true );
10270
sn_ConsoleOut( tOutput( "$player_silenced_all") );
10707
10274
static tConfItemFunc silenceall_conf("SILENCE_ALL",&SilenceAll_conf);
10708
10275
static tAccessLevelSetter se_silenceallConfLevel( silenceall_conf, tAccessLevel_Moderator );
10710
10277
static void Voice_conf(std::istream &s)
10279
if ( se_NeedsServer( "VOICE", s ) || se_NeedsServer( "UNSILENCE", s ))
10712
10284
ePlayerNetID * p = ReadPlayer( s );
10713
10285
if ( p && p->IsSilenced() )
10716
if ( sn_GetNetState() == nCLIENT )
10717
sn_ConsoleOut( tOutput( "$player_voiced_local", p->GetColoredName() ) );
10720
sn_ConsoleOut( tOutput( "$player_voiced", p->GetColoredName() ) );
10287
sn_ConsoleOut( tOutput( "$player_voiced", p->GetColoredName() ) );
10721
10288
p->SetSilenced( false );