03.12.2013, 09:31
Hey nice to meet you and sorry for bother, I'm trying to make a new Advertisement system for my script and I need your help: I wanna do when I do AD, I want it'll show me few categories to place on them : AutoMobile/Real Estate/Buying/Selling, and I massed up, Here's the code of the start, the rest of all the codes are at the bottom of thread:
ALL OF THE CODE include the last code :
Код:
case DIALOG_ADPLACE: { if(response) { case 1: ShowPlayerDialog(playerid, DIALOG_ADNEWLIST, DIALOG_STYLE_LIST, "AutoMobile\nReal Estate\nBuying\nSelling" case 2: { if(PlayerInfo[playerid][pADMute] == 1) { SendClientMessageEx(playerid, COLOR_GREY, "You are muted from advertisements."); } else if(PlayerInfo[playerid][pPnumber] == 0) { SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have a cell phone."); } else ShowPlayerDialog(playerid, DIALOG_ADPLACE, DIALOG_STYLE_INPUT, "Advertisements - Place Advertisement", "Enter your desired advertisement text! Keep it below 128 characters.", "Submit", "Return"); } case 3: { if(PlayerInfo[playerid][pADMute] == 1) { SendClientMessageEx(playerid, COLOR_GREY, "You are muted from advertisements."); } else if(PlayerInfo[playerid][pPnumber] == 0) { SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have a cell phone."); } else if(iAdverTimer >= 1) { ShowPlayerDialog(playerid, DIALOG_ADMAIN, DIALOG_STYLE_LIST, "Advertisements", "List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement", "Select", "Cancel"); return SendClientMessageEx(playerid, COLOR_GREY, "Only one priority advertisement can be placed every 30 seconds."); } else 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 $10,000.", "Submit", "Return"); } }
Код:
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 < 500) { iRand = random(iCount); if(arrAdverts[iRand] != INVALID_PLAYER_ID) { 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_ADMAIN, DIALOG_STYLE_LIST, "Advertisements", "List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement", "Select", "Cancel"); SendClientMessage(playerid, COLOR_GREY, "No advertisements have been posted."); } case 1: ShowPlayerDialog(playerid, DIALOG_ADSEARCH, DIALOG_STYLE_INPUT, "Advertisements - Search", "Enter a search phrase.", "Search", "Return"); case 2: { if(PlayerInfo[playerid][pADMute] == 1) { SendClientMessageEx(playerid, COLOR_GREY, "You are muted from advertisements."); } else if(PlayerInfo[playerid][pPnumber] == 0) { SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have a cell phone."); } else ShowPlayerDialog(playerid, DIALOG_ADPLACE, DIALOG_STYLE_INPUT, "Advertisements - Place Advertisement", "Enter your desired advertisement text! Keep it below 128 characters.", "Submit", "Return"); } case 3: { if(PlayerInfo[playerid][pADMute] == 1) { SendClientMessageEx(playerid, COLOR_GREY, "You are muted from advertisements."); } else if(PlayerInfo[playerid][pPnumber] == 0) { SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have a cell phone."); } else if(iAdverTimer >= 1) { ShowPlayerDialog(playerid, DIALOG_ADMAIN, DIALOG_STYLE_LIST, "Advertisements", "List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement", "Select", "Cancel"); return SendClientMessageEx(playerid, COLOR_GREY, "Only one priority advertisement can be placed every 30 seconds."); } else 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 $10,000.", "Submit", "Return"); } } case DIALOG_ADPLACE: { if(response) { case 1: ShowPlayerDialog(playerid, DIALOG_ADNEWLIST, DIALOG_STYLE_LIST, "AutoMobile\nReal Estate\nBuying\nSelling" case 2: { if(PlayerInfo[playerid][pADMute] == 1) { SendClientMessageEx(playerid, COLOR_GREY, "You are muted from advertisements."); } else if(PlayerInfo[playerid][pPnumber] == 0) { SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have a cell phone."); } else ShowPlayerDialog(playerid, DIALOG_ADPLACE, DIALOG_STYLE_INPUT, "Advertisements - Place Advertisement", "Enter your desired advertisement text! Keep it below 128 characters.", "Submit", "Return"); } case 3: { if(PlayerInfo[playerid][pADMute] == 1) { SendClientMessageEx(playerid, COLOR_GREY, "You are muted from advertisements."); } else if(PlayerInfo[playerid][pPnumber] == 0) { SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have a cell phone."); } else if(iAdverTimer >= 1) { ShowPlayerDialog(playerid, DIALOG_ADMAIN, DIALOG_STYLE_LIST, "Advertisements", "List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement", "Select", "Cancel"); return SendClientMessageEx(playerid, COLOR_GREY, "Only one priority advertisement can be placed every 30 seconds."); } else 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 $10,000.", "Submit", "Return"); } } new iLength = strlen(inputtext); if(!(2 <= iLength <= 127)) { ShowPlayerDialog(playerid, DIALOG_ADMAIN, DIALOG_STYLE_LIST, "Advertisements", "List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement", "Select", "Cancel"); return SendClientMessage(playerid, COLOR_GREY, "Your input was too long or too short."); } iLength *= 50; if(GetPlayerCash(playerid) < iLength) { ShowPlayerDialog(playerid, DIALOG_ADMAIN, DIALOG_STYLE_LIST, "Advertisements", "List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement", "Select", "Cancel"); return SendClientMessage(playerid, COLOR_GREY, "You don't have enough cash for this."); } strcpy(szAdvert[playerid], inputtext, 128); GivePlayerCash(playerid, -iLength); format(string, sizeof(string), "Congratulations, you have placed your advertisement for $%d!", iLength); SendClientMessage(playerid, COLOR_WHITE, string); } else ShowPlayerDialog(playerid, DIALOG_ADMAIN, DIALOG_STYLE_LIST, "Advertisements", "List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement", "Select", "Cancel"); } case DIALOG_ADPLACEP: { if(response) { if(iAdverTimer >= 1) { 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 $30000.", "Submit", "Return"); } else if(GetPlayerCash(playerid) < 30000) { ShowPlayerDialog(playerid, DIALOG_ADMAIN, DIALOG_STYLE_LIST, "Advertisements", "List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority 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 Priority Advertisement", "Select", "Cancel"); return SendClientMessage(playerid, COLOR_GREY, "Your input was too long or too short."); } iAdverTimer = 30; strcpy(szAdvert[playerid], inputtext, 128); GivePlayerCash(playerid, -30000); new szMessage[128]; format(szMessage, sizeof(szMessage), "Advertisement: %s - contact %s (%i)", inputtext, GetPlayerNameEx(playerid), PlayerInfo[playerid][pPnumber]); SendClientMessageToAllEx(TEAM_GROVE_COLOR, szMessage); return SendClientMessage(playerid, COLOR_WHITE, "Congratulations, you've placed your priority advertisement!"); } else ShowPlayerDialog(playerid, DIALOG_ADMAIN, DIALOG_STYLE_LIST, "Advertisements", "List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement", "Select", "Cancel"); } case DIALOG_ADSEARCH: { if(response) { if(!(4 <= strlen(inputtext) <= 80)) { return ShowPlayerDialog(playerid, DIALOG_ADSEARCH, DIALOG_STYLE_INPUT, "Advertisements - Search", "Queries must be between 4\n and 80 characters in length.\n\nEnter a search phrase.", "Search", "Return"); } else for(new x; x < 50; ++x) ListItemTrackId[playerid][x] = -1; new szDialog[2256], szSearch[80], szBuffer[32], iCount; strcat(szSearch, inputtext, sizeof(szSearch)); // strfindex is a piece of shit when it comes to non-indexed arrays, maybe this'll help. foreach(Player, i) if(!isnull(szAdvert[i])) { // printf("[ads] [NAME: %s] [ID: %i] [AD: %s] [SEARCH: %s]", GetPlayerNameEx(i), i, szAdvert[i], szSearch); if(strfindex(szAdvert[i], szSearch, true) != -1 && iCount < 50) { // printf("[ads - MATCH] [NAME: %s] [ID: %i] [AD: %s] [SEARCH: %s] [COUNT: %i] [DIALOG LENGTH: %i] [FINDPOS: %i]", GetPlayerNameEx(i), i, szAdvert[i], szSearch, iCount, strlen(szDialog), strfind(szAdvert[i], szSearch, true)); strcpy(szBuffer, szAdvert[i], sizeof(szBuffer)); if(PlayerInfo[playerid][pAdmin] <= 1) format(szDialog, sizeof(szDialog), "%s%s... (%i)\r\n", szDialog, szBuffer, PlayerInfo[i][pPnumber]); else format(szDialog, sizeof(szDialog), "%s%s... (%s)\r\n", szDialog, szBuffer, GetPlayerNameEx(i)); ListItemTrackId[playerid][iCount++] = i; } } if(!isnull(szDialog)) ShowPlayerDialog(playerid, DIALOG_ADSEARCHLIST, DIALOG_STYLE_LIST, "Advertisements - Search Results", szDialog, "Select", "Return"); else ShowPlayerDialog(playerid, DIALOG_ADSEARCHLIST, DIALOG_STYLE_INPUT, "Advertisements - Search", "No results found.\n\nEnter a search phrase.", "Search", "Return"); } else ShowPlayerDialog(playerid, DIALOG_ADMAIN, DIALOG_STYLE_LIST, "Advertisements", "List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement", "Select", "Cancel"); } case DIALOG_ADSEARCHLIST: 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]); 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."); } case DIALOG_ADFINAL: { if(response) return ShowPlayerDialog(playerid, DIALOG_ADMAIN, DIALOG_STYLE_LIST, "Advertisements", "List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement", "Select", "Cancel"); } 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 Priority Advertisement", "Select", "Cancel"); } }