20.08.2017, 07:32
Your best option would be to make an enumerator, IMO. Here's an idea:
I assume you already have a command to call. During the initial /call 911, loop through 911Data and grab a free ID and store it in a player variable. Such as:
During each step of call (using OnPlayerText for this instance), you can add each part:
And so on...
At the end when the call is ended would be the best part to make callExists true.
This is assuming you have a MDC with 911 list in it:
Give it a shot and see how it works. Wrote this on the forums so there could be a typo or an error. Post if you need more help though.
PHP код:
enum 911_CALL_DATA
{
bool: callExists,
callLocation[90],
callEmergency[128],
callDescription[90],
callerName[32],
}
new 911Data[100][911_CALL_DATA];
PHP код:
//Top of your script:
new player911Index[MAX_PLAYERS];
//Inside /call 911:
for(new i = 0; i < sizeof(911Data); i++)
{
if(!911Data[i][callExists])
{
player911Index[playerid] = i;
break;
}
}
PHP код:
OnPlayerText(playerid, text[])
{
switch(player911CallStep[playerid])
{
case location:
{
format(911Data[player911Index[playerid]][callLocation], 90, "%s", text);
}
}
}
At the end when the call is ended would be the best part to make callExists true.
This is assuming you have a MDC with 911 list in it:
PHP код:
#define DIALOG_911_LIST 555
OnDialogResponse(playerid, ...)
{
case YOUR_911_DIALOG:
{
if(response)
{
switch(listitem)
{
case YOUR_911LIST_LIST:
{
new principal_str[650], sub_str[128];
strcat(principal_str, "Caller\tLocation\t\n");
for(new i = 0; i < sizeof(911Data); i++)
{
if(911Data[i][callExists])
{
format(sub_str, sizeof(sub_str), "%s\t%s\t\n", 911Data[i][callerName], 911Data[i][callLocation]);
strcat(principal_str, sub_str);
}
}
ShowPlayerDialog(playerid, DIALOG_911_LIST, DIALOG_STYLE_TABLIST_HEADERS, "911 Calls:", principal_str, "Select", "<<");
}
}
}
}
}