weapon info cmd
#1

i wana do a cmd that if i write /winfo, it tells me what kind of weapons the player has, and the ammo..
and i want it to tell me what are the weapons that the player has, even if hes not holding them.. is it possible, and how ?
Reply
#2

Try GetPlayerWeaponData

there's roughly 13 weapons a person can carry simultaneously I think, so best go with 15. That pawn function returns both weapon id and weapon ammo. REMEMBER: Just because it says a player has 65535 ammo, doesn't mean he has that much, it just means that the server can't get that information from the player
Reply
#3

i tryed that cmd, but had no luck, can you direct me a little?
Reply
#4

pawn Код:
new WeapAmmo[2], name[24], string[128];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s's Weapons:", name);
for(new w = 0; w < 13; w++)
{
    GetPlayerWeaponData(playerid, w, WeapAmmo[0], WeapAmmo[1]);
    GetWeaponName(WeapAmmo[0], name, sizeof(name));
    format(string, sizeof(string), "%s %s(%d),", string, name, WeapAmmo[1]);
}
string[strlen(string)-1] = 0;
SendClientMessage(playerid, COLOR_WHITE, string);
Reply
#5

oh thanks!~!
o and last question..
in the cmd you gave me, can i do that itll show me only the weapons he has, and wont show the 0's
Reply
#6

maybe try that
pawn Код:
new WeapAmmo[2], name[24], string[128];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s's Weapons:", name);
for(new w = 0; w < 13; w++)
{
    GetPlayerWeaponData(playerid, w, WeapAmmo[0], WeapAmmo[1]);
    if(WeapAmmo[0] == 0) continue;
    GetWeaponName(WeapAmmo[0], name, sizeof(name));
    format(string, sizeof(string), "%s %s(%d),", string, name, WeapAmmo[1]);
}
string[strlen(string)-1] = 0;
SendClientMessage(playerid, COLOR_WHITE, string);
dont know if that will work
Reply
#7

Quote:
Originally Posted by Nero_3D
maybe try that
pawn Код:
new WeapAmmo[2], name[24], string[128];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s's Weapons:", name);
for(new w = 0; w < 13; w++)
{
    GetPlayerWeaponData(playerid, w, WeapAmmo[0], WeapAmmo[1]);
    if(WeapAmmo[0] == 0) continue;
    GetWeaponName(WeapAmmo[0], name, sizeof(name));
    format(string, sizeof(string), "%s %s(%d),", string, name, WeapAmmo[1]);
}
string[strlen(string)-1] = 0;
SendClientMessage(playerid, COLOR_WHITE, string);
dont know if that will work
yeah it works perfectly, thanks a lot dude !!!
Reply
#8

sorry for asking this, i realy have no clue

i can't see the cmd code of it, like what Dark-X said (/winfo)

should i add something like this in it?

if (strcmp(cmdtext, "/winfo", true)==0)

or maybe is already added but i'm too amateur to see it
Reply
#9

Quote:
Originally Posted by ♣ ⓐⓢⓢ
maybe try that
pawn Код:
new WeapAmmo[2], name[24], string[128];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s's Weapons:", name);
for(new w = 0; w < 13; w++)
{
    GetPlayerWeaponData(playerid, w, WeapAmmo[0], WeapAmmo[1]);
    if(WeapAmmo[0] == 0) continue;
    GetWeaponName(WeapAmmo[0], name, sizeof(name));
    format(string, sizeof(string), "%s %s(%d),", string, name, WeapAmmo[1]);
}
string[strlen(string)-1] = 0;
SendClientMessage(playerid, COLOR_WHITE, string);
dont know if that will work
I am not sure if 13 is the maximum of holding guns.
Yes, it is. My bad.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)