Dialog selection problem - what is wrong [REP ++ ]
#1

Hello guys. I am working on a command called /gps which should show me 2 types of categories: 1. 24/7 Stores and 2.Clothing Store.
If i press on 24/7 Stores are showed 2 businesses because 2 of 24/7 Store are stored in my db.
If i press on Clothing Stores are showed 2businesses because 2 of Clothing Store are stored in my db.
All working fine up here.
I tried to do the next: When you click the specific business to put a checkpoint on it. My next problem is that always the first business ( first listitem ) it puts the checkpoint to the first 24/7 Store ( business id 1 )
Per example if i am at the Clothing Stores there are showed 2 clothing stores. If i click the one it put's wrong checkpoint ( points at clothing store 1) if i click the 2 it's putting checkpoint correctly to the 2nd binco store.
Look at my script:
pawn Код:
new SelBusiness[MAX_PLAYERS];
pawn Код:
CMD:gps(playerid, params[])
{

    ShowPlayerDialog(playerid,113,DIALOG_STYLE_LIST,"Locations:","Driving School (DMV)\nLos Santos\nLas Venturas\nVehicle Mod Shops\nPaintball\nDealership","Select","Cancel");
    SelBusiness[playerid] = 0;
    return 1;
}
pawn Код:
if(dialogid == 113)
    {
        if(response)
        {
            switch(listitem)
            {
                case 0:
                {
                    SCM(playerid, COLOR_TEAL,"Server has set you a checkpoint to Driving School!");
                    SetPlayerCheckpoint(playerid,1219.6129,-1814.2854,16.5938,4.0);
                }
                case 1:
                {
                    ShowPlayerDialog(playerid, 6543, DIALOG_STYLE_LIST, "Los Santos Locations", "24/7 Stores\nClothing Stores", "Checkpoint", "Cancel");
                }
            }
        }
    }
All working fine , distance calculating fine , the only problem is setting the checkpoint to the selected listitem.
pawn Код:
case 6543:
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        new szString[980];
                        new szDialogString[128];
                        for(new xf = 0; xf < MAX_BUSINESSES; xf++)
                        {
                            if(businessVariables[xf][bType] == 69)
                            {
                                if(businessVariables[xf][bType] == 69)
                                {
                                    format(szDialogString, 128, "24/7 Store");
                                }
                                new Float: fDistance = GetPlayerDistanceFromPoint(playerid, businessVariables[xf][bExteriorPos][0], businessVariables[xf][bExteriorPos][1], businessVariables[xf][bExteriorPos][2]);
                                format(szString, sizeof(szString), "%s\n%s (%.0fm away)", szString,szDialogString, fDistance);
                            }
                        }
                        ShowPlayerDialog(playerid, 6542, DIALOG_STYLE_LIST, "24/7 Store", szString, "Checkpoint", "Cancel");
                    }
                    case 1:
                    {
                        new szString[980];
                        new szDialogString[128];
                        for(new xf = 0; xf < MAX_BUSINESSES; xf++)
                        {
                            if(businessVariables[xf][bType] == 34)
                            {
                                if(businessVariables[xf][bType] == 34)
                                {
                                    format(szDialogString, 128, "Clothing Store");
                                }
                                new Float: fDistance = GetPlayerDistanceFromPoint(playerid, businessVariables[xf][bExteriorPos][0], businessVariables[xf][bExteriorPos][1], businessVariables[xf][bExteriorPos][2]);
                                format(szString, sizeof(szString), "%s\n%s (%.0fm away)", szString,szDialogString, fDistance);
                            }
                        }
                        ShowPlayerDialog(playerid, 6542, DIALOG_STYLE_LIST, "Clothing Store", szString, "Checkpoint", "Cancel");
                    }
                }
            }
        }
And the important part of setting up the checkpoint! :
pawn Код:
case 6542:
        {
            if(response)
            {
                        new item = listitem +1;
                        SelBusiness[playerid] = item;
                        new Float: Position[3];
                        GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
                        SetPlayerCheckpoint(playerid, businessVariables[SelBusiness[playerid]][bExteriorPos][0], businessVariables[SelBusiness[playerid]][bExteriorPos][1], businessVariables[SelBusiness[playerid]][bExteriorPos][2], 1.0);
                }
            }
        }
What could be wrong ? i tried many different things ..
Thanks for helping me ! I give rep who resolvs the problem.
Reply
#2

