1 #include "g_local.h"
2 #include "m_player.h"
3 
Cmd_Notify_Cheat(edict_t * ent)4 void Cmd_Notify_Cheat (edict_t *ent)
5 {
6 	gi.bprintf (PRINT_MEDIUM,"%s is trying to cheat.\n", ent->client->pers.netname);
7 }
8 
ClientTeam(edict_t * ent)9 char *ClientTeam (edict_t *ent)
10 {
11 	char		*p;
12 	static char	value[512];
13 
14 	value[0] = 0;
15 
16 	if (!ent->client)
17 		return value;
18 
19 	strcpy(value, Info_ValueForKey (ent->client->pers.userinfo, "skin"));
20 	p = strchr(value, '/');
21 	if (!p)
22 		return value;
23 
24 	if ((int)(dmflags->value) & DF_MODELTEAMS)
25 	{
26 		*p = 0;
27 		return value;
28 	}
29 
30 	// if ((int)(dmflags->value) & DF_SKINTEAMS)
31 	return ++p;
32 }
33 
OnSameTeam(edict_t * ent1,edict_t * ent2)34 qboolean OnSameTeam (edict_t *ent1, edict_t *ent2)
35 {
36 	char	ent1Team [512];
37 	char	ent2Team [512];
38 
39 	if (sv_teams->value&&deathmatch->value)
40 		if (ent1->TeamName!=0 && ent2->TeamName!=0)
41 			if (ent1->TeamName==ent2->TeamName)
42 				return true;
43 
44 	if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS)))
45 		return false;
46 
47 	strcpy (ent1Team, ClientTeam (ent1));
48 	strcpy (ent2Team, ClientTeam (ent2));
49 
50 	if (strcmp(ent1Team, ent2Team) == 0)
51 		return true;
52 
53 	return false;
54 }
55 
56 
SelectNextItem(edict_t * ent,int itflags)57 void SelectNextItem (edict_t *ent, int itflags)
58 {
59 	gclient_t	*cl;
60 	int			i, index;
61 	gitem_t		*it;
62 
63 	if (ent->killer)
64 	{
65 		ent->client->viewcam_dist=0;
66 		ChaseCamNextMonster(ent);
67 	}
68 
69 	if (ent->health<=0)
70 	{
71 		//gi.cprintf (ent, PRINT_HIGH, "You must be alive to use this command\n");
72 		return;
73 	}
74 
75 	cl = ent->client;
76 
77 	if (cl->chase_target) {
78 		ChaseNext(ent);
79 		return;
80 	}
81 
82 	// scan  for the next valid one
83 	for (i=1 ; i<=MAX_ITEMS ; i++)
84 	{
85 		index = (cl->pers.selected_item + 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 
SelectPrevItem(edict_t * ent,int itflags)101 void SelectPrevItem (edict_t *ent, int itflags)
102 {
103 	gclient_t	*cl;
104 	int			i, index;
105 	gitem_t		*it;
106 
107 	if (ent->killer)
108 	{
109 		ent->client->viewcam_dist=0;
110 		ChaseCamPrevMonster(ent);
111 	}
112 
113 	if (ent->health<=0)
114 	{
115 		//gi.cprintf (ent, PRINT_HIGH, "You must be alive to use this command\n");
116 		return;
117 	}
118 
119 	cl = ent->client;
120 
121 	if (cl->chase_target) {
122 		ChasePrev(ent);
123 		return;
124 	}
125 
126 	// scan  for the next valid one
127 	for (i=1 ; i<=MAX_ITEMS ; i++)
128 	{
129 		index = (cl->pers.selected_item + MAX_ITEMS - i)%MAX_ITEMS;
130 		if (!cl->pers.inventory[index])
131 			continue;
132 		it = &itemlist[index];
133 		if (!it->use)
134 			continue;
135 		if (!(it->flags & itflags))
136 			continue;
137 
138 		cl->pers.selected_item = index;
139 		return;
140 	}
141 
142 	cl->pers.selected_item = -1;
143 }
144 
ValidateSelectedItem(edict_t * ent)145 void ValidateSelectedItem (edict_t *ent)
146 {
147 	gclient_t	*cl;
148 
149 	if (ent->health<=0)
150 	{
151 		//gi.cprintf (ent, PRINT_HIGH, "You must be alive to use this command\n");
152 		return;
153 	}
154 
155 	cl = ent->client;
156 
157 	if (cl->pers.inventory[cl->pers.selected_item])
158 		return;		// valid
159 
160 	SelectNextItem (ent, -1);
161 }
162 
163 
164 //=================================================================================
165 
166 /*
167 =================
168 Cmd_Flashlight_f
169 =================
170 */
Cmd_Flashlight_f(edict_t * ent)171 void Cmd_Flashlight_f (edict_t *ent)
172 {
173 	if (ent->health<=0)
174 	{
175 		//gi.cprintf (ent, PRINT_HIGH, "You must be alive to use this command\n");
176 		return;
177 	}
178 
179 	if (ent->client->flashlight_on == 1)
180 		ent->client->flashlight_on = 0;
181 	else
182 		ent->client->flashlight_on = 1;
183 }
184 
185 /*
186 ==================
187 Cmd_Give_f
188 
189 Give items to a client
190 ==================
191 */
Cmd_Give_f(edict_t * ent)192 void Cmd_Give_f (edict_t *ent)
193 {
194 	char		*name;
195 	gitem_t		*it;
196 	int			index;
197 	int			i;
198 	qboolean	give_all;
199 	edict_t		*it_ent;
200 
201 	if (ent->health<=0)
202 	{
203 		//gi.cprintf (ent, PRINT_HIGH, "You must be alive to use this command\n");
204 		return;
205 	}
206 
207 	gi.bprintf (PRINT_MEDIUM,"%s is a cheating bastard.\n", ent->client->pers.netname);
208 
209 	name = gi.args();
210 
211 	if (Q_stricmp(name, "all") == 0)
212 		give_all = true;
213 	else
214 		give_all = false;
215 
216 	if (give_all || Q_stricmp(gi.argv(1), "health") == 0)
217 	{
218 		if (gi.argc() == 3)
219 			ent->health = atoi(gi.argv(2));
220 		else
221 			ent->health = ent->max_health;
222 		if (!give_all)
223 			return;
224 	}
225 
226 	if (give_all || Q_stricmp(name, "weapons") == 0)
227 	{
228 		for (i=0 ; i<game.num_items ; i++)
229 		{
230 			it = itemlist + i;
231 			if (!it->pickup)
232 				continue;
233 			if (!(it->flags & IT_WEAPON))
234 				continue;
235 			ent->client->pers.inventory[i] += 1;
236 		}
237 		if (!give_all)
238 			return;
239 	}
240 
241 	if (give_all || Q_stricmp(name, "ammo") == 0)
242 	{
243 		for (i=0 ; i<game.num_items ; i++)
244 		{
245 			it = itemlist + i;
246 			if (!it->pickup)
247 				continue;
248 			if (!(it->flags & IT_AMMO))
249 				continue;
250 			Add_Ammo (ent, it, 1000);
251 		}
252 		if (!give_all)
253 			return;
254 	}
255 
256 	if (give_all || Q_stricmp(name, "armor") == 0)
257 	{
258 		gitem_armor_t	*info;
259 
260 		it = FindItem("Jacket Armor");
261 		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;
262 
263 		it = FindItem("Combat Armor");
264 		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;
265 
266 		it = FindItem("Body Armor");
267 		info = (gitem_armor_t *)it->info;
268 		ent->client->pers.inventory[ITEM_INDEX(it)] = info->max_count;
269 
270 		if (!give_all)
271 			return;
272 	}
273 
274 /*	if (give_all || Q_stricmp(name, "Power Shield") == 0)
275 	{
276 		it = FindItem("Power Shield");
277 		it_ent = G_Spawn();
278 		it_ent->classname = it->classname;
279 		SpawnItem (it_ent, it);
280 		Touch_Item (it_ent, ent, NULL, NULL);
281 		if (it_ent->inuse)
282 			G_FreeEdict(it_ent);
283 
284 		if (!give_all)
285 			return;
286 	}*/
287 
288 	if (give_all)
289 	{
290 		for (i=0 ; i<game.num_items ; i++)
291 		{
292 			it = itemlist + i;
293 			if (!it->pickup)
294 				continue;
295 			if (it->flags & (IT_ARMOR|IT_WEAPON|IT_AMMO))
296 				continue;
297 			ent->client->pers.inventory[i] = 1;
298 		}
299 		return;
300 	}
301 
302 	it = FindItem (name);
303 	if (!it)
304 	{
305 		name = gi.argv(1);
306 		it = FindItem (name);
307 		if (!it)
308 		{
309 			gi.cprintf (ent, PRINT_HIGH, "unknown item\n");
310 			return;
311 		}
312 	}
313 
314 	if (!it->pickup)
315 	{
316 		gi.cprintf (ent, PRINT_HIGH, "non-pickup item\n");
317 		return;
318 	}
319 
320 	index = ITEM_INDEX(it);
321 
322 	if (it->flags & IT_AMMO)
323 	{
324 		if (gi.argc() == 3)
325 			ent->client->pers.inventory[index] = atoi(gi.argv(2));
326 		else
327 			ent->client->pers.inventory[index] += it->quantity;
328 	}
329 	else
330 	{
331 		it_ent = G_Spawn();
332 		it_ent->classname = it->classname;
333 		SpawnItem (it_ent, it);
334 		Touch_Item (it_ent, ent, NULL, NULL);
335 		if (it_ent->inuse)
336 			G_FreeEdict(it_ent);
337 	}
338 }
339 
340 /*
341 ==================
342 Cmd_God_f
343 
344 Sets client to godmode
345 
346 argv(0) god
347 ==================
348 */
Cmd_God_f(edict_t * ent)349 void Cmd_God_f (edict_t *ent)
350 {
351 	char	*msg;
352 
353 	if (ent->health<=0)
354 	{
355 		//gi.cprintf (ent, PRINT_HIGH, "You must be alive to use this command\n");
356 		return;
357 	}
358 
359 	if (deathmatch->value && !sv_cheats->value)
360 	{
361 		gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
362 		return;
363 	}
364 
365 	ent->flags ^= FL_GODMODE;
366 	if (!(ent->flags & FL_GODMODE) )
367 		msg = "godmode OFF\n";
368 	else
369 		msg = "godmode ON\n";
370 
371 	gi.cprintf (ent, PRINT_HIGH, msg);
372 }
373 
374 
375 /*
376 ==================
377 Cmd_Notarget_f
378 
379 Sets client to notarget
380 
381 argv(0) notarget
382 ==================
383 */
Cmd_Notarget_f(edict_t * ent)384 void Cmd_Notarget_f (edict_t *ent)
385 {
386 	char	*msg;
387 
388 /*	if (deathmatch->value && !sv_cheats->value)
389 	{
390 		gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
391 		return;
392 	}*/
393 
394 	ent->flags ^= FL_NOTARGET;
395 	if (!(ent->flags & FL_NOTARGET) )
396 		msg = "notarget OFF\n";
397 	else
398 		msg = "notarget ON\n";
399 
400 	gi.cprintf (ent, PRINT_HIGH, msg);
401 }
402 
403 
404 /*
405 ==================
406 Cmd_Noclip_f
407 
408 argv(0) noclip
409 ==================
410 */
Cmd_Noclip_f(edict_t * ent)411 void Cmd_Noclip_f (edict_t *ent)
412 {
413 	char	*msg;
414 
415 	if (deathmatch->value && !sv_cheats->value)
416 	{
417 		gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
418 		return;
419 	}
420 
421 	if (ent->movetype == MOVETYPE_NOCLIP)
422 	{
423 		ent->movetype = MOVETYPE_WALK;
424 		msg = "noclip OFF\n";
425 	}
426 	else
427 	{
428 		ent->movetype = MOVETYPE_NOCLIP;
429 		msg = "noclip ON\n";
430 	}
431 
432 	gi.cprintf (ent, PRINT_HIGH, msg);
433 }
434 
435 
436 /*
437 ==================
438 Cmd_Use_f
439 
440 Use an inventory item
441 ==================
442 */
Cmd_Use_f(edict_t * ent)443 void Cmd_Use_f (edict_t *ent)
444 {
445 	int			index;
446 	gitem_t		*it;
447 	char		*s;
448 	char		*msg="";
449 	int			ismsg=0;
450 
451 	s = gi.args();
452 	it = FindItem (s);
453 
454 	if (ent->health<=0)
455 	{
456 		//gi.cprintf (ent, PRINT_HIGH, "You must be alive to use this command\n");
457 		return;
458 	}
459 	if (!it)
460 	{
461 		gi.cprintf (ent, PRINT_HIGH, "unknown item: %s\n", s);
462 		return;
463 	}
464 	if (!it->use)
465 	{
466 		gi.cprintf (ent, PRINT_HIGH, "Item is not usable.\n");
467 		return;
468 	}
469 	index = ITEM_INDEX(it);
470 	if (!ent->client->pers.inventory[index])
471 	{
472 		gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s);
473 		return;
474 	}
475 	if (ismsg==1)
476 		gi.cprintf (ent, PRINT_HIGH, msg);
477 
478 	it->use (ent, it);
479 }
480 
Cmd_Alt_Mode_f(edict_t * ent)481 void Cmd_Alt_Mode_f (edict_t *ent)
482 {
483 	char		*msg="";
484 	int			ismsg = 0;
485 	int			banned = sv_banned_weapons->value;
486 
487 	if (ent->health<=0)
488 	{
489 		//gi.cprintf (ent, PRINT_HIGH, "You must be alive to use this command\n");
490 		return;
491 	}
492 
493 	if (ent->client->aquasuit)
494 	{
495 		fireMagic(ent);
496 		return;
497 	}
498 
499 	ent->client->tazer = (ent->client->tazer) ? 10 : 0;
500 
501 	if (!Q_strcasecmp(ent->client->pers.weapon->pickup_name,"Grenade Launcher"))
502 	{
503 		if (ent->client->grn_set==0)
504 		{
505 			ent->client->grn_set=1;
506     		ent->client->grnl_set=0;
507 			ent->client->gren_set=2;
508 			msg = "Normal Gas Grenade Launcher\n";
509 		}
510 		else if (ent->client->grn_set==1)
511 		{
512 			ent->client->grn_set=2;
513     		ent->client->grnl_set=0;
514 			ent->client->gren_set=3;
515 			msg = "Normal Cluster Grenade Launcher\n";
516 		}
517 		else if (ent->client->grn_set==2)
518 		{
519 			ent->client->grn_set=3;
520     		ent->client->grnl_set=0;
521 			ent->client->gren_set=1;
522 			msg = "Normal Flashbang Launcher\n";
523 		}
524 		else if (ent->client->grn_set==3)
525 		{
526 			ent->client->grn_set=4;
527     		ent->client->grnl_set=1;
528 			ent->client->gren_set=0;
529 			msg = "Sticky Fragmentation Grenade Launcher\n";
530 		}
531 		else if (ent->client->grn_set==4)
532 		{
533 			ent->client->grn_set=5;
534     		ent->client->grnl_set=1;
535 			ent->client->gren_set=2;
536 			msg = "Sticky Gas Grenade Launcher\n";
537 		}
538 		else if (ent->client->grn_set==5)
539 		{
540 			ent->client->grn_set=6;
541     		ent->client->grnl_set=1;
542 			ent->client->gren_set=3;
543 			msg = "Sticky Cluster Grenade Launcher\n";
544 		}
545 		else if (ent->client->grn_set==6)
546 		{
547 			ent->client->grn_set=7;
548     		ent->client->grnl_set=1;
549 			ent->client->gren_set=1;
550 			msg = "Sticky Flashbang Launcher\n";
551 		}
552 		else
553 		{
554 			ent->client->grn_set=0;
555     		ent->client->grnl_set=0;
556 			ent->client->gren_set=0;
557 			msg = "Normal Fragmentation Grenade Launcher\n";
558 		}
559 
560 		ismsg = 1;
561 	}
562 
563 	if (!Q_strcasecmp(ent->client->pers.weapon->pickup_name,"Grenades"))
564 	{
565 		if (ent->client->gren_set==1)
566 		{
567     		ent->client->gren_set=0;
568 			msg = "Fragmentation Grenades\n";
569 		}
570 		else if (ent->client->gren_set==3)
571 		{
572 			ent->client->gren_set=1;
573 			msg = "Flashbangs\n";
574 		}
575 		else if (ent->client->gren_set==0)
576 		{
577 			ent->client->gren_set=2;
578 			msg = "Gas Grenades\n";
579 		}
580 		else
581 		{
582 			ent->client->gren_set=3;
583 			msg = "Cluster Grenades\n";
584 		}
585 
586 		ismsg = 1;
587 	}
588 
589 	if (!Q_strcasecmp(ent->client->pers.weapon->pickup_name,"Rocket Launcher"))
590 	{
591 		if (ent->client->rock_set==1)
592 		{
593     		ent->client->rock_set=0;
594 			msg = "Direct Fire Rockets\n";
595 		}
596 		else
597 		{
598 			ent->client->rock_set=1;
599 			msg = "Indirect Fire Rockets\n";
600 		}
601 
602 		ismsg = 1;
603 	}
604 
605 	if (!Q_strcasecmp(ent->client->pers.weapon->pickup_name,"Chaingun"))
606 	{
607 		if (ent->client->chan_set==1)
608 		{
609     		ent->client->chan_set=0;
610 			msg = "Minigun\n";
611 		}
612 		else
613 		{
614 			ent->client->chan_set=1;
615 			msg = "Roatary Shotgun\n";
616 		}
617 
618 		ismsg = 1;
619 	}
620 
621 	if (!Q_strcasecmp(ent->client->pers.weapon->pickup_name,"Shotgun"))
622 	{
623 		if (ent->client->shot_set==1)
624 		{
625     		ent->client->shot_set=0;
626 			msg = "Auto-Shotgun Shells\n";
627 		}
628 		else
629 		{
630 			ent->client->shot_set=1;
631 			msg = "Auto-Cannon Slugs\n";
632 		}
633 
634 		ismsg = 1;
635 	}
636 
637 	if (!Q_strcasecmp(ent->client->pers.weapon->pickup_name,"Super Shotgun"))
638 	{
639 		if (ent->client->shot_set==1)
640 		{
641     		ent->client->shot_set=0;
642 			msg = "Super Shotgun Shells\n";
643 		}
644 		else
645 		{
646 			ent->client->shot_set=1;
647 			msg = "Super Shotgun Slugs\n";
648 		}
649 
650 		ismsg = 1;
651 	}
652 
653 	if (!Q_strcasecmp(ent->client->pers.weapon->pickup_name,"Machinegun"))
654 	{
655 		if (ent->client->mach_set==1)
656 		{
657     		ent->client->mach_set=0;
658 			msg = "SubMachinegun Rapid Fire\n";
659 		}
660 		else
661 		{
662 			ent->client->mach_set=1;
663 			msg = "SubMachinegun Burst Fire\n";
664 		}
665 
666 		ismsg = 1;
667 	}
668 
669 	if (!Q_strcasecmp(ent->client->pers.weapon->pickup_name,"HyperBlaster"))
670 	{
671 		if (ent->client->hypr_set==1)
672 		{
673     		ent->client->hypr_set=0;
674 			ent->client->machinegun_shots=0;
675 			msg = "Flame Thrower\n";
676 		}
677 		else
678 		{
679 			ent->client->hypr_set=1;
680 			ent->client->machinegun_shots=0;
681 			msg = "Plasma Rifle\n";
682 		}
683 
684 		ismsg = 1;
685 	}
686 	if (!Q_strcasecmp(ent->client->pers.weapon->pickup_name,"Blaster"))
687 	{
688 		if (ent->client->blst_set==1)
689 		{
690     		ent->client->blst_set=0;
691 			ent->client->machinegun_shots=0;
692 			msg = ".50 Calibre Ammunition\n";
693 		}
694 		else
695 		{
696 			ent->client->blst_set=1;
697 			ent->client->machinegun_shots=0;
698 			msg = "Smack\n";
699 		}
700 		ismsg = 1;
701 	}
702 	if ((!sv_waterlevel->value)&&(!Q_strcasecmp(ent->client->pers.weapon->pickup_name,"Railgun")) )
703 	{
704 		if (ent->client->rail_set==1 && !(banned&NO_RAILGUN))
705 		{
706 			ent->client->rail_set=0;
707 			msg = ".50 Calibre Sniper Rifle\n";
708 		}
709 		else if (!sv_waterlevel->value && !(banned&NO_TAZER))
710 		{
711 			ent->client->rail_set=1;
712 			msg = "Tazer\n";
713 		}
714 
715 		ismsg = 1;
716 	}
717 	if (!Q_strcasecmp(ent->client->pers.weapon->pickup_name,"BFG10K"))
718 	{
719 		if (ent->client->bfg_set==2 && !(banned&NO_ROCKETBFG))
720 		{
721 			ent->client->bfg_set=0;
722 			msg = "Nuke Launcher Operational\n";
723 		}
724 //		else if (ent->client->bfg_set==0)
725 //		{
726 //			ent->client->bfg_set=1;
727 //			msg = "Guided Nuke Launcher Operational\n";
728 //		}
729 		else if (!(banned&NO_BFGLASER))
730 		{
731     		ent->client->bfg_set=2;
732 			msg = "Heavy Laser Operational\n";
733 		}
734 
735 		ismsg = 1;
736 	}
737 
738 	if (ismsg)
739 		gi.cprintf (ent, PRINT_HIGH, msg);
740 }
741 
742 /*
743 ==================
744 Cmd_Drop_f
745 
746 Drop an inventory item
747 ==================
748 */
Cmd_Drop_f(edict_t * ent)749 void Cmd_Drop_f (edict_t *ent)
750 {
751 	int			index;
752 	gitem_t		*it;
753 	char		*s;
754 
755 	if (ent->health<=0)
756 	{
757 		//gi.cprintf (ent, PRINT_HIGH, "You must be alive to use this command\n");
758 		return;
759 	}
760 
761 	s = gi.args();
762 	it = FindItem (s);
763 	if (!it)
764 	{
765 		gi.cprintf (ent, PRINT_HIGH, "unknown item: %s\n", s);
766 		return;
767 	}
768 	if (!it->drop)
769 	{
770 		gi.cprintf (ent, PRINT_HIGH, "Item is not dropable.\n");
771 		return;
772 	}
773 	index = ITEM_INDEX(it);
774 	if (!ent->client->pers.inventory[index])
775 	{
776 		gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s);
777 		return;
778 	}
779 	if (ent->client->kami==666)
780 		if (!Q_strcasecmp(it->classname, "C-4 Explosive"))
781 		{
782 			gi.cprintf (ent, PRINT_HIGH, "Cannot drop C-4 once armed\n");
783 			return;
784 		}
785 
786 	it->drop (ent, it);
787 
788 	ValidateSelectedItem (ent);
789 }
790 
791 /*
792 ==================
793 Cmd_WeapDrop_f
794 
795 Drop an inventory item
796 ==================
797 */
Cmd_WeapDrop_f(edict_t * ent)798 void Cmd_WeapDrop_f (edict_t *ent)
799 {
800 	int			index;
801 	gitem_t		*it;
802 
803 	if (ent->health<=0)
804 	{
805 		//gi.cprintf (ent, PRINT_HIGH, "You must be alive to use this command\n");
806 		return;
807 	}
808 
809 	it = ent->client->pers.weapon;
810 	if (!it)
811 	{
812 		gi.cprintf (ent, PRINT_HIGH, "Weapon is unavailable.\n");
813 		return;
814 	}
815 	if (!it->drop)
816 	{
817 		gi.cprintf (ent, PRINT_HIGH, "Weapon is not dropable.\n");
818 		return;
819 	}
820 
821 	index = ITEM_INDEX(it);
822 
823 	it->drop (ent, it);
824 
825 	ValidateSelectedItem (ent);
826 }
827 
828 /*
829 =================
830 Cmd_Inven_f
831 =================
832 */
Cmd_Inven_f(edict_t * ent)833 void Cmd_Inven_f (edict_t *ent)
834 {
835 	//*
836 	int			i;
837 	gclient_t	*cl;
838 
839 	cl = ent->client;
840 
841 	cl->showscores = false;
842 	cl->showhelp = false;
843 
844 	if (cl->showinventory)
845 	{
846 		cl->showinventory = false;
847 		return;
848 	}
849 
850 	cl->showinventory = true;
851 
852 	gi.WriteByte (svc_inventory);
853 	for (i=0 ; i<MAX_ITEMS ; i++)
854 	{
855 		gi.WriteShort (cl->pers.inventory[i]);
856 	}
857 	gi.unicast (ent, true);
858 }
859 
860 /*
861 =================
862 Cmd_InvUse_f
863 =================
864 */
Cmd_InvUse_f(edict_t * ent)865 void Cmd_InvUse_f (edict_t *ent)
866 {
867 	gitem_t		*it;
868 
869 	if (ent->health<=0)
870 	{
871 		//gi.cprintf (ent, PRINT_HIGH, "You must be alive to use this command\n");
872 		return;
873 	}
874 
875 	ValidateSelectedItem (ent);
876 
877 	if (ent->client->pers.selected_item == -1)
878 	{
879 		gi.cprintf (ent, PRINT_HIGH, "No item to use.\n");
880 		return;
881 	}
882 
883 	it = &itemlist[ent->client->pers.selected_item];
884 	if (!it->use)
885 	{
886 		gi.cprintf (ent, PRINT_HIGH, "Item is not usable.\n");
887 		return;
888 	}
889 	it->use (ent, it);
890 }
891 
892 /*
893 =================
894 Cmd_WeapPrev_f
895 =================
896 */
Cmd_WeapPrev_f(edict_t * ent)897 void Cmd_WeapPrev_f (edict_t *ent)
898 {
899 	gclient_t	*cl;
900 	int			i, index;
901 	gitem_t		*it;
902 	int			selected_weapon;
903 
904 	if (ent->health<=0)
905 	{
906 		//gi.cprintf (ent, PRINT_HIGH, "You must be alive to use this command\n");
907 		return;
908 	}
909 
910 	if (ent->client->aquasuit)
911 		return;
912 
913 	if (!Q_strcasecmp(ent->client->pers.weapon->pickup_name,"Railgun"))
914 		ent->client->ps.fov=(ent->client->old_fov>30)?ent->client->old_fov:90;
915 
916 	cl = ent->client;
917 
918 	if (!cl->pers.weapon)
919 		return;
920 
921 	selected_weapon = ITEM_INDEX(cl->pers.weapon);
922 
923 	// scan  for the next valid one
924 	for (i=1 ; i<=MAX_ITEMS ; i++)
925 	{
926 		index = (selected_weapon + i)%MAX_ITEMS;
927 		if (!cl->pers.inventory[index])
928 			continue;
929 		it = &itemlist[index];
930 		if (!it->use)
931 			continue;
932 		if (! (it->flags & IT_WEAPON) )
933 			continue;
934 		it->use (ent, it);
935 		if (cl->pers.weapon == it)
936 			return;	// successful
937 	}
938 }
939 
940 /*
941 =================
942 Cmd_WeapNext_f
943 =================
944 */
Cmd_WeapNext_f(edict_t * ent)945 void Cmd_WeapNext_f (edict_t *ent)
946 {
947 	gclient_t	*cl;
948 	int			i, index;
949 	gitem_t		*it;
950 	int			selected_weapon;
951 
952 	if (ent->health<=0)
953 	{
954 		//gi.cprintf (ent, PRINT_HIGH, "You must be alive to use this command\n");
955 		return;
956 	}
957 
958 	if (ent->client->aquasuit)
959 		return;
960 
961 	if (!Q_strcasecmp(ent->client->pers.weapon->pickup_name,"Railgun"))
962 		ent->client->ps.fov=(ent->client->old_fov>30)?ent->client->old_fov:90;
963 
964 	cl = ent->client;
965 
966 	if (!cl->pers.weapon)
967 		return;
968 
969 	selected_weapon = ITEM_INDEX(cl->pers.weapon);
970 
971 	// scan  for the next valid one
972 	for (i=1 ; i<=MAX_ITEMS ; i++)
973 	{
974 		index = (selected_weapon + MAX_ITEMS - i)%MAX_ITEMS;
975 		if (!cl->pers.inventory[index])
976 			continue;
977 		it = &itemlist[index];
978 		if (!it->use)
979 			continue;
980 		if (! (it->flags & IT_WEAPON) )
981 			continue;
982 		it->use (ent, it);
983 		if (cl->pers.weapon == it)
984 			return;	// successful
985 	}
986 }
987 
988 /*
989 =================
990 Cmd_WeapLast_f
991 =================
992 */
Cmd_WeapLast_f(edict_t * ent)993 void Cmd_WeapLast_f (edict_t *ent)
994 {
995 	gclient_t	*cl;
996 	int			index;
997 	gitem_t		*it;
998 
999 	if (ent->health<=0)
1000 	{
1001 		//gi.cprintf (ent, PRINT_HIGH, "You must be alive to use this command\n");
1002 		return;
1003 	}
1004 
1005 	cl = ent->client;
1006 
1007 	if (!cl->pers.weapon || !cl->pers.lastweapon)
1008 		return;
1009 
1010 	index = ITEM_INDEX(cl->pers.lastweapon);
1011 	if (!cl->pers.inventory[index])
1012 		return;
1013 	it = &itemlist[index];
1014 	if (!it->use)
1015 		return;
1016 	if (! (it->flags & IT_WEAPON) )
1017 		return;
1018 	it->use (ent, it);
1019 }
1020 
1021 /*
1022 =================
1023 Cmd_InvDrop_f
1024 =================
1025 */
Cmd_InvDrop_f(edict_t * ent)1026 void Cmd_InvDrop_f (edict_t *ent)
1027 {
1028 	gitem_t		*it;
1029 
1030 	if (ent->health<=0)
1031 	{
1032 		//gi.cprintf (ent, PRINT_HIGH, "You must be alive to use this command\n");
1033 		return;
1034 	}
1035 
1036 	ValidateSelectedItem (ent);
1037 
1038 	if (ent->client->pers.selected_item == -1)
1039 	{
1040 		gi.cprintf (ent, PRINT_HIGH, "No item to drop.\n");
1041 		return;
1042 	}
1043 
1044 	it = &itemlist[ent->client->pers.selected_item];
1045 	if (!it->drop)
1046 	{
1047 		gi.cprintf (ent, PRINT_HIGH, "Item is not dropable.\n");
1048 		return;
1049 	}
1050 	if (ent->client->kami==666)
1051 		if (!Q_strcasecmp(it->classname, "item_quad"))
1052 		{
1053 			gi.cprintf (ent, PRINT_HIGH, "Cannot drop C-4 once armed\n");
1054 			return;
1055 		}
1056 
1057 	it->drop (ent, it);
1058 
1059 	ValidateSelectedItem (ent);
1060 }
1061 
1062 /*
1063 =================
1064 Cmd_Kill_f
1065 =================
1066 */
Cmd_Kill_f(edict_t * ent)1067 void Cmd_Kill_f (edict_t *ent)
1068 {
1069 	if (ent->health<=0)
1070 	{
1071 		//gi.cprintf (ent, PRINT_HIGH, "You must be alive to use this command\n");
1072 		return;
1073 	}
1074 
1075 	if((level.time - ent->client->respawn_time) < 1)
1076 		return;
1077 
1078 	if (ent->client->pers.inventory[ITEM_INDEX(FindItem("C-4 Explosive"))])
1079 	{
1080 		if (ent->client->kami!=666)
1081 		{
1082 			ent->client->pers.inventory[ITEM_INDEX(FindItem("C-4 Explosive"))]--;
1083 			ValidateSelectedItem (ent);
1084 			gi.cprintf (ent, PRINT_HIGH, "C4 Armed - Detonate at will.\n");
1085 			gi.sound (ent, CHAN_WEAPON, gi.soundindex("weapons/railgr1a.wav"), 1, ATTN_NORM, 0);
1086 			ent->client->kami=666;
1087 			return;
1088 		}
1089 	}
1090 
1091 	ent->flags &= ~FL_GODMODE;
1092 	ent->health = 0;
1093 	meansOfDeath = MOD_SUICIDE;
1094 	//ent->health=-500;
1095 	player_die (ent, ent, ent, 100000, vec3_origin);
1096 }
1097 
1098 /*
1099 =================
1100 Cmd_PutAway_f
1101 =================
1102 */
Cmd_PutAway_f(edict_t * ent)1103 void Cmd_PutAway_f (edict_t *ent)
1104 {
1105 	ent->client->showscores = false;
1106 	ent->client->showhelp = false;
1107 	ent->client->showinventory = false;
1108 }
1109 
1110 
PlayerSort(void const * a,void const * b)1111 int PlayerSort (void const *a, void const *b)
1112 {
1113 	int		anum, bnum;
1114 
1115 	anum = *(int *)a;
1116 	bnum = *(int *)b;
1117 
1118 	anum = game.clients[anum].ps.stats[STAT_FRAGS];
1119 	bnum = game.clients[bnum].ps.stats[STAT_FRAGS];
1120 
1121 	if (anum < bnum)
1122 		return -1;
1123 	if (anum > bnum)
1124 		return 1;
1125 	return 0;
1126 }
1127 
1128 /*
1129 =================
1130 Cmd_Players_f
1131 =================
1132 */
Cmd_Players_f(edict_t * ent)1133 void Cmd_Players_f (edict_t *ent)
1134 {
1135 	int		i;
1136 	int		count;
1137 	char	small[64];
1138 	char	large[1280];
1139 	int		index[256];
1140 
1141 	count = 0;
1142 	for (i = 0 ; i < maxclients->value ; i++)
1143 		if (game.clients[i].pers.connected)
1144 		{
1145 			index[count] = i;
1146 			count++;
1147 		}
1148 
1149 	// sort by frags
1150 	qsort (index, count, sizeof(index[0]), PlayerSort);
1151 
1152 	// print information
1153 	large[0] = 0;
1154 
1155 	for (i = 0 ; i < count ; i++)
1156 	{
1157 		Com_sprintf (small, sizeof(small), "%3i %s\n",
1158 			game.clients[index[i]].ps.stats[STAT_FRAGS],
1159 			game.clients[index[i]].pers.netname);
1160 		if (strlen (small) + strlen(large) > sizeof(large) - 100 )
1161 		{	// can't print all of them in one packet
1162 			strcat (large, "...\n");
1163 			break;
1164 		}
1165 		strcat (large, small);
1166 	}
1167 
1168 	gi.cprintf (ent, PRINT_HIGH, "%s\n%i players\n", large, count);
1169 }
1170 
1171 /*
1172 =================
1173 Cmd_Wave_f
1174 =================
1175 */
Cmd_Wave_f(edict_t * ent)1176 void Cmd_Wave_f (edict_t *ent)
1177 {
1178 	int		i;
1179 
1180 	if (ent->health<=0)
1181 	{
1182 		//gi.cprintf (ent, PRINT_HIGH, "You must be alive to use this command\n");
1183 		return;
1184 	}
1185 
1186 	i = atoi (gi.argv(1));
1187 
1188 	// can't wave when ducked
1189 	if (ent->client->ps.pmove.pm_flags & PMF_DUCKED)
1190 		return;
1191 
1192 	if (ent->client->anim_priority > ANIM_WAVE)
1193 		return;
1194 
1195 	ent->client->anim_priority = ANIM_WAVE;
1196 
1197 	switch (i)
1198 	{
1199 	case 0:
1200 		gi.cprintf (ent, PRINT_HIGH, "flipoff\n");
1201 		ent->s.frame = FRAME_flip01-1;
1202 		ent->client->anim_end = FRAME_flip12;
1203 		break;
1204 	case 1:
1205 		gi.cprintf (ent, PRINT_HIGH, "salute\n");
1206 		ent->s.frame = FRAME_salute01-1;
1207 		ent->client->anim_end = FRAME_salute11;
1208 		break;
1209 	case 2:
1210 		gi.cprintf (ent, PRINT_HIGH, "taunt\n");
1211 		ent->s.frame = FRAME_taunt01-1;
1212 		ent->client->anim_end = FRAME_taunt17;
1213 		break;
1214 	case 3:
1215 		gi.cprintf (ent, PRINT_HIGH, "wave\n");
1216 		ent->s.frame = FRAME_wave01-1;
1217 		ent->client->anim_end = FRAME_wave11;
1218 		break;
1219 	case 4:
1220 	default:
1221 		gi.cprintf (ent, PRINT_HIGH, "point\n");
1222 		ent->s.frame = FRAME_point01-1;
1223 		ent->client->anim_end = FRAME_point12;
1224 		break;
1225 	}
1226 }
1227 
1228 /*
1229 ==================
1230 Cmd_Say_f
1231 ==================
1232 */
ChatBlocked(edict_t * ent,edict_t * other)1233 qboolean ChatBlocked(edict_t *ent, edict_t *other)
1234 {
1235 	int i=0;
1236 	while (other->blockedChat[i])
1237 	{
1238 		if (other->blockedChat[i]==ent)
1239 			return true;
1240 		i++;
1241 	}
1242 	return false;
1243 }
Cmd_Say_f(edict_t * ent,qboolean team,qboolean arg0)1244 void Cmd_Say_f (edict_t *ent, qboolean team, qboolean arg0)
1245 {
1246 	int		i, j;
1247 	edict_t	*other;
1248 	char	*p;
1249 	char	text[2048];
1250 	gclient_t *cl;
1251 
1252 	if (gi.argc () < 2 && !arg0)
1253 		return;
1254 
1255 	if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS))&&!(sv_teams->value&&deathmatch->value))
1256 		team = false;
1257 
1258 	if ((team)&&!(sv_teams->value&&deathmatch->value))
1259 		Com_sprintf (text, sizeof(text), "(%s)%s ", make_green(ent->client->pers.netname),make_green(":") );
1260 	else if (sv_teams->value&&deathmatch->value)
1261 	{
1262 		char	teamname[12];
1263 		teamname[0] = 0;
1264 		if (ent->TeamName)
1265 		{
1266 			switch (ent->TeamName)
1267 			{
1268 				case 1:
1269 					Com_sprintf (teamname, sizeof(teamname), "Red");
1270 					break;
1271 				case 2:
1272 					Com_sprintf (teamname, sizeof(teamname),"Gold");
1273 					break;
1274 				case 3:
1275 					Com_sprintf (teamname, sizeof(teamname),"Violet");
1276 					break;
1277 				case 4:
1278 					Com_sprintf (teamname, sizeof(teamname),"Blue");
1279 					break;
1280 				case 5:
1281 					Com_sprintf (teamname, sizeof(teamname),"Turquoise");
1282 					break;
1283 				case 6:
1284 					Com_sprintf (teamname, sizeof(teamname),"Green");
1285 					break;
1286 				case 7:
1287 					Com_sprintf (teamname, sizeof(teamname),"White");
1288 					break;
1289 				default:
1290 					Com_sprintf (teamname, sizeof(teamname),"Solo");
1291 					break;
1292 			}
1293 		} else
1294 			Com_sprintf (teamname, sizeof(teamname),"Solo");
1295 
1296 		Com_sprintf (text, sizeof(text), "%s%s%s%s%s%s ", make_green("("),
1297 			(ent->deadflag == DEAD_DEAD)? "Dead-" : "",
1298 			teamname, make_green(")"), make_green(ent->client->pers.netname),make_green(":") );
1299 	}
1300 	else
1301 		Com_sprintf (text, sizeof(text), "%s%s%s%s%s  ",
1302 		(ent->deadflag == DEAD_DEAD)? make_green("(") : "",
1303 		(ent->deadflag == DEAD_DEAD)? "Dead" : "",
1304 		(ent->deadflag == DEAD_DEAD)? make_green(")") : "",
1305 		make_green(ent->client->pers.netname),make_green(":") );
1306 
1307 	if (arg0)
1308 	{
1309 		strcat (text, gi.argv(0));
1310 		strcat (text, " ");
1311 		strcat (text, gi.args());
1312 	}
1313 	else
1314 	{
1315 		p = gi.args();
1316 
1317 		if (*p == '"')
1318 		{
1319 			p++;
1320 			p[strlen(p)-1] = 0;
1321 		}
1322 		strcat(text, p);
1323 	}
1324 
1325 	// don't let text be too long for malicious reasons
1326 	if (strlen(text) > 150)
1327 
1328 	text[150] = 0;
1329 
1330 	strcat(text, "\n");
1331 
1332 	for (j = 1; j <= game.maxclients; j++)
1333 	{
1334 		other = &g_edicts[j];
1335 		if (!other->inuse)
1336 			continue;
1337 		if (!other->client)
1338 			continue;
1339 		if (ent->blockedChat)
1340 		{
1341 			if (ChatBlocked(ent, other))
1342 				continue;
1343 		}
1344 		if (team)
1345 		{
1346 			if (!OnSameTeam(ent, other))
1347 				continue;
1348 		}
1349 		if ((ent->deadflag == DEAD_DEAD)&&sv_teams->value&&deathmatch->value)
1350 		{
1351 			if (other->deadflag!=DEAD_DEAD)
1352 				continue;
1353 		}
1354 
1355 		if (sv_chatdistance->value)
1356 		{
1357 			char	scrambled[2048];
1358 			vec3_t	distance;
1359 			scrambled[0] = 0;
1360 
1361 			VectorSubtract (ent->s.origin, other->s.origin, distance);
1362 			if (!(VectorLength(distance)<sv_chatdistance->value && CanDamage (other, ent))
1363 				|| (ent->health<=0&&other->health>0))
1364 				continue;
1365 		}
1366 
1367 		gi.cprintf(other, PRINT_CHAT, "");
1368 		gi.cprintf(other, PRINT_HIGH, "%s", text);
1369 
1370 	}
1371 	if (dedicated->value)
1372 		gi.cprintf(NULL, PRINT_CHAT, "%s", make_white(text));
1373 	make_white(ent->client->pers.netname);
1374 }
1375 
Cmd_PlayerList_f(edict_t * ent)1376 void Cmd_PlayerList_f(edict_t *ent)
1377 {
1378 	int i;
1379 	char st[80];
1380 	char text[1400];
1381 	edict_t *e2;
1382 
1383 	// connect time, ping, headshots/score, name
1384 	*text = 0;
1385 	for (i = 0, e2 = g_edicts + 1; i < maxclients->value; i++, e2++) {
1386 		if (!e2->inuse)
1387 			continue;
1388 
1389 		Com_sprintf(st, sizeof(st), "%02d:%02d %4d %3d %s%s\n",
1390 			(level.framenum - e2->client->resp.enterframe) / 600,
1391 			((level.framenum - e2->client->resp.enterframe) % 600)/10,
1392 			e2->client->ping,
1393 			e2->client->resp.score,
1394 			e2->client->pers.netname,
1395 			e2->client->resp.spectator ? " (spectator)" : "");
1396 		if (strlen(text) + strlen(st) > sizeof(text) - 50) {
1397 			sprintf(text+strlen(text), "And more...\n");
1398 			gi.cprintf(ent, PRINT_HIGH, "%s", text);
1399 			return;
1400 		}
1401 		strcat(text, st);
1402 	}
1403 	gi.cprintf(ent, PRINT_HIGH, "%s", text);
1404 }
1405 
Cmd_Info_f(edict_t * ent)1406 void Cmd_Info_f (edict_t *ent)
1407 {
1408 	gi.cprintf(ent, PRINT_HIGH, "\n\n-------------------------------\n");
1409 	gi.cprintf(ent, PRINT_HIGH, make_green("PsychoMod Help"));
1410 	gi.cprintf(ent, PRINT_HIGH, "\nListed Below are Binds and Vars\n");
1411 	gi.cprintf(ent, PRINT_HIGH, "-------------------------------\n\n");
1412 	gi.cprintf(ent, PRINT_HIGH, " > ");
1413 	gi.cprintf(ent, PRINT_HIGH, make_green("bind "));
1414 	gi.cprintf(ent, PRINT_HIGH, "\"key\" \"firemode\"\n");
1415 	gi.cprintf(ent, PRINT_HIGH, " > ");
1416 	gi.cprintf(ent, PRINT_HIGH, make_green("bind "));
1417 	gi.cprintf(ent, PRINT_HIGH, "\"key\" \"thirdperson\"\n");
1418 	gi.cprintf(ent, PRINT_HIGH, " > ");
1419 	gi.cprintf(ent, PRINT_HIGH, make_green("bind "));
1420 	gi.cprintf(ent, PRINT_HIGH, "\"key\" \"use grapple\"\n");
1421 	gi.cprintf(ent, PRINT_HIGH, " > ");
1422 	gi.cprintf(ent, PRINT_HIGH, make_green("bind "));
1423 	gi.cprintf(ent, PRINT_HIGH, "\"key\" \"jetpack\"\n");
1424 	gi.cprintf(ent, PRINT_HIGH, " > ");
1425 	gi.cprintf(ent, PRINT_HIGH, make_green("bind "));
1426 	gi.cprintf(ent, PRINT_HIGH, "\"key\" \"+hook\"\n");
1427 	gi.cprintf(ent, PRINT_HIGH, " > ");
1428 	gi.cprintf(ent, PRINT_HIGH, make_green("bind "));
1429 	gi.cprintf(ent, PRINT_HIGH, "\"key\" \"+stunt\"\n");
1430 	gi.cprintf(ent, PRINT_HIGH, " > ");
1431 	gi.cprintf(ent, PRINT_HIGH, make_green("bind "));
1432 	gi.cprintf(ent, PRINT_HIGH, "\"key\" \"+zoom\"\n");
1433 	gi.cprintf(ent, PRINT_HIGH, " > ");
1434 	gi.cprintf(ent, PRINT_HIGH, make_green("bind "));
1435 	gi.cprintf(ent, PRINT_HIGH, "\"key\" \"+use\"\n\n");
1436 
1437 
1438 	gi.cprintf(ent, PRINT_HIGH, " > ");
1439 	gi.cprintf(ent, PRINT_HIGH, make_green("ID "));
1440 	gi.cprintf(ent, PRINT_HIGH, "\n");
1441 	gi.cprintf(ent, PRINT_HIGH, " > ");
1442 	gi.cprintf(ent, PRINT_HIGH, make_green("ViewCam "));
1443 	gi.cprintf(ent, PRINT_HIGH, "\n");
1444 	gi.cprintf(ent, PRINT_HIGH, " > ");
1445 	gi.cprintf(ent, PRINT_HIGH, make_green("Block "));
1446 	gi.cprintf(ent, PRINT_HIGH, "\"ClientName\"\n");
1447 	gi.cprintf(ent, PRINT_HIGH, " > ");
1448 	gi.cprintf(ent, PRINT_HIGH, make_green("UnBlock "));
1449 	gi.cprintf(ent, PRINT_HIGH, "\"ClientName\"\n");
1450 	gi.cprintf(ent, PRINT_HIGH, " > ");
1451 	gi.cprintf(ent, PRINT_HIGH, make_green("UnBlock "));
1452 	gi.cprintf(ent, PRINT_HIGH, "\"all\"\n");
1453 	gi.cprintf(ent, PRINT_HIGH, " > ");
1454 	gi.cprintf(ent, PRINT_HIGH, make_green("Team "));
1455 	gi.cprintf(ent, PRINT_HIGH, "\"1-6\"\n");
1456 	gi.cprintf(ent, PRINT_HIGH, " > ");
1457 	gi.cprintf(ent, PRINT_HIGH, make_green("BFGColor "));
1458 	gi.cprintf(ent, PRINT_HIGH, "\"0-2\"\n");
1459 	gi.cprintf(ent, PRINT_HIGH, " > ");
1460 	gi.cprintf(ent, PRINT_HIGH, make_green("GrappleType "));
1461 	gi.cprintf(ent, PRINT_HIGH, "\"0-1\" \"0-1\"\n");
1462 	gi.cprintf(ent, PRINT_HIGH, "\n-------------------------------\n\n");
1463 }
1464 
Cmd_InfoSV_f(edict_t * ent)1465 void Cmd_InfoSV_f (edict_t *ent)
1466 {
1467 
1468 	gi.cprintf(ent, PRINT_HIGH, "\n\n-------------------------------\n");
1469 	gi.cprintf(ent, PRINT_HIGH, make_green("PsychoMod Server Help"));
1470 	gi.cprintf(ent, PRINT_HIGH, "\nListed Below are Server Cmds\n");
1471 	gi.cprintf(ent, PRINT_HIGH, "-------------------------------\n\n");
1472 	gi.cprintf(ent, PRINT_HIGH, " > ");
1473 	gi.cprintf(ent, PRINT_HIGH, make_green("sv cheats "));
1474 	gi.cprintf(ent, PRINT_HIGH, "\"0 or 1\"\n");
1475 	gi.cprintf(ent, PRINT_HIGH, " > ");
1476 	gi.cprintf(ent, PRINT_HIGH, make_green("sv teams "));
1477 	gi.cprintf(ent, PRINT_HIGH, "\"0 or 1 or 'lock' or 'unlock'\"\n");
1478 	gi.cprintf(ent, PRINT_HIGH, " > ");
1479 	gi.cprintf(ent, PRINT_HIGH, make_green("sv tracers "));
1480 	gi.cprintf(ent, PRINT_HIGH, "\"amount\"\n");
1481 	gi.cprintf(ent, PRINT_HIGH, " > ");
1482 	gi.cprintf(ent, PRINT_HIGH, make_green("sv bulletmarks "));
1483 	gi.cprintf(ent, PRINT_HIGH, "\"amount\"\n");
1484 	gi.cprintf(ent, PRINT_HIGH, " > ");
1485 	gi.cprintf(ent, PRINT_HIGH, make_green("sv spawn "));
1486 	gi.cprintf(ent, PRINT_HIGH, "\"monster name\"\n");
1487 	gi.cprintf(ent, PRINT_HIGH, "\n-------------------------------\n\n");
1488 }
1489 
Cmd_BFG_Color_f(edict_t * ent)1490 void Cmd_BFG_Color_f (edict_t *ent)
1491 {
1492 	char		*name;
1493 
1494 
1495 	name = gi.args();
1496 
1497 	if ((Q_stricmp(name, "red") == 0) || (Q_stricmp(name, "1") == 0))
1498 	{
1499 		ent->bfg_laser_type=BFG_LASER_RED;
1500 		if (ent->configed)
1501 			gi.cprintf(ent, PRINT_HIGH, "\n- Red BFG Laser -\n\n");
1502 	}
1503 	else if  ((Q_stricmp(name, "blue") == 0) || (Q_stricmp(name, "0") == 0))
1504 	{
1505 		ent->bfg_laser_type=BFG_LASER_BLUE;
1506 		if (ent->configed)
1507 			gi.cprintf(ent, PRINT_HIGH, "\n- Blue BFG Laser -\n\n");
1508 	}
1509 	else
1510 	{
1511 		ent->bfg_laser_type=BFG_LASER_GREEN;
1512 		if (ent->configed)
1513 			gi.cprintf(ent, PRINT_HIGH, "\n- Green BFG Laser -\n\n");
1514 	}
1515 }
1516 
Cmd_Grapple_Type_f(edict_t * ent)1517 void Cmd_Grapple_Type_f (edict_t *ent)
1518 {
1519 	char		*name, *name2;
1520 	name = gi.argv(2);
1521 	name2 = gi.argv(1);
1522 
1523 	if (gi.argc() >= 2)
1524 	{
1525 		gi.cprintf(ent, PRINT_HIGH, "\n");
1526 		if (Q_stricmp(name2, "1") == 0)
1527 		{
1528 			ent->grappleType=GRAPPLE_LASER;
1529 			if (ent->configed)
1530 				gi.cprintf(ent, PRINT_HIGH, "- Laser Type - ");
1531 		}
1532 	/*	else if (Q_stricmp(name2, "2") == 0) // Lag Maker...
1533 		{
1534 			ent->grappleType=GRAPPLE_CHAIN;
1535 			gi.cprintf(ent, PRINT_HIGH, "- Chain Type - ");
1536 		}*/
1537 		else if (Q_stricmp(name2, "100") == 0)
1538 		{
1539 			ent->grappleType=GRAPPLE_SHIP1;
1540 			if (ent->configed)
1541 				gi.cprintf(ent, PRINT_HIGH, "- Strogg Type - ");
1542 		}
1543 		else if (Q_stricmp(name2, "101") == 0)
1544 		{
1545 			ent->grappleType=GRAPPLE_SHIP2;
1546 			if (ent->configed)
1547 				gi.cprintf(ent, PRINT_HIGH, "- Viper Type - ");
1548 		}
1549 		else
1550 		{
1551 			ent->grappleType=GRAPPLE_ROPE;
1552 			if (ent->configed)
1553 				gi.cprintf(ent, PRINT_HIGH, "- Rope Type - ");
1554 		}
1555 
1556 		if (gi.argc() >= 3)
1557 		{
1558 			if (Q_stricmp(name, "2") == 0)
1559 			{
1560 				ent->grapple=ROPE_GRAPPLE;
1561 				if (ent->configed)
1562 					gi.cprintf(ent, PRINT_HIGH, "Rope Grapple -\n");
1563 			}
1564 			else if (Q_stricmp(name, "1") == 0)
1565 			{
1566 				ent->grapple=LITHIUM_GRAPPLE;
1567 				if (ent->configed)
1568 					gi.cprintf(ent, PRINT_HIGH, "Lithium Grapple -\n");
1569 			}
1570 			else
1571 			{
1572 				ent->grapple=PSYCHOMOD_GRAPPLE;
1573 				if (ent->configed)
1574 					gi.cprintf(ent, PRINT_HIGH, "Psychomod Grapple -\n");
1575 			}
1576 		}
1577 		else if (ent->configed)
1578 			gi.cprintf(ent, PRINT_HIGH, "\n");
1579 
1580 		if (ent->configed)
1581 			gi.cprintf(ent, PRINT_HIGH, "\n");
1582 	}
1583 	else if (ent->configed)
1584 		gi.cprintf(ent, PRINT_HIGH, "Invalid Arguments\n");
1585 
1586 
1587 	//	ent->client->pers.inventory[index] = atoi(gi.argv(2));
1588 	/*
1589 	#define ROPE 2
1590 	#define LITHIUM 1
1591 	#define PSYCHOMOD 0
1592 	*/
1593 }
1594 
Cmd_ViewCam_Type_f(edict_t * ent)1595 void Cmd_ViewCam_Type_f (edict_t *ent)
1596 {
1597 	if (ent->viewcam_on)
1598 		ent->viewcam_on = 0;
1599 	else if (ent->viewcam_on==0)
1600 		ent->viewcam_on = 1;
1601 
1602 	gi.cprintf(ent, PRINT_HIGH, "View Cam %s\n", (ent->viewcam_on==0)? "OFF" : "ON");
1603 }
1604 
Cmd_ID_f(edict_t * ent)1605 void Cmd_ID_f (edict_t *ent)
1606 {
1607 	if (ent->Player_ID)
1608 	{
1609 		ent->Player_ID= 0;
1610 		if (ent->configed)
1611 			gi.cprintf(ent, PRINT_HIGH, "Client ID Off\n");
1612 	}
1613 	else
1614 	{
1615 		ent->Player_ID=1;
1616 		if (ent->configed)
1617 			gi.cprintf(ent, PRINT_HIGH, "Client ID On\n");
1618 	}
1619 }
1620 
Cmd_Team_f(edict_t * ent)1621 void Cmd_Team_f (edict_t *ent)
1622 {
1623 	if (sv_teams_locked->value)
1624 	{
1625 		gi.cprintf(ent, PRINT_HIGH, "Teams are Locked.\n", ent->TeamName);
1626 		return;
1627 	}
1628 
1629 	if (gi.argc() > 1)
1630 	{
1631 		if ( atoi(gi.argv(1))>=0 && atoi(gi.argv(1))<=7 )
1632 		{
1633 			ent->TeamName=atoi (gi.argv(1));
1634 			switch (ent->TeamName)
1635 			{
1636 				case 1:
1637 					gi.cprintf(ent, PRINT_HIGH, "You have now joined the \"%s\" team.\n",
1638 							make_white("Red"));
1639 					break;
1640 				case 2:
1641 					gi.cprintf(ent, PRINT_HIGH, "You have now joined the \"%s\" team.\n",
1642 							make_white("Gold"));
1643 					break;
1644 				case 3:
1645 					gi.cprintf(ent, PRINT_HIGH, "You have now joined the \"%s\" team.\n",
1646 							make_white("Violet"));
1647 					break;
1648 				case 4:
1649 					gi.cprintf(ent, PRINT_HIGH, "You have now joined the \"%s\" team.\n",
1650 							make_white("Blue"));
1651 					break;
1652 				case 5:
1653 					gi.cprintf(ent, PRINT_HIGH, "You have now joined the \"%s\" team.\n",
1654 							make_white("Turquoise"));
1655 					break;
1656 				case 6:
1657 					gi.cprintf(ent, PRINT_HIGH, "You have now joined the \"%s\" team.\n",
1658 							make_white("Green"));
1659 					break;
1660 				case 7:
1661 					gi.cprintf(ent, PRINT_HIGH, "You have now joined the \"%s\" team.\n",
1662 							make_white("White"));
1663 					break;
1664 				case 0:
1665 					gi.cprintf(ent, PRINT_HIGH, "You have now joined the \"%s\" team.\n",
1666 							make_white("Solo"));
1667 					break;
1668 			}
1669 		}
1670 		else
1671 			gi.cprintf(ent, PRINT_HIGH, "Invalid Arguments\n");
1672 	}
1673 	else
1674 		switch (ent->TeamName)
1675 			{
1676 				case 1:
1677 					gi.cprintf(ent, PRINT_HIGH, "You are on the \"%s\" team.\n",
1678 							make_white("Red"));
1679 					break;
1680 				case 2:
1681 					gi.cprintf(ent, PRINT_HIGH, "You are on the \"%s\" team.\n",
1682 							make_white("Gold"));
1683 					break;
1684 				case 3:
1685 					gi.cprintf(ent, PRINT_HIGH, "You are on the \"%s\" team.\n",
1686 							make_white("Violet"));
1687 					break;
1688 				case 4:
1689 					gi.cprintf(ent, PRINT_HIGH, "You are on the \"%s\" team.\n",
1690 							make_white("Blue"));
1691 					break;
1692 				case 5:
1693 					gi.cprintf(ent, PRINT_HIGH, "You are on the \"%s\" team.\n",
1694 							make_white("Turquoise"));
1695 					break;
1696 				case 6:
1697 					gi.cprintf(ent, PRINT_HIGH, "You are on the \"%s\" team.\n",
1698 							make_white("Green"));
1699 					break;
1700 				case 7:
1701 					gi.cprintf(ent, PRINT_HIGH, "You are on the \"%s\" team.\n",
1702 							make_white("White"));
1703 					break;
1704 				case 0:
1705 					gi.cprintf(ent, PRINT_HIGH, "You are on the \"%s\" team.\n",
1706 							make_white("Solo"));
1707 					break;
1708 			}
1709 }
1710 
Cmd_UnBlockChat_f(edict_t * ent)1711 void Cmd_UnBlockChat_f (edict_t *ent)
1712 {
1713 	edict_t *other;
1714 	int j, i=0;
1715 
1716 	if (gi.argc()<=1)
1717 	{
1718 		gi.cprintf(ent, PRINT_HIGH, make_green("-------------------------"));
1719 		gi.cprintf(ent, PRINT_HIGH, "\n");
1720 		gi.cprintf(ent, PRINT_HIGH, make_green("Blocked Clients"));
1721 		gi.cprintf(ent, PRINT_HIGH, "\n");
1722 		gi.cprintf(ent, PRINT_HIGH, make_green("-------------------------"));
1723 		gi.cprintf(ent, PRINT_HIGH, "\n");
1724 		while (ent->blockedChat[i])
1725 		{
1726 			if (ent->blockedChat[i])
1727 				gi.cprintf(ent, PRINT_HIGH, "%s\n", ent->blockedChat[i]->client->pers.netname);
1728 			i++;
1729 		}
1730 		if (i==0)
1731 			gi.cprintf(ent, PRINT_HIGH, "No Clients Blocked\n");
1732 		gi.cprintf(ent, PRINT_HIGH, make_green("-------------------------"));
1733 		gi.cprintf(ent, PRINT_HIGH, "\n");
1734 		return;
1735 	}
1736 
1737 	if (!Q_stricmp(gi.argv(1), "all"))
1738 	{
1739 		while (ent->blockedChat[i])
1740 		{
1741 			gi.cprintf(ent->blockedChat[i], PRINT_HIGH, "%s has UnBlocked your chat.\n", ent->client->pers.netname);
1742 			ent->blockedChat[i]=NULL;
1743 			i++;
1744 		}
1745 
1746 		gi.cprintf(ent, PRINT_HIGH, "All Clients UnBlocked\n");
1747 		return;
1748 	}
1749 
1750 	for (j = 1; j <= game.maxclients; j++)
1751 	{
1752 		other = &g_edicts[j];
1753 		if (!other->client)
1754 			continue;
1755 		if (!Q_stricmp(gi.argv(1), make_white(other->client->pers.netname)))
1756 		{
1757 			ent->blockedChat[i]=other;
1758 			gi.cprintf(other, PRINT_HIGH, "%s has UnBlocked your chat.\n", ent->client->pers.netname);
1759 			gi.cprintf(ent, PRINT_HIGH, "Client \"%s\" UnBlocked\n", other->client->pers.netname);
1760 			while (ent->blockedChat[i])
1761 			{
1762 				ent->blockedChat[i]=ent->blockedChat[i+1];
1763 					i++;
1764 			}
1765 			ent->blockedChat[i]=NULL;
1766 			return;
1767 		}
1768 	}
1769 	gi.cprintf(ent, PRINT_HIGH, "No Client UnBlocked\n");
1770 }
1771 
Cmd_BlockChat_f(edict_t * ent)1772 void Cmd_BlockChat_f (edict_t *ent)
1773 {
1774 	edict_t *other;
1775 	int j, i=0;
1776 
1777 	if (gi.argc()<=1)
1778 	{
1779 		gi.cprintf(ent, PRINT_HIGH, make_green("-------------------------"));
1780 		gi.cprintf(ent, PRINT_HIGH, "\n");
1781 		gi.cprintf(ent, PRINT_HIGH, make_green("Clients"));
1782 		gi.cprintf(ent, PRINT_HIGH, "\n");
1783 		gi.cprintf(ent, PRINT_HIGH, make_green("-------------------------"));
1784 		gi.cprintf(ent, PRINT_HIGH, "\n");
1785 		for (j = 1; j <= game.maxclients; j++)
1786 		{
1787 			other = &g_edicts[j];
1788 			if (!other->client)
1789 				continue;
1790 			if (Q_stricmp("", make_white(other->client->pers.netname)))
1791 			{
1792 				gi.cprintf(ent, PRINT_HIGH, "%s\n", other->client->pers.netname);
1793 			}
1794 		}
1795 		gi.cprintf(ent, PRINT_HIGH, make_green("-------------------------"));
1796 		gi.cprintf(ent, PRINT_HIGH, "\n");
1797 		return;
1798 	}
1799 
1800 	while (ent->blockedChat[i])
1801 	{
1802 		if (ent->blockedChat[i])
1803 			i++;
1804 	}
1805 
1806 	for (j = 1; j <= game.maxclients; j++)
1807 	{
1808 		other = &g_edicts[j];
1809 		if (!other->client)
1810 			continue;
1811 		if (!Q_stricmp(gi.argv(1), make_white(other->client->pers.netname)))
1812 		{
1813 			ent->blockedChat[i]=other;
1814 			gi.cprintf(ent, PRINT_HIGH, "%s Blocked\n", other->client->pers.netname);
1815 			gi.cprintf(other, PRINT_HIGH, "%s has Blocked your chat.\n", ent->client->pers.netname);
1816 			return;
1817 		}
1818 	}
1819 	gi.cprintf(ent, PRINT_HIGH, "No Client Blocked\n");
1820 }
1821 
1822 /*
1823 =================
1824 ClientCommand
1825 =================
1826 */
ClientCommand(edict_t * ent)1827 void ClientCommand (edict_t *ent)
1828 {
1829 	char	*cmd;
1830 
1831 	if (!ent->client)
1832 		return;		// not fully in game yet
1833 
1834 	cmd = gi.argv(0);
1835 
1836 	if (Q_stricmp (cmd, "players") == 0)
1837 	{
1838 		Cmd_Players_f (ent);
1839 		return;
1840 	}
1841 	if (Q_stricmp (cmd, "say") == 0)
1842 	{
1843 		Cmd_Say_f (ent, false, false);
1844 		return;
1845 	}
1846 	if (Q_stricmp (cmd, "say_team") == 0)
1847 	{
1848 		Cmd_Say_f (ent, true, false);
1849 		return;
1850 	}
1851 
1852 	//MY COMMANDS
1853 	if (Q_stricmp(cmd, "bfgcolor") == 0)
1854 	{
1855 		Cmd_BFG_Color_f(ent);
1856 		return;
1857 	}
1858 	if (Q_stricmp(cmd, "grappletype") == 0)
1859 	{
1860 		Cmd_Grapple_Type_f(ent);
1861 		return;
1862 	}
1863 	if (Q_stricmp(cmd, "helpme") == 0)
1864 	{
1865 		Cmd_Info_f(ent);
1866 		return;
1867 	}
1868 	if (Q_stricmp(cmd, "helpsv") == 0)
1869 	{
1870 		Cmd_InfoSV_f(ent);
1871 		return;
1872 	}
1873 	if (Q_stricmp (cmd, "id") == 0)
1874 	{
1875 		Cmd_ID_f (ent);
1876 		return;
1877 	}
1878 	if (Q_stricmp (cmd, "viewcam") == 0)
1879 	{
1880 		Cmd_ViewCam_Type_f (ent);
1881 		return;
1882 	}
1883 	if (Q_stricmp(cmd, "stunton") == 0)
1884 	{
1885 		ent->client->stunt=true;
1886 		CheckStunt (ent);
1887 		return;
1888 	}
1889 	if (Q_stricmp (cmd, "stuntoff") == 0)
1890 	{
1891 		ent->client->stunt=false;
1892 		return;
1893 	}
1894 
1895 	if ( (level.framenum-ent->client->resp.enterframe)/10 < ent->client->MotdTime)
1896 	{
1897 		if ((Q_stricmp (cmd, "score") == 0)||(Q_stricmp (cmd, "help") == 0))
1898 		{
1899 			ent->client->showinventory = false;
1900 			ent->client->showscores = false;
1901 			ent->client->showhelp = false;
1902 			ent->client->ps.stats[STAT_LAYOUTS] = 0;
1903 			ent->client->MotdTime = 0;
1904 			return;
1905 		}
1906 	}
1907 	if (Q_stricmp (cmd, "score") == 0)
1908 	{
1909 		Cmd_Score_f (ent);
1910 		return;
1911 	}
1912 	if (Q_stricmp (cmd, "help") == 0)
1913 	{
1914 		Cmd_Help_f (ent);
1915 		return;
1916 	}
1917 
1918 	if (level.intermissiontime)
1919 		return;
1920 
1921 	if (Q_stricmp (cmd, "use") == 0)
1922 		Cmd_Use_f (ent);
1923 	else if (Q_stricmp (cmd, "drop") == 0)
1924 		Cmd_Drop_f (ent);
1925 
1926 	else if (Q_stricmp(cmd, "alt_fire") == 0)
1927 		Cmd_Alt_Mode_f(ent);
1928 	else if (Q_stricmp(cmd, "attack2") == 0)
1929 		Cmd_Alt_Mode_f(ent);
1930 	else if (Q_stricmp(cmd, "firemode") == 0)
1931 		Cmd_Alt_Mode_f(ent);
1932 
1933 	else if (Q_stricmp (cmd, "team") == 0)
1934 		Cmd_Team_f (ent);
1935 
1936 	else if (Q_stricmp (cmd, "Block") == 0)
1937 		Cmd_BlockChat_f (ent);
1938 	else if (Q_stricmp (cmd, "UnBlock") == 0)
1939 		Cmd_UnBlockChat_f (ent);
1940 
1941 //############ **** CHEATS **** ############
1942 
1943 	else if (Q_stricmp (cmd, "give") == 0 && sv_cheats->value)
1944 		Cmd_Give_f (ent);
1945 	else if (Q_stricmp (cmd, "god") == 0 && sv_cheats->value)
1946 		Cmd_God_f (ent);
1947 	else if (Q_stricmp (cmd, "notarget") == 0 && sv_cheats->value)
1948 		Cmd_Notarget_f (ent);
1949 	else if (Q_stricmp (cmd, "noclip") == 0 && sv_cheats->value)
1950 		Cmd_Noclip_f (ent);
1951 /*
1952 	else if (Q_stricmp (cmd, "give") == 0 && !sv_cheats->value)
1953 		Cmd_Notify_Cheat (ent);
1954 	else if (Q_stricmp (cmd, "god") == 0 && !sv_cheats->value)
1955 		Cmd_Notify_Cheat (ent);
1956 	else if (Q_stricmp (cmd, "notarget") == 0 && !sv_cheats->value)
1957 		Cmd_Notify_Cheat (ent);
1958 	else if (Q_stricmp (cmd, "noclip") == 0 && !sv_cheats->value)
1959 		Cmd_Notify_Cheat (ent);
1960 */
1961 //############ **** CHEATS **** ############
1962 
1963 	else if (Q_stricmp (cmd, "inven") == 0)
1964 		Cmd_Inven_f (ent);
1965 	else if (Q_stricmp (cmd, "invnext") == 0)
1966 		SelectNextItem (ent, -1);
1967 	else if (Q_stricmp (cmd, "invprev") == 0)
1968 		SelectPrevItem (ent, -1);
1969 	else if (Q_stricmp (cmd, "invnextw") == 0)
1970 		SelectNextItem (ent, IT_WEAPON);
1971 	else if (Q_stricmp (cmd, "invprevw") == 0)
1972 		SelectPrevItem (ent, IT_WEAPON);
1973 	else if (Q_stricmp (cmd, "invnextp") == 0)
1974 		SelectNextItem (ent, IT_POWERUP);
1975 	else if (Q_stricmp (cmd, "invprevp") == 0)
1976 		SelectPrevItem (ent, IT_POWERUP);
1977 	else if (Q_stricmp (cmd, "invuse") == 0)
1978 		Cmd_InvUse_f (ent);
1979 	else if (Q_stricmp (cmd, "weapdrop") == 0)
1980 		Cmd_WeapDrop_f (ent);
1981 	else if (Q_stricmp (cmd, "invdrop") == 0)
1982 		Cmd_InvDrop_f (ent);
1983 	else if (Q_stricmp (cmd, "weapprev") == 0)
1984 		Cmd_WeapPrev_f (ent);
1985 	else if (Q_stricmp (cmd, "weapnext") == 0)
1986 		Cmd_WeapNext_f (ent);
1987 	else if (Q_stricmp (cmd, "weaplast") == 0)
1988 		Cmd_WeapLast_f (ent);
1989 	else if (Q_stricmp (cmd, "kill") == 0)
1990 		Cmd_Kill_f (ent);
1991 	else if (Q_stricmp (cmd, "putaway") == 0)
1992 		Cmd_PutAway_f (ent);
1993 	else if (Q_stricmp (cmd, "wave") == 0)
1994 		Cmd_Wave_f (ent);
1995 	else if (Q_stricmp(cmd, "playerlist") == 0)
1996 		Cmd_PlayerList_f(ent);
1997 	else if (Q_stricmp(cmd, "listplayers") == 0)
1998 		Cmd_PlayerList_f(ent);
1999 	else if (Q_stricmp(cmd, "setspot") == 0)
2000 	{
2001 		VectorCopy (ent->s.origin, nextmonsterspawn);
2002 		VectorCopy (ent->s.angles, nextmonsterspawnangles);
2003 	}
2004 	else if (Q_stricmp (cmd, "thirdperson") == 0 && (deathmatch->value || coop->value || sv_cheats->value))
2005 		Cmd_Chasecam_Toggle (ent);
2006 	else	// anything that doesn't match a command will be a chat
2007 		Cmd_Say_f (ent, false, true);
2008 }
2009