Easiest way to put this into a dialog?
#1

Hey!

I'm not lazy, but I do know a way or two to do this, but I use functions like this very common.

What's the easiest way to make this display in a dialog.

pawn Код:
for(new x = 1; x < MAX_VEHICLES; x++)
    {
        if(VehOwner[x] == PlayerSQLID[x])
        {
            am++;
        }
        if(am > 0)
        {
            for(new y = 1; y < MAX_TICKETS; y++)
            {
                if(PTVehSQLID[y] == VehicleSQLID[x])
                {
                    am2++;
                }
            }
        }
    }
    if(am == 0)return SendClientMessage(playerid, COLOUR_GREY, "You do not own any vehicles.");
    if(am2 == 0)return SendClientMessage(playerid, COLOUR_GREY, "You do not have any outstanding parking tickets.");

I'm looking to place the tickets with the ID in a dialog in this format.

pawn Код:
if(n == 0)
                        {
                            format(dialogstring, sizeof(dialogstring), ""#COL_WHITE"%s", PlayerArrests[n][ar_cr]);
                        }
                        else
                        {
                            format(dialogstring, sizeof(dialogstring), "%s\n"#COL_WHITE"%s", dialogstring, PlayerArrests[n][ar_cr]);
                        }
Reply
#2

Bump
Reply
#3

The best way to do this I believe is SQL. If a player owns a specific vehicle and from what I see, each vehicle has its own unique ID in the table, send a query that will count how many tickets exist for that vehicle. If you do not want this though, the next one would be foreach. Have all vehicles in an iterator and loop through created/added (static) vehicles ONLY instead of 2000 times everytime.

pawn Код:
if(VehOwner[x] == PlayerSQLID[x])
That'd get out of bounds as the max value MAX_PLAYERS can be defined is 1000 and loop goes up to 1999.
Another loop for players would be needed.

As for the last one, why not just:
pawn Код:
// outside of the loop:
new dialogstring[150] = "{FFFFFF}"; // Increase if you want to, just an example
// inside the loop:
format(dialogstring, sizeof(dialogstring), "%s%s\n", dialogstring, PlayerArrests[n][ar_cr]);
And about the ID: if you store them somewhere and the "n" is the same index for it, it's piece of cake.
Reply
#4

I appreciate your support on the loop part, I was mainly meaning the dialog as it is the part I was trying to brainstorm. Will that display every single result with the correct ID?
Reply
#5

I was just trying to show you that you don't need to check if n is not equal to 0 so you can put a new line and the previous formatted text. If the string is empty, it will insert nothing. Basically, it does the same exact thing without any extra checks.

About the IDs, did that format insert the ID because I see %s specifier for strings and I don't know what PlayerArrests[n][ar_cr] is supposed to be.
Reply
#6

That was an example, basically. I want the dialog to display all the results of the tickets, then when I click that result it allows me to view the ticket and click it for further information (that's additional) I need to ensure when I click the correct ticket, it displays the ID in the MYSQL relevant to that ticket.


I appreciate your response.
Reply
#7

I still believe a query and a loop to retrieve the data afterwards in order to display all the tickets would be way easier. As for the ID when you click a ticket, I guess storing the IDs along with the rest would be possible to achieve that.
Reply
#8

Thanks very much.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)