give all weapon (help asap +rep)
#1

Код:
CMD:giveallweapon(playerid, params[])
{
    if(PlayerInfo[playerid][Level] >= 5 || IsPlayerAdmin(playerid))
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
          new weapon, ammo, string[128], name[128];
          if(sscanf(params,"ii", weapon, ammo)) return SendClientMessage(playerid, grey,"Syntax: /giveallweapon [weaponid] [ammo]");
          if(IsPlayerConnected(i)) { GivePlayerWeapon(i, weapon, ammo); }
          format(string,sizeof(string),"Administrator %s has given all players weapon: %d with %d ammo",name,weapon,ammo);
          SendClientMessageToAll(blue,string);
          CMDMessageToAdmins(playerid,"GIVEALLWEAPON");
	}
    else SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
    return 1;
}
i want to show that "Administrator %s has given all players weapon: %d with %d ammo" one time, but its showing how much number of player is playing, that much time..
Reply
#2

comon help?
Reply
#3

You forgot to use GetPlayerName, to store the player's name inside the name array/variable.

pawn Код:
CMD:giveallweapon(playerid, params[])
{
    new
        weapon,
        ammo,
        string[ 128 ],
        name[ MAX_PLAYER_NAME ]
    ;

    GetPlayerName(playerid, name, MAX_PLAYER_NAME);

    if(PlayerInfo[playerid][Level] <= 5 || !IsPlayerAdmin(playerid))
        return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");

    if(sscanf(params,"ii", weapon, ammo))
        return SendClientMessage(playerid, grey,"Syntax: /giveallweapon [weaponid] [ammo]");

    for(new i = 0; i < MAX_PLAYERS; i++)
    {
          if(!IsPlayerConnected(i)) continue;
          GivePlayerWeapon(i, weapon, ammo);
    }
    format(string,sizeof(string),"Administrator %s has given all players weapon: %d with %d ammo", name, weapon, ammo);
    SendClientMessageToAll(blue, string);
    return CMDMessageToAdmins(playerid,"GIVEALLWEAPON");
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)