Getting every vehicle price with a function or...
#1

So I bassicly have a dealership where I can buy vehicles from.
I already have each vehicle category sorted and the vehicles inside that category.

Now I have a question, I know I can bassicly do a dialog response for each vehicle to take the price but that'll just take too LONG and just flood the script itself, which would make it quite ugly.

I am wondering if it possible to create a function that'd do the work for me in acouple of lines instead of doing like at-least 200+ lines for everything with responses, defines, etc.
Reply
#2

Make an array with prices saved in it. And to access the price you could do like VehPrice[listitem] or something similar.
Reply
#3

Quote:
Originally Posted by mirou123
Посмотреть сообщение
Make an array with prices saved in it. And to access the price you could do like VehPrice[listitem] or something similar.
I think I understand what you mean, could you give me an example of how to create such array (I have never tried to do any of that stuff, therefore I am not experienced with it) with like one vehicle price inside, and maybe you could try to use it inside something? If you could just make something very simple so I would be able to understand it.
Thanks.
Reply
#4

PHP код:
enum vDealerInfo
{
    
DVehName[25],
    
DVehPrice,
    
DVehModel
}

new 
VehDetails_Sports[xxx][vDealerInfo]=
{
//     Name     Price  ModelID
    
{"Infernus"100000,  411}, //0
    
.. // 1
    
..// 2
    
..// etc
    
};

new 
VehDetails_Bikes[xxx][vDealerInfo]=
{
//     Name     Price  ModelID
    
{"NRG-500",  50000,   511}, //0
    
.. //1
    
.. //2
    
..//etc
};


CMD:buy(playeridparams[])
{
    
//ifPlayerHasn'tReachedMax_OwnedVehicleLimit                        0      1     2....
    
ShowPlayerDialog(playerid0DIALOG_STYLE_LIST"Dealership!!""Sports\nBikes\netc""Select""");
    return 
1;
}


public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
dialogid == 0)
    {
        if(!
response// If they clicked 'Cancel' or pressed esc
        
{
            
SendClientMessage(playerid, -1"BitchPlease you too poor.");
        }
        else 
// Pressed ENTER
        
{
            switch(
listitem)
            {
                case 
0:
                {
                    for(new 
0i<sizeof(VehDeatails_Sports); i++)
                    {
                        
format(MSGsizeof(MSG), "%s%s - %i\n"MSG,VehDetails_Sports[i][VehName], VehDetails_Sports[i][VehPrice]);
                    }
                    
ShowPlayerDialog(playerid1DIALOG_STYLE_LIST"Sports"MSG);
                }
                case 
1:
                {
                    for(new 
0i<sizeof(VehDeatails_Bikes); i++)
                    {
                        
format(MSGsizeof(MSG), "%s%s - %i\n"MSG,VehDetails_Bikes[i][VehName], VehDetails_Bikes[i][VehPrice]);
                    }
                    
ShowPlayerDialog(playerid2DIALOG_STYLE_LIST"Bikes"MSG);
                }
            }
        }
        return 
1// We handled dialog, so return 1.
    
}
    else if(
dialogid == 1)//Sports
    
{
        if(!
response)
        {
            
SendClientMessage(playerid, -1"You aint even rich enough to read their names!");
        }
        else
        {
            
//Store the Values and Show him the rest of the infos.
            /*
                For Example:
                PlayerChosenVehicle[playerid]==VehDetails_Sports[listitem][DVehModel];
                ShowPlayerDialog(SeleteColorForVehicle);
                ...
            */
        
}
    }
    else if(
dialogid == 2)//Bikes
    
{
         if(!
response)
        {
            
SendClientMessage(playerid, -1"Can you even hold a stick bro?");
        }
        else
        {
            
//Store the Values and Show him the rest of the infos.
        
}
    }
    return 
0// You MUST return 0 here

Reply
#5

Define the name/price or whatever you are using and put it in a dialog, It will not make you that much of lines.
Reply
#6

Quote:
Originally Posted by Mic_H
Посмотреть сообщение
PHP код:
enum vDealerInfo
{
    
DVehName[25],
    
DVehPrice,
    
DVehModel
}
new 
VehDetails_Sports[xxx][vDealerInfo]=
{
//     Name     Price  ModelID
    
{"Infernus"100000,  411}, //0
    
.. // 1
    
..// 2
    
..// etc
    
};
new 
VehDetails_Bikes[xxx][vDealerInfo]=
{
//     Name     Price  ModelID
    
{"NRG-500",  50000,   511}, //0
    
.. //1
    
.. //2
    
..//etc
};
CMD:buy(playeridparams[])
{
    
//ifPlayerHasn'tReachedMax_OwnedVehicleLimit                        0      1     2....
    
ShowPlayerDialog(playerid0DIALOG_STYLE_LIST"Dealership!!""Sports\nBikes\netc""Select""");
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
dialogid == 0)
    {
        if(!
response// If they clicked 'Cancel' or pressed esc
        
{
            
SendClientMessage(playerid, -1"BitchPlease you too poor.");
        }
        else 
// Pressed ENTER
        
{
            switch(
listitem)
            {
                case 
0:
                {
                    for(new 
0i<sizeof(VehDeatails_Sports); i++)
                    {
                        
format(MSGsizeof(MSG), "%s%s - %i\n"MSG,VehDetails_Sports[i][VehName], VehDetails_Sports[i][VehPrice]);
                    }
                    
ShowPlayerDialog(playerid1DIALOG_STYLE_LIST"Sports"MSG);
                }
                case 
1:
                {
                    for(new 
0i<sizeof(VehDeatails_Bikes); i++)
                    {
                        
format(MSGsizeof(MSG), "%s%s - %i\n"MSG,VehDetails_Bikes[i][VehName], VehDetails_Bikes[i][VehPrice]);
                    }
                    
ShowPlayerDialog(playerid2DIALOG_STYLE_LIST"Bikes"MSG);
                }
            }
        }
        return 
1// We handled dialog, so return 1.
    
}
    else if(
dialogid == 1)//Sports
    
{
        if(!
response)
        {
            
SendClientMessage(playerid, -1"You aint even rich enough to read their names!");
        }
        else
        {
            
//Store the Values and Show him the rest of the infos.
            /*
                For Example:
                PlayerChosenVehicle[playerid]==VehDetails_Sports[listitem][DVehModel];
                ShowPlayerDialog(SeleteColorForVehicle);
                ...
            */
        
}
    }
    else if(
dialogid == 2)//Bikes
    
{
         if(!
response)
        {
            
SendClientMessage(playerid, -1"Can you even hold a stick bro?");
        }
        else
        {
            
//Store the Values and Show him the rest of the infos.
        
}
    }
    return 
0// You MUST return 0 here

Thank you so much.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)