Select House Spawn (Dailog)
#1

Hi,

For example : I own three houses ; ID 1, ID 5, and ID 6. I would be shown a dialog after logging in where I can spawn (Spawn at House ID 1, 5 or 6.). These houses would be shown in the dialog. After selecting one of those houses they get spawned to its entery coords.

What my problem is : I seriously have no idea how I can make sure that the listitem is the house ID I clicked on.

Any help?

Thank you.
Yoran.
Reply
#2

Basic example

login
pawn Код:
for(new houseid = 0; houseid != MAX_HOUSES_IN_GAME; houseid++)
    if(HouseInfo[houseid][Ownerid] == PlayerInfo[playerid][accountID])
        format(str,sizeof(str),"%sYour houseID: %d\n",str,houseid);

if(str[0] != '\0')
{
    str[ strlen(str) - 2] = '\0';
    ShowPlayerDialog(DIALOG_CHOOSE_SPAWN, str);
}
else
{
    // not owning anyone
}
pawn Код:
if(dialogid == DIALOG_CHOOSE_SPAWN)
{
    if(response)
    {
        new pos = strfind(inputtext,":",true);
        if(pos != -1)
        {
            PlayerHouseSpawnID[playerid] = strval(inputtext[pos + 2]);
        }
    }
    return 1;
}
OnPlayerConnect
pawn Код:
PlayerHouseSpawnID[playerid] = -1;
OnPlayerSpawn

pawn Код:
if(PlayerHouseSpawnID[playerid] != -1)
{
    new ID = PlayerHouseSpawnID[playerid];
    // interior
    // virtualworld
    SetPlayerPos(playerid,HouseInfo[ID][hX],HouseInfo[ID][hY],HouseInfo[ID][hZ]);
    return 1;
}
Reply
#3

Thank you jeff! Although the "Else not owning anyone" isnt executing when i dont own any houses.
Reply
#4

Its impossible ;p show your code over the loop
Reply
#5

Not sure if you mean by "Show your code over the loop" but this is what I'll give ya :P

pawn Код:
new text[500], HouseFile[500], zone[100], iString[500];
                GetPlayerName(playerid, PlayerName, 24);
                for(new i=1; i<MAX_HOUSES; i++)
                {
                    format(HouseFile, sizeof(HouseFile), "Houses/%d.ini", i);
                    if(dini_Exists(HouseFile))
                    {
                        GetZone(House[i][HX], House[i][HY], House[i][HZ], zone);
                        if(!strcmp(House[i][HOwner], PlayerName, false))
                        {
                            format(text, sizeof(text),"{FFFFFF}House ID : %d | House Location : %s\n", i, zone);
                            strcat(iString, text);
                            if(text[0] != '\0')
                            {
                                text[ strlen(text) - 2] = '\0';
                                ShowPlayerDialog(playerid, 10, DIALOG_STYLE_LIST, "Select Spawn", iString, "Select", "Cancel");
                            }
                            else
                            {
                                SetSpawnInfo(playerid, 0, 1, 362.9318, 173.6587, 1008.3828, 90.0000, 0, 0, 0, 0, 0, 0);
                                TogglePlayerSpectating(playerid, false);
                                SpawnPlayer(playerid);
                                SetPlayerInterior(playerid, 3);
                                SetPlayerVirtualWorld(playerid, 500);
                            }
                        }
                    }
                }
Reply
#6

pawn Код:
new text[500], zone[100];
GetPlayerName(playerid, PlayerName, 24);
for(new i=1; i<MAX_HOUSES; i++)
    if(House[i][HOwner][0] != '\0')
        if(!strcmp(House[i][HOwner], PlayerName))
        {
            GetZone(House[i][HX], House[i][HY], House[i][HZ], zone);
            format(text, sizeof(text),"%s{FFFFFF}House ID : %d | House Location : %s\n",text, i, zone);
        }

if(text[0] != '\0')
{
    text[ strlen(text) - 2] = '\0';
    ShowPlayerDialog(playerid, 10, DIALOG_STYLE_LIST, "Select Spawn", text, "Select", "Cancel");
}
else
{
    SetSpawnInfo(playerid, 0, 1, 362.9318, 173.6587, 1008.3828, 90.0000, 0, 0, 0, 0, 0, 0);
    TogglePlayerSpectating(playerid, false);
    SpawnPlayer(playerid);
    SetPlayerInterior(playerid, 3);
    SetPlayerVirtualWorld(playerid, 500);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)