Dialog won't open, strcat issue I think. -
Dokins - 30.03.2014
At the strcat part, I'm trying to copy over the string, so I can save it so they can go back to the string if the response is 0 on the next dialog, means they can browse through records.
pawn Код:
else if(dialogid == DIALOG_SHOWPERSON)
{
if(response == 0) //response 0 is always the SECOND BUTTON! (in our case this was "Close".
{
return 1;
}
else //If the player did not press the close button, but the "Select" button, the script reads the following.
{
new dialogstring[200], string[128];
format(string, sizeof(string), "SELECT * FROM `arecords` WHERE `PSQLID` = %d ORDER BY `id` DESC LIMIT 10", psql[playerid]);
mysql_query(string);
mysql_store_result();
new r_msg[500];
new n = 0;
printf("psqlid: %d", psql[playerid]);
if(mysql_num_rows() < 1)return SendClientMessage(playerid, COLOUR_GREY, "No records found.");
while(mysql_fetch_row(r_msg))
{
sscanf(r_msg, "p<|>e<iiiis[24]iiii>", PlayerArrests[n]);
if(n == 0)
{
format(dialogstring, sizeof(dialogstring), ""#COL_WHITE"CRIME: "#COL_RED"%s", PlayerArrests[n][ar_cr]);
strcat(Pdialogstring[playerid], dialogstring, 200);
}
else
{
format(dialogstring, sizeof(dialogstring), "%s\n"#COL_WHITE"CRIME: "#COL_RED"%s", dialogstring, PlayerArrests[n][ar_cr]);
strcat(Pdialogstring[playerid], dialogstring, 200);
}
n++;
}
ShowPlayerDialog(playerid, DIALOG_RECORDS, DIALOG_STYLE_LIST, "Showing 10 Latest Records.", dialogstring, "Select", "Black");
}
}
I'm trying to get the dialog to open the saved string, based on a per-player array so it doesn't get over-written if someone else uses the dialog.
pawn Код:
else if(dialogid == DIALOG_RECORDS) //if the player responsed to the dialog (ID = 0, as we've set it as such - you'll use your definition) then the script continues here
{
if(response == 0) //response 0 is always the SECOND BUTTON! (in our case this was "Close".
{
ShowPlayerDialog(playerid, DIALOG_RECORDS, DIALOG_STYLE_LIST, "Showing 10 Latest Records.", Pdialogstring[playerid], "Select", "Black");
}
Re: Dialog won't open, strcat issue I think. -
Konstantinos - 30.03.2014
So basically you want Pdialogstring[playerid] to store the text of dialogstring but you insert the text to the old one. You need to reset Pdialogstring[playerid] first and then use strcat; although a macro is easier:
pawn Код:
#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)
and change:
pawn Код:
if(n == 0)
{
format(dialogstring, sizeof(dialogstring), ""#COL_WHITE"CRIME: "#COL_RED"%s", PlayerArrests[n][ar_cr]);
strcat(Pdialogstring[playerid], dialogstring, 200);
}
else
{
format(dialogstring, sizeof(dialogstring), "%s\n"#COL_WHITE"CRIME: "#COL_RED"%s", dialogstring, PlayerArrests[n][ar_cr]);
strcat(Pdialogstring[playerid], dialogstring, 200);
}
to:
pawn Код:
if(n == 0) format(dialogstring, sizeof(dialogstring), ""#COL_WHITE"CRIME: "#COL_RED"%s", PlayerArrests[n][ar_cr]);
else format(dialogstring, sizeof(dialogstring), "%s\n"#COL_WHITE"CRIME: "#COL_RED"%s", dialogstring, PlayerArrests[n][ar_cr]);
strcpy(Pdialogstring[playerid], dialogstring, 200);
Re: Dialog won't open, strcat issue I think. -
Dokins - 30.03.2014
Thanks man! Truly appreciate it.
REP ++;