SA-MP Forums Archive
/giveweapon - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /giveweapon (/showthread.php?tid=174869)



/giveweapon - Face9000 - 07.09.2010

Hi all,i need /giveweapon command (only for admins)

If i write /giveweapon playerid weaponid ammo,i will give the weapon to a specific id

Thanks!


Re: /giveweapon - Sparnex - 07.09.2010

Код:
if(strcmp(cmd, "/givegun", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /givegun [playerid/PartOfName] [weaponid(eg. 46 = Parachute)] [ammo]");
				return 1;
			}
			new playa;
			new gun;
			new ammo;
			playa = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			gun = strval(tmp);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /givegun [playerid/PartOfName] [weaponid] [ammo]");
				SendClientMessage(playerid, COLOR_GRAD4, "3(Club) 4(knife) 5(bat) 6(Shovel) 7(Cue) 8(Katana) 10-13(Dildo) 14(Flowers) 16(Grenades) 18(Molotovs) 22(Pistol) 23(SPistol)");
				SendClientMessage(playerid, COLOR_GRAD3, "24(Eagle) 25(shotgun) 29(MP5) 30(AK47) 31(M4) 33(Rifle) 34(Sniper) 37(Flamethrower) 41(spray) 42(exting) 43(Camera) 46(Parachute)");
				return 1;
			}
			/*if(gun < 1||gun > 46||gun==27||gun==1||gun==2||gun==9||gun==17||gun==19||gun==20||gun==21||gun==35||gun==36||gun==39||gun==40||gun==44||gun==45)
			{ SendClientMessage(playerid, COLOR_GRAD1, "   wrong WeaponID!"); return 1; }*/
			tmp = strtok(cmdtext, idx);
			ammo = strval(tmp);
			if(ammo <1||ammo > 9999)
			{ SendClientMessage(playerid, COLOR_GRAD1, "   dont go below 1 or above 9999 bullets!"); return 1; }
			if (PlayerInfo[playerid][pAdmin] >= 7)
			{
			    if(IsPlayerConnected(playa))
			    {
			        if(playa != INVALID_PLAYER_ID)
			        {
						SafeGivePlayerWeapon(playa, gun, ammo);
						GetPlayerName(playa, giveplayer, sizeof(giveplayer));
						GetPlayerName(playerid, sendername, sizeof(sendername));
						format(string, 256, "AdmWarning: %s has given %s gun id %d.", sendername,giveplayer,gun);
						ABroadCast(COLOR_YELLOW,string,1);
					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "   you are not authorized to use that command!");
			}
		}
		return 1;
	}



Re: /giveweapon - Face9000 - 07.09.2010

lol doesn't work...


Re: /giveweapon - Sparnex - 07.09.2010

what a problem?


Re: /giveweapon - Face9000 - 07.09.2010

It return me alot of error


Re: /giveweapon - iggy1 - 07.09.2010

Learn to use zcmd and sscanf and the commands get alot simpler heres another quick command i made.

pawn Код:
COMMAND:giveweapon(playerid,paams[])
{
    new pid, wid, amt;
    if(sscanf(params,"udd",pid,wid,amt))return SendClientMessage(playerid,0xff0000FF,"ERROR: Usage /giveweapon [playerid/name][weaponid][ammo]");
    if(wid < 0 || wid >40)return SendClientMessage(playerid,0xff0000FF,"ERROR: Invalid weaponid");
    if(pid != INVALID_PLAYER_ID && IsPlayerConnected(pid))
    {
        if(IsPlayerAdmin(playerid))
        {
            GivePlayerWeapon(pid,wid,amt);
        }
        else SendClientMessage(playerid,0xff0000FF,"ERROR: You don't have permission to use that command");
    }
    else  SendClientMessage(playerid,0xff0000FF,"ERROR: Player not found");
    return 1;
}



Re: /giveweapon - Ash. - 07.09.2010

Quote:
Originally Posted by iggy1
Посмотреть сообщение
Learn to use zcmd and sscanf and the commands get alot simpler heres another quick command i made.

pawn Код:
COMMAND:giveweapon(playerid,paams[])
{
    new pid, wid, amt;
    if(sscanf(params,"udd",pid,wid,amt))return SendClientMessage(playerid,0xff0000FF,"ERROR: Usage /giveweapon [playerid/name][weaponid][ammo]");
    if(wid < 0 || wid >40)return SendClientMessage(playerid,0xff0000FF,"ERROR: Invalid weaponid");
    if(pid != INVALID_PLAYER_ID && IsPlayerConnected(pid))
    {
        if(IsPlayerAdmin(playerid))
        {
            GivePlayerWeapon(pid,wid,amt);
        }
        else SendClientMessage(playerid,0xff0000FF,"ERROR: You don't have permission to use that command");
    }
    else  SendClientMessage(playerid,0xff0000FF,"ERROR: Player not found");
    return 1;
}
Who cant spell params? xD - Not really, you forget the 'r' in params

pawn Код:
COMMAND:giveweapon(playerid,params[])



Re: /giveweapon - iggy1 - 07.09.2010

Edited that about 15mins ago lol keyboard on my laptop is fooking up


Re: /giveweapon - Ash. - 07.09.2010

Still says paams to me though :S lol


Re: /giveweapon - iggy1 - 07.09.2010

Lol thats stange its edited on mine well spotted btw (lol look how i spelt strange!) 'r' is on its way out