SA-MP Forums Archive
How to put this in dialog? - 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: How to put this in dialog? (/showthread.php?tid=634410)



How to fix this dialog? - Mikkel_RE - 18.05.2017

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



Re: How to put this in dialog? - Mikkel_RE - 20.05.2017

anyone?


Re: How to put this in dialog? - Kane - 20.05.2017

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



Re: How to put this in dialog? - Mikkel_RE - 20.05.2017

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

Код:
code
Nope, thats not working


Re: How to put this in dialog? - IceBilizard - 21.05.2017

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