SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 29/04/2015, 08:30 PM   #1
arlindi
Banned
 
Join Date: May 2014
Posts: 871
Reputation: 27
Default Client CmD

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
arlindi is offline   Reply With Quote
Old 29/04/2015, 08:36 PM   #2
zeax
Banned
 
Join Date: Feb 2015
Posts: 36
Reputation: 33
Default Re: Client CmD [+REP]

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");
}
zeax is offline   Reply With Quote
Old 29/04/2015, 08:39 PM   #3
arlindi
Banned
 
Join Date: May 2014
Posts: 871
Reputation: 27
Default Re: Client CmD

FIXED

Thank You
arlindi is offline   Reply With Quote
Old 29/04/2015, 08:39 PM   #4
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,865
Reputation: 1394
Default Re: Client CmD

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.
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System
Konstantinos is offline   Reply With Quote
Old 29/04/2015, 08:46 PM   #5
arlindi
Banned
 
Join Date: May 2014
Posts: 871
Reputation: 27
Default Re: Client CmD

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");

arlindi is offline   Reply With Quote
Old 29/04/2015, 09:11 PM   #6
arlindi
Banned
 
Join Date: May 2014
Posts: 871
Reputation: 27
Default Re: Client CmD

Sorry for this spamm:
https://www.youtube.com/watch?v=C4-SyeWrTY8
Youtube Link
I want like this
arlindi is offline   Reply With Quote
Old 30/04/2015, 11:28 AM   #7
arlindi
Banned
 
Join Date: May 2014
Posts: 871
Reputation: 27
Default Re: Client CmD

AnyOne please
arlindi is offline   Reply With Quote
Old 30/04/2015, 05:36 PM   #8
arlindi
Banned
 
Join Date: May 2014
Posts: 871
Reputation: 27
Default Re: Client CmD

BUMP
arlindi is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Client bug Dredd Bug Reports 3 17/08/2014 07:24 PM
Help with Client (0.3x-0.3z) RazerTT Client Support 2 20/06/2014 05:55 PM
SA-MP 0.3x RC2-2-2 (Client) Translator Client Support 7 21/01/2013 07:14 PM
Client IDs? Calgon Help Archive 1 22/08/2010 12:46 PM
client 0.2 and 0.3 straco Client Support 3 21/10/2009 11:34 PM


All times are GMT. The time now is 10:47 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.