Advertisement
jxsl13

Untitled

Aug 22nd, 2015
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.93 KB | None | 0 0
  1. /* begin zCatch*/
  2. if (!str_comp_num("/", pMsg->m_pMessage, 1))
  3. {
  4. if (str_comp_nocase_num(pMsg->m_pMessage + 1, "w ", 2) == 0)
  5. {
  6. char pWhisperMsg[256];
  7. str_copy(pWhisperMsg, pMsg->m_pMessage + 3, 256);
  8. Whisper(pPlayer->GetCID(), pWhisperMsg);
  9. }
  10. else if (str_comp_nocase_num(pMsg->m_pMessage + 1, "whisper ", 8) == 0)
  11. {
  12. char pWhisperMsg[256];
  13. str_copy(pWhisperMsg, pMsg->m_pMessage + 9, 256);
  14. Whisper(pPlayer->GetCID(), pWhisperMsg);
  15. }
  16. else if (str_comp_nocase_num(pMsg->m_pMessage + 1, "c ", 2) == 0)
  17. {
  18. char pWhisperMsg[256];
  19. str_copy(pWhisperMsg, pMsg->m_pMessage + 3, 256);
  20. Converse(pPlayer->GetCID(), pWhisperMsg);
  21. }
  22. else if (str_comp_nocase_num(pMsg->m_pMessage + 1, "converse ", 9) == 0)
  23. {
  24. char pWhisperMsg[256];
  25. str_copy(pWhisperMsg, pMsg->m_pMessage + 10, 256);
  26. Converse(pPlayer->GetCID(), pWhisperMsg);
  27. }
  28. else if (!str_comp_nocase("w", pMsg->m_pMessage + 1) || !str_comp_nocase("whisper", pMsg->m_pMessage + 1)
  29. || !str_comp_nocase("c", pMsg->m_pMessage + 1) || !str_comp_nocase("converse", pMsg->m_pMessage + 1)) {
  30. char aBuf[128];
  31. str_format(aBuf, sizeof(aBuf), "Type /help to see how use this command.");
  32. SendChatTarget(ClientID, aBuf);
  33. }
  34. else if (!str_comp_nocase("info", pMsg->m_pMessage + 1))
  35. {
  36. char aBuf[128];
  37. str_format(aBuf, sizeof(aBuf), "zCatch %s by erd and Teetime, modified by Teelevision modified by Savander. See /help.", ZCATCH_VERSION);
  38. SendChatTarget(ClientID, aBuf);
  39. SendChatTarget(ClientID, "You are caught when killed and released when your killer dies. Catch everyone to win the round.");
  40. if (g_Config.m_SvLastStandingPlayers > 2)
  41. {
  42. 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);
  43. SendChatTarget(ClientID, aBuf);
  44. }
  45. }
  46. else if (!str_comp_nocase("cmdlist", pMsg->m_pMessage + 1))
  47. {
  48. if (RankingEnabled())
  49. SendChatTarget(ClientID, "Chat commands: /info, /help, /kills, /victims, /t <name> <msg>, /ti <id> <msg>, /top [<category>], /rank [<player>]");
  50. else
  51. SendChatTarget(ClientID, "Chat commands: /info, /help, /kills, /victims, /t <name> <msg>, /ti <id> <msg>");
  52. }
  53. else if (!str_comp_nocase("help", pMsg->m_pMessage + 1))
  54. {
  55. SendChatTarget(ClientID, "--- Help topics ---");
  56. SendChatTarget(ClientID, "/help 1: zCatch/TeeVi");
  57. SendChatTarget(ClientID, "/help 2: releasing");
  58. SendChatTarget(ClientID, "/help 3: writing PMs");
  59. SendChatTarget(ClientID, "/help 4: ranking system");
  60. }
  61. else if (!str_comp_nocase("help 1", pMsg->m_pMessage + 1))
  62. {
  63. SendChatTarget(ClientID, "--- Help 1 / 4 ---");
  64. SendChatTarget(ClientID, "Players you catch (kill) join again when you die. Catch everyone to win.");
  65. SendChatTarget(ClientID, "/kills: list of players you caught");
  66. SendChatTarget(ClientID, "/victims: who is waiting for your death");
  67. }
  68. else if (!str_comp_nocase("help 2", pMsg->m_pMessage + 1))
  69. {
  70. SendChatTarget(ClientID, "--- Help 2 / 4 ---");
  71. 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'.");
  72. }
  73. else if (!str_comp_nocase("help 3", pMsg->m_pMessage + 1))
  74. {
  75. SendChatTarget(ClientID, "--- Help 3 / 4 ---");
  76. SendChatTarget(ClientID, "You can write private messages:");
  77. SendChatTarget(ClientID, "/w <name> <msg>: write PM to <name>");
  78. SendChatTarget(ClientID, "/wi <id> <msg>: write PM via ID");
  79. SendChatTarget(ClientID, "/c <name>: start conversation with <name>");
  80. SendChatTarget(ClientID, "/ci <id>: start conversation with <id>");
  81. SendChatTarget(ClientID, "/c : End conversation.");
  82. }
  83. else if (!str_comp_nocase("help 4", pMsg->m_pMessage + 1))
  84. {
  85. if (RankingEnabled())
  86. {
  87. SendChatTarget(ClientID, "--- Help 4 / 4 ---");
  88. 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.");
  89. SendChatTarget(ClientID, "/top [<category>]: display top 5 players");
  90. SendChatTarget(ClientID, "/rank [<player>]: display own/players's rank");
  91. }
  92. else
  93. {
  94. SendChatTarget(ClientID, "--- Help 4 / 4 ---");
  95. SendChatTarget(ClientID, "The ranking system is disabled on this server.");
  96. }
  97. }
  98. else if (!str_comp_nocase("victims", pMsg->m_pMessage + 1))
  99. {
  100. if (pPlayer->m_zCatchNumVictims)
  101. {
  102. char aBuf[256], bBuf[256];
  103. CPlayer::CZCatchVictim *v = pPlayer->m_ZCatchVictims;
  104. str_format(aBuf, sizeof(aBuf), "%d player(s) await your death: ", pPlayer->m_zCatchNumVictims);
  105. while (v != NULL)
  106. {
  107. 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)" : "");
  108. str_copy(aBuf, bBuf, sizeof(aBuf));
  109. v = v->prev;
  110. }
  111. SendChatTarget(ClientID, aBuf);
  112. }
  113. else
  114. {
  115. SendChatTarget(ClientID, "No one awaits your death.");
  116. }
  117. }
  118. else if (!str_comp_nocase("kills", pMsg->m_pMessage + 1))
  119. {
  120. if (pPlayer->m_zCatchNumKillsInARow)
  121. {
  122. char aBuf[256];
  123. str_format(aBuf, sizeof(aBuf), "You caught %d player(s) since your last death.", pPlayer->m_zCatchNumKillsInARow);
  124. SendChatTarget(ClientID, aBuf);
  125. }
  126. else
  127. {
  128. SendChatTarget(ClientID, "You caught no one since your last death.");
  129. }
  130. }
  131.  
  132. /**whispering / conversation by jxsl13*/
  133.  
  134. // tell / PM someone privately
  135. else if (!str_comp_nocase_num("talk ", pMsg->m_pMessage + 1, 2)
  136. || !str_comp_nocase_num("talk ", pMsg->m_pMessage + 1, 3))
  137. {
  138. const char *recipientStart;
  139.  
  140.  
  141.  
  142. if (str_comp_nocase_num("talk", pMsg->m_pMessage + 1, 4) == 0)
  143. {
  144. if (m_apPlayers[ClientID]->m_Recipient_ID >= 0) {
  145. m_apPlayers[ClientID]->m_Recipient_ID = -1;
  146.  
  147. SendChatTarget(ClientID, "You left the conversation.");
  148. }
  149. else {
  150. SendChatTarget(ClientID, "You are in no conversation.");
  151. }
  152. return;
  153.  
  154. }
  155.  
  156. //look for the space after the playername
  157. // by name
  158. if (str_comp_nocase_num("talk ", pMsg->m_pMessage + 1, 5) == 0)
  159. {
  160. int recipientNameLength;
  161. const char *recipientName;
  162. recipientStart = str_skip_whitespaces((char*)pMsg->m_pMessage + 3);
  163. // check _all_ players (there might be partly identical names)
  164. for (int i = 0; i < MAX_CLIENTS; ++i)
  165. {
  166. if (m_apPlayers[i]
  167. && (recipientName = Server()->ClientName(i))
  168. && (recipientNameLength = str_length(recipientName))
  169. && !str_comp_num(recipientName, recipientStart, recipientNameLength)
  170. && recipientStart[recipientNameLength] == ' '
  171. )
  172. {
  173. m_apPlayers[ClientID]->m_Recipient_ID = i;
  174. if (m_apPlayers[ClientID]->m_Recipient_ID >= 0)
  175. {
  176.  
  177. // prepare message
  178.  
  179. char *msg = (char*)malloc((52 + MAX_NAME_LENGTH) * sizeof(char));
  180.  
  181. // send to sender and recipient
  182. 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));
  183.  
  184. SendChatTarget(ClientID, msg);
  185.  
  186. free(msg);
  187. return;
  188.  
  189. }
  190. else {
  191. SendChatTarget(ClientID, "Could not deliver private message. More than one player could be addressed.");
  192. return;
  193. }
  194.  
  195. }
  196. }
  197. }
  198. }
  199.  
  200. /* ranking system */
  201. else if (RankingEnabled() && (!str_comp_nocase("top", pMsg->m_pMessage + 1) || !str_comp_nocase("top5", pMsg->m_pMessage + 1)))
  202. {
  203. m_pController->OnChatCommandTop(pPlayer);
  204. }
  205. else if (RankingEnabled() && (!str_comp_nocase_num("top ", pMsg->m_pMessage + 1, 4) || !str_comp_nocase_num("top5 ", pMsg->m_pMessage + 1, 5)))
  206. {
  207. char *category = str_skip_whitespaces((char*)pMsg->m_pMessage + 5);
  208. int length = str_length(category);
  209. /* trim right */
  210. while (length > 0 && str_skip_whitespaces(category + length - 1) >= (category + length)) {
  211. --length;
  212. category[length] = 0;
  213. }
  214. m_pController->OnChatCommandTop(pPlayer, category);
  215. }
  216. else if (RankingEnabled() && (!str_comp_nocase("rank", pMsg->m_pMessage + 1)))
  217. {
  218. m_pController->OnChatCommandOwnRank(pPlayer);
  219. }
  220. else if (RankingEnabled() && (!str_comp_nocase_num("rank ", pMsg->m_pMessage + 1, 5)))
  221. {
  222. char *name = str_skip_whitespaces((char*)pMsg->m_pMessage + 6);
  223. int length = str_length(name);
  224. /* trim right */
  225. while (length > 0 && str_skip_whitespaces(name + length - 1) >= (name + length)) {
  226. --length;
  227. name[length] = 0;
  228. }
  229. m_pController->OnChatCommandRank(pPlayer, name);
  230. }
  231.  
  232. else
  233. {
  234. SendChatTarget(ClientID, "Unknown command, try /info");
  235. }
  236.  
  237. }
  238. else
  239. {
  240. // send to chat
  241. if (MuteValidation(pPlayer))
  242. {
  243. SendChat(ClientID, Team, pMsg->m_pMessage);
  244. }
  245. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement