Advertisement
Guest User

SOF2 Chat Prefixes

a guest
Sep 17th, 2013
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.15 KB | None | 0 0
  1. /*
  2. ==================
  3. G_SayTo
  4. ==================
  5.  */
  6. static void G_SayTo(gentity_t *ent, gentity_t *other, int mode, const char *name, const char *message, char *sound, qboolean override) {
  7.     qboolean ghost = qfalse;
  8.     qboolean spec = qfalse;
  9.     qboolean adminchat = qfalse;
  10.     qboolean srcadmin = qfalse;
  11.     qboolean dstadmin = qfalse;
  12.     const char* type;
  13.     const char* chat;
  14.     const char* color;
  15.  
  16.     if (!other) {
  17.         return;
  18.     }
  19.  
  20.     if (!other->inuse) {
  21.         return;
  22.     }
  23.  
  24.     if (!other->client) {
  25.         return;
  26.     }
  27.  
  28.     if (other->client->pers.connected != CON_CONNECTED) {
  29.         return;
  30.     }
  31.  
  32.     if (mode == SAY_TEAM && !OnSameTeam(ent, other)) {
  33.         return;
  34.     }
  35.  
  36.     if (!override) {
  37.         if (ent->client->sess.muted) {
  38.             return;
  39.         }
  40.  
  41.         if (ent->client->sess.modData->penalty) {
  42.             return;
  43.         }
  44.     }
  45.  
  46.     if (ent->client->sess.modData->adminref == -1) {
  47.         srcadmin = 2;
  48.     } else {
  49.         srcadmin = ent->client->sess.modData->adminref;
  50.     }
  51.     if (other->client->sess.modData->adminref == -1) {
  52.         dstadmin = 2;
  53.     } else {
  54.         dstadmin = other->client->sess.modData->adminref;
  55.     }
  56.  
  57.     if (G_IsClientChatIgnored(other->s.number, ent->s.number) && mode != SAY_ADMIN_ALL && mode != SAY_ADMIN_ONLY) {
  58.         return;
  59.     }
  60.  
  61.     if ((mode == SAY_ADMIN_ALL || mode == SAY_ADMIN_ONLY) && srcadmin < 2 && !override) {
  62.         return;
  63.     }
  64.  
  65.     if (mode == SAY_ADMIN_ONLY && dstadmin < 2) {
  66.         return;
  67.     }
  68.  
  69.     if ((mode == SAY_REF_ALL || mode == SAY_REF_ONLY) && srcadmin == 0 && !override) {
  70.         return;
  71.     }
  72.  
  73.     if (mode == SAY_REF_ONLY && dstadmin == 0) {
  74.         return;
  75.     }
  76.  
  77.     if (mode == SAY_CLAN_ONLY && !ent->client->sess.modData->clan && !override) {
  78.         return;
  79.     }
  80.  
  81.     if (mode == SAY_CLAN_ONLY && (!other->client->sess.modData->clan && other->client->sess.modData->adminref < 2 && other->client->sess.modData->adminref > -1)) {
  82.         return;
  83.     }
  84.  
  85.     if (!level.intermissiontime && !level.intermissionQueued) {
  86.         // Spectators cant talk to alive people
  87.         if (ent->client->sess.team == TEAM_SPECTATOR) {
  88.             spec = qtrue;
  89.         }
  90.  
  91.         if (level.gametypeData->respawnType == RT_NONE) {
  92.             // Dead people cant talk to alive people
  93.             if (!spec && G_IsClientDead(ent->client)) {
  94.                 ghost = qtrue;
  95.             }
  96.  
  97.             // If the client we are talking to is alive then a check
  98.             // must be made to see if this talker is alowed to speak to this person
  99.             if (ent->s.number != other->s.number && !G_IsClientDead(other->client) && !G_IsClientSpectating(other->client) && (ghost || spec) && mode != SAY_ADMIN_ALL && mode != SAY_ADMIN_ONLY && !g_voiceTalkingGhosts.integer) {
  100.                 return;
  101.             }
  102.         }
  103.     }
  104.  
  105.     chat = "";
  106.     color = "";
  107.     type = "";
  108.    
  109.     // Visitor
  110.     if(ent->client->sess.modData->clan == 0 && ent->client->sess.modData->adminref == 0) {
  111.         type = "^1** ^7Visitor ^1** ";
  112.     }
  113.     // Clan
  114.     if (ent->client->sess.modData->clan == 1 && ent->client->sess.modData->adminref < 3 && ent->client->sess.modData->adminref < 2 && ent->client->sess.modData->adminref < 1) {
  115.         type = "^1** ^7Clan ^1** ";
  116.     }
  117.     // Referee
  118.     else if (ent->client->sess.modData->adminref == 1 && ent->client->sess.modData->clan == 1) {
  119.         type = "^1** ^7Referee ^1** ";
  120.     }
  121.     // Admin
  122.     else if (ent->client->sess.modData->adminref == 2 && ent->client->sess.modData->clan == 1) {
  123.         type = "^1** ^7Admin ^1** ";
  124.     }
  125.     // Sysop
  126.     else if (ent->client->sess.modData->adminref == 3 && ent->client->sess.modData->clan == 1) {
  127.         type = "^1** ^7Sysop ^1** ";
  128.     }
  129.    
  130.     if (mode == SAY_TEAM) {
  131.         chat = "tchat";
  132.     } else {
  133.         chat = "chat";
  134.     }
  135.  
  136.     if (mode == SAY_ADMIN_TELL) {
  137.         color = "^7";
  138.         adminchat = qtrue;
  139.         if (g_anonymousAdmin.integer && dstadmin < 2) {
  140.             name = "";
  141.         }
  142.     } else if (mode == SAY_ADMIN_ALL) {
  143.         color = "^7";
  144.         type = "^5*admin* ^7";
  145.         if (sv_modClient.integer || other->client->sess.modData->versionVerified) {
  146.             chat = "achat";
  147.         } else {
  148.             chat = "chat";
  149.             adminchat = qtrue;
  150.         }
  151.         if (g_anonymousAdmin.integer && dstadmin < 2) {
  152.             name = "";
  153.         }
  154.     } else if (mode == SAY_ADMIN_ONLY) {
  155.         type = "^6*admins only* ^7";
  156.         if (sv_modClient.integer || other->client->sess.modData->versionVerified) {
  157.             chat = "achat";
  158.         } else {
  159.             chat = "chat";
  160.             adminchat = qtrue;
  161.         }
  162.     } else if (mode == SAY_REF_ALL) {
  163.         color = "^7";
  164.         type = "^3*referee* ^7";
  165.         if (sv_modClient.integer || other->client->sess.modData->versionVerified) {
  166.             chat = "achat";
  167.         } else {
  168.             chat = "chat";
  169.             adminchat = qtrue;
  170.         }
  171.     } else if (mode == SAY_REF_ONLY) {
  172.         type = "^6*referees only* ^7";
  173.         if (sv_modClient.integer || other->client->sess.modData->versionVerified) {
  174.             chat = "achat";
  175.         } else {
  176.             chat = "chat";
  177.             adminchat = qtrue;
  178.         }
  179.     } else if (mode == SAY_CLAN_ALL) {
  180.         color = "^7";
  181.         type = "^1*clan* ^7";
  182.     } else if (mode == SAY_CLAN_ONLY) {
  183.         type = "^1*clan only* ^7";
  184.     } else if (ghost) {
  185.         type = "*ghost* ";
  186.     } else if (spec) {
  187.         type = "*spec* ";
  188.     }
  189.     trap_SendServerCommand(other - g_entities, va("%s %d \"%s%s%s%s\"", chat, ent->s.number, type, name, color, message));
  190.     if (adminchat) {
  191.         G_LocalSound(other->s.number, "sound/misc/menus/quit_request.wav");
  192.     }
  193.     if (g_voiceCommandsEnabled.integer && sound[0]) {
  194.         if (g_voiceCommandsEnabled.integer == 1 && sv_modClient.integer || other->client->sess.modData->versionVerified) {
  195.             trap_SendServerCommand(other - g_entities, va("sound %i \"%s\"", ent->client->sess.team, sound));
  196.         } else {
  197.             G_LocalSound(other->s.number, sound);
  198.         }
  199.     }
  200. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement