Posts: 73
Threads: 13
Joined: Oct 2012
Reputation:
0
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.
Posts: 2,593
Threads: 34
Joined: Dec 2007
10.05.2014, 19:29
(
Последний раз редактировалось Jefff; 10.05.2014 в 20:13.
)
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;
}
Posts: 73
Threads: 13
Joined: Oct 2012
Reputation:
0
Thank you jeff! Although the "Else not owning anyone" isnt executing when i dont own any houses.
Posts: 2,593
Threads: 34
Joined: Dec 2007
Its impossible ;p show your code over the loop
Posts: 2,593
Threads: 34
Joined: Dec 2007
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);
}