Код:
case DIALOG_ADCATEGORY: if(response) switch(listitem) {
case 0: {
new
szDialog[2256],
szBuffer[32],
arrAdverts[MAX_PLAYERS] = INVALID_PLAYER_ID,
iDialogCount,
iCount,
iBreak,
iRand;
for(new x; x < 50; ++x) ListItemTrackId[playerid][x] = -1;
foreach(new i: Player)
{ if(!isnull(szAdvert[i])) arrAdverts[iCount++] = i; }
while(iDialogCount < 50 && iBreak < 500) {
iRand = random(iCount);
if(arrAdverts[iRand] != INVALID_PLAYER_ID) {
if(AdvertType[arrAdverts[iRand]] == 1) //Real Estate
{
strcpy(szBuffer, szAdvert[arrAdverts[iRand]], sizeof(szBuffer));
if(PlayerInfo[playerid][pAdmin] <= 1) format(szDialog, sizeof(szDialog), "%s%s... (%i)\r\n", szDialog, szBuffer, PlayerInfo[arrAdverts[iRand]][pPnumber]);
else format(szDialog, sizeof(szDialog), "%s%s... (%s)\r\n", szDialog, szBuffer, GetPlayerNameEx(arrAdverts[iRand]));
ListItemTrackId[playerid][iDialogCount++] = arrAdverts[iRand];
arrAdverts[iRand] = INVALID_PLAYER_ID;
}
}
++iBreak;
}
if(!isnull(szDialog)) return ShowPlayerDialog(playerid, DIALOG_ADLIST, DIALOG_STYLE_LIST, "Advertisements - List", szDialog, "Select", "Return");
ShowPlayerDialog(playerid, DIALOG_ADCATEGORY, DIALOG_STYLE_LIST, "Advertisements Categories", "Real Estate\nAutomobile\nBuying\nSelling\nMiscellaneous", "Select", "Cancel");
SendClientMessage(playerid, COLOR_GREY, "No advertisements have been posted.");
}
case 1: {
new
szDialog[2256],
szBuffer[32],
arrAdverts[MAX_PLAYERS] = INVALID_PLAYER_ID,
iDialogCount,
iCount,
iBreak,
iRand;
for(new x; x < 50; ++x) ListItemTrackId[playerid][x] = -1;
foreach(new i: Player)
{ if(!isnull(szAdvert[i])) arrAdverts[iCount++] = i; }
while(iDialogCount < 50 && iBreak < 500) {
iRand = random(iCount);
if(arrAdverts[iRand] != INVALID_PLAYER_ID) {
if(AdvertType[arrAdverts[iRand]] == 2) //Automobile
{
strcpy(szBuffer, szAdvert[arrAdverts[iRand]], sizeof(szBuffer));
if(PlayerInfo[playerid][pAdmin] <= 1) format(szDialog, sizeof(szDialog), "%s%s... (%i)\r\n", szDialog, szBuffer, PlayerInfo[arrAdverts[iRand]][pPnumber]);
else format(szDialog, sizeof(szDialog), "%s%s... (%s)\r\n", szDialog, szBuffer, GetPlayerNameEx(arrAdverts[iRand]));
ListItemTrackId[playerid][iDialogCount++] = arrAdverts[iRand];
arrAdverts[iRand] = INVALID_PLAYER_ID;
}
}
++iBreak;
}
if(!isnull(szDialog)) return ShowPlayerDialog(playerid, DIALOG_ADLIST, DIALOG_STYLE_LIST, "Advertisements - List", szDialog, "Select", "Return");
ShowPlayerDialog(playerid, DIALOG_ADCATEGORY, DIALOG_STYLE_LIST, "Advertisements Categories", "Real Estate\nAutomobile\nBuying\nSelling\nMiscellaneous", "Select", "Cancel");
SendClientMessage(playerid, COLOR_GREY, "No advertisements have been posted.");
}
case 2: {
new
szDialog[2256],
szBuffer[32],
arrAdverts[MAX_PLAYERS] = INVALID_PLAYER_ID,
iDialogCount,
iCount,
iBreak,
iRand;
for(new x; x < 50; ++x) ListItemTrackId[playerid][x] = -1;
foreach(new i: Player)
{ if(!isnull(szAdvert[i])) arrAdverts[iCount++] = i; }
while(iDialogCount < 50 && iBreak < 500) {
iRand = random(iCount);
if(arrAdverts[iRand] != INVALID_PLAYER_ID) {
if(AdvertType[arrAdverts[iRand]] == 3) //Buying
{
strcpy(szBuffer, szAdvert[arrAdverts[iRand]], sizeof(szBuffer));
if(PlayerInfo[playerid][pAdmin] <= 1) format(szDialog, sizeof(szDialog), "%s%s... (%i)\r\n", szDialog, szBuffer, PlayerInfo[arrAdverts[iRand]][pPnumber]);
else format(szDialog, sizeof(szDialog), "%s%s... (%s)\r\n", szDialog, szBuffer, GetPlayerNameEx(arrAdverts[iRand]));
ListItemTrackId[playerid][iDialogCount++] = arrAdverts[iRand];
arrAdverts[iRand] = INVALID_PLAYER_ID;
}
}
++iBreak;
}
if(!isnull(szDialog)) return ShowPlayerDialog(playerid, DIALOG_ADLIST, DIALOG_STYLE_LIST, "Advertisements - List", szDialog, "Select", "Return");
ShowPlayerDialog(playerid, DIALOG_ADCATEGORY, DIALOG_STYLE_LIST, "Advertisements Categories", "Real Estate\nAutomobile\nBuying\nSelling\nMiscellaneous", "Select", "Cancel");
SendClientMessage(playerid, COLOR_GREY, "No advertisements have been posted.");
}
case 3: {
new
szDialog[2256],
szBuffer[32],
arrAdverts[MAX_PLAYERS] = INVALID_PLAYER_ID,
iDialogCount,
iCount,
iBreak,
iRand;
for(new x; x < 50; ++x) ListItemTrackId[playerid][x] = -1;
foreach(new i: Player)
{ if(!isnull(szAdvert[i])) arrAdverts[iCount++] = i; }
while(iDialogCount < 50 && iBreak < 500) {
iRand = random(iCount);
if(arrAdverts[iRand] != INVALID_PLAYER_ID) {
if(AdvertType[arrAdverts[iRand]] == 4) //Selling
{
strcpy(szBuffer, szAdvert[arrAdverts[iRand]], sizeof(szBuffer));
if(PlayerInfo[playerid][pAdmin] <= 1) format(szDialog, sizeof(szDialog), "%s%s... (%i)\r\n", szDialog, szBuffer, PlayerInfo[arrAdverts[iRand]][pPnumber]);
else format(szDialog, sizeof(szDialog), "%s%s... (%s)\r\n", szDialog, szBuffer, GetPlayerNameEx(arrAdverts[iRand]));
ListItemTrackId[playerid][iDialogCount++] = arrAdverts[iRand];
arrAdverts[iRand] = INVALID_PLAYER_ID;
}
}
++iBreak;
}
if(!isnull(szDialog)) return ShowPlayerDialog(playerid, DIALOG_ADLIST, DIALOG_STYLE_LIST, "Advertisements - List", szDialog, "Select", "Return");
ShowPlayerDialog(playerid, DIALOG_ADCATEGORY, DIALOG_STYLE_LIST, "Advertisements Categories", "Real Estate\nAutomobile\nBuying\nSelling\nMiscellaneous", "Select", "Cancel");
SendClientMessage(playerid, COLOR_GREY, "No advertisements have been posted.");
}
case 4: {
new
szDialog[2256],
szBuffer[32],
arrAdverts[MAX_PLAYERS] = INVALID_PLAYER_ID,
iDialogCount,
iCount,
iBreak,
iRand;
for(new x; x < 50; ++x) ListItemTrackId[playerid][x] = -1;
foreach(new i: Player)
{ if(!isnull(szAdvert[i])) arrAdverts[iCount++] = i; }
while(iDialogCount < 50 && iBreak < 500) {
iRand = random(iCount);
if(arrAdverts[iRand] != INVALID_PLAYER_ID) {
if(AdvertType[arrAdverts[iRand]] == 5) //Miscellaneous
{
strcpy(szBuffer, szAdvert[arrAdverts[iRand]], sizeof(szBuffer));
if(PlayerInfo[playerid][pAdmin] <= 1) format(szDialog, sizeof(szDialog), "%s%s... (%i)\r\n", szDialog, szBuffer, PlayerInfo[arrAdverts[iRand]][pPnumber]);
else format(szDialog, sizeof(szDialog), "%s%s... (%s)\r\n", szDialog, szBuffer, GetPlayerNameEx(arrAdverts[iRand]));
ListItemTrackId[playerid][iDialogCount++] = arrAdverts[iRand];
arrAdverts[iRand] = INVALID_PLAYER_ID;
}
}
++iBreak;
}
if(!isnull(szDialog)) return ShowPlayerDialog(playerid, DIALOG_ADLIST, DIALOG_STYLE_LIST, "Advertisements - List", szDialog, "Select", "Return");
ShowPlayerDialog(playerid, DIALOG_ADCATEGORY, DIALOG_STYLE_LIST, "Advertisements Categories", "Real Estate\nAutomobile\nBuying\nSelling\nMiscellaneous", "Select", "Cancel");
SendClientMessage(playerid, COLOR_GREY, "No advertisements have been posted.");
}
}