SA-MP Forums Archive
Bug with /give gun - 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: Bug with /give gun (/showthread.php?tid=248952)



Bug with /give gun - ShawnMiller1337 - 16.04.2011

Код:
	if(strcmp(cmd, "/give", true) == 0) // by Ellis
	{
	    if(IsPlayerConnected(playerid))
	    {
			new x_nr[256];
			x_nr = strtok(cmdtext, idx);
			if(!strlen(x_nr))
			{
			    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /give [name] [playerid/PartOfName] ([ammount])");
				SendClientMessage(playerid, COLOR_WHITE, "Available names: gun");
				return 1;
			}
        	if(strcmp(x_nr,"gun",true) == 0)
			{
			    tmp = strtok(cmdtext, idx);
			    if(!strlen(tmp))
				{
					SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /give gun [playerid/PartOfName]");
					return 1;
				}
				giveplayerid = ReturnUser(tmp);
				if(IsPlayerConnected(giveplayerid))
				{
				    if(giveplayerid != INVALID_PLAYER_ID)
				    {
						if(ProxDetectorS(5.0, playerid, giveplayerid))
						{
						    new playergun;
			    	        new playerammo;
			    	        playergun = GetPlayerWeapon(playerid);
			    	        playerammo = GetPlayerAmmo(playerid);
			    	        if(playergun < 1)
			    	        {
			    	           SendClientMessage(playerid, COLOR_GREY, " You don't have a weapon !");
			    	           return 1;
					    	}
					    	if(playerammo < 1)
			    	        {
			    	           SendClientMessage(playerid, COLOR_GREY, " You don't have ammo !");
			    	           return 1;
					    	}
						    if(playergun > 0)
				    	    {
					            GivePlayerWeapon(playerid, playergun, -playerammo);
						        GivePlayerWeapon(giveplayerid, playergun, playerammo);
						        GetPlayerName(playerid, sendername, sizeof(sendername));
						        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
						        format(string,sizeof(string), " %s has given you a weapon", sendername);
						        SendClientMessage(giveplayerid, COLOR_ARGOGREEN, string);
						        format(string,sizeof(string), " You have given %s a weapon", giveplayer);
                                SendClientMessage(playerid, COLOR_ARGOGREEN, string);
				    	        format(string, sizeof(string), "* %s has given %s a weapon.", sendername ,giveplayer);
							    ProxDetector(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
						    }
						}
						else
						{
						    SendClientMessage(playerid, COLOR_GREY, "   Player is not near you ! ");
						    return 1;
						}
				    }
				}
			}
			else
			{
				return 1;
			}

	    }
	    return 1;
	}
Example: I'm holding a M4 with 500 ammo and i do /give gun 4 200

Well it gives ID 4 unlimited ammo and removes the weapon I have?

any solution ?


Re: Bug with /give gun - Seven_of_Nine - 16.04.2011

Yes it gives a weap to the player (but with your amount of ammo) and removes from your slot.
If you don't like it, here's mine (zcmd) anyways:
http://pastebin.com/0Fz3PS2j


Re: Bug with /give gun - ShawnMiller1337 - 16.04.2011

Not really what I looked for...Suppose to be for players and not admins like if im not holding a M4 it will say You dont have a gun , If I have a m4 with 500 ammo and i do /give gun ID amount , amout being 200 , It should give that player 200 M4 ammo and subtract 200 ammo from me


Re: Bug with /give gun - ShawnMiller1337 - 17.04.2011

anyone ?