Is it possible to get a variable in DialogResponse -
||123|| - 17.06.2010
I created this little function which makes a gang dynamically, but I am facing some problem in it. the variable
family is the gang slot the stuff needs to be saved in but it always keeps getting saved in gang slot 1. Here is the code.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new family;
if(dialogid == 1)
{
if(listitem == 0)
{
family = 1;
}
if(listitem == 1)
{
family = 2;
}
if(listitem == 2)
{
family = 3;
}
if(listitem == 3)
{
family = 4;
}
if(listitem == 4)
{
family = 5;
}
if(listitem == 5)
{
family = 6;
}
if(listitem == 6)
{
family = 7;
}
if(listitem == 7)
{
family = 8;
}
if(listitem == 8)
{
family = 9;
}
if(listitem == 9)
{
family = 10;
}
if(listitem == 10)
{
family = 11;
}
if(listitem == 11)
{
family = 12;
}
if(listitem == 12)
{
family = 13;
}
if(listitem == 13)
{
family = 14;
}
PlayerPlaySound(playerid, 1132, 0.0, 0.0, 0.0);
ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Gang Creation - 2nd step","Please enter the name of the gang you want to create below.","Done","Cancel");
}
if(dialogid == 2)
{
if(!strlen(inputtext))
{
SendClientMessage(playerid, 0xFF0000FF, "Gang Creation setup canceled");
return 1;
}
if(!response)
{
SendClientMessage(playerid, 0xFF0000FF, "Gang Creation setup canceled");
return 1;
}
new idx;
new length = strlen(inputtext);
while ((idx < length) && (inputtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = inputtext[idx];
idx++;
}
result[idx - offset] = EOS;
PlayerPlaySound(playerid, 1132, 0.0, 0.0, 0.0);
strmid(FamilyInfo[family][FamilyName], result, 0, strlen(result), 255);
SaveFamilies();
SendClientMessage(playerid, COLOR_WHITE, "You've adjusted your Family's Name.");
}
return 1;
}
Re: Is it possible to get a variable in DialogResponse -
||123|| - 17.06.2010
Bump.
Re: Is it possible to get a variable in DialogResponse -
||123|| - 17.06.2010
Anyone?
Re: Is it possible to get a variable in DialogResponse -
dpstdd - 17.06.2010
couldn't you..
family = listitem;
and save 50 lines, idk what you're asking thou
unless you want something like
new family[MAX_PLAYERS];// (top of script)
family[playerid] = listitem;
Re: Is it possible to get a variable in DialogResponse -
||123|| - 17.06.2010
The variable
family is having a problem in the script. family is actually = the slot id of the gang, so no matter what listitem for gangid I choose, it always gets saved into gang id slot 1. That is the problem.
Re: Is it possible to get a variable in DialogResponse -
||123|| - 17.06.2010
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new family;
if(dialogid == 1)
{
PlayerPlaySound(playerid, 1132, 0.0, 0.0, 0.0);
ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Gang Creation - 2nd step","Please enter the name of the gang you want to create below.","Done","Cancel");
family = listitem;
}
if(dialogid == 2)
{
if(!strlen(inputtext))
{
SendClientMessage(playerid, 0xFF0000FF, "Gang Creation setup canceled");
return 1;
}
if(!response)
{
SendClientMessage(playerid, 0xFF0000FF, "Gang Creation setup canceled");
return 1;
}
new idx;
new length = strlen(inputtext);
while ((idx < length) && (inputtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = inputtext[idx];
idx++;
}
result[idx - offset] = EOS;
PlayerPlaySound(playerid, 1132, 0.0, 0.0, 0.0);
strmid(FamilyInfo[family][FamilyName], result, 0, strlen(result), 255);
SaveFamilies();
SendClientMessage(playerid, COLOR_WHITE, "You've adjusted your Family's Name.");
}
return 1;
}
Updated.....same problem.