givegun command help
#1

hi, i'm doing givegun command, but its not working idk why, anyone can fix it?
this command if i did /givegun [playerid] [bullets] it will give another player same weapon with bullets, and the player that gave the another player, will lose just bullets.

pawn Код:
CMD:givegun(playerid,params[])
{
  new id, wam;
  if(sscanf(params, "ui", id, wam))return SendClientMessage(playerid,-1,"usage: /givegun [playerid] [bullets]");
  if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid,-1,"invalid player id!");
  if(GetPlayerWeapon(playerid) == 0)return SendClientMessage(playerid, -1, "You have no weapon in your hand you could pass!");
  if(GetPlayerAmmo(playerid) < wam)return SendClientMessage(playerid,-1,"You do not have enough Munnition");
  GivePlayerWeapon(id, GetPlayerWeapon(playerid), wam);
  SetPlayerAmmo(playerid, GetPlayerAmmo(playerid) -wam); // this line
  new string[128], sendername[24], sendername1[24], weaponname[24];
  GetPlayerName(playerid, sendername, 24),GetPlayerName(id, sendername1, 24), GetWeaponName(GetPlayerWeapon(playerid), weaponname, 24);
  format(string, sizeof(string), "Player %s has given you the weapon %s with %i each shot!", sendername, weaponname, wam);
  SendClientMessage(id, -1, string);
  format(string, sizeof(string), "You have the players  %s %s handed over the weapon with each shot i%",sendername1, weaponname, wam);
  SendClientMessage(playerid,-1,string);
  return 1;
}



pawn Код:
warning 202: number of arguments does not match definition
Reply
#2

okay its working fine, but i added isplayernearplayer, but when i try to /givegun it says " player is too far away " even if he is near me
pawn Код:
CMD:givegun(playerid,params[])
{
  new id, playerb, wam;
  if(sscanf(params, "ui", id, wam))return SendClientMessage(playerid,-1,"usage: /givegun [playerid] [bullets]");
  if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid,-1,"invalid player id!");
  if(GetPlayerWeapon(playerid) == 0)return SendClientMessage(playerid, -1, "You have no weapon in your hand you could pass!");
  if(!IsPlayerNearPlayer(playerid, playerb, 5)) return SendClientMessage(playerid, COLOR_GREY, "You are too far away from that player.");
  if(GetPlayerAmmo(playerid) < wam)return SendClientMessage(playerid,-1,"You do not have enough Munnition");
  GiveZaiatWeapon(id, GetPlayerWeapon(playerid), wam);
  SetPlayerAmmo(playerid, GetPlayerWeapon(playerid), GetPlayerAmmo(playerid) - wam);
  new string[128], sendername[24], sendername1[24], weaponname[24];
  GetPlayerName(playerid, sendername, 24),GetPlayerName(id, sendername1, 24), GetWeaponName(GetPlayerWeapon(playerid), weaponname, 24);
  format(string, sizeof(string), "* %s has gave %s a %s with $s bullets.", NORPN(playerb), NORPN(playerid), weaponname, wam);
  SendNearbyMessage(playerid, 6, string, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE);
  /*format(string, sizeof(string), "Player %s has given you the weapon %s with %i each shot!", sendername, weaponname, wam);
  SendClientMessage(id, -1, string);
  format(string, sizeof(string), "You have the players  %s %s handed over the weapon with each shot i%",sendername1, weaponname, wam);
  SendClientMessage(playerid,COLOR_GREY,string);*/

  return 1;
}
can u help?
Reply
#3

Code of the function: IsPlayerNearPlayer ?
Reply
#4

i don't understand what you mean -_- i'm not good with scripting..
Reply
#5

its working only at interiors xD
Reply
#6

try this one dude
pawn Код:
CMD:givegun(playerid,params[])
{
  new id, playerb, wam;
  if(sscanf(params, "ui", id, wam))return SendClientMessage(playerid,-1,"usage: /givegun [playerid] [bullets]");
  if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid,-1,"invalid player id!");
  if(GetPlayerWeapon(playerid) == 0)return SendClientMessage(playerid, -1, "You have no weapon in your hand you could pass!");
  if(!IsPlayerNearPlayer(playerid, id, 5)) return SendClientMessage(playerid, COLOR_GREY, "You are too far away from that player."); // <<<<<<<<<<<<<<<<<<<<
  if(GetPlayerAmmo(playerid) < wam)return SendClientMessage(playerid,-1,"You do not have enough Munnition");
  GiveZaiatWeapon(id, GetPlayerWeapon(playerid), wam);
  SetPlayerAmmo(playerid, GetPlayerWeapon(playerid), GetPlayerAmmo(playerid) - wam);
  new string[128], sendername[24], sendername1[24], weaponname[24];
  GetPlayerName(playerid, sendername, 24),GetPlayerName(id, sendername1, 24), GetWeaponName(GetPlayerWeapon(playerid), weaponname, 24);
  format(string, sizeof(string), "* %s has gave %s a %s with $s bullets.", NORPN(playerb), NORPN(playerid), weaponname, wam);
  SendNearbyMessage(playerid, 6, string, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE);
  /*format(string, sizeof(string), "Player %s has given you the weapon %s with %i each shot!", sendername, weaponname, wam);
  SendClientMessage(id, -1, string);
  format(string, sizeof(string), "You have the players  %s %s handed over the weapon with each shot i%",sendername1, weaponname, wam);
  SendClientMessage(playerid,COLOR_GREY,string);*/

  return 1;
}
where did "playerb" come from?
Reply
#7

Works thanks both <3
+rep
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)