06.04.2017, 20:05
Can someone tell me why this /weps command shows blank dialog instead of player's weapons?
pawn Код:
CMD:weps(playerid, params[])
{
if (Player[playerid][Level] < 1)
{
return SendClientMessage(playerid, COLOR_TOMATO, "You must be admin level 1+ to use this command.");
}
else
{
new pID, bool:all = isnull(params);
sscanf(params, "U(-1)", pID);
if(pID == INVALID_PLAYER_ID && !all) return SendClientMessage(playerid, COLOR_TOMATO, "The specified player is not connected.");
else
{
new CountW,weapon[24];
static strTemp[220],strDest[220 char],strWeap[5500 char],weap[2][2];
if(all)
{
strWeap = !"{00BBF6}Name\t{00BBF6}Weapon\t{00BBF6}Ammo\n";
foreach(new i : Player)
{
GetPlayerWeaponData(i, 7, weap[0][0], weap[0][1]);
GetPlayerWeaponData(i, 8, weap[1][0], weap[1][1]);
strTemp[0] = EOS;
//--------------------------------------------------------------
if(WEAPON_ROCKETLAUNCHER <= weap[0][0] <= WEAPON_MINIGUN)
{
GetWeaponNameEx(weap[0][0], weapon);
format(strTemp, sizeof(strTemp), "{00FF00}%s {00BBF6}(ID:%d) \t{00FF00}%s \t{FF0000}%d\n", ReturnPlayerName(i), i, weapon, weap[0][1]),CountW++;
}
if(WEAPON_GRENADE <= weap[1][0] <= WEAPON_MOLTOV)
{
GetWeaponNameEx(weap[1][0], weapon);
if(!strTemp[0]) format(strTemp, sizeof(strTemp), "{00FF00}%s {00BBF6}(ID:%d) \t{00FF00}%s \t{FF0000}%d\n", ReturnPlayerName(i), i, weapon, weap[1][1]);
else format(strTemp, sizeof(strTemp), "%s{00FF00}%s {00BBF6}(ID:%d) \t{00FF00}%s \t{FF0000}%d\n", strTemp, ReturnPlayerName(i), i, weapon, weap[1][1]);
CountW++;
}
if(strTemp[0])
{
strpack(strDest,strTemp);
strcat(strWeap,strDest);
}
}
if(!CountW) SendClientMessage(playerid, 0xFF000000, "USAGE: {49FFFF}/weaps [ID/Name]");
else{
strWeap{strlen(strWeap)-1} = EOS;
ShowPlayerDialog(playerid, 123, DIALOG_WEPS, "{BBFF00}Players with {00BBF6}Big Weapons", strWeap, "Close", "");
}
}
else
{
for(new i=0; i != 13; i++)
{
GetPlayerWeaponData(pID, i, weap[0][0], weap[0][1]);
if(weap[0][0] > 0 && weap[0][1] > 0)
CountW++;
}
if(CountW < 1) SendClientMessage(playerid, 0x00FF0000, "This player don't have Weapons!");
else{
strWeap = !"{00BBF6}Weapon\t{00BBF6}Ammo\n";
for(new i=0; i != 13; i++)
{
GetPlayerWeaponData(pID, i, weap[0][0], weap[0][1]);
if(weap[0][0] > 0 && weap[0][1] > 0)
{
GetWeaponNameEx(weap[0][0], weapon);
if(weap[0][1] == 65535 || weap[0][1] == 1) format(strTemp, sizeof(strTemp), "{00FF00}%s \t{FF0000}1\n",weapon);
else format(strTemp, sizeof(strTemp), "{00FF00}%s \t{FF0000}%d\n",weapon, weap[0][1]);
strpack(strDest,strTemp);
strcat(strWeap,strDest);
}
}
strWeap{strlen(strWeap)-1} = EOS;
format(strTemp, sizeof(strTemp), "{BBFF00}%s's {00BBF6}Weapons:", ReturnPlayerName(pID)),
ShowPlayerDialog(playerid, 123, DIALOG_WEPS, strTemp, strWeap, "Close", "");
}
}
}
}
return 1;
}