[Tutorial] Simple Advertisement system (SSCANF, ZCMD)
#1

I were to share a simple way to create an advertisement system which allows you to post an advertisement only every 60 seconds.

Place this on top of the script
pawn Code:
new ServerAdvert;
// COLOR
#define COLOR_LIME 0x10F441AA
Now for the actual Command.
pawn Code:
CMD:advertisement(playerid, params[])
{
    new string[128], name[64] ;
        GetPlayerName(playerid, name, sizeof(name));
    if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid, COLOR_GRAY, "You need to be level 2 to advertise!");
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_GRAY, "USAGE: /ad(vertisement) [Text]");
    if(ServerAdvert == 1)
    {
        SendClientMessage(playerid, COLOR_RED, "Only one advertisement every 60 seconds!");
    }
    else
    {
        ServerAdvert = 1;
        format(string, sizeof(string), "[Advertisement] %s Contact: %s Ph: %d", params, name(playerid), PlayerInfo[playerid][Phone]);
        SendClientMessageToAll(COLOR_LIME, string);
        SetTimer("AdTimer", 60000, false);
        GivePlayerMoney(playerid, -1000);
    }
    return 1;
}

Now for the timer to limit the amount of advertisements placed.
pawn Code:
public AdTimer()
{
    ServerAdvert = 0;
    return 1;
}
You can use your own function to get the Underscore from the name.
Reply
#2

Place this, place this, place this. Hardly anything explained. Besides that you imply that everyone uses PlayerInfo with the variables pLevel and Phone.
Reply
#3

This isn't a tutorial at all. A tutorial must have EVERY single thing explained in an appropriate way which you don't show at all. Also you use variables which you obligate that each person should use.
Reply
#4

Good tutorial for anyone who has a basic notion Dr. Pawn but bad for the beginners lacked explanation + REPUTATION
Reply
#5

Its a snippet of your script that you copy pasted.
Reply
#6

Try to explain the code piece by piece, elaborate what it does/means.
Reply
#7

Bumping a tutorial from 2013 and telling the OP to explain it. Why?
Reply
#8

Working with a variable such ServerAdvert will only allow one advertisement in 60 seconds per players, meaning, if someone has already used the command, other players must wait for 60 before advertising, why not make it a player variable instead?

And why did you type this /ad(vertisement) if you are not going to demonstrate the creation of the /ad alias?
Reply
#9

Quote:
Originally Posted by Arthur Kane
View Post
Bumping a tutorial from 2013 and telling the OP to explain it. Why?
OK, haha didn't notice that. apologies.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)