Command /weaps problem...
#1

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...

PHP код:
CMD:weaps(playeridparams[])
{
    if(
Player[playerid][Level] >= || Player[playerid][VIP] >= 7)
    {
        new 
pIDCountWxWeapName[24], slotweapammoCountP 0Str[0] = '\0'Str2[0] = '\0';
        new 
Str4[50] = "{00BBF6}Name\t{00BBF6}Weapon\t{00BBF6}Ammo";
        
//----------------------------------------------------------------------
        
if(sscanf(params"u"pID))
        {
            foreach(new 
Player)
            {
                new 
weapons[2][4];
                
GetPlayerWeaponData(l7weapons[1][0], weapons[1][1]);
                
GetPlayerWeaponData(l8weapons[1][2], weapons[1][3]);
                if(
weapons[1][2] == 16)
                {
                       
format(Str2024"{00FF00}%s {00BBF6}(ID:%d) \t{00FF00}Grenades \t{FF0000}%d\n%s"ReturnName(l), lweapons[1][3], Str);
                       
CountP++;
                   }
                   
//--------------------------------------------------------------
                   
else if(weapons[1][2] == 18)
                   {
                    
format(Str2024"{00FF00}%s {00BBF6}(ID:%d) \t{00FF00}Molotovs \t{FF0000}%d\n%s"ReturnName(l), lweapons[1][3], Str);
                       
CountP++;
                }
                
//--------------------------------------------------------------
                
if(weapons[1][0] == 35)
                {
                    
format(Str2024"{00FF00}%s {00BBF6}(ID:%d) \t{00FF00}Rocket Launcher \t{FF0000}%d\n%s"ReturnName(l), lweapons[1][1], Str);
                     
CountP++;
                }
                
//--------------------------------------------------------------
                
else if(weapons[1][0] == 36)
                {
                    
format(Str2024"{00FF00}%s {00BBF6}(ID:%d) \t{00FF00}Heat Seeker \t{FF0000}%d\n%s"ReturnName(l), lweapons[1][1], Str);
                     
CountP++;
                }
                
//--------------------------------------------------------------
                
else if(weapons[1][0] == 37)
                {
                    
format(Str2024"{00FF00}%s {00BBF6}(ID:%d) \t{00FF00}FlameThrower \t{FF0000}%d\n%s"ReturnName(l), lweapons[1][1], Str);
                     
CountP++;
                }
              }
            new 
Str3[100];
            
format(Str3300"%s\n%s"Str4Str);
            if(
CountP == 0) return SendClientMessage(playerid0xFF0000AA"USAGE: {49FFFF}/weaps [ID]");
            
//--------------------------------------------------------------------------
            
else return ShowPlayerDialog(playerid123DIALOG_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(Str128"%s's Weapons:"ReturnName(pID)), SendClientMessage(playerid0x00FF00AAStr);
            
//------------------------------------------------------------------
            
for(slot 0slot 14slot++)
            {
                
GetPlayerWeaponData(pIDslotweapammo);
                
//--------------------------------------------------------------
                
if(ammo != && weap != 0CountW++;
            }
            if(
CountW 1SendClientMessage(playerid0x00FF00AA"This player don't have Weapons!");
            
//------------------------------------------------------------------
            
if(CountW >= 1)
            {
                for(
slot 0slot 14slot++)
                {
                    
GetPlayerWeaponData(pIDslotweapammo); SendCommandToAdmins(playerid"Weaps");
                    
//----------------------------------------------------------
                    
if(ammo != && weap != 0)
                    {
                        
GetWeaponName(weapWeapNamesizeof(WeapName));
                        
//------------------------------------------------------
                        
if(ammo == 65535 || ammo == 1format(Str2128"%s%s (1)"Str2WeapName);
                        else 
format(Str2128"%s%s (%d)"Str2WeapNameammo); x++;
                        
//------------------------------------------------------
                        
if(>= 5)
                        {
                             
SendClientMessage(playerid0x00FF00AAStr2); 0format(Str2128"");
                        }
                        else 
format(Str2128"%s,  "Str2);
                    }
                }
                
//--------------------------------------------------------------
                
if(<= && 0)
                {
                    
Str2[strlen(Str2)-3] = '.'SendClientMessage(playerid0x00FF00AAStr2);
                }
            }
            
//------------------------------------------------------------------
            
return 1;
        }
        
//----------------------------------------------------------------------
        
else return ERROR_NotConnected(playerid);
    }
    else return 
ErrorMessages(playerid4);

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!
Reply


Messages In This Thread
Command /weaps problem... - by TheRullZ - 17.04.2015, 12:01
Re: Command /weaps problem... - by Jefff - 17.04.2015, 14:28
Re: Command /weaps problem... - by TheRullZ - 17.04.2015, 15:50
Re: Command /weaps problem... - by Jefff - 17.04.2015, 16:20
Re: Command /weaps problem... - by TheRullZ - 17.04.2015, 18:28
Re: Command /weaps problem... - by Jefff - 17.04.2015, 19:46
Re: Command /weaps problem... - by TheRullZ - 17.04.2015, 20:07
Re: Command /weaps problem... - by Jefff - 17.04.2015, 21:56
Re: Command /weaps problem... - by TheRullZ - 19.04.2015, 15:16
Re: Command /weaps problem... - by Jefff - 19.04.2015, 17:58

Forum Jump:


Users browsing this thread: 1 Guest(s)