[CMD] GiveMyGunTo by Garciat
#1

[CMD] GiveMyGunTo 1.0
Gives your current weapon to a fellow player!
Commands:
  • /givemygunto [playerid] - Gives your current weapon to player #[id]
Inspired by exora's idea.

Script
Код:
	if(strcmp(cmd, "/givemygunto", true) == 0) {
		new tmp[256];
		new string[256];
		new weaponname[65], playername[MAX_PLAYER_NAME], player2name[MAX_PLAYER_NAME];
		new playermsg[256], player2msg[256];
		tmp = strtok(cmdtext, idx);

		if(!strlen(tmp)) {
			SendClientMessage(playerid, COLOR_RED, "Usage: /givemygunto [playerid]");
			return 1;
		}
		new player2id = strval(tmp);

		if(IsPlayerConnected(player2id))
		{
			if(player2id==playerid)
			{
				SendClientMessage(playerid, COLOR_RED, "You can't use your own ID");
				return 1;
			}
			else
			{
				new weaponid = GetPlayerWeapon(playerid);
				new weaponammo;
				if(weaponid == 0)
				{
					SendClientMessage(playerid, COLOR_RED, "You're not holding a weapon");
					return 1;
				}
				else
				{
					new weapons[13][2];
					for(new i;i<13;i++)
					{
						GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
						if(weapons[i][0]==weaponid) weaponammo=weapons[i][1];
					}
					ResetPlayerWeapons(playerid);
					for(new i;i<13;i++) if(weapons[i][0]!=weaponid) GivePlayerWeapon(playerid, weapons[i][0], weapons[i][1]);
					GivePlayerWeapon(player2id, weaponid, weaponammo);
					
					GetWeaponName(weaponid, weaponname, 64);
					GetPlayerName(playerid, playername, sizeof(playername));
					GetPlayerName(player2id, player2name, sizeof(player2name));
					
					format(playermsg, 255, "You gave your %s to %s(%d)", weaponname, player2name, player2id);
					SendClientMessage(playerid, COLOR_YELLOW, playermsg);
					
					format(player2msg, 255, "You recived a %s from %s(%d)", weaponname, playername, playerid);
					SendClientMessage(player2id, COLOR_YELLOW, player2msg);
				}
			}
		}
		else
		{
			format(string, sizeof(string), "(%d) is not an active player", player2id);
			SendClientMessage(playerid, COLOR_RED, string);
		}
		return 1;
	}
If you want any custom settings, PM me or EMAIL me.
Reply


Messages In This Thread
[CMD] GiveMyGunTo by Garciat - by Garciat - 29.12.2007, 13:45
Re: [CMD] GiveMyGunTo by Garciat - by Rks25 - 29.12.2007, 14:04
Re: [CMD] GiveMyGunTo by Garciat - by Garciat - 29.12.2007, 14:07
Re: [CMD] GiveMyGunTo by Garciat - by cmg4life - 29.12.2007, 14:18
Re: [CMD] GiveMyGunTo by Garciat - by SinisterCrime- - 29.12.2007, 14:21
Re: [CMD] GiveMyGunTo by Garciat - by Garciat - 29.12.2007, 14:25
Re: [CMD] GiveMyGunTo by Garciat - by woot - 29.12.2007, 15:02
Re: [CMD] GiveMyGunTo by Garciat - by SinisterCrime- - 29.12.2007, 15:05
Re: [CMD] GiveMyGunTo by Garciat - by woot - 29.12.2007, 15:10
Re: [CMD] GiveMyGunTo by Garciat - by SinisterCrime- - 29.12.2007, 15:16

Forum Jump:


Users browsing this thread: 1 Guest(s)