GetPlayerWeaponData -
BigGroter - 04.05.2013
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.
AW: GetPlayerWeaponData -
Nero_3D - 04.05.2013
Everything fine you just put a return inside the loop which will stop it after the first message, just remove it
Re: GetPlayerWeaponData -
RVRP - 04.05.2013
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.
Re: GetPlayerWeaponData -
BigGroter - 04.05.2013
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.
Re: GetPlayerWeaponData -
Admigo - 04.05.2013
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.
Re: GetPlayerWeaponData -
RVRP - 04.05.2013
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.