Surely there is a shorter way of doing this dam dialog... 172,380 Lines...
#1

Hey Fellow scripters :P
I ahh... am having troubles with a VERY large script that i think can and should be compressed or re-written in another way because this is bullsh*t...

Okay, in this list there is nearly every vehicle(Other than trains and what ever else isn't really RP to be driving around a city.) So... by a rough guess almost 80-90 Vehicles.

Case 100: (4 Lines a vehicle )
pawn Код:
case 100:
        {
            if(!response)
            {
                return 1;
            }
           
            switch(listitem)
            {
                case 0://Stretch
                {
                    ShowPlayerDialog(playerid, 101, DIALOG_STYLE_MSGBOX, "Vehicle Information", "Price:\n \n\nDescription:\n ","Continue","Back");
                }
                case 1://Cheetah
                {
                    ShowPlayerDialog(playerid, 102, DIALOG_STYLE_MSGBOX, "Vehicle Information", "Price:\n \n\nDescription:\n ","Continue","Back");
                }
                case 2://Admiral
                {
                    ShowPlayerDialog(playerid, 103, DIALOG_STYLE_MSGBOX, "Vehicle Information", "Price:\n $\n\nDescription:","Continue","Back");
                }
                case 3://Feltzer
                {
                    ShowPlayerDialog(playerid, 104, DIALOG_STYLE_MSGBOX, "Vehicle Information", "Price:\n $\n\nDescription:","Continue","Back");
                }
                case 4://Huntley
                {
                    ShowPlayerDialog(playerid, 105, DIALOG_STYLE_MSGBOX, "Vehicle Information", "Price:\n $\n\nDescription:","Continue","Back");
                }

Then each vehicle is separated into it's own 'case'
Case 101: (8 lines a vehicle)
pawn Код:
case 101://Stretch
        {
            if(!response)
            {
                ShowPlayerDialog(playerid, 100, DIALOG_STYLE_LIST, "Vehicle Catalogue", "Stretch\r\nCheetah\r\nAdmiral\r\nFeltzer\r\nHuntley\r\nBanshee\r\n...","Continue","Cancel");
            }
            if(response)
            {
                   new dialog[370];
                   strcat(dialog,"{000000}BLACK\r\n{FFFFFF}WHITE
                ShowPlayerDialog(playerid, 102, DIALOG_STYLE_LIST, "
Select a Primary vehicle colour", dialog, "Continue","Back");
            }
        }
Then we have the next case...
Okay there are 126 colours, well... that we are going to use...

Secondary Colour Selection....
Case 102: (126 Colours x 8 Lines = 1008)
pawn Код:
case 102://Stretch Secondary Colour Table
        {
            if(!response)
            {
                ShowPlayerDialog(playerid, 100, DIALOG_STYLE_LIST, "Vehicle Catalogue", "Stretch\r\nCheetah\r\nAdmiral\r\nFeltzer\r\nHuntley\r\nBanshee\r\n...,"Continue","Cancel");
            }
            switch(listitem)
            {
                case 0://BLACK
                {
                    new dialog[370];
                    strcat(dialog,"
{000000}BLACK\r\n{FFFFFF}WHITE");
                    ShowPlayerDialog(playerid, 103, DIALOG_STYLE_LIST, "
Select a Secondary Colour", dialog,"Continue","Back");
                }
                case 1://WHITE
                {
                    new dialog[370]
                    strcat(dialog,"
{000000}BLACK\r\n{FFFFFF}WHITE");
                    ShowPlayerDialog(playerid, 104, DIALOG_STYLE_LIST, "
Select a Secondary Colour", dialog, "Continue", "Back");
                }
Then we have our final case


Purchase Confirmation
Case 103:(8 lines each Colour, 126 colours, 8x126=1008)
pawn Код:
case 103://Vehicle Confirmation.
        {
            if(!response)
            {
                ShowPlayerDialog(playerid, 100, DIALOG_STYLE_LIST, "Vehicle Catalogue", "Stretch\r\nCheetah\r\nAdmiral\r\nFeltzer\r\nHuntley\r\nBanshee\r\n...","Continue","Cancel");
            }
            switch(listitem)
            {
                case 0://BLACK
                {
                    new dialog[370];
                    strcat(dialog,"rar rar rar \n");
                    ShowPlayerDialog(playerid,152,DIALOG_STYLE_MSGBOX,"Purchase Confirmation",dialog,"Sign", "Decline");
                }
                case 1://WHITE
                {
                    new dialog[370];
                    strcat(dialog,"Rar rar rar \n");
                    ShowPlayerDialog(playerid,153,DIALOG_STYLE_MSGBOX,"Purchase Confirmation",dialog,"Sign", "Decline");
                }
            }

So, to sum it all up...
4 Lines a Vehicle
8 Lines a Vehicle
8 Lines a Colour x 126 Colours = 1008
8 Lines a Colour x 126 Colours = 1008

4 + 8 + 1008 + 1008 = 2028 Lines
2028 Lines x 85 Vehicles = 172,380 Lines?
Daphuk?
Surely i calculated something wrong...
Reply
#2

Upon selecting a vehicle, set a variable to the listitem and instead of having a ton of dialogs per vehicle, have one dialog do stuff based off of the variable.
Reply
#3

Yea, I'm not sure how to make the variable save the colour 1 selection while you select colour 2..? Blah... i'm not very good with variables at all to be honest, never really focused on them much but thanks.. will look into them..


EDIT:
Blah, I knew what a variable was Just didn't know what it was called, and still i don't know much about them :P
Okay, Well with this out the way, how do i get the 'Vehicle Confirmation' to follow what the player has selected..?

For example...
I want a red and black Stretch.

How does the script recall i clicked on, the stretch, red and black...?

Edit 2:
Duh... Through the Variable... -.-
Reply
#4

Okay so like so...?

pawn Код:
if(!response)
    {
        ShowPlayerDialog(playerid, 100, DIALOG_STYLE_LIST, "Vehicle Catalogue", "Stretch\r\nCheetah\r\nAdmiral","Continue","Cancel");
    }
    switch(listitem)
    {
        case 102://Stretch Secondary Colour Table
        {
            if(!response)
            {
                ShowPlayerDialog(playerid, 100, DIALOG_STYLE_LIST, "Vehicle Catalogue", "Stretch\r\nCheetah\r\nAdmiral","Continue","Cancel");
            }
            switch(listitem)
            {
                case 0://BLACK
                {
                    new dialog[370];
                    new colour1 = 0;
                    strcat(dialog,"{000000}BLACK\r\n{FFFFFF}WHITE
                    ShowPlayerDialog(playerid, 103, DIALOG_STYLE_LIST, "
Select a Secondary Colour", dialog,"Continue","Back");
                    colour1 += 1;
                }
                case 1://WHITE
                {
                    new dialog[370];
                    new colour1 = 0;
                    strcat(dialog,"
{000000}BLACK\r\n{FFFFFF}WHITE");
                    ShowPlayerDialog(playerid, 103, DIALOG_STYLE_LIST, "
Select a Secondary Colour", dialog,"Continue","Back");
                    colour1 +=2;
                }
Reply
#5

Go read pawn-lang.pdf! The problem is that you do not understand what the code does, if you did you would see how easily that can be written.
Reply
#6

Basicly players choose a Vehicle.

Once selected there should be an array ex. new Vehicle[MAX_PLAYERS] and set Vehicle[playerid] = ModelIDOfTheVehicleTheyChose.

Then on the second dialog, they choose the color for the car, but there's two colors they have to choose, so we create another array ex. new VehicleColor[MAX_PLAYERS][2].

Once they've selected the primary color through dialog we should set VehicleColor[playerid][0] = ThePrimaryColor.

And then lastly there's a dialog for the secondary color, loop to the primary color dialog just as before, just instead of setting VehicleColor[playerid][0] (because it's already set) we set VehicleColor[playerid][1] = TheSecondaryColor.

and at the end we create our vehicle for the player and put the player in it like this,

Код:
new Float: X,
Float: Y, Float: Z, Float: A;
GetPlayerPos(playerid, X, Y, Z); GetPlayerFacingAngle(playerid, A); new VehicleID = CreateVehicle(Vehicle[playerid], X, Y, Z, A, VehicleColor[playerid][0], VehicleColor[playerid][1], -1); PutPlayerInVehicle(playerid, VehicleID, 0);
Note. Put the arrays above the main() {} callback.
Note. You can use the same color dialog for all vehicles. Making it 85 + 126 = 211
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)