PDA

View Full Version : Dialog input problem


makaronek123
23/03/2017, 12:08 PM
Hi, i want create dialog style input where i can type name of Item and destroy it, i make this:

if(strcmp("/destroy", cmdtext, true) == 0)
{
if(gTeam[playerid] == TEAM_XX)
{
SendClientMessage(playerid, COLOR_RED, "You cant use this command as Zombie");
return 1;
}
ShowPlayerDialog(playerid,67,DIALOG_STYLE_INPUT,"Destroy","Item Name\n Item name:","Destroy","Quit");
}



Response:

if(dialogid==67){

new params[64];
strcat(params,inputtext[6]);
if(response){
if(inputtext[playerid] == params) {

if(!PlayerHasItem(playerid,params))return SendClientMessage(playerid,-1,"You dont have this item!");

RemoveItem(playerid,params,1);
}
return 1;
}
return 0;
}

And i get: error 033: array must be indexed (variable "params")

What i must change? maybe i do a mistake, idk

Toroi
23/03/2017, 12:34 PM
strcat(params,inputtext);

what is this, though?

if(inputtext[playerid] == params)

makaronek123
23/03/2017, 12:40 PM
Lol idk, i think i take this from my old /give command

Jihanz
23/03/2017, 12:42 PM
strcat(params,inputtext);

what is this, though?

if(inputtext[playerid] == params)

I like you Helping people :D
REP+ for you from me (Y)

Toroi
23/03/2017, 12:44 PM
Lol idk, i think i take this from my old /give command

Well, it has no solid reason to be there, so you should consider to remove that statement.

In addition:

- You may want to check if the inputtext is empty and return the same dialog.
- There is no need for strcat or a new string to be there as you have inputtext for that, hence, instead of params you should directly use inputtext and remove both the params declaration and the strcat function.

makaronek123
23/03/2017, 12:49 PM
But how to check a name of Item type to inputtext? or what i should write in inputtext[playerid] == THERE

Toroi
23/03/2017, 12:52 PM
I'm pretty sure your PlayerHasItem(playerid,item) function will handle that.

If the player type ' asdfsda' in the box, it'll return the following:
SendClientMessage(playerid,-1,"You dont have this item!");

Unless the player write an item name, that function wont execute so rest assured. You don't need these checks.

makaronek123
23/03/2017, 01:09 PM
Okey, i got this :)

Thanks very much for help, love you <3