Small problem
#1

Hi , i want to make a house teleport system so when i use /gohome it's give me a dialog , but i want to do this with Player Owner name so i'am trying this :

PHP код:
                        for (new iMAX_HOUSESi++)
                        {
                            if(!
strcmp(AHouseData[i][Owner], GetName(playerid)))
                                
format(HouseList1000"%s{00FF00}%s{FFFFFF}\n"HouseListAHouseData[i][HouseName]);
                        }
                        
ShowPlayerDialog(playeridDialogGoHomeDIALOG_STYLE_TABLIST"Choose your house :"HouseList"Select""Cancel"); 
When i use this command, i got the dialog but nothing write in it , but i can't find the problem, thank's for advance.
Reply
#2

What
PHP код:
HouseList 
means?
Reply
#3

pawn Код:
COMMAND:gohome(playerid, params[])
{
    new HouseList[258], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    for (new i, h = MAX_HOUSES; i != h; i++)
    {
        if(!strcmp(AHouseData[i][Owner], pName, false))
        {
            new iHouse[58];
            format(iHouse, sizeof(iHouse), "{00FF00}%s{FFFFFF}\n", AHouseData[i][HouseName]);
            strcat(HouseList, iHouse);
        }
    }
    ShowPlayerDialog(playerid, DialogGoHome, DIALOG_STYLE_TABLIST, "Choose your house :", HouseList, "Select", "Cancel");
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DialogGoHome && response)
    {
        new iCount, pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, sizeof(pName));
        for (new i, h = MAX_HOUSES; i != h; i++)
        {
            if(!strcmp(AHouseData[i][Owner], pName, false))
            {
                if(iCount == listitem)
                {
                    SetPlayerPos(playerid, housecordx, housecordy, housecordz);
                    break;
                }
                iCount++;
            }
        }
    }
    if(dialogid == DialogGoHome && !response) return 0;
}
Reply
#4

House list is a variable :

PHP код:
new HouseList[1000]; 
i will try your solution d3ll.
Reply
#5

the same problem , when i click the listitem 1 it will response for listitem 2 and when i click 3 response for listitem 4 ect ... , and when i do /gohome i got nothing in the first case like " ", thank's for helping.
Reply
#6

Anyone?
Reply
#7

Instead of looping through all the houses, wouldn't it be better having a limit per-player? By that, you wouldn't need to loop twice (in the OnDialogResponse callback too).

Anyway, strcmp returns 0 even if one or both strings are NULL so you have to check if they're not and add them to the dialog's info string.

pawn Код:
if(!isnull(AHouseData[i][Owner]) && !strcmp(AHouseData[i][Owner], GetName(playerid)))
Reply
#8

Work fine now , but when i do the command i have a full list of my house Name like "My House Name\n My HouseName ect ... )
Reply
#9

Wasn't it what you wanted? Having in a dialog all the houses' name you own and then on selecting a specific house to teleport you there? d3ll's example is very good to retrieve it in OnDialogResponse, just don't forget the isnull check along with strcmp.
Reply
#10

Yes , but i want just to show in the dialog the houses that i own it , now i got it , but the dialog is bugged i got the dialog anothers houses Name that i don't own it , but the name of the houses stay the same "My House Name"

Example :

i have 1 house , when i do /gohome i got a dialog with many houses that have the same name house.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)