you're doing
pawn Код:
case 6542:
        {
            if(response)
            {
                        new item = listitem +1;
                        SelBusiness[playerid] = item;
No matter if you have the clothes or the 24/7 dialog before, you use "listitem"... there is no seperation which dialog you had before...
You should add something like
pawn Код:
playerStoreType[playerid] = 0;
or
pawn Код:
playerStoreType[playerid] = 1;
into this part:
pawn Код:
if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        new szString[980];
                        new szDialogString[128];
                        for(new xf = 0; xf < MAX_BUSINESSES; xf++)
                        {
                            if(businessVariables[xf][bType] == 69)
                            {
                                if(businessVariables[xf][bType] == 69)
                                {
                                    format(szDialogString, 128, "24/7 Store");
                                }
                                new Float: fDistance = GetPlayerDistanceFromPoint(playerid, businessVariables[xf][bExteriorPos][0], businessVariables[xf][bExteriorPos][1], businessVariables[xf][bExteriorPos][2]);
                                format(szString, sizeof(szString), "%s\n%s (%.0fm away)", szString,szDialogString, fDistance);
                            }
                        }
                        ShowPlayerDialog(playerid, 6542, DIALOG_STYLE_LIST, "24/7 Store", szString, "Checkpoint", "Cancel");
                    }
                    case 1:
                    {
                        new szString[980];
                        new szDialogString[128];
                        for(new xf = 0; xf < MAX_BUSINESSES; xf++)
                        {
                            if(businessVariables[xf][bType] == 34)
                            {
                                if(businessVariables[xf][bType] == 34)
                                {
                                    format(szDialogString, 128, "Clothing Store");
                                }
                                new Float: fDistance = GetPlayerDistanceFromPoint(playerid, businessVariables[xf][bExteriorPos][0], businessVariables[xf][bExteriorPos][1], businessVariables[xf][bExteriorPos][2]);
                                format(szString, sizeof(szString), "%s\n%s (%.0fm away)", szString,szDialogString, fDistance);
                            }
                        }
                        ShowPlayerDialog(playerid, 6542, DIALOG_STYLE_LIST, "Clothing Store", szString, "Checkpoint", "Cancel");
                    }
                }
            }
so you can later on seperate it
Reply
#3

You should really look into y_dialogs if your writing them it's much easier to organize your code. A couple of things if your going to do it the way your doing it make sure you define your dialog ids example.

pawn Код:
#define 113 SET_CHECKPOINT
I would also write these system in an include if your trying to write this all into one script directly into your're gamemode there will be issues like this so you should be using includes and hooking.

But the post above explains your offsetting your index incorrectly.
Reply
#4

Quote:
Originally Posted by Sascha
Посмотреть сообщение
you're doing
pawn Код:
case 6542:
        {
            if(response)
            {
                        new item = listitem +1;
                        SelBusiness[playerid] = item;
No matter if you have the clothes or the 24/7 dialog before, you use "listitem"... there is no seperation which dialog you had before...
You should add something like
pawn Код:
playerStoreType[playerid] = 0;
or
pawn Код:
playerStoreType[playerid] = 1;
into this part:
pawn Код:
if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        new szString[980];
                        new szDialogString[128];
                        for(new xf = 0; xf < MAX_BUSINESSES; xf++)
                        {
                            if(businessVariables[xf][bType] == 69)
                            {
                                if(businessVariables[xf][bType] == 69)
                                {
                                    format(szDialogString, 128, "24/7 Store");
                                }
                                new Float: fDistance = GetPlayerDistanceFromPoint(playerid, businessVariables[xf][bExteriorPos][0], businessVariables[xf][bExteriorPos][1], businessVariables[xf][bExteriorPos][2]);
                                format(szString, sizeof(szString), "%s\n%s (%.0fm away)", szString,szDialogString, fDistance);
                            }
                        }
                        ShowPlayerDialog(playerid, 6542, DIALOG_STYLE_LIST, "24/7 Store", szString, "Checkpoint", "Cancel");
                    }
                    case 1:
                    {
                        new szString[980];
                        new szDialogString[128];
                        for(new xf = 0; xf < MAX_BUSINESSES; xf++)
                        {
                            if(businessVariables[xf][bType] == 34)
                            {
                                if(businessVariables[xf][bType] == 34)
                                {
                                    format(szDialogString, 128, "Clothing Store");
                                }
                                new Float: fDistance = GetPlayerDistanceFromPoint(playerid, businessVariables[xf][bExteriorPos][0], businessVariables[xf][bExteriorPos][1], businessVariables[xf][bExteriorPos][2]);
                                format(szString, sizeof(szString), "%s\n%s (%.0fm away)", szString,szDialogString, fDistance);
                            }
                        }
                        ShowPlayerDialog(playerid, 6542, DIALOG_STYLE_LIST, "Clothing Store", szString, "Checkpoint", "Cancel");
                    }
                }
            }
so you can later on seperate it
I tried to separate them but for what? The checkpoint function should work on the clicked listitem for the case 0 or case 1.
The text is formmating correctly , the distance is calculating correctly, just the checkpoint has problems.
Any ideeas or fixing answers?
Reply
#5

Any ideeas?
So how to separate them because i tried with the playerStoreType and nothing happens ??
Reply
#6

UP!!!
Reply
#7

The problem is that you are usng the same dialog id for the list of clothes and the list of 24/7..
how should the server know which dialog the listitem came from?
if you click the first item on 24/7 it's listitem = 0 and if you click the first item on clothes it's listitem = 0, too..
so either use a different dialogid or use something like
pawn Код:
SetPVarInt(playerid, "FromDialog", 1);
when showing the 24/7
and
pawn Код:
SetPVarInt(playerid, "FromDialog", 2);
when showing the clothes
and then do
pawn Код:
if(GetPVarInt(playerid, "FromDialog") == 1)
{
     set check point and stuff
}
else if(GetPVarInt(playerid, "FromDialog") == 2)
{
     set check points for clothes
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)