How to put this in dialog?
#1

Hi, when i do /ad and enter "List Advertisements" it only shows the last advertisement,
How to make that it shows the past 10-20 ads?

pawn Код:
switch(dialogid) {
        case DIALOG_ADMAIN: 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(Player, i) if(!isnull(szAdvert[i])) arrAdverts[iCount++] = i;

                while(iDialogCount < 50 && iBreak < 5000) {
                    iRand = random(iCount);
                    if(arrAdverts[iRand] != INVALID_PLAYER_ID) {
                        strcpy(szBuffer, szAdvert[arrAdverts[iRand]], sizeof(szBuffer));
                        if(PlayerInfo[playerid][pAdmin] == 0) 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, GetName(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_ADMAIN, DIALOG_STYLE_LIST, "Advertisements", "List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Attention Advertisement", "Select", "Cancel");
                SendClientMessage(playerid, COLOR_GREY, "No advertisements have been posted.");
            }
pawn Код:
case DIALOG_ADPLACEP: {
            if(response) {
                if ((!adds) && !(PlayerInfo[playerid][pAdmin] & ADMIN_CHANNELS) && PlayerInfo[playerid][pMember] != 17 && PlayerInfo[playerid][pDonatorLevel] < 3) {
                    SendClientMessage(playerid, COLOR_GREY, "Only one priority advertisement can be placed every 30 seconds.");
                    return ShowPlayerDialog(playerid, DIALOG_ADPLACEP, DIALOG_STYLE_INPUT, "Advertisements - Priority Advertisement",
                    "Enter your desired advertisement text! Keep it below 128 characters.\nAs this is a priority advertisement, it will be broadcasted, and will cost you $800.", "Submit", "Return");
                }
                else if(GetMoney(playerid) < 800) {
                    ShowPlayerDialog(playerid, DIALOG_ADMAIN, DIALOG_STYLE_LIST, "Advertisements", "List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Attention Advertisement", "Select", "Cancel");
                    return SendClientMessage(playerid, COLOR_GREY, "You don't have enough cash for this.");
                }
                else if(!(2 <= strlen(inputtext) <= 79)) {
                    ShowPlayerDialog(playerid, DIALOG_ADMAIN, DIALOG_STYLE_LIST, "Advertisements", "List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Attention Advertisement", "Select", "Cancel");
                    return SendClientMessage(playerid, COLOR_GREY, "Your input was too long or too short.");
                }
                if(!(PlayerInfo[playerid][pAdmin] & ADMIN_CHANNELS)){SetTimer("AddsOn", addtimer, 0);adds = 0;}
                strcpy(szAdvert[playerid], inputtext, 128);
                GiveMoney(playerid, -800);
                new szMessage[128];
                format(szMessage, sizeof(szMessage), "Advertisement: %s, Contact: %s Ph: %d",  inputtext, Name(playerid),PlayerInfo[playerid][pPnumber]);
                OOCNews(TEAM_GROVE_COLOR,szMessage);
                UpdateNewspapers(szMessage);
                return SendClientMessage(playerid, COLOR_WHITE, "Congratulations, you've submitted your attention advertisement!");
            }
            else ShowPlayerDialog(playerid, DIALOG_ADMAIN, DIALOG_STYLE_LIST, "Advertisements", "List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Attention Advertisement", "Select", "Cancel");
        }

pawn Код:
case DIALOG_ADLIST: {
            if(response) {

                new
                    i = ListItemTrackId[playerid][listitem],
                    szDialog[164];
                if(IsPlayerConnected(i) && !isnull(szAdvert[i])) {
                    format(szDialog, sizeof(szDialog), "%s\r\nContact: %i", szAdvert[i], PlayerInfo[i][pPnumber]);
                    return ShowPlayerDialog(playerid, DIALOG_ADFINAL, DIALOG_STYLE_MSGBOX, "Advertisements - Search Result", szDialog, "Return", "Exit");
                }
                else SendClientMessage(playerid, COLOR_GREY, "This player has either disconnected or withdrawn their advertisement.");
            }
            else ShowPlayerDialog(playerid, DIALOG_ADMAIN, DIALOG_STYLE_LIST, "Advertisements", "List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Attention Advertisement", "Select", "Cancel");
        }
    }
Reply
#2

anyone?
Reply
#3

Try this. Not sure if it'll work though. Bolded everything I added.

Код:
ALOG_ADLIST: {
			if(response) {

				new
					i = ListItemTrackId[playerid][listitem],
					szDialog[164];

					szDialog[0] = 0;
				if(IsPlayerConnected(i) && !isnull(szAdvert[i])) {
					format(szDialog, sizeof(szDialog), "%s%s\r\nContact: %i\n", szDialog, szAdvert[i], PlayerInfo[i][pPnumber]);
					return ShowPlayerDialog(playerid, DIALOG_ADFINAL, DIALOG_STYLE_MSGBOX, "Advertisements - Search Result", szDialog, "Return", "Exit");
				}
				else SendClientMessage(playerid, COLOR_GREY, "This player has either disconnected or withdrawn their advertisement.");
			}
			else ShowPlayerDialog(playerid, DIALOG_ADMAIN, DIALOG_STYLE_LIST, "Advertisements", "List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Attention Advertisement", "Select", "Cancel");
  		}
  	}
Reply
#4

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
Try this. Not sure if it'll work though. Bolded everything I added.

Код:
code
Nope, thats not working
Reply
#5

You have to save the last 10 or 20 contract in a file then read them from the file.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)