GetPlayerWeaponData
#1

pawn Код:
CMD:getweapons(playerid, params[])
{
    new message[128], Player, weapon, ammo;
    if(pInfo[playerid][AdminLevel] < 2) return admMsg(playerid);
    if(sscanf(params, "u", Player)) return SCM(playerid, 0xC4C4C4FF, "Usage: /getweapons <playerid>");
    for(new i=0;i<13;i++)
    {
        GetPlayerWeaponData(Player, i, weapon, ammo);
        if(weapon != 0)
        {
            format(message, sizeof(message), "Player %s's weapons: Slot(%d): Weapon ID(%d) Ammo(%d)", GetName(Player),i, weapon, ammo);
            SCM(playerid, -1, message);
            return 1;
        }
    }
    return 1;
}
First time using GetPlayerWeaponData and I'm tired, so it's probably easy.
How do I make it print ALL the weapons the player has? This prints one of them.
Reply
#2

Everything fine you just put a return inside the loop which will stop it after the first message, just remove it
Reply
#3

As far as I know the only way to display all of the player's weapons is to save the IDs and then list all of the weapons from there.

So you should be adding the following under the enum:
pawn Код:
pWeapon1,
pWeapon2,
pWeapon3,
//etc...
And then use that information in your command.
Reply
#4

Quote:
Originally Posted by RVRP
Посмотреть сообщение
As far as I know the only way to display all of the player's weapons is to save the IDs and then list all of the weapons from there.

So you should be adding the following under the enum:
pawn Код:
pWeapon1,
pWeapon2,
pWeapon3,
//etc...
And then use that information in your command.
I'm already getting the weapon ID here;
pawn Код:
GetPlayerWeaponData(Player, i, weapon, ammo);
GetPlayerWeaponData() stores the weapon ID and ammo.

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
Everything fine you just put a return inside the loop which will stop it after the first message, just remove it
Thank you, I knew it was something so simple, haha.
Reply
#5

Try this:
Код:
while( GetPlayerWeaponData(Player, idx, weapon, ammo) )
{
        if(weapon != 0)
        {
                format(message, sizeof(message), "Player %s's weapons: Slot(%d): Weapon ID(%d) Ammo(%d)", GetName(Player),i, weapon, ammo);
                SCM(playerid, -1, message);
                idx ++;
        }
}
I didnt tested it.
Reply
#6

Quote:
Originally Posted by BigGroter
Посмотреть сообщение
I'm already getting the weapon ID here;
pawn Код:
GetPlayerWeaponData(Player, i, weapon, ammo);
GetPlayerWeaponData() stores the weapon ID and ammo.



Thank you, I knew it was something so simple, haha.
I misinterpreted what you were trying to do. I apologize.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)