Advertisements
#1

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;
}
Reply
#2

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.
Reply
#3

I Compile it, its work for me!
Reply
#4

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
Посмотреть сообщение
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.
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?
Reply
#5

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
Reply
#6

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)