Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* begin zCatch*/
- if (!str_comp_num("/", pMsg->m_pMessage, 1))
- {
- if (str_comp_nocase_num(pMsg->m_pMessage + 1, "w ", 2) == 0)
- {
- char pWhisperMsg[256];
- str_copy(pWhisperMsg, pMsg->m_pMessage + 3, 256);
- Whisper(pPlayer->GetCID(), pWhisperMsg);
- }
- else if (str_comp_nocase_num(pMsg->m_pMessage + 1, "whisper ", 8) == 0)
- {
- char pWhisperMsg[256];
- str_copy(pWhisperMsg, pMsg->m_pMessage + 9, 256);
- Whisper(pPlayer->GetCID(), pWhisperMsg);
- }
- else if (str_comp_nocase_num(pMsg->m_pMessage + 1, "c ", 2) == 0)
- {
- char pWhisperMsg[256];
- str_copy(pWhisperMsg, pMsg->m_pMessage + 3, 256);
- Converse(pPlayer->GetCID(), pWhisperMsg);
- }
- else if (str_comp_nocase_num(pMsg->m_pMessage + 1, "converse ", 9) == 0)
- {
- char pWhisperMsg[256];
- str_copy(pWhisperMsg, pMsg->m_pMessage + 10, 256);
- Converse(pPlayer->GetCID(), pWhisperMsg);
- }
- else if (!str_comp_nocase("w", pMsg->m_pMessage + 1) || !str_comp_nocase("whisper", pMsg->m_pMessage + 1)
- || !str_comp_nocase("c", pMsg->m_pMessage + 1) || !str_comp_nocase("converse", pMsg->m_pMessage + 1)) {
- char aBuf[128];
- str_format(aBuf, sizeof(aBuf), "Type /help to see how use this command.");
- SendChatTarget(ClientID, aBuf);
- }
- else if (!str_comp_nocase("info", pMsg->m_pMessage + 1))
- {
- char aBuf[128];
- str_format(aBuf, sizeof(aBuf), "zCatch %s by erd and Teetime, modified by Teelevision modified by Savander. See /help.", ZCATCH_VERSION);
- SendChatTarget(ClientID, aBuf);
- SendChatTarget(ClientID, "You are caught when killed and released when your killer dies. Catch everyone to win the round.");
- if (g_Config.m_SvLastStandingPlayers > 2)
- {
- str_format(aBuf, sizeof(aBuf), "If there are less than %d players, the round does not end and all players are released instead.", g_Config.m_SvLastStandingPlayers);
- SendChatTarget(ClientID, aBuf);
- }
- }
- else if (!str_comp_nocase("cmdlist", pMsg->m_pMessage + 1))
- {
- if (RankingEnabled())
- SendChatTarget(ClientID, "Chat commands: /info, /help, /kills, /victims, /t <name> <msg>, /ti <id> <msg>, /top [<category>], /rank [<player>]");
- else
- SendChatTarget(ClientID, "Chat commands: /info, /help, /kills, /victims, /t <name> <msg>, /ti <id> <msg>");
- }
- else if (!str_comp_nocase("help", pMsg->m_pMessage + 1))
- {
- SendChatTarget(ClientID, "--- Help topics ---");
- SendChatTarget(ClientID, "/help 1: zCatch/TeeVi");
- SendChatTarget(ClientID, "/help 2: releasing");
- SendChatTarget(ClientID, "/help 3: writing PMs");
- SendChatTarget(ClientID, "/help 4: ranking system");
- }
- else if (!str_comp_nocase("help 1", pMsg->m_pMessage + 1))
- {
- SendChatTarget(ClientID, "--- Help 1 / 4 ---");
- SendChatTarget(ClientID, "Players you catch (kill) join again when you die. Catch everyone to win.");
- SendChatTarget(ClientID, "/kills: list of players you caught");
- SendChatTarget(ClientID, "/victims: who is waiting for your death");
- }
- else if (!str_comp_nocase("help 2", pMsg->m_pMessage + 1))
- {
- SendChatTarget(ClientID, "--- Help 2 / 4 ---");
- SendChatTarget(ClientID, "On suicide via console the last victim is released instead. You die if there is noone to release. The console command for suicide is 'kill'.");
- }
- else if (!str_comp_nocase("help 3", pMsg->m_pMessage + 1))
- {
- SendChatTarget(ClientID, "--- Help 3 / 4 ---");
- SendChatTarget(ClientID, "You can write private messages:");
- SendChatTarget(ClientID, "/w <name> <msg>: write PM to <name>");
- SendChatTarget(ClientID, "/wi <id> <msg>: write PM via ID");
- SendChatTarget(ClientID, "/c <name>: start conversation with <name>");
- SendChatTarget(ClientID, "/ci <id>: start conversation with <id>");
- SendChatTarget(ClientID, "/c : End conversation.");
- }
- else if (!str_comp_nocase("help 4", pMsg->m_pMessage + 1))
- {
- if (RankingEnabled())
- {
- SendChatTarget(ClientID, "--- Help 4 / 4 ---");
- SendChatTarget(ClientID, "The ranking system saves various stats about players. The stats are updated at the end of a round and on leaving the server.");
- SendChatTarget(ClientID, "/top [<category>]: display top 5 players");
- SendChatTarget(ClientID, "/rank [<player>]: display own/players's rank");
- }
- else
- {
- SendChatTarget(ClientID, "--- Help 4 / 4 ---");
- SendChatTarget(ClientID, "The ranking system is disabled on this server.");
- }
- }
- else if (!str_comp_nocase("victims", pMsg->m_pMessage + 1))
- {
- if (pPlayer->m_zCatchNumVictims)
- {
- char aBuf[256], bBuf[256];
- CPlayer::CZCatchVictim *v = pPlayer->m_ZCatchVictims;
- str_format(aBuf, sizeof(aBuf), "%d player(s) await your death: ", pPlayer->m_zCatchNumVictims);
- while (v != NULL)
- {
- str_format(bBuf, sizeof(bBuf), (v == pPlayer->m_ZCatchVictims) ? "%s '%s'%s" : "%s, '%s'%s", aBuf, Server()->ClientName(v->ClientID), (v->Reason == CPlayer::ZCATCH_CAUGHT_REASON_JOINING) ? " (joined the game)" : "");
- str_copy(aBuf, bBuf, sizeof(aBuf));
- v = v->prev;
- }
- SendChatTarget(ClientID, aBuf);
- }
- else
- {
- SendChatTarget(ClientID, "No one awaits your death.");
- }
- }
- else if (!str_comp_nocase("kills", pMsg->m_pMessage + 1))
- {
- if (pPlayer->m_zCatchNumKillsInARow)
- {
- char aBuf[256];
- str_format(aBuf, sizeof(aBuf), "You caught %d player(s) since your last death.", pPlayer->m_zCatchNumKillsInARow);
- SendChatTarget(ClientID, aBuf);
- }
- else
- {
- SendChatTarget(ClientID, "You caught no one since your last death.");
- }
- }
- /**whispering / conversation by jxsl13*/
- // tell / PM someone privately
- else if (!str_comp_nocase_num("talk ", pMsg->m_pMessage + 1, 2)
- || !str_comp_nocase_num("talk ", pMsg->m_pMessage + 1, 3))
- {
- const char *recipientStart;
- if (str_comp_nocase_num("talk", pMsg->m_pMessage + 1, 4) == 0)
- {
- if (m_apPlayers[ClientID]->m_Recipient_ID >= 0) {
- m_apPlayers[ClientID]->m_Recipient_ID = -1;
- SendChatTarget(ClientID, "You left the conversation.");
- }
- else {
- SendChatTarget(ClientID, "You are in no conversation.");
- }
- return;
- }
- //look for the space after the playername
- // by name
- if (str_comp_nocase_num("talk ", pMsg->m_pMessage + 1, 5) == 0)
- {
- int recipientNameLength;
- const char *recipientName;
- recipientStart = str_skip_whitespaces((char*)pMsg->m_pMessage + 3);
- // check _all_ players (there might be partly identical names)
- for (int i = 0; i < MAX_CLIENTS; ++i)
- {
- if (m_apPlayers[i]
- && (recipientName = Server()->ClientName(i))
- && (recipientNameLength = str_length(recipientName))
- && !str_comp_num(recipientName, recipientStart, recipientNameLength)
- && recipientStart[recipientNameLength] == ' '
- )
- {
- m_apPlayers[ClientID]->m_Recipient_ID = i;
- if (m_apPlayers[ClientID]->m_Recipient_ID >= 0)
- {
- // prepare message
- char *msg = (char*)malloc((52 + MAX_NAME_LENGTH) * sizeof(char));
- // send to sender and recipient
- str_format(msg, (52 + MAX_NAME_LENGTH) * sizeof(char), "Now talking to '%s', use /c to stop your conversation.", Server()->ClientName(m_apPlayers[ClientID]->m_Recipient_ID));
- SendChatTarget(ClientID, msg);
- free(msg);
- return;
- }
- else {
- SendChatTarget(ClientID, "Could not deliver private message. More than one player could be addressed.");
- return;
- }
- }
- }
- }
- }
- /* ranking system */
- else if (RankingEnabled() && (!str_comp_nocase("top", pMsg->m_pMessage + 1) || !str_comp_nocase("top5", pMsg->m_pMessage + 1)))
- {
- m_pController->OnChatCommandTop(pPlayer);
- }
- else if (RankingEnabled() && (!str_comp_nocase_num("top ", pMsg->m_pMessage + 1, 4) || !str_comp_nocase_num("top5 ", pMsg->m_pMessage + 1, 5)))
- {
- char *category = str_skip_whitespaces((char*)pMsg->m_pMessage + 5);
- int length = str_length(category);
- /* trim right */
- while (length > 0 && str_skip_whitespaces(category + length - 1) >= (category + length)) {
- --length;
- category[length] = 0;
- }
- m_pController->OnChatCommandTop(pPlayer, category);
- }
- else if (RankingEnabled() && (!str_comp_nocase("rank", pMsg->m_pMessage + 1)))
- {
- m_pController->OnChatCommandOwnRank(pPlayer);
- }
- else if (RankingEnabled() && (!str_comp_nocase_num("rank ", pMsg->m_pMessage + 1, 5)))
- {
- char *name = str_skip_whitespaces((char*)pMsg->m_pMessage + 6);
- int length = str_length(name);
- /* trim right */
- while (length > 0 && str_skip_whitespaces(name + length - 1) >= (name + length)) {
- --length;
- name[length] = 0;
- }
- m_pController->OnChatCommandRank(pPlayer, name);
- }
- else
- {
- SendChatTarget(ClientID, "Unknown command, try /info");
- }
- }
- else
- {
- // send to chat
- if (MuteValidation(pPlayer))
- {
- SendChat(ClientID, Team, pMsg->m_pMessage);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement