Client CmD
#1

PHP Code:
CMD:client(playeridparams[])
{
    if(
pInfo[playerid][pAdminLevel] >= 1)
    {
        new 
AdminDutyMsg[128], targetid;
        
format(AdminDutyMsgsizeof(AdminDutyMsg), ""COL_WHITE"["COL_CADMIN"ADMIN"COL_WHITE"]"COL_CGREY" %s > client > %s" ,PlayerName(playerid), PlayerName(targetid));
        
SendMessageToAllAduty(-1,AdminDutyMsg);
        new 
count 0;
        new 
ammoweaponidweapon[24], string[128], id;
        if(!
sscanf(params"u"id))
        {
                for (new 
013c++)
                {
                    
GetPlayerWeaponData(idcweaponidammo);
                    if (
weaponid != && ammo != 0)
                    {
                        
count++;
                    }
                }
                
SendClientMessage(playeridCOLOR_ORANGE"||=============WEAPONS AND AMMO===========||");
                if(
count 0)
                {
                    for (new 
013c++)
                    {
                        
GetPlayerWeaponData(idcweaponidammo);
                        if (
weaponid != && ammo != 0)
                        {
                            
GetWeaponName(weaponidweapon24);
                            
format(stringsizeof(string), "Weapons: %s  Ammo: %d\n"weaponammo);
                            
ShowPlayerDialog(playerid,DIALOG_ADMINS,DIALOG_STYLE_MSGBOX,"Client",string,"Close","");
                        }
                    }
                }
                else
                {
                    
SendClientMessage(playeridCOLOR_GREY"This player has no weapons!");
                }
                return 
1;
        }
        else return 
SendClientMessage(playeridCOLOR_GREY"USAGE: /cw [ID]");
    }
    else return 
SendClientMessage(playeridCOLOR_GREY"You are not allowed to do this");

Hello

This command was work sucsessfull
But i am try to change it from SendClientMessage To Dialog
I want to get weapons i dialog

But it gave mee just the first Weapon and ammo

Thanks
Reply
#2

Fixed up your code
  1. ShowPlayerDialog() doesn't need to be called 13 times (put it outside the loop)
  2. You need to add the string to the string
pawn Code:
CMD:client(playerid, params[])
{
    if(pInfo[playerid][pAdminLevel] >= 1)
    {

        new AdminDutyMsg[128], targetid;
        format(AdminDutyMsg, sizeof(AdminDutyMsg), ""COL_WHITE"["COL_CADMIN"ADMIN"COL_WHITE"]"COL_CGREY" %s > client > %s" ,PlayerName(playerid), PlayerName(targetid));
        SendMessageToAllAduty(-1,AdminDutyMsg);
        new count = 0;
        new ammo, weaponid, weapon[24], string[128], id;
        if(!sscanf(params, "u", id))
        {
                for (new c = 0; c < 13; c++)
                {
                    GetPlayerWeaponData(id, c, weaponid, ammo);
                    if (weaponid != 0 && ammo != 0)
                    {
                        count++;
                    }
                }
                SendClientMessage(playerid, COLOR_ORANGE, "||=============WEAPONS AND AMMO===========||");

                if(count > 0)
                {
                    for (new c = 0; c < 13; c++)
                    {
                        GetPlayerWeaponData(id, c, weaponid, ammo);
                        if (weaponid != 0 && ammo != 0)
                        {
                            GetWeaponName(weaponid, weapon, 24);
                            format(string, sizeof(string), "%sWeapons: %s  Ammo: %d\n", string, weapon, ammo);
                        }
                    }
                    ShowPlayerDialog(playerid,DIALOG_ADMINS,DIALOG_STYLE_MSGBOX,"Client",string,"Close","");
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "This player has no weapons!");
                }
                return 1;
        }
        else return SendClientMessage(playerid, COLOR_GREY, "USAGE: /cw [ID]");
    }
    else return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to do this");
}
Reply
#3

