Dynamic Dialog List
#1

Hey!

I was wondering if somebody could point me in the right direction logically with something I am wanting to get working.

I have created a MDC for a police faction and such and there is a button on the main list called "View Active 911 Calls" which is all fine. The part I am having issues with Logically is when displaying the list of current calls that are in the system, How can I make the dialog response (Clicking on the call) open up more in depth information. I can do it statically but I can't figure out how to deal with the response for new incoming calls.

EDIT: Very similar to this logic with how he can view the current active calls and click on them for more information.
I'm just having issues with the logic behind it.
https://www.youtube.com/watch?v=6ocX1S6_OIk

Thank you guys.
Reply
#2

Your best option would be to make an enumerator, IMO. Here's an idea:

PHP код:
enum 911_CALL_DATA
{
     
boolcallExists,
     
callLocation[90],
     
callEmergency[128],
     
callDescription[90],
     
callerName[32],
}
new 
911Data[100][911_CALL_DATA]; 
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:

PHP код:
//Top of your script:
new player911Index[MAX_PLAYERS]; 
//Inside /call 911:
for(new 0sizeof(911Data); i++)
{
     if(!
911Data[i][callExists])
     {
         
player911Index[playerid] = i;
         break;
     }

During each step of call (using OnPlayerText for this instance), you can add each part:
PHP код:
OnPlayerText(playeridtext[])
{
    switch(
player911CallStep[playerid])
    {
       case 
location:
       {
             
format(911Data[player911Index[playerid]][callLocation], 90"%s"text);
       }
    }

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:

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 
0sizeof(911Data); i++)
                     {
                         if(
911Data[i][callExists])
                         {
                             
format(sub_strsizeof(sub_str), "%s\t%s\t\n"911Data[i][callerName], 911Data[i][callLocation]);
                             
strcat(principal_strsub_str);
                          }
                      }
                     
ShowPlayerDialog(playeridDIALOG_911_LISTDIALOG_STYLE_TABLIST_HEADERS"911 Calls:"principal_str"Select""<<");
                 }
             }
        }
    }

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.
Reply
#3

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
.
Thanks exactly what I needed. I have basically everything set up already, I was just having troubling processing the logic behind how it should function.

Thanks for taking the time to respond man, I really do appreciate it.
Reply
#4

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
.
Was just going to add, Everything you posted previously helped me out tremendously with more than even just what I was asking about and I'd like to thank you again.

Also,

I was curious if there was a way to add on top of this that in the dialog list of current calls if there was a way to click on a call on that list and pull up more information about that call.

For example on the list it just says the Caller Name and the location of the call. If I was wanting to add information to the enum for each call, How would I interact with the specific call from the dialog to display another dialog showing more information?

Thanks again.
Reply
#5

PHP код:
OnDialogResponse(playerid, ...)
{
    case 
DIALOG_911_LIST// the dialog we call when we show the 911 list.
    
{
         if(
response)
         {
                new 
principal_str[350], sub_str[128]; 
                
format(sub_strsizeof(sub_str), "Name: %s"911Info[listitem][callerName]);
                
strcat(principal_strsub_str);
                
// and et cetera... 
                
ShowPlayerDialog(playeridDIALOG_IDDIALOG_STYLE_LIST"911 Information"principal_str"<<""");
         }
    }

The key is listitem.
Reply
#6

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
.
Thanks for clarifying. You cleared it all up for me!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)