GivePlayerWeapon Problem
#1

pawn Код:
CMD:giveweapon(playerid, params[])
{
   new id,weapon,name[MAX_PLAYER_NAME],pName[MAX_PLAYER_NAME],string[128],ammo;
   if(sscanf(params, "uii",weapon,ammo)) return SendClientMessage(playerid, -1, "*  Usage: /giveweapon <playerid> <weaponid> <ammo>.")&&
   SendClientMessage(playerid, 0xFFCC00AA, "*  Function: Give weapon To Player.");
   if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "*  Player is not connected.");
   GivePlayerWeapon(id,weapon,ammo);
   GetPlayerName(playerid, name,sizeof(name));
   GetPlayerName(id,pName,sizeof(pName));
   format(string,sizeof(string), "*  Admin: %s Gave You Weapon ID %i",name,weapon);
   SendClientMessage(id, -1, string);
   format(string,sizeof(string), "*  You Gave Weapon %i To %s (ID:%d)",weapon,pName,id);
   SendClientMessage(playerid, -1, string);
   return 1;
   }
But when i used this to me i have'nt weapon please set this
Reply
#2

pawn Код:
if(sscanf(params, "uii",weapon,ammo))
to:
pawn Код:
if(sscanf(params, "uii", id, weapon, ammo))
You forgot to add the id on it.
Reply
#3

not working
Reply
#4

It does. I even tested and it works fine.
Reply
#5

ok now works it can you tell me how can i give to all players?
Reply
#6

pawn Код:
CMD:giveallweapon(playerid, params[])
{
    new weapon, ammo;
    if(sscanf(params, "ii", weapon, ammo)) return SendClientMessage(playerid, -1, "*  Usage: /giveallweapon <weaponid> <ammo>.")&&
    SendClientMessage(playerid, 0xFFCC00AA, "*  Function: Give weapon To Everyone.");
    new string[128];
    GetPlayerName(playerid, string, MAX_PLAYER_NAME);
    format(string,sizeof(string), "*  Admin: %s Gave to everyone Weapon ID %i", string, weapon);
    SendClientMessageToAll(-1, string);
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        GivePlayerWeapon(i, weapon, ammo);
    }
    return 1;
}
However, I recommend foreach since it loops only through connected players.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)