[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
#2

Why don't you host this in the Usefull Commands topic?

Anyway, nice work !

Rkss
Reply
#3

Quote:
Originally Posted by Rks25
Why don't you host this in the Usefull Commands topic?

Anyway, nice work !

Rkss
Thanks. I'm "new" to the forum, I've never heard of a useful commands topic. A link might help.
Reply
#4

Nice Commands Garciat, you should make a topic Garciat CMDS :P

http://forum.sa-mp.com/index.php?topic=2868.0 > Useful commands but is kinda big
Reply
#5

Good stuff
Reply
#6

Quote:
Originally Posted by SinisterCrime-
Good stuff
Thank you. If you have good ideas, I can script them for you or anyone.
Reply
#7

Thanks, man
Reply
#8

How about.. Scripting

A person uses /takeweapon [playerid] and the player id the person is takeing it from.. Has to confirm it.. If he comfirms it it will go to the person who asked for it
Reply
#9

Lol, weird

Код:
C:\DOKUME~1\MANUEL~1\Desktop\GTASTU~1\SAMP02~1.WIN\GAMEMO~1\training.pwn(121) : error 017: undefined symbol "idx"
tmp = strtok(cmdtext, idx);

xD
Reply
#10

Do Top of script

new idx;

Or put it under

OnPlayerCommandText
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)