Thread: Two questions!
View Single Post
Old 06-06-2006, 03:14 AM   #6
Dom_152's Avatar
Join Date: Jan 2006
Location: England
Posts: 150
It's probably a bit bloated and some things could be done more effectivly because I'm new to this but here it is.

void Cmd_XtraModTakeSaber_f(gentity_t *taker)
	gentity_t *victim;
	gentity_t *others;
	char arg[1024]; //Command arguments
	char *msg = " has taken your Lightsaber\n"; //Message to display to the victim
	char *bmsg1 = "Player "; //Message to display if command bad
	char *bmsg2 = " does not exist\n"; //Second messgage to display if command bad
	char *bmsg3 = "You must provide the name of the player of whom you wish to take the Lightsaber from.\ne.g. /takeSaber XharocK";
	char *msg2 = " has had their Lightsaber taken away by ";
	char *takername = taker->client->pers.netname;
	int victimnum = 0;
	int i = 0;

	trap_Argv(1, arg, 1024); //get the commands arguments

	if(arg == NULL)
		trap_SendServerCommand(taker->client->ps.clientNum, va("print \"%s\"", bmsg3));


	victimnum  = G_ClientNumFromNetname(arg); //Victims Client Number, the name is from the given arguments

	victim = &g_entities[victimnum];

	if(!victim->client) //Check if the client does not exist
		trap_SendServerCommand(taker->client->ps.clientNum, va("print \"%s%s%s\"", bmsg1, arg, bmsg2));

	if(victim->client->ps.weapon == WP_SABER)
		victim->client->ps.weapon = WP_NONE;
		//victim->client->NoSaber == qtrue;

	trap_SendServerCommand(victimnum,  va("print \"%s%s\"", takername, msg));

	for(i = 0; i < MAX_CLIENTS; i++)
		if(i == victimnum)
			break; //Don't send this message to the victim

		others = &g_entities[i];

			break; //If the client doesn't exist don't send the message

		trap_SendServerCommand(i,  va("print \"%s%s%s\n\"", victim->client->pers.netname, msg2, takername));

Dom_152 is offline   you may: quote & reply,