27.03.2012, 20:22
'Sup? I've scripted a "/weaps"-command, which gives players ( level 1+ ) the option to get the info of their weapons, well, usually straight to see all the weapons the player has! But for some reason, whenever I check my own weapons, it won't show them, lol! There's just written "No weapons found!". When I'm buying myself a MP5, it otherwise would show my MP5 with the given ammo:
I think that "GetPlayerWeaponData" is not the function which is required, right?
pawn Код:
CMD:weaps(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] >= 1)
{
new Target;
if(sscanf(params, "u", Target)) return SendClientMessage(playerid, COLOR_BLUEAQUA, "USAGE: /weaps [playerid]");
if(!IsPlayerConnected(Target))
return SendClientMessage(playerid, COLOR_RED,"ERROR: Player is not connected!");
new Count;
new x;
new string[128], string2[64];
new WeapName[24], slot, weap, ammo;
new name[MAX_PLAYER_NAME];
GetPlayerName(Target,name,sizeof(name));
format(string2,sizeof(string2),"_______|- %s's Weapons -|_______",name);
SendClientMessage(playerid,COLOR_YELLOW,string2);
for(slot = 0; slot < 14; slot++)
{
GetPlayerWeaponData(Target, slot, weap, ammo);
if( ammo != 0 && weap != 0)
Count++;
}
if(Count < 1) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"No weapons found!");
if(Count >= 1)
{
for (slot = 0; slot < 14; slot++)
{
GetPlayerWeaponData(Target, slot, weap, ammo);
if( ammo != 0 && weap != 0)
{
GetWeaponName(weap, WeapName, sizeof(WeapName));
if(ammo == 65535 || ammo == 1)
format(string,sizeof(string),"%s%s (1)",string, WeapName);
else format(string,sizeof(string),"%s%s (%d)",string, WeapName, ammo);
x++;
}
if(x >= 5)
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
x = 0;
format(string, sizeof(string), "");
}
else format(string, sizeof(string), "%s, ", string);
}
}
if(x <= 4 && x > 0)
{
string[strlen(string)-3] = '.';
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
}
else return SendClientMessage(playerid,COLOR_RED,"ERROR: You need to be level 1 to use this command!");
return 1;
}