FIXED

Thank You
Reply
#4

Never use ShowPlayerDialog in a loop as it'll be called way too many times and also no need to loop twice:
PHP Code:
for (new 013c++)
{
    
GetPlayerWeaponData(idcweaponidammo);
    if (
weaponid != && ammo != 0)
    {
        
GetWeaponName(weaponidweapon24);
        
format(stringsizeof(string), "%sWeapons: %s  Ammo: %d\n"stringweaponammo);
        
count++;
    }
}
if(!
countSendClientMessage(playeridCOLOR_GREY"This player has no weapons!");
else 
ShowPlayerDialog(playerid,DIALOG_ADMINS,DIALOG_STYLE_MSGBOX,"Client",string,"Close","");
return 
1
PS: You declared "targetid" and you are trying to get the name. It has not been assigned to any value so it will always return the name of the player with ID 0.
Reply
#5

Quote:
Originally Posted by Konstantinos
View Post
Never use ShowPlayerDialog in a loop as it'll be called way too many times and also no need to loop twice:
PHP Code:
for (new 013c++)
{
    
GetPlayerWeaponData(idcweaponidammo);
    if (
weaponid != && ammo != 0)
    {
        
GetWeaponName(weaponidweapon24);
        
format(stringsizeof(string), "%sWeapons: %s  Ammo: %d\n"stringweaponammo);
        
count++;
    }
}
if(!
countSendClientMessage(playeridCOLOR_GREY"This player has no weapons!");
else 
ShowPlayerDialog(playerid,DIALOG_ADMINS,DIALOG_STYLE_MSGBOX,"Client",string,"Close","");
return 
1
PS: You declared "targetid" and you are trying to get the name. It has not been assigned to any value so it will always return the name of the player with ID 0.
Thanks What about here now
I want to get name just one time not 2 times and the name
I get 2 times the name or if i have 3 weapons i get the name 3 times
What i must do ? THanks for help TOoo

PHP Code:
CMD:client(playeridparams[])
{
    if(
pInfo[playerid][pAdminLevel] >= 1)
    {
        new 
AdminDutyMsg[128], targetid;
        
format(AdminDutyMsgsizeof(AdminDutyMsg), ""COL_WHITE"["COL_CADMIN"ADMIN"COL_WHITE"]"COL_CGREY" %s > client > %s" ,PlayerName(playerid), PlayerName(targetid));
        
SendMessageToAllAduty(-1,AdminDutyMsg);
        new 
count 0;
        new 
ammoweaponidweapon[24], string[128], id;
        if(!
sscanf(params"u"id))
        {
                for (new 
013c++)
                {
                    
GetPlayerWeaponData(idcweaponidammo);
                    if (
weaponid != && ammo != 0)
                    {
                        
count++;
                    }
                }
                if(
count 0)
                {
                    for (new 
013c++)
                    {
                        
GetPlayerWeaponData(idcweaponidammo);
                        if (
weaponid != && ammo != 0)
                        {
                            
GetWeaponName(weaponidweapon24);
                            
format(stringsizeof(string), "Players:%s(%d)\n  %sWeapons: %s(%d)\n",PlayerName(targetid),targetidstringweaponammo);
                            
ShowPlayerDialog(playerid,DIALOG_ADMINS,DIALOG_STYLE_MSGBOX,"Viewing Client Info",string,"Close","");
                        }
                    }
                }
                else
                {
                    
SendClientMessage(playeridCOLOR_GREY"This player has no weapons!");
                }
                return 
1;
        }
        else return 
SendClientMessage(playeridCOLOR_GREY"USAGE: /cw [ID]");
    }
    else return 
SendClientMessage(playeridCOLOR_GREY"You are not allowed to do this");

Reply
#6

Sorry for this spamm:
https://www.youtube.com/watch?v=C4-SyeWrTY8
Youtube Link
I want like this
Reply
#7

AnyOne please
Reply
#8

BUMP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)