Array Problem -
NealPeteros - 06.06.2017
What I want to do: List all 911 calls, and assign each of them into a dialog
PHP код:
new calls9110[200][5];
new calls9111[200][5];
new calls9112[200][5];
new calls9113[200][5];
new calls9114[200][5];
PHP код:
for(new i=0; i<10; i++)
{
if(isNull(calls9110[i]))
{
format(calls9110[i], 300, "|_______________911 Call_______________|");
break;
}
}
for(new i=0; i<10; i++)
{
if(isNull(calls9111[i]))
{
format(calls9111[i], 300, "Caller: %s Phone: %i Call Trace: %s",GetName(playerid), PlayerInfo[playerid][pNumber], szZone);
break;
}
}
for(new i=0; i<10; i++)
{
if(isNull(calls9112[i]))
{
format(calls9112[i], 300, "Services Required: SJPD");
break;
}
}
for(new i=0; i<10; i++)
{
if(isNull(calls9113[i]))
{
format(calls9113[i], 300, "Location: %s", text);
break;
}
}
for(new i=0; i<10; i++)
{
if(isNull(calls9114[i]))
{
format(calls9114[i], 300, "Situation: %s", PlayerCrime[playerid][SituationStr]);
break;
}
}
PHP код:
new holder[500], string2[200];
format(string2, sizeof(string2), "%s\n", calls9110[0]);
strcat(holder, string2, sizeof(holder));
format(string2, sizeof(string2), "%s\n", calls9111[0]);
strcat(holder, string2, sizeof(holder));
format(string2, sizeof(string2), "%s\n", calls9112[0]);
strcat(holder, string2, sizeof(holder));
format(string2, sizeof(string2), "%s\n", calls9113[0]);
strcat(holder, string2, sizeof(holder));
format(string2, sizeof(string2), "%s\n", calls9114[0]);
strcat(holder, string2, sizeof(holder));
ShowPlayerDialog(playerid, DIALOG_MDC_911_CALLS, DIALOG_STYLE_MSGBOX, "MDC Police - Page 0", holder, "Next Page", "Cancel");
Re: Array Problem -
NealPeteros - 06.06.2017
Forgot to post the errors
Re: Array Problem -
CheezIt - 06.06.2017
You only need one array and a pointer (a variable). Increase the pointer by one when you go to the next page, use the pointer as the index of the array to show the according information.
Simple as that.
Re: Array Problem -
NealPeteros - 06.06.2017
If you mean this
PHP код:
case DIALOG_MDC_911_CALLS1:
{
if(response)
{
new holder[500], string2[200];
format(string2, sizeof(string2), "%s\n", calls9110[2]);
strcat(holder, string2, sizeof(holder));
format(string2, sizeof(string2), "%s\n", calls9111[2]);
strcat(holder, string2, sizeof(holder));
format(string2, sizeof(string2), "%s\n", calls9112[2]);
strcat(holder, string2, sizeof(holder));
format(string2, sizeof(string2), "%s\n", calls9113[2]);
strcat(holder, string2, sizeof(holder));
format(string2, sizeof(string2), "%s\n", calls9114[2]);
strcat(holder, string2, sizeof(holder));
ShowPlayerDialog(playerid, DIALOG_MDC_911_CALLS2, DIALOG_STYLE_MSGBOX, "MDC Police - Page 2", holder, "Next Page", "Cancel");
}
}
That's what I used
Re: Array Problem -
CheezIt - 06.06.2017
Why are you ~removing~ all your posts?
Re: Array Problem -
NealPeteros - 06.06.2017
Fixed, forgot to inform
Re: Array Problem -
CheezIt - 06.06.2017
Post the solution and put back your old posts, or I'll report your thread. Because as it is right now, it's basically useless for future reference (people searching for solutions to their issues).
Otherwise, don't ever post a thread in this section again. You're breaking the meaning and purpose of "community forums". If you want private help and don't want to post your code, then go somewhere else.
Re: Array Problem -
NealPeteros - 06.06.2017
Oh, alright, hold on.
EDIT: I'll post the necessary parts, I didn't remember everything I did
FIX: Used an enumerator to replace the 4 variables.