SA-MP Forums

SA-MP Forums (http://forum.sa-mp.com/index.php)
-   Tutorials (http://forum.sa-mp.com/forumdisplay.php?f=70)
-   -   [Tutorial] Simple Advertisement system (SSCANF, ZCMD) (http://forum.sa-mp.com/showthread.php?t=442764)

FalconWingsX 08/06/2013 08:38 PM

Simple Advertisement system (SSCANF, ZCMD)
 
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
Code:

new ServerAdvert;
// COLOR
#define COLOR_LIME 0x10F441AA


Now for the actual Command.
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.
Code:

public AdTimer()
{
        ServerAdvert = 0;
        return 1;
}


You can use your own function to get the Underscore from the name.

Vince 08/06/2013 08:42 PM

Re: Simple Advertisement system (SSCANF, ZCMD)
 
Place this, place this, place this. Hardly anything explained. Besides that you imply that everyone uses PlayerInfo with the variables pLevel and Phone.

Red_Dragon. 08/06/2013 11:20 PM

Re: Simple Advertisement system (SSCANF, ZCMD)
 
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.

GuilhermeNunes 13/07/2017 02:44 AM

Re: Simple Advertisement system (SSCANF, ZCMD)
 
Good tutorial for anyone who has a basic notion Dr. Pawn but bad for the beginners lacked explanation + REPUTATION

iLearner 13/07/2017 02:48 AM

Re: Simple Advertisement system (SSCANF, ZCMD)
 
Its a snippet of your script that you copy pasted.

saffierr 13/07/2017 08:06 AM

Re: Simple Advertisement system (SSCANF, ZCMD)
 
Try to explain the code piece by piece, elaborate what it does/means.

Arthur Kane 13/07/2017 08:51 AM

Re: Simple Advertisement system (SSCANF, ZCMD)
 
Bumping a tutorial from 2013 and telling the OP to explain it. Why?

Eoussama 13/07/2017 09:00 AM

Re: Simple Advertisement system (SSCANF, ZCMD)
 
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?

iLearner 13/07/2017 09:02 AM

Re: Simple Advertisement system (SSCANF, ZCMD)
 
Quote:

Originally Posted by Arthur Kane (Post 3901345)
Bumping a tutorial from 2013 and telling the OP to explain it. Why?

OK, haha didn't notice that. apologies.


All times are GMT. The time now is 02:09 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.