29.04.2015, 20:46
Quote:
Never use ShowPlayerDialog in a loop as it'll be called way too many times and also no need to loop twice:
PHP Code:
|
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(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++;
}
}
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), "Players:%s(%d)\n %sWeapons: %s(%d)\n",PlayerName(targetid),targetid, string, weapon, ammo);
ShowPlayerDialog(playerid,DIALOG_ADMINS,DIALOG_STYLE_MSGBOX,"Viewing Client Info",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");
}