|
|
1.1 ! root 1: #include "g_local.h" ! 2: #include "m_player.h" ! 3: ! 4: ! 5: char *ClientTeam (edict_t *ent) ! 6: { ! 7: char *p; ! 8: static char value[512]; ! 9: ! 10: value[0] = 0; ! 11: ! 12: if (!ent->client) ! 13: return value; ! 14: ! 15: strcpy(value, Info_ValueForKey (ent->client->pers.userinfo, "skin")); ! 16: p = strchr(value, '/'); ! 17: if (!p) ! 18: return value; ! 19: ! 20: if ((int)(dmflags->value) & DF_MODELTEAMS) ! 21: { ! 22: *p = 0; ! 23: return value; ! 24: } ! 25: ! 26: // if ((int)(dmflags->value) & DF_SKINTEAMS) ! 27: return ++p; ! 28: } ! 29: ! 30: qboolean OnSameTeam (edict_t *ent1, edict_t *ent2) ! 31: { ! 32: char ent1Team [512]; ! 33: char ent2Team [512]; ! 34: ! 35: if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS))) ! 36: return false; ! 37: ! 38: strcpy (ent1Team, ClientTeam (ent1)); ! 39: strcpy (ent2Team, ClientTeam (ent2)); ! 40: ! 41: if (strcmp(ent1Team, ent2Team) == 0) ! 42: return true; ! 43: return false; ! 44: } ! 45: ! 46: ! 47: void SelectNextItem (edict_t *ent, int itflags) ! 48: { ! 49: gclient_t *cl; ! 50: int i, index; ! 51: gitem_t *it; ! 52: ! 53: cl = ent->client; ! 54: ! 55: // scan for the next valid one ! 56: for (i=1 ; i<=MAX_ITEMS ; i++) ! 57: { ! 58: index = (cl->pers.selected_item + i)%MAX_ITEMS; ! 59: if (!cl->pers.inventory[index]) ! 60: continue; ! 61: it = &itemlist[index]; ! 62: if (!it->use) ! 63: continue; ! 64: if (!(it->flags & itflags)) ! 65: continue; ! 66: ! 67: cl->pers.selected_item = index; ! 68: return; ! 69: } ! 70: ! 71: cl->pers.selected_item = -1; ! 72: } ! 73: ! 74: void SelectPrevItem (edict_t *ent, int itflags) ! 75: { ! 76: gclient_t *cl; ! 77: int i, index; ! 78: gitem_t *it; ! 79: ! 80: cl = ent->client; ! 81: ! 82: // scan for the next valid one ! 83: for (i=1 ; i<=MAX_ITEMS ; i++) ! 84: { ! 85: index = (cl->pers.selected_item + MAX_ITEMS - i)%MAX_ITEMS; ! 86: if (!cl->pers.inventory[index]) ! 87: continue; ! 88: it = &itemlist[index]; ! 89: if (!it->use) ! 90: continue; ! 91: if (!(it->flags & itflags)) ! 92: continue; ! 93: ! 94: cl->pers.selected_item = index; ! 95: return; ! 96: } ! 97: ! 98: cl->pers.selected_item = -1; ! 99: } ! 100: ! 101: void ValidateSelectedItem (edict_t *ent) ! 102: { ! 103: gclient_t *cl; ! 104: ! 105: cl = ent->client; ! 106: ! 107: if (cl->pers.inventory[cl->pers.selected_item]) ! 108: return; // valid ! 109: ! 110: SelectNextItem (ent, -1); ! 111: } ! 112: ! 113: ! 114: //================================================================================= ! 115: ! 116: /* ! 117: ================== ! 118: Cmd_Give_f ! 119: ! 120: Give items to a client ! 121: ================== ! 122: */ ! 123: void Cmd_Give_f (edict_t *ent) ! 124: { ! 125: char *name; ! 126: gitem_t *it; ! 127: int index; ! 128: int i; ! 129: qboolean give_all; ! 130: edict_t *it_ent; ! 131: ! 132: if (deathmatch->value && !sv_cheats->value) ! 133: { ! 134: gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); ! 135: return; ! 136: } ! 137: ! 138: name = gi.args(); ! 139: ! 140: if (Q_stricmp(name, "all") == 0) ! 141: give_all = true; ! 142: else ! 143: give_all = false; ! 144: ! 145: if (give_all || Q_stricmp(gi.argv(1), "health") == 0) ! 146: { ! 147: if (gi.argc() == 3) ! 148: ent->health = atoi(gi.argv(2)); ! 149: else ! 150: ent->health = ent->max_health; ! 151: if (!give_all) ! 152: return; ! 153: } ! 154: ! 155: if (give_all || Q_stricmp(name, "weapons") == 0) ! 156: { ! 157: for (i=0 ; i<game.num_items ; i++) ! 158: { ! 159: it = itemlist + i; ! 160: if (!it->pickup) ! 161: continue; ! 162: if (!(it->flags & IT_WEAPON)) ! 163: continue; ! 164: ent->client->pers.inventory[i] += 1; ! 165: } ! 166: if (!give_all) ! 167: return; ! 168: } ! 169: ! 170: if (give_all || Q_stricmp(name, "ammo") == 0) ! 171: { ! 172: for (i=0 ; i<game.num_items ; i++) ! 173: { ! 174: it = itemlist + i; ! 175: if (!it->pickup) ! 176: continue; ! 177: if (!(it->flags & IT_AMMO)) ! 178: continue; ! 179: Add_Ammo (ent, it, 1000); ! 180: } ! 181: if (!give_all) ! 182: return; ! 183: } ! 184: ! 185: if (give_all || Q_stricmp(name, "armor") == 0) ! 186: { ! 187: gitem_armor_t *info; ! 188: ! 189: it = FindItem("Jacket Armor"); ! 190: ent->client->pers.inventory[ITEM_INDEX(it)] = 0; ! 191: ! 192: it = FindItem("Combat Armor"); ! 193: ent->client->pers.inventory[ITEM_INDEX(it)] = 0; ! 194: ! 195: it = FindItem("Body Armor"); ! 196: info = (gitem_armor_t *)it->info; ! 197: ent->client->pers.inventory[ITEM_INDEX(it)] = info->max_count; ! 198: ! 199: if (!give_all) ! 200: return; ! 201: } ! 202: ! 203: if (give_all || Q_stricmp(name, "Power Shield") == 0) ! 204: { ! 205: it = FindItem("Power Shield"); ! 206: it_ent = G_Spawn(); ! 207: it_ent->classname = it->classname; ! 208: SpawnItem (it_ent, it); ! 209: Touch_Item (it_ent, ent, NULL, NULL); ! 210: if (it_ent->inuse) ! 211: G_FreeEdict(it_ent); ! 212: ! 213: if (!give_all) ! 214: return; ! 215: } ! 216: ! 217: if (give_all) ! 218: { ! 219: for (i=0 ; i<game.num_items ; i++) ! 220: { ! 221: it = itemlist + i; ! 222: if (!it->pickup) ! 223: continue; ! 224: if (it->flags & (IT_ARMOR|IT_WEAPON|IT_AMMO)) ! 225: continue; ! 226: ent->client->pers.inventory[i] = 1; ! 227: } ! 228: return; ! 229: } ! 230: ! 231: it = FindItem (name); ! 232: if (!it) ! 233: { ! 234: name = gi.argv(1); ! 235: it = FindItem (name); ! 236: if (!it) ! 237: { ! 238: gi.dprintf ("unknown item\n"); ! 239: return; ! 240: } ! 241: } ! 242: ! 243: if (!it->pickup) ! 244: { ! 245: gi.dprintf ("non-pickup item\n"); ! 246: return; ! 247: } ! 248: ! 249: index = ITEM_INDEX(it); ! 250: ! 251: if (it->flags & IT_AMMO) ! 252: { ! 253: if (gi.argc() == 3) ! 254: ent->client->pers.inventory[index] = atoi(gi.argv(2)); ! 255: else ! 256: ent->client->pers.inventory[index] += it->quantity; ! 257: } ! 258: else ! 259: { ! 260: it_ent = G_Spawn(); ! 261: it_ent->classname = it->classname; ! 262: SpawnItem (it_ent, it); ! 263: Touch_Item (it_ent, ent, NULL, NULL); ! 264: if (it_ent->inuse) ! 265: G_FreeEdict(it_ent); ! 266: } ! 267: } ! 268: ! 269: ! 270: /* ! 271: ================== ! 272: Cmd_God_f ! 273: ! 274: Sets client to godmode ! 275: ! 276: argv(0) god ! 277: ================== ! 278: */ ! 279: void Cmd_God_f (edict_t *ent) ! 280: { ! 281: char *msg; ! 282: ! 283: if (deathmatch->value && !sv_cheats->value) ! 284: { ! 285: gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); ! 286: return; ! 287: } ! 288: ! 289: ent->flags ^= FL_GODMODE; ! 290: if (!(ent->flags & FL_GODMODE) ) ! 291: msg = "godmode OFF\n"; ! 292: else ! 293: msg = "godmode ON\n"; ! 294: ! 295: gi.cprintf (ent, PRINT_HIGH, msg); ! 296: } ! 297: ! 298: ! 299: /* ! 300: ================== ! 301: Cmd_Notarget_f ! 302: ! 303: Sets client to notarget ! 304: ! 305: argv(0) notarget ! 306: ================== ! 307: */ ! 308: void Cmd_Notarget_f (edict_t *ent) ! 309: { ! 310: char *msg; ! 311: ! 312: if (deathmatch->value && !sv_cheats->value) ! 313: { ! 314: gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); ! 315: return; ! 316: } ! 317: ! 318: ent->flags ^= FL_NOTARGET; ! 319: if (!(ent->flags & FL_NOTARGET) ) ! 320: msg = "notarget OFF\n"; ! 321: else ! 322: msg = "notarget ON\n"; ! 323: ! 324: gi.cprintf (ent, PRINT_HIGH, msg); ! 325: } ! 326: ! 327: ! 328: /* ! 329: ================== ! 330: Cmd_Noclip_f ! 331: ! 332: argv(0) noclip ! 333: ================== ! 334: */ ! 335: void Cmd_Noclip_f (edict_t *ent) ! 336: { ! 337: char *msg; ! 338: ! 339: if (deathmatch->value && !sv_cheats->value) ! 340: { ! 341: gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); ! 342: return; ! 343: } ! 344: ! 345: if (ent->movetype == MOVETYPE_NOCLIP) ! 346: { ! 347: ent->movetype = MOVETYPE_WALK; ! 348: msg = "noclip OFF\n"; ! 349: } ! 350: else ! 351: { ! 352: ent->movetype = MOVETYPE_NOCLIP; ! 353: msg = "noclip ON\n"; ! 354: } ! 355: ! 356: gi.cprintf (ent, PRINT_HIGH, msg); ! 357: } ! 358: ! 359: ! 360: /* ! 361: ================== ! 362: Cmd_Use_f ! 363: ! 364: Use an inventory item ! 365: ================== ! 366: */ ! 367: void Cmd_Use_f (edict_t *ent) ! 368: { ! 369: int index; ! 370: gitem_t *it; ! 371: char *s; ! 372: ! 373: s = gi.args(); ! 374: it = FindItem (s); ! 375: if (!it) ! 376: { ! 377: gi.cprintf (ent, PRINT_HIGH, "unknown item: %s\n", s); ! 378: return; ! 379: } ! 380: if (!it->use) ! 381: { ! 382: gi.cprintf (ent, PRINT_HIGH, "Item is not usable.\n"); ! 383: return; ! 384: } ! 385: index = ITEM_INDEX(it); ! 386: if (!ent->client->pers.inventory[index]) ! 387: { ! 388: gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s); ! 389: return; ! 390: } ! 391: ! 392: it->use (ent, it); ! 393: } ! 394: ! 395: ! 396: /* ! 397: ================== ! 398: Cmd_Drop_f ! 399: ! 400: Drop an inventory item ! 401: ================== ! 402: */ ! 403: void Cmd_Drop_f (edict_t *ent) ! 404: { ! 405: int index; ! 406: gitem_t *it; ! 407: char *s; ! 408: ! 409: s = gi.args(); ! 410: it = FindItem (s); ! 411: if (!it) ! 412: { ! 413: gi.cprintf (ent, PRINT_HIGH, "unknown item: %s\n", s); ! 414: return; ! 415: } ! 416: if (!it->drop) ! 417: { ! 418: gi.cprintf (ent, PRINT_HIGH, "Item is not dropable.\n"); ! 419: return; ! 420: } ! 421: index = ITEM_INDEX(it); ! 422: if (!ent->client->pers.inventory[index]) ! 423: { ! 424: gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s); ! 425: return; ! 426: } ! 427: ! 428: it->drop (ent, it); ! 429: } ! 430: ! 431: ! 432: /* ! 433: ================= ! 434: Cmd_Inven_f ! 435: ================= ! 436: */ ! 437: void Cmd_Inven_f (edict_t *ent) ! 438: { ! 439: int i; ! 440: gclient_t *cl; ! 441: ! 442: cl = ent->client; ! 443: ! 444: cl->showscores = false; ! 445: cl->showhelp = false; ! 446: ! 447: if (cl->showinventory) ! 448: { ! 449: cl->showinventory = false; ! 450: return; ! 451: } ! 452: ! 453: cl->showinventory = true; ! 454: ! 455: gi.WriteByte (svc_inventory); ! 456: for (i=0 ; i<MAX_ITEMS ; i++) ! 457: { ! 458: gi.WriteShort (cl->pers.inventory[i]); ! 459: } ! 460: gi.unicast (ent, true); ! 461: } ! 462: ! 463: /* ! 464: ================= ! 465: Cmd_InvUse_f ! 466: ================= ! 467: */ ! 468: void Cmd_InvUse_f (edict_t *ent) ! 469: { ! 470: gitem_t *it; ! 471: ! 472: ValidateSelectedItem (ent); ! 473: ! 474: if (ent->client->pers.selected_item == -1) ! 475: { ! 476: gi.cprintf (ent, PRINT_HIGH, "No item to use.\n"); ! 477: return; ! 478: } ! 479: ! 480: it = &itemlist[ent->client->pers.selected_item]; ! 481: if (!it->use) ! 482: { ! 483: gi.cprintf (ent, PRINT_HIGH, "Item is not usable.\n"); ! 484: return; ! 485: } ! 486: it->use (ent, it); ! 487: } ! 488: ! 489: /* ! 490: ================= ! 491: Cmd_WeapPrev_f ! 492: ================= ! 493: */ ! 494: void Cmd_WeapPrev_f (edict_t *ent) ! 495: { ! 496: gclient_t *cl; ! 497: int i, index; ! 498: gitem_t *it; ! 499: int selected_weapon; ! 500: ! 501: cl = ent->client; ! 502: ! 503: if (!cl->pers.weapon) ! 504: return; ! 505: ! 506: selected_weapon = ITEM_INDEX(cl->pers.weapon); ! 507: ! 508: // scan for the next valid one ! 509: for (i=1 ; i<=MAX_ITEMS ; i++) ! 510: { ! 511: index = (selected_weapon + i)%MAX_ITEMS; ! 512: if (!cl->pers.inventory[index]) ! 513: continue; ! 514: it = &itemlist[index]; ! 515: if (!it->use) ! 516: continue; ! 517: if (! (it->flags & IT_WEAPON) ) ! 518: continue; ! 519: it->use (ent, it); ! 520: if (cl->pers.weapon == it) ! 521: return; // successful ! 522: } ! 523: } ! 524: ! 525: /* ! 526: ================= ! 527: Cmd_WeapNext_f ! 528: ================= ! 529: */ ! 530: void Cmd_WeapNext_f (edict_t *ent) ! 531: { ! 532: gclient_t *cl; ! 533: int i, index; ! 534: gitem_t *it; ! 535: int selected_weapon; ! 536: ! 537: cl = ent->client; ! 538: ! 539: if (!cl->pers.weapon) ! 540: return; ! 541: ! 542: selected_weapon = ITEM_INDEX(cl->pers.weapon); ! 543: ! 544: // scan for the next valid one ! 545: for (i=1 ; i<=MAX_ITEMS ; i++) ! 546: { ! 547: index = (selected_weapon + MAX_ITEMS - i)%MAX_ITEMS; ! 548: if (!cl->pers.inventory[index]) ! 549: continue; ! 550: it = &itemlist[index]; ! 551: if (!it->use) ! 552: continue; ! 553: if (! (it->flags & IT_WEAPON) ) ! 554: continue; ! 555: it->use (ent, it); ! 556: if (cl->pers.weapon == it) ! 557: return; // successful ! 558: } ! 559: } ! 560: ! 561: /* ! 562: ================= ! 563: Cmd_WeapLast_f ! 564: ================= ! 565: */ ! 566: void Cmd_WeapLast_f (edict_t *ent) ! 567: { ! 568: gclient_t *cl; ! 569: int index; ! 570: gitem_t *it; ! 571: ! 572: cl = ent->client; ! 573: ! 574: if (!cl->pers.weapon || !cl->pers.lastweapon) ! 575: return; ! 576: ! 577: index = ITEM_INDEX(cl->pers.lastweapon); ! 578: if (!cl->pers.inventory[index]) ! 579: return; ! 580: it = &itemlist[index]; ! 581: if (!it->use) ! 582: return; ! 583: if (! (it->flags & IT_WEAPON) ) ! 584: return; ! 585: it->use (ent, it); ! 586: } ! 587: ! 588: /* ! 589: ================= ! 590: Cmd_InvDrop_f ! 591: ================= ! 592: */ ! 593: void Cmd_InvDrop_f (edict_t *ent) ! 594: { ! 595: gitem_t *it; ! 596: ! 597: ValidateSelectedItem (ent); ! 598: ! 599: if (ent->client->pers.selected_item == -1) ! 600: { ! 601: gi.cprintf (ent, PRINT_HIGH, "No item to drop.\n"); ! 602: return; ! 603: } ! 604: ! 605: it = &itemlist[ent->client->pers.selected_item]; ! 606: if (!it->drop) ! 607: { ! 608: gi.cprintf (ent, PRINT_HIGH, "Item is not dropable.\n"); ! 609: return; ! 610: } ! 611: it->drop (ent, it); ! 612: } ! 613: ! 614: /* ! 615: ================= ! 616: Cmd_Kill_f ! 617: ================= ! 618: */ ! 619: void Cmd_Kill_f (edict_t *ent) ! 620: { ! 621: if((level.time - ent->client->respawn_time) < 5) ! 622: return; ! 623: ent->flags &= ~FL_GODMODE; ! 624: ent->health = 0; ! 625: meansOfDeath = MOD_SUICIDE; ! 626: player_die (ent, ent, ent, 100000, vec3_origin); ! 627: // don't even bother waiting for death frames ! 628: ent->deadflag = DEAD_DEAD; ! 629: respawn (ent); ! 630: } ! 631: ! 632: /* ! 633: ================= ! 634: Cmd_PutAway_f ! 635: ================= ! 636: */ ! 637: void Cmd_PutAway_f (edict_t *ent) ! 638: { ! 639: ent->client->showscores = false; ! 640: ent->client->showhelp = false; ! 641: ent->client->showinventory = false; ! 642: } ! 643: ! 644: ! 645: int PlayerSort (void const *a, void const *b) ! 646: { ! 647: int anum, bnum; ! 648: ! 649: anum = *(int *)a; ! 650: bnum = *(int *)b; ! 651: ! 652: anum = game.clients[anum].ps.stats[STAT_FRAGS]; ! 653: bnum = game.clients[bnum].ps.stats[STAT_FRAGS]; ! 654: ! 655: if (anum < bnum) ! 656: return -1; ! 657: if (anum > bnum) ! 658: return 1; ! 659: return 0; ! 660: } ! 661: ! 662: /* ! 663: ================= ! 664: Cmd_Players_f ! 665: ================= ! 666: */ ! 667: void Cmd_Players_f (edict_t *ent) ! 668: { ! 669: int i; ! 670: int count; ! 671: char small[64]; ! 672: char large[1280]; ! 673: int index[256]; ! 674: ! 675: count = 0; ! 676: for (i = 0 ; i < maxclients->value ; i++) ! 677: if (game.clients[i].pers.connected) ! 678: { ! 679: index[count] = i; ! 680: count++; ! 681: } ! 682: ! 683: // sort by frags ! 684: qsort (index, count, sizeof(index[0]), PlayerSort); ! 685: ! 686: // print information ! 687: large[0] = 0; ! 688: ! 689: for (i = 0 ; i < count ; i++) ! 690: { ! 691: Com_sprintf (small, sizeof(small), "%3i %s\n", ! 692: game.clients[index[i]].ps.stats[STAT_FRAGS], ! 693: game.clients[index[i]].pers.netname); ! 694: if (strlen (small) + strlen(large) > sizeof(large) - 100 ) ! 695: { // can't print all of them in one packet ! 696: strcat (large, "...\n"); ! 697: break; ! 698: } ! 699: strcat (large, small); ! 700: } ! 701: ! 702: gi.cprintf (ent, PRINT_HIGH, "%s\n%i players\n", large, count); ! 703: } ! 704: ! 705: /* ! 706: ================= ! 707: Cmd_Wave_f ! 708: ================= ! 709: */ ! 710: void Cmd_Wave_f (edict_t *ent) ! 711: { ! 712: int i; ! 713: ! 714: i = atoi (gi.argv(1)); ! 715: ! 716: // can't wave when ducked ! 717: if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) ! 718: return; ! 719: ! 720: if (ent->client->anim_priority > ANIM_WAVE) ! 721: return; ! 722: ! 723: ent->client->anim_priority = ANIM_WAVE; ! 724: ! 725: switch (i) ! 726: { ! 727: case 0: ! 728: gi.cprintf (ent, PRINT_HIGH, "flipoff\n"); ! 729: ent->s.frame = FRAME_flip01-1; ! 730: ent->client->anim_end = FRAME_flip12; ! 731: break; ! 732: case 1: ! 733: gi.cprintf (ent, PRINT_HIGH, "salute\n"); ! 734: ent->s.frame = FRAME_salute01-1; ! 735: ent->client->anim_end = FRAME_salute11; ! 736: break; ! 737: case 2: ! 738: gi.cprintf (ent, PRINT_HIGH, "taunt\n"); ! 739: ent->s.frame = FRAME_taunt01-1; ! 740: ent->client->anim_end = FRAME_taunt17; ! 741: break; ! 742: case 3: ! 743: gi.cprintf (ent, PRINT_HIGH, "wave\n"); ! 744: ent->s.frame = FRAME_wave01-1; ! 745: ent->client->anim_end = FRAME_wave11; ! 746: break; ! 747: case 4: ! 748: default: ! 749: gi.cprintf (ent, PRINT_HIGH, "point\n"); ! 750: ent->s.frame = FRAME_point01-1; ! 751: ent->client->anim_end = FRAME_point12; ! 752: break; ! 753: } ! 754: } ! 755: ! 756: /* ! 757: ================== ! 758: Cmd_Say_f ! 759: ================== ! 760: */ ! 761: void Cmd_Say_f (edict_t *ent, qboolean team, qboolean arg0) ! 762: { ! 763: int j; ! 764: edict_t *other; ! 765: char *p; ! 766: char text[2048]; ! 767: ! 768: if (gi.argc () < 2 && !arg0) ! 769: return; ! 770: ! 771: if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS))) ! 772: team = false; ! 773: ! 774: if (team) ! 775: Com_sprintf (text, sizeof(text), "(%s): ", ent->client->pers.netname); ! 776: else ! 777: Com_sprintf (text, sizeof(text), "%s: ", ent->client->pers.netname); ! 778: ! 779: if (arg0) ! 780: { ! 781: strcat (text, gi.argv(0)); ! 782: strcat (text, " "); ! 783: strcat (text, gi.args()); ! 784: } ! 785: else ! 786: { ! 787: p = gi.args(); ! 788: ! 789: if (*p == '"') ! 790: { ! 791: p++; ! 792: p[strlen(p)-1] = 0; ! 793: } ! 794: strcat(text, p); ! 795: } ! 796: ! 797: // don't let text be too long for malicious reasons ! 798: if (strlen(text) > 150) ! 799: text[150] = 0; ! 800: ! 801: strcat(text, "\n"); ! 802: ! 803: if (dedicated->value) ! 804: gi.cprintf(NULL, PRINT_CHAT, "%s", text); ! 805: ! 806: for (j = 1; j <= game.maxclients; j++) ! 807: { ! 808: other = &g_edicts[j]; ! 809: if (!other->inuse) ! 810: continue; ! 811: if (!other->client) ! 812: continue; ! 813: if (team) ! 814: { ! 815: if (!OnSameTeam(ent, other)) ! 816: continue; ! 817: } ! 818: gi.cprintf(other, PRINT_CHAT, "%s", text); ! 819: } ! 820: } ! 821: ! 822: /* ! 823: ================= ! 824: ClientCommand ! 825: ================= ! 826: */ ! 827: void ClientCommand (edict_t *ent) ! 828: { ! 829: char *cmd; ! 830: ! 831: if (!ent->client) ! 832: return; // not fully in game yet ! 833: ! 834: cmd = gi.argv(0); ! 835: ! 836: if (Q_stricmp (cmd, "players") == 0) ! 837: { ! 838: Cmd_Players_f (ent); ! 839: return; ! 840: } ! 841: if (Q_stricmp (cmd, "say") == 0) ! 842: { ! 843: Cmd_Say_f (ent, false, false); ! 844: return; ! 845: } ! 846: if (Q_stricmp (cmd, "say_team") == 0) ! 847: { ! 848: Cmd_Say_f (ent, true, false); ! 849: return; ! 850: } ! 851: if (Q_stricmp (cmd, "score") == 0) ! 852: { ! 853: Cmd_Score_f (ent); ! 854: return; ! 855: } ! 856: if (Q_stricmp (cmd, "help") == 0) ! 857: { ! 858: Cmd_Help_f (ent); ! 859: return; ! 860: } ! 861: ! 862: if (level.intermissiontime) ! 863: return; ! 864: ! 865: if (Q_stricmp (cmd, "use") == 0) ! 866: Cmd_Use_f (ent); ! 867: else if (Q_stricmp (cmd, "drop") == 0) ! 868: Cmd_Drop_f (ent); ! 869: else if (Q_stricmp (cmd, "give") == 0) ! 870: Cmd_Give_f (ent); ! 871: else if (Q_stricmp (cmd, "god") == 0) ! 872: Cmd_God_f (ent); ! 873: else if (Q_stricmp (cmd, "notarget") == 0) ! 874: Cmd_Notarget_f (ent); ! 875: else if (Q_stricmp (cmd, "noclip") == 0) ! 876: Cmd_Noclip_f (ent); ! 877: else if (Q_stricmp (cmd, "inven") == 0) ! 878: Cmd_Inven_f (ent); ! 879: else if (Q_stricmp (cmd, "invnext") == 0) ! 880: SelectNextItem (ent, -1); ! 881: else if (Q_stricmp (cmd, "invprev") == 0) ! 882: SelectPrevItem (ent, -1); ! 883: else if (Q_stricmp (cmd, "invnextw") == 0) ! 884: SelectNextItem (ent, IT_WEAPON); ! 885: else if (Q_stricmp (cmd, "invprevw") == 0) ! 886: SelectPrevItem (ent, IT_WEAPON); ! 887: else if (Q_stricmp (cmd, "invnextp") == 0) ! 888: SelectNextItem (ent, IT_POWERUP); ! 889: else if (Q_stricmp (cmd, "invprevp") == 0) ! 890: SelectPrevItem (ent, IT_POWERUP); ! 891: else if (Q_stricmp (cmd, "invuse") == 0) ! 892: Cmd_InvUse_f (ent); ! 893: else if (Q_stricmp (cmd, "invdrop") == 0) ! 894: Cmd_InvDrop_f (ent); ! 895: else if (Q_stricmp (cmd, "weapprev") == 0) ! 896: Cmd_WeapPrev_f (ent); ! 897: else if (Q_stricmp (cmd, "weapnext") == 0) ! 898: Cmd_WeapNext_f (ent); ! 899: else if (Q_stricmp (cmd, "weaplast") == 0) ! 900: Cmd_WeapLast_f (ent); ! 901: else if (Q_stricmp (cmd, "kill") == 0) ! 902: Cmd_Kill_f (ent); ! 903: else if (Q_stricmp (cmd, "putaway") == 0) ! 904: Cmd_PutAway_f (ent); ! 905: else if (Q_stricmp (cmd, "wave") == 0) ! 906: Cmd_Wave_f (ent); ! 907: else // anything that doesn't match a command will be a chat ! 908: Cmd_Say_f (ent, false, true); ! 909: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.