SA-MP Forums Archive
Small problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Small problem (/showthread.php?tid=575735)



Small problem - AlexBlack - 29.05.2015

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.


Re: Small problem - PepsiCola23 - 29.05.2015

What
PHP код:
HouseList 
means?


Re: Small problem - d3ll - 29.05.2015

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;
}



Re : Small problem - AlexBlack - 29.05.2015

House list is a variable :

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


Re : Small problem - AlexBlack - 29.05.2015

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.


Re : Small problem - AlexBlack - 30.05.2015

Anyone?


Re: Small problem - Konstantinos - 30.05.2015

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)))



Re : Small problem - AlexBlack - 30.05.2015

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 ... )


Re: Small problem - Konstantinos - 30.05.2015

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.


Re : Small problem - AlexBlack - 30.05.2015

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.