SA-MP Forums Archive
Help with giving ammo - 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: Help with giving ammo (/showthread.php?tid=117766)



Help with giving ammo - Guso - 01.01.2010

alot of players told me to fix this when people gives their weapon, they want so they type /give gun 50
it then gives the gun that they have out, it works perfectly but how do i make so it gives the selected ammo that they write?
here is the code
Код:
			else if(strcmp(x_nr,"gun",true) == 0)
			{
			  tmp = strtok(cmdtext, idx);
			  if(!strlen(tmp))
				{
					SendClientMessage(playerid, COLOR_WHITE, "[Usage] /give gun [playerid/partofname]");
					return 1;
				}
				giveplayerid = ReturnUser(tmp);
				if(IsPlayerConnected(giveplayerid))
				{
				  if(giveplayerid != INVALID_PLAYER_ID)
				  {
		  			if(giveplayerid == playerid)
				  	{
    					SendClientMessage(playerid, COLOR_GREY, "[Error] You can not give guns to yourself");
    					return 1;
				  	}
						if(ProxDetectorS(5.0, playerid, giveplayerid))
						{
						  new gunID = GetPlayerWeapon(playerid);
      				new gunAmmo = GetPlayerAmmo(playerid);

						  GetPlayerName(playerid, sendername, sizeof(sendername));
						  GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));

						  if(gunID != 0 && gunAmmo != 0)
						  {
						    SafeGivePlayerWeapon(giveplayerid, gunID, gunAmmo);
						    RemovePlayerWeapon(playerid, gunID);
						    format(string, sizeof(string), "%s hands a weapon to %s", sendername, giveplayer);
						    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
		      			return 1;
						  }
						  else
						  {
						    SendClientMessage(playerid, COLOR_GREY, "[Error] You do not have a gun to give");
						    return 1;
						  }
						}
						else
						{
						  SendClientMessage(playerid, COLOR_GREY, "[Error] That player is not in range");
						  return 1;
						}
				  }
				}
			}