SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 08/06/2013, 09:38 PM   #1
FalconWingsX
Little Clucker
 
Join Date: Sep 2012
Posts: 34
Reputation: 2
Default 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.
FalconWingsX is offline   Reply With Quote
Old 08/06/2013, 09:42 PM   #2
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 11,039
Reputation: 2647
Default 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.
__________________
Vince is offline   Reply With Quote
Old 09/06/2013, 12:20 AM   #3
Red_Dragon.
High-roller
 
Red_Dragon.'s Avatar
 
Join Date: Sep 2012
Posts: 1,405
Reputation: 46
Default 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.
Red_Dragon. is offline   Reply With Quote
Old 13/07/2017, 03:44 AM   #4
GuilhermeNunes
Gangsta
 
Join Date: Feb 2017
Posts: 585
Reputation: 8
Default 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
GuilhermeNunes is offline   Reply With Quote
Old 13/07/2017, 03:48 AM   #5
iLearner
Banned
 
Join Date: Apr 2017
Posts: 430
Reputation: 89
Default Re: Simple Advertisement system (SSCANF, ZCMD)

Its a snippet of your script that you copy pasted.
iLearner is offline   Reply With Quote
Old 13/07/2017, 09:06 AM   #6
saffierr
High-roller
 
saffierr's Avatar
 
Join Date: Jul 2013
Location: GetPlayerGirlHouse(targetplayer);
Posts: 1,155
Reputation: 36
Default Re: Simple Advertisement system (SSCANF, ZCMD)

Try to explain the code piece by piece, elaborate what it does/means.
saffierr is offline   Reply With Quote
Old 13/07/2017, 09:51 AM   #7
Arthur Kane
Gangsta
 
Join Date: Sep 2012
Location: Los Angeles
Posts: 706
Reputation: 96
Default Re: Simple Advertisement system (SSCANF, ZCMD)

Bumping a tutorial from 2013 and telling the OP to explain it. Why?
Arthur Kane is offline   Reply With Quote
Old 13/07/2017, 10:00 AM   #8
Eoussama
High-roller
 
Eoussama's Avatar
 
Join Date: Jul 2016
Location: Kingdom of Morocco // Tangier
Posts: 1,121
Reputation: 153
Default 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?
__________________
Eoussama is online now   Reply With Quote
Old 13/07/2017, 10:02 AM   #9
iLearner
Banned
 
Join Date: Apr 2017
Posts: 430
Reputation: 89
Default Re: Simple Advertisement system (SSCANF, ZCMD)

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.
iLearner is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorial] Simple Lottery System [ZCMD | SSCANF] L.Hudson Tutorials 18 08/11/2015 07:07 PM
[Tutorial] Making a simple PM system with ZCMD & sscanf Toni Tutorials 35 08/11/2014 03:44 PM
[Tutorial] Simple Ingame Mapper system [Yini|sscanf|zcmd|streamer] faff Tutorials 15 29/04/2014 02:46 AM
[Tutorial] Making a very simple VIP system with /setvip command using dini+sscanf+ZCMD electrux Tutorials 2 25/07/2012 10:00 AM
[Tutorial] Simple Private Message System Using zCMD And Sscanf with Logs Jason_Thunde Tutorials 3 19/10/2011 09:59 PM


All times are GMT. The time now is 07:57 PM.


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