17.04.2015, 12:01
Hello, guys!
I want to make a command that, when you type /weaps [ID], it shows you selected player's weapons, and when you type just /weaps (without completting the param), it shows you a Dialog Style Tablist like this:

If the Player X has a Rocket and Grenades, his name will appear there two times, showing the both Weapons and their ammo.
If there are 10 players with big weapons, in this dialog I want all of them to appear..
There is what I made...
Can someone help me fix this command ? It have lot of bugs... Sometimes, when I type /weaps [ID], it shows me about 10 times this on the chat: SendCommandToAdmins(playerid, "Weaps");
Sometimes, when 2 players have 2 different big weapons, and I type /weaps, the server gets crashed, and sometimes it shows me the message 'SERVER: UNKNOWN COMMAND', but I have in my GameMode the callback 'public OnPlayerCommandPerformed'...
Thank you very much!
I want to make a command that, when you type /weaps [ID], it shows you selected player's weapons, and when you type just /weaps (without completting the param), it shows you a Dialog Style Tablist like this:

If the Player X has a Rocket and Grenades, his name will appear there two times, showing the both Weapons and their ammo.
If there are 10 players with big weapons, in this dialog I want all of them to appear..
There is what I made...
PHP код:
CMD:weaps(playerid, params[])
{
if(Player[playerid][Level] >= 3 || Player[playerid][VIP] >= 7)
{
new pID, CountW, x, WeapName[24], slot, weap, ammo, CountP = 0; Str[0] = '\0'; Str2[0] = '\0';
new Str4[50] = "{00BBF6}Name\t{00BBF6}Weapon\t{00BBF6}Ammo";
//----------------------------------------------------------------------
if(sscanf(params, "u", pID))
{
foreach(new l : Player)
{
new weapons[2][4];
GetPlayerWeaponData(l, 7, weapons[1][0], weapons[1][1]);
GetPlayerWeaponData(l, 8, weapons[1][2], weapons[1][3]);
if(weapons[1][2] == 16)
{
format(Str, 2024, "{00FF00}%s {00BBF6}(ID:%d) \t{00FF00}Grenades \t{FF0000}%d\n%s", ReturnName(l), l, weapons[1][3], Str);
CountP++;
}
//--------------------------------------------------------------
else if(weapons[1][2] == 18)
{
format(Str, 2024, "{00FF00}%s {00BBF6}(ID:%d) \t{00FF00}Molotovs \t{FF0000}%d\n%s", ReturnName(l), l, weapons[1][3], Str);
CountP++;
}
//--------------------------------------------------------------
if(weapons[1][0] == 35)
{
format(Str, 2024, "{00FF00}%s {00BBF6}(ID:%d) \t{00FF00}Rocket Launcher \t{FF0000}%d\n%s", ReturnName(l), l, weapons[1][1], Str);
CountP++;
}
//--------------------------------------------------------------
else if(weapons[1][0] == 36)
{
format(Str, 2024, "{00FF00}%s {00BBF6}(ID:%d) \t{00FF00}Heat Seeker \t{FF0000}%d\n%s", ReturnName(l), l, weapons[1][1], Str);
CountP++;
}
//--------------------------------------------------------------
else if(weapons[1][0] == 37)
{
format(Str, 2024, "{00FF00}%s {00BBF6}(ID:%d) \t{00FF00}FlameThrower \t{FF0000}%d\n%s", ReturnName(l), l, weapons[1][1], Str);
CountP++;
}
}
new Str3[100];
format(Str3, 300, "%s\n%s", Str4, Str);
if(CountP == 0) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: {49FFFF}/weaps [ID]");
//--------------------------------------------------------------------------
else return ShowPlayerDialog(playerid, 123, DIALOG_STYLE_TABLIST_HEADERS, "{BBFF00}Players with {00BBF6}Big Weapons", Str3, "Close", ""), SendCommandToAdmins(playerid, "Weaps");
}
Str[0] = '\0'; Str2[0] = '\0';
//----------------------------------------------------------------------
if(IsPlayerConnected(pID) && pID != INVALID_PLAYER_ID)
{
format(Str, 128, "%s's Weapons:", ReturnName(pID)), SendClientMessage(playerid, 0x00FF00AA, Str);
//------------------------------------------------------------------
for(slot = 0; slot < 14; slot++)
{
GetPlayerWeaponData(pID, slot, weap, ammo);
//--------------------------------------------------------------
if(ammo != 0 && weap != 0) CountW++;
}
if(CountW < 1) SendClientMessage(playerid, 0x00FF00AA, "This player don't have Weapons!");
//------------------------------------------------------------------
if(CountW >= 1)
{
for(slot = 0; slot < 14; slot++)
{
GetPlayerWeaponData(pID, slot, weap, ammo); SendCommandToAdmins(playerid, "Weaps");
//----------------------------------------------------------
if(ammo != 0 && weap != 0)
{
GetWeaponName(weap, WeapName, sizeof(WeapName));
//------------------------------------------------------
if(ammo == 65535 || ammo == 1) format(Str2, 128, "%s%s (1)", Str2, WeapName);
else format(Str2, 128, "%s%s (%d)", Str2, WeapName, ammo); x++;
//------------------------------------------------------
if(x >= 5)
{
SendClientMessage(playerid, 0x00FF00AA, Str2); x = 0; format(Str2, 128, "");
}
else format(Str2, 128, "%s, ", Str2);
}
}
//--------------------------------------------------------------
if(x <= 4 && x > 0)
{
Str2[strlen(Str2)-3] = '.'; SendClientMessage(playerid, 0x00FF00AA, Str2);
}
}
//------------------------------------------------------------------
return 1;
}
//----------------------------------------------------------------------
else return ERROR_NotConnected(playerid);
}
else return ErrorMessages(playerid, 4);
}
Sometimes, when 2 players have 2 different big weapons, and I type /weaps, the server gets crashed, and sometimes it shows me the message 'SERVER: UNKNOWN COMMAND', but I have in my GameMode the callback 'public OnPlayerCommandPerformed'...
Thank you very much!