Advertisements - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Advertisements (
/showthread.php?tid=409882)
Advertisements -
Da_Noob - 23.01.2013
So I want to make an /ad command, but I want it so only 1 advertisement every 60seconds can be send.
I know how to code the command, but I don't really understand timers. Can somebody make a timer for me so it works?
My cmd:
Код:
CMD:ad(playerid, params[])
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ad [chat]");
{
new s[100];
format(s,sizeof(s), "Advertisement: %s, Name: %s, Ph: %s", params, GetName(playerid), PlayerInfo[playerid][pPhone]);
SendClientMessageToAll(COLOR_GREEN, s);
}
return 1;
}
Re: Advertisements -
LarzI - 23.01.2013
https://sampforum.blast.hk/showthread.php?tid=182948
I suggest reading the "Timer" part there, and DL the YSI package. It's incredibly simple - way simpler than the standard SetTimer function method, imo.
Re: Advertisements -
theomanking - 23.01.2013
I Compile it, its work for me!
Re: Advertisements -
Da_Noob - 23.01.2013
Quote:
Originally Posted by theomanking
I Compile it, its work for me!
|
Yes, I know it works... I just need a timer to work for it.
Quote:
Originally Posted by LarzI
|
I've read through it, and it looks like Chinese to me. I'll download it and look into it, but for now, can you explain how to make a simple timer like I want?
Re: Advertisements -
Xbowman - 23.01.2013
here's a link 2 the instructions + my additional instructions:
https://sampwiki.blast.hk/wiki/SetTimer
ok, now for my additional instructions. A boolean is a value that u set to either false or true, false means no and true means yes.
Basicly what a timer does is calling another function after a certain amount of time. But that function must be forwarded with forward <function>();
that's basicly how timers work. Also i'm asking nicely: don't forget 2 add 2 my reputation if i was helpfull
Re: Advertisements -
DiGiTaL_AnGeL - 23.01.2013
pawn Код:
new adtimer = 0;
forward ADTimer();
public ADTimer()
{
adtimer = 0;
return 1;
}
And then you check the variable in the cmd:
pawn Код:
CMD:ad(playerid, params[])
{
if(adtimer == 0)
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ad [chat]");
{
new s[100];
format(s,sizeof(s), "Advertisement: %s, Name: %s, Ph: %s", params, GetName(playerid), PlayerInfo[playerid][pPhone]);
SendClientMessageToAll(COLOR_GREEN, s);
adtimer = 1;
SetTimer("ADTimer", 60000, 0);
}
}
else
{
SendClientMessage(playerid, 0xFF0000FF, "You must wait 60 seconds before advertise something!");
}
return 1;
}