:) [Help]/ad command
#1

Hi, help for make /advertise command
Reply
#2

PHP код:
CMD:advertisements(playeridparams[]) {
    if(
gPlayerLogged[playerid] == 0) {
        
SendClientMessage(playeridCOLOR_GREY"You're not logged in.");
    }
    else if(
GetPVarType(playerid"Injured")) {
        
SendClientMessage(playeridCOLOR_GREY"You can't use advertisements while injured.");
    }
    else if(
PlayerCuffed[playerid] != 0) {
        
SendClientMessage(playeridCOLOR_GREY"You can't use advertisements right now.");
    }
    else if(
PlayerInfo[playerid][pJailTime] > 0) {
        
SendClientMessage(playeridCOLOR_GREY"You can't use advertisements while in jail.");
    }
    else 
ShowPlayerDialogEx(playeridDIALOG_ADMAINDIALOG_STYLE_LIST"Advertisements""List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement""Select""Cancel");
    return 
1;

OnDialogResponse

PHP код:
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 
x50; ++xListItemTrackId[playerid][x] = -1;
                foreach(
Playeri) if(!isnull(szAdvert[i])) arrAdverts[iCount++] = i;
                while(
iDialogCount 50 && iBreak 5000) {
                    
iRand random(iCount);
                    if(
arrAdverts[iRand] != INVALID_PLAYER_ID) {
                        
strcpy(szBufferszAdvert[arrAdverts[iRand]], sizeof(szBuffer));
                        if(
AdminDuty[playerid] == 0format(szDialogsizeof(szDialog), "%s%s... (%i)\r\n"szDialogszBufferPlayerInfo[arrAdverts[iRand]][pNumber]);
                        else 
format(szDialogsizeof(szDialog), "%s%s... (%s)\r\n"szDialogszBufferGetPlayerNameEx(arrAdverts[iRand]));
                        
ListItemTrackId[playerid][iDialogCount++] = arrAdverts[iRand];
                        
arrAdverts[iRand] = INVALID_PLAYER_ID;
                    }
                    ++
iBreak;
                }
                if(!
isnull(szDialog)) return ShowPlayerDialogEx(playeridDIALOG_ADLISTDIALOG_STYLE_LIST"Advertisements - List"szDialog"Select""Return");
                
ShowPlayerDialogEx(playeridDIALOG_ADMAINDIALOG_STYLE_LIST"Advertisements""List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement""Select""Cancel");
                
SendClientMessage(playeridCOLOR_GREY"No advertisements have been posted.");
            }
            case 
1ShowPlayerDialogEx(playeridDIALOG_ADSEARCHDIALOG_STYLE_INPUT"Advertisements - Search""Enter a search phrase.""Search""Return");
            case 
2: {
                if(
PlayerInfo[playerid][pADMute] == 1) {
                    
SendClientMessage(playeridCOLOR_GREY"You're muted from advertisements.");
                }
                else if(
PlayerInfo[playerid][pNumber] == 0) {
                    
SendClientMessage(playeridCOLOR_GRAD2"You don't have a cell phone.");
                }
                else 
ShowPlayerDialogEx(playeridDIALOG_ADPLACEDIALOG_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(playeridCOLOR_GREY"You're muted from advertisements.");
                }
                else if(
PlayerInfo[playerid][pNumber] == 0) {
                    
SendClientMessage(playeridCOLOR_GRAD2"You don't have a cell phone.");
                }
                else if(
iAdverTimer >= 1) {
                    
ShowPlayerDialogEx(playeridDIALOG_ADMAINDIALOG_STYLE_LIST"Advertisements""List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement""Select""Cancel");
                    return 
SendClientMessage(playeridCOLOR_GREY"Only one priority advertisement can be placed every 30 seconds.");
                }
                else if(
GetPVarType(playerid"adT")) {
                    
ShowPlayerDialogEx(playeridDIALOG_ADMAINDIALOG_STYLE_LIST"Advertisements""List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement""Select""Cancel");
                    return 
SendClientMessage(playeridCOLOR_GREY"You may only place one priority advertisement every two minutes.");
                }
                else 
ShowPlayerDialogEx(playeridDIALOG_ADPLACEPDIALOG_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");
            }
        }
        case 
DIALOG_ADPLACE: {
            if(
response) {
                new
                    
iLength strlen(inputtext);
                if(!(
<= iLength <= 127)) {
                    
ShowPlayerDialogEx(playeridDIALOG_ADMAINDIALOG_STYLE_LIST"Advertisements""List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement""Select""Cancel");
                    return 
SendClientMessage(playeridCOLOR_GREY"Your input was too long or too short.");
                }
                
iLength *= 5;
                if(
GetPlayerCash(playerid) < iLength) {
                    
ShowPlayerDialogEx(playeridDIALOG_ADMAINDIALOG_STYLE_LIST"Advertisements""List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement""Select""Cancel");
                    return 
SendClientMessage(playeridCOLOR_GREY"You don't have enough cash for this.");
                }
                
strcpy(szAdvert[playerid], inputtext128);
                
GivePlayerCash(playerid, -iLength);
                
format(stringsizeof(string), "Congratulations, you have placed your advertisement for $%d!"iLength);
                
SendClientMessage(playeridCOLOR_WHITEstring);
            }
            else 
ShowPlayerDialogEx(playeridDIALOG_ADMAINDIALOG_STYLE_LIST"Advertisements""List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement""Select""Cancel");
        }
        case 
DIALOG_ADPLACEP: {
            if(
response) {
                if(
iAdverTimer >= 1) {
                    
SendClientMessage(playeridCOLOR_GREY"Only one priority advertisement can be placed every 30 seconds.");
                    return 
ShowPlayerDialogEx(playeridDIALOG_ADPLACEPDIALOG_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(
GetPlayerCash(playerid) < 800) {
                    
ShowPlayerDialogEx(playeridDIALOG_ADMAINDIALOG_STYLE_LIST"Advertisements""List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement""Select""Cancel");
                    return 
SendClientMessage(playeridCOLOR_GREY"You don't have enough cash for this.");
                }
                else if(!(
<= strlen(inputtext) <= 79)) {
                    
ShowPlayerDialogEx(playeridDIALOG_ADMAINDIALOG_STYLE_LIST"Advertisements""List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement""Select""Cancel");
                    return 
SendClientMessage(playeridCOLOR_GREY"Your input was too long or too short.");
                }
                
iAdverTimer 30;
                
SetPVarInt(playerid"adT"120);
                
strcpy(szAdvert[playerid], inputtext128);
                
GivePlayerCash(playerid, -800);
                new
                    
szMessage[128];
                 
format(szMessagesizeof(szMessage), "Advertisement: %s - contact %s (%i)"inputtextGetPlayerNameEx(playerid), PlayerInfo[playerid][pNumber]);
                
SendClientMessageToAllEx(TEAM_GROVE_COLORszMessage);
                return 
SendClientMessage(playeridCOLOR_WHITE"Congratulations, you've placed your priority advertisement!");
            }
            else 
ShowPlayerDialogEx(playeridDIALOG_ADMAINDIALOG_STYLE_LIST"Advertisements""List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement""Select""Cancel");
        }
        case 
DIALOG_ADSEARCH: {
            if(
response) {
                if(!(
<= strlen(inputtext) <= 80))
                    return 
ShowPlayerDialogEx(playeridDIALOG_ADSEARCHDIALOG_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 
x50; ++xListItemTrackId[playerid][x] = -1;
                new
                    
szDialog[2256],
                    
szSearch[80],
                    
szBuffer[32],
                    
iCount;
                
strcat(szSearchinputtextsizeof(szSearch)); // strfind is a piece of shit when it comes to non-indexed arrays, maybe this'll help.
                
foreach(Playeri) if(!isnull(szAdvert[i])) {
                    
// printf("[ads] [NAME: %s] [ID: %i] [AD: %s] [SEARCH: %s]", GetPlayerNameEx(i), i, szAdvert[i], szSearch);
                    
if(strfind(szAdvert[i], szSearchtrue) != -&& 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(szBufferszAdvert[i], sizeof(szBuffer));
                        if(
AdminDuty[playerid] == 0format(szDialogsizeof(szDialog), "%s%s... (%i)\r\n"szDialogszBufferPlayerInfo[i][pNumber]);
                        else 
format(szDialogsizeof(szDialog), "%s%s... (%s)\r\n"szDialogszBufferGetPlayerNameEx(i));
                        
ListItemTrackId[playerid][iCount++] = i;
                    }
                }
                if(!
isnull(szDialog)) ShowPlayerDialogEx(playeridDIALOG_ADSEARCHLISTDIALOG_STYLE_LIST"Advertisements - Search Results"szDialog"Select""Return");
                else 
ShowPlayerDialogEx(playeridDIALOG_ADSEARCHLISTDIALOG_STYLE_INPUT"Advertisements - Search""No results found.\n\nEnter a search phrase.""Search""Return");
            }
            else 
ShowPlayerDialogEx(playeridDIALOG_ADMAINDIALOG_STYLE_LIST"Advertisements""List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement""Select""Cancel");
        }
        case 
DIALOG_ADSEARCHLIST: if(response) {
            new
                
ListItemTrackId[playerid][listitem],
                
szDialog[164];
            if(
IsPlayerConnected(i) && !isnull(szAdvert[i])) {
                
format(szDialogsizeof(szDialog), "%s\r\nContact: %i"szAdvert[i], PlayerInfo[i][pNumber]);
                
ShowPlayerDialogEx(playeridDIALOG_ADFINALDIALOG_STYLE_MSGBOX"Advertisements - Search Result"szDialog"Return""Exit");
            }
            else 
SendClientMessage(playeridCOLOR_GREY"This player has either disconnected or withdrawn their advertisement.");
        }
        case 
DIALOG_ADFINAL: {
            if(
response) return ShowPlayerDialogEx(playeridDIALOG_ADMAINDIALOG_STYLE_LIST"Advertisements""List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement""Select""Cancel");
        }
        case 
DIALOG_ADLIST: {
            if(
response) {
                new
                    
ListItemTrackId[playerid][listitem],
                    
szDialog[164];
                if(
IsPlayerConnected(i) && !isnull(szAdvert[i])) {
                    
format(szDialogsizeof(szDialog), "%s\r\nContact: %i"szAdvert[i], PlayerInfo[i][pNumber]);
                    return 
ShowPlayerDialogEx(playeridDIALOG_ADFINALDIALOG_STYLE_MSGBOX"Advertisements - Search Result"szDialog"Return""Exit");
                }
                else 
SendClientMessage(playeridCOLOR_GREY"This player has either disconnected or withdrawn their advertisement.");
            }
            else 
ShowPlayerDialogEx(playeridDIALOG_ADMAINDIALOG_STYLE_LIST"Advertisements""List Advertisements\nSearch Advertisements\nPlace Advertisement\nPlace Priority Advertisement""Select""Cancel");
        }
    } 
Define everything and it will be okay.
Reply
#3

No , no in dialog in /ad [text]
Reply
#4

advertise what?
Reply
#5

For example /ad [text]
[AD]Sell house | Contact:%s[ID:%s]
Reply
#6

Код:
CMD:ad(playerid, params[])
{
    if(isnull(params)) return SendClientMessage(playerid, -1, "{0008F7}USAGE: {FFFFFF}/AD TEXT");
    GameTextForAll(params, 4000, 0);
    return 1;
}
Reply
#7

not in CMD: in if(strcmp, cmdtext, "/ad"
Reply
#8

Get zcmd.inc better
http://sampff.weebly.com/download.html
Copy it to Pawno/include/
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)