02.05.2012, 03:07
Im using this cmd but when i /advertisement and place priority advertisements its not showing the advertisement
Dialogs
Code:
CMD:advertisements(playerid, params[]) { if(gPlayerLogged{playerid} == 0) { SendClientMessage(playerid, COLOR_GREY, "You're not logged in."); } else if(GetPVarType(playerid, "Injured") == 1) { SendClientMessage(playerid, COLOR_GREY, "You can't use advertisements while injured."); } else if(PlayerCuffed[playerid] != 0) { SendClientMessage(playerid, COLOR_GREY, "You can't use advertisements right now."); } else if(PlayerInfo[playerid][pJailTime] > 0) { SendClientMessage(playerid, COLOR_GREY, "You can't use advertisements while in jail."); } else ShowPlayerDialog(playerid, DIALOG_ADMAIN, DIALOG_STYLE_LIST, "Advertisements", "List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement", "Select", "Cancel"); return 1; }
Code:
// ADS. #define DIALOG_ADMAIN 32700 #define DIALOG_ADLIST 32701 #define DIALOG_ADPLACE 32702 #define DIALOG_ADPLACEP 32703 #define DIALOG_ADSEARCH 32704 #define DIALOG_ADSEARCHLIST 32705 #define DIALOG_ADFINAL 32706 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(GetPVarString(i, "adStr", szBuffer, sizeof(szBuffer))) arrAdverts[iCount++] = i; while(iDialogCount < 50 && iDialogCount < iCount && iBreak < 5000) { iRand = random(iCount); if(arrAdverts[iRand] != INVALID_PLAYER_ID) { GetPVarString(arrAdverts[iRand], "adStr", szBuffer, sizeof(szBuffer)); if(PlayerInfo[playerid][pAdmin] <= 1) format(szDialog, sizeof(szDialog), "%s\n%s... (%i)", szDialog, szBuffer, PlayerInfo[arrAdverts[iRand]][pPnumber]); else format(szDialog, sizeof(szDialog), "%s\n%s... (%s)", 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) { SendClientMessage(playerid, COLOR_GREY, "You are muted from advertisements."); } else if(PlayerInfo[playerid][pPnumber] == 0) { SendClientMessage(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) { SendClientMessage(playerid, COLOR_GREY, "You are muted from advertisements."); } else if(PlayerInfo[playerid][pPnumber] == 0) { SendClientMessage(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 SendClientMessage(playerid, COLOR_GREY, "Only one priority advertisement can be placed every 30 seconds."); } else if(GetPVarType(playerid, "adT")) { 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 may only place one priority advertisement every two minutes."); } 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 $100,000.", "Submit", "Return"); } } case DIALOG_ADPLACE: { if(response) { new iLength = strlen(inputtext); if(iLength >= 128) { 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."); } 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."); } SetPVarString(playerid, "adStr", inputtext); GivePlayerCash(playerid, -iLength); SendClientMessage(playerid, COLOR_WHITE, "Congratulations, you have placed your advertisement!"); } 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(GetPlayerCash(playerid) < 100000) { 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(strlen(inputtext) >= 128) { 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."); } iAdverTimer = 30; SetPVarInt(playerid, "adT", 120); SetPVarString(playerid, "adStr", inputtext); GivePlayerCash(playerid, -150000); new szMessage[128]; inputtext[79] = 0; format(szMessage, sizeof(szMessage), "Advertisement: %s... contact %s (%i)", inputtext, GetPlayerNameEx(playerid), PlayerInfo[playerid][pPnumber]); foreach(Player, i) if(!gNews[i]) SendClientMessage(i, TEAM_GROVE_COLOR, szMessage); return SendClientMessage(playerid, COLOR_WHITE, "Congratulations, you have 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], szBuffer[128], iCount; foreach(Player, i) if(GetPVarString(i, "adStr", szBuffer, sizeof(szBuffer))) { if(strfind(szBuffer, inputtext, true) != -1 && ++iCount < 2) { szBuffer[32] = 0; if(PlayerInfo[playerid][pAdmin] <= 1) format(szDialog, sizeof(szDialog), "%s\n%s... (%i)", szDialog, szBuffer, PlayerInfo[i][pPnumber]); else format(szDialog, sizeof(szDialog), "%s\n%s... (%s)", 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: { new i = ListItemTrackId[playerid][listitem], szDialog[164]; GetPVarString(i, "adStr", szDialog, sizeof(szDialog)); format(szDialog, sizeof(szDialog), "%s\nContact: %i", szDialog, PlayerInfo[i][pPnumber]); ShowPlayerDialog(playerid, DIALOG_ADFINAL, DIALOG_STYLE_MSGBOX, "Advertisements - Search Result", szDialog, "Return", "Exit"); } 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]; GetPVarString(i, "adStr", szDialog, sizeof(szDialog)); format(szDialog, sizeof(szDialog), "%s\nContact: %i", szDialog, PlayerInfo[i][pPnumber]); return ShowPlayerDialog(playerid, DIALOG_ADFINAL, DIALOG_STYLE_MSGBOX, "Advertisements - Search Result", szDialog, "Return", "Exit"); } else ShowPlayerDialog(playerid, DIALOG_ADMAIN, DIALOG_STYLE_LIST, "Advertisements", "List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement", "Select", "Cancel"); } }