PDA

View Full Version : [HELP] Show list in DialogStyleList with 'if' possible strcat


iryston
13/08/2014, 10:51 PM
Hi, i want put in Dialog a list with itens of player, for example.
I have Item 1, item 2 and item 4;

and i want show, in dialog.

if(PlayerHaveEagle == 1)
{
format(string,sizeof(string),"Item 1: Eagle (Have)\n");
}
else{
format(string,sizeof(string),"Item 1: Eagle (Don't Have)\n");
}
if(PlayerHaveKnife == 1)
{
format(string,sizeof(string),"Item 1: Knife (Have)\n");
}
else{
format(string,sizeof(string),"Item 1: Knife (Don't Have)\n");
}if(PlayerHaveShotgun == 1)
{
format(string,sizeof(string),"Item 1: ShotGun (Have)\n");
}
else{
format(string,sizeof(string),"Item 1: ShotGun (Don't Have)\n");
}
strcat(str,string);
ShowPlayerDialog(playerid, DialogWeapons, DIALOG_STYLE_LIST, "Chose a weapon to get:", str, "Select", "Cancel");

Is only a base of my idea, so don't have script complete, i need only base to create correct, this method is correct?

But, how show in dialog it? with strcat?

Jefff
13/08/2014, 11:08 PM
Its not ok because you can see only last item, use strcat, char array and packed strings

static itemstr[128 char];

if(PlayerHaveEagle == 1) itemstr = !"Item 1: Eagle (Have)\n";
else itemstr = !"Item 1: Eagle (Don't Have)\n";

if(PlayerHaveKnife == 1) strcat(itemstr,!"Item 1: Knife (Have)\n");
else strcat(itemstr,!"Item 1: Knife (Don't Have)\n");

if(PlayerHaveShotgun == 1) strcat(itemstr,!"Item 1: ShotGun (Have)");
else strcat(itemstr,!"Item 1: ShotGun (Don't Have)");

show itemstr

iryston
14/08/2014, 01:06 AM
Very thanks, work.

But if i want put a string in itemstr? example:

itemstr = !"Item 1: Eagle (Have) Ammo: %i\n",EagleAmo;

Is wrong, the pawn don't show error, but don't work, how be?

Thanks!

Jefff
14/08/2014, 01:16 AM
You need use 'format' for this

static itemstr[128];

if(PlayerHaveEagle == 1) format(itemstr,sizeof(itemstr),"Item 1: Eagle (Have) Ammo: %i\n",EagleAmo);
else itemstr = "Item 1: Eagle (Don't Have)\n";

if(PlayerHaveKnife == 1) format(itemstr,sizeof(itemstr),"%sItem 1: Knife (Have) Ammo: %i\n",itemstr, KnifeAmo);
else strcat(itemstr,"Item 1: Knife (Don't Have)\n");

if(PlayerHaveShotgun == 1) format(itemstr,sizeof(itemstr),"%sItem 1: ShotGun (Have) Ammo: %i",itemstr, ShotGunAmo);
else strcat(itemstr,"Item 1: ShotGun (Don't Have)");

iryston
14/08/2014, 01:48 AM
Perfectly work. Very very thanks man!