SA-MP Forums Archive
[Include] CountDownForPlayer, CountDownForAll - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] CountDownForPlayer, CountDownForAll (/showthread.php?tid=254356)



CountDownForPlayer, CountDownForAll - Biesmen - 10.05.2011

CountDown include 1.0
Created by:
Biesmen


About
Well, I'm sure someone else has made something like this before, but I couldn't find it on this forum. I decided to create an include like this for you. I saw some people requested an include like this. It's a very simple script. It's not hard to use, only two functions. This script will create a timer, which will stop once the second variable reached 0. It will countdowon from the seconds you selected, and it will send a final message once the countdown ended.

Functions:
pawn Код:
CountDownForAll(Color, EndMessage, Seconds);
CountDownForPlayer(playerid, Color, EndMessage, Seconds);
How-to-use
Download the file below, extract the two files to the correct folder(The correct folder is also being shown in the .rar file).
Once you installed the include, type this at the top of your gamemode/filterscript/script:
pawn Код:
#include <CountDown>
Advice how to use them in a command:
At the top of your script type:
pawn Код:
#include <sscanf2>
(Make sure you download SSCANF2 first, at this link: https://sampforum.blast.hk/showthread.php?tid=120356)

The two CMDS:

pawn Код:
dcmd_cd(playerid, params[])
{
    new color[2], time, message[30];
    if(sscanf(params, "s[2]is[30]", color, time, message)) return SendClientMessage(playerid, -1, "Usage: /cd [color] [time in seconds] [message]");
    CountDownForAll(color, message, time);
    return 1;
}

dcmd_cdp(playerid, params[])
{
    new color[2], time, message[30], giveplayerid;
    if(sscanf(params, "us[2]is[30]", giveplayerid, color, time, message)) return SendClientMessage(playerid, -1, "Usage: /cdp [playerid/PartOfName] [color] [time in seconds] [message]");
    CountDownForPlayer(giveplayerid, color, message, time);
    return 1;
}
Download
Mediafire Version: 1.0
Pastebin Version: 1.0
(Pastebin:- Make sure you've got the Foreach include by ******. (That include is included at the Mediafire mirror))
No mirrors allowed

Known bugs
-

Credits
  • Biesmen
  • ****** - Foreach include
Feedback and critism allowed. This will only make the script function and look better.
Enjoy



Re: CountDownForPlayer, CountDownForAll - gamer931215 - 10.05.2011

Looks good , il might use it the next time someone is spamming me on xfire to make a /countdown again >,>


Re: CountDownForPlayer, CountDownForAll - TheGarfield - 10.05.2011

don't bad and don't nice.
+ or -


Re: CountDownForPlayer, CountDownForAll - Markx - 10.05.2011

Quote:
Originally Posted by TheGarfield
Посмотреть сообщение
don't bad and don't nice.
+ or -
Your English grammar is horrible.

Nice work.


Re: CountDownForPlayer, CountDownForAll - Biesmen - 17.05.2011

Thanks.


Re: CountDownForPlayer, CountDownForAll - Hiddos - 17.05.2011

Quote:
Originally Posted by Markx
Посмотреть сообщение
Your English grammar is horrible.
Hehe

I'm wondering about some things, for example these two stocks:
pawn Код:
stock AvailableColors(TColor[])
{
        if(strcmp(TColor,"r", true) == 0) return 1;
        if(strcmp(TColor,"g", true) == 0) return 1;
        if(strcmp(TColor,"b", true) == 0) return 1;
        if(strcmp(TColor,"w", true) == 0) return 1;
        if(strcmp(TColor,"y", true) == 0) return 1;
        if(strcmp(TColor,"p", true) == 0) return 1;
        if(strcmp(TColor,"l", true) == 0) return 1;
        if(strcmp(TColor,"h", true) == 0) return 1;
        else return 0;
}

stock CountDownForAll(Color[2], EndMessage[30], Seconds)
{
        foreach(Player, i)
        {
                if(CD[i][CDUsed] == 1) return print("CountDown ERROR: There's a player still having the Countdown messages!");
                if(strlen(Color) > 1 || !AvailableColors(Color)) return print("CountDown ERROR: Invalid color used!");
                if(strlen(EndMessage) > 30) return print("CountDown ERROR: End Message is too long!");
                if(Seconds < 0 ) return print("CountDown ERROR: Negative amount of seconds.");
                CD[i][cdc] = Color;
                CD[i][cdem] = EndMessage;
                CD[i][cds] = Seconds;
                CDTimerA = SetTimer("CountD", 1000, true);
                CD[i][CDUsed] = 1;
        }
        return 1;
}
Why are you using strings to check the colour? You could just use numbers or the #define function, like:
pawn Код:
#define COLOR_CDI_RED 0
#define COLOR_CDI_GREEN 1
Then when formatting the string, you'll only need an if - else if statement when choosing the colour.


Re: CountDownForPlayer, CountDownForAll - Biesmen - 17.05.2011

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
[...]
Well, people are used to those default SA:MP colors: "h, g,r, b, etc.". That's why I checked the string.


Re: CountDownForPlayer, CountDownForAll - Michael@Belgium - 17.05.2011

Awesome work


Respuesta: CountDownForPlayer, CountDownForAll - Lunnatiicz - 17.05.2011

I was searching this DD

ЎThanks & awesome work!


Re: CountDownForPlayer, CountDownForAll - Sasino97 - 18.05.2011

Quote:
Originally Posted by Markx
Посмотреть сообщение
Your English grammar is horrible.

Nice work.
LOL:


Quote:
Originally Posted by Markx
Посмотреть сообщение
Well, its simple.

When i /ban someone, it should show up on my website.. How to do that? A pic in attachment.
Quote:
Originally Posted by ******
Посмотреть сообщение
I'm sorry, I had to reply given your signature!



"it's" has an apostrophe when used as a contraction of "it is", it does not have a apostrophe when used for possession, contrary to the usual rule for possession. If for some reason you are talking about multiple "its" (such as in this sentence) then again there is no apostrophe. Never mind that this sentence has no context and thus "it's" is incorrect and that you started it with "Well".



"I" is always capitalised. "/ban" is the name of a command, and as such is a noun, not a verb. You cannot "/ban" someone, you can ban someone using "/ban", you could use your "/ban" command on someone, but there needs to be an action in the sentence. Sentences should end with only one full stop, there is sometimes a use of three, but not two. The last sentence was just a mess and I have completely rewritten it. Firstly "pic" is an abbreviation so should be "pic.", or simply "picture". Secondly that sentence has an object (the picture in the attachment) but no subject (what about the picture in the attachment)? Even as an object it is wrong and should be something more along the lines of "the picture in the attachment", or "the attached picture".

If you want to be a grammar Nazi, you had better make sure you are perfect, or at least very close! If you wish to rip apart this post feel free, but I am making no claims that it is correct, unlike you.

As for your original problem, how are you banning people and how are you saving that data? Does your website have access to the location in which you are storing that ban data (SQL, Scriptfiles, samp.ban etc)?