SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 13/07/2013, 01:10 PM   #1
JEkvall95
Huge Clucker
 
Join Date: Jun 2012
Posts: 453
Reputation: -13
Default Super easy Countdown command

How can I create a super easy Countdown which works for everyone? It's a filterscript



pawn Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#include <a_samp>
#include <TextDrawCountDown>

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

#endif



public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/cd", cmdtext, true, 10) == 0)
    {
  // Do something here
        return 1;
    }
    return 0;
}

here is the include

Code:
/*   TextDrawCountDown by Littlejohny (TextDrawCountDown)       */
/*                                      by Littlejohny                                  */
/*              **************************************          */
/*      TextDrawCountDownForPlayer(playerid, seconds)                   */
/*      TextDrawCountDownForAll(seconds)                                                */
/*      HideCountDownForPlayer(playerid)                                                */
/*      HideCountDownForAll()                                                                   */
 
#if defined _TextDrawCountDown_included
  #endinput
#endif
 
#include <a_samp>
 
#define _TextDrawCountDown_included
#pragma library TextDrawCountDown
 
#define RED 0xE60000FF
 
new tdcstr[64];
 
new PlayerText:tdcd[MAX_PLAYERS],
        pcdtime[MAX_PLAYERS],
        ptdctimer[MAX_PLAYERS],
        pCOUNT_ON[MAX_PLAYERS] = 0;
 
new cdtime,
        tdctimer,
        COUNT_ON;
 
forward TextDrawCountDownForAll(seconds);
forward TextDrawCountDownForPlayer(playerid, seconds);
forward HideCountDownForAll();
forward HideCountDownForPlayer(playerid);
forward PlayerCountTimer(playerid);
forward TextCountTimer();
 
public OnPlayerConnect(playerid)
{
    tdcd[playerid] = CreatePlayerTextDraw(playerid, 320.000000,410.000000, "TDCD");
        PlayerTextDrawTextSize(playerid, tdcd[playerid],636.000000,824.000000);
        PlayerTextDrawAlignment(playerid, tdcd[playerid], 2);
        PlayerTextDrawFont(playerid, tdcd[playerid],3);
        PlayerTextDrawLetterSize(playerid, tdcd[playerid],0.499999,1.800000);
        PlayerTextDrawColor(playerid, tdcd[playerid],0xffffffff);
        PlayerTextDrawSetProportional(playerid, tdcd[playerid],2);
        PlayerTextDrawSetShadow(playerid, tdcd[playerid],1);
        PlayerTextDrawSetOutline(playerid, tdcd[playerid], 1);
        if(funcidx("tdcd_OnPlayerConnect") != -1) return CallLocalFunction("tdcd_OnPlayerConnect", "d",playerid);
        return 1;
}
#if defined _ALS_OnPlayerConnect
    #undef OnPlayerConnect
#else
    #define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect tdcd_OnPlayerConnect
forward tdcd_OnPlayerConnect(playerid);
 
public TextDrawCountDownForPlayer(playerid, seconds)
{
    if(pCOUNT_ON[playerid] == 1) return 1;
 
        pcdtime[playerid] = seconds;
        if(pcdtime[playerid] < 1 || pcdtime[playerid] > 30)
        {
            pcdtime[playerid] = 0;
                return 1;
        }
        ptdctimer[playerid] = SetTimerEx("PlayerCountTimer", 1000, 1, "i", playerid);
        pCOUNT_ON[playerid] = 1;
       
        format(tdcstr,sizeof(tdcstr), "~w~CountDown: ~r~%d ~w~second/s", pcdtime[playerid]);
        pcdtime[playerid]--;
       
        PlayerTextDrawSetString(playerid, tdcd[playerid], tdcstr);
        PlayerTextDrawShow(playerid, tdcd[playerid]);
        PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
        return 1;
}
 
public TextDrawCountDownForAll(seconds)
{
        if(COUNT_ON == 1) return 1;
 
        COUNT_ON = 1;
        cdtime = seconds;
        if(cdtime < 1 || cdtime > 30)
        {
            cdtime = 0;
                return 1;
        }
        tdctimer = SetTimer("TextCountTimer", 1000, 1);
       
        format(tdcstr,sizeof(tdcstr), "~w~CountDown: ~r~%d ~w~second/s", cdtime);
        cdtime--;
       
        for (new i = 0; i < MAX_PLAYERS; i++)
        {
                if(IsPlayerConnected(i) && pCOUNT_ON[i] == 0)
                {
                        PlayerTextDrawSetString(i, tdcd[i], tdcstr);
                        PlayerTextDrawShow(i, tdcd[i]);
                        PlayerPlaySound(i, 1058, 0.0, 0.0, 0.0);
                }
        }
        return 1;
}
 
public HideCountDownForPlayer(playerid)
{
        PlayerTextDrawHide(playerid, tdcd[playerid]);
        pCOUNT_ON[playerid] = 0;
        return 1;
}
 
public HideCountDownForAll()
{
        for (new i = 0; i < MAX_PLAYERS; i++)
        {
        if(IsPlayerConnected(i) && pCOUNT_ON[i] == 0)
                {
                PlayerTextDrawHide(i, tdcd[i]);
                }
        }
        COUNT_ON = 0;
        return 1;
}
 
public TextCountTimer()
{
        if(cdtime <= 30 && cdtime >= 1)
        {
            format(tdcstr,sizeof(tdcstr), "~w~CountDown: ~r~%d ~w~second/s", cdtime);
                cdtime--;
 
            for (new i = 0; i < MAX_PLAYERS; i++)
                {
                if(IsPlayerConnected(i) && pCOUNT_ON[i] == 0)
                        {
                        PlayerTextDrawSetString(i, tdcd[i], tdcstr);
                        PlayerTextDrawShow(i, tdcd[i]);
                        PlayerPlaySound(i, 1058, 0.0, 0.0, 0.0);
                        }
                }
        }
        else if(cdtime == 0)
        {
            for (new i = 0; i < MAX_PLAYERS; i++)
                {
                if(IsPlayerConnected(i) && pCOUNT_ON[i] == 0)
                        {
                                KillTimer(tdctimer);
                                PlayerTextDrawSetString(i, tdcd[i], "~w~CountDown: ~g~GO !");
                                PlayerTextDrawShow(i, tdcd[i]);
                                PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
                        }
                }
                SetTimer("HideCountDownForAll", 3000, 0);
        }
        return 1;
}
 
public PlayerCountTimer(playerid)
{
        if(pcdtime[playerid] <= 30 && pcdtime[playerid] >= 1)
        {
            format(tdcstr,sizeof(tdcstr), "~w~CountDown: ~r~%d ~w~second/s", pcdtime[playerid]);
            PlayerTextDrawSetString(playerid, tdcd[playerid], tdcstr);
            PlayerTextDrawShow(playerid, tdcd[playerid]);
            PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
            pcdtime[playerid]--;
        }
        else if(pcdtime[playerid] == 0)
        {
                        KillTimer(ptdctimer[playerid]);
                        PlayerTextDrawSetString(playerid, tdcd[playerid], "~w~CountDown: ~g~GO !");
                        PlayerTextDrawShow(playerid, tdcd[playerid]);
                        SetTimerEx("HideCountDownForPlayer", 3000, 0, "i", playerid);
                        PlayerPlaySound(playerid, 1056, 0.0, 0.0, 0.0);
        }
        return 1;
}
JEkvall95 is offline   Reply With Quote
Old 13/07/2013, 01:14 PM   #2
Bakr
Gangsta
 
Join Date: Apr 2011
Posts: 975
Reputation: 198
Default Re: Super easy Countdown command

Find the thread for the script and read how to use it...?
__________________

Looking for some people to help me with script testing. If you would be interested, send me a PM.

Quote:
Originally Posted by RiChArD_A
Bakr, what have done to you . You don't know me to be saying that I'm lazy. Your fucked ass mom is the only idiot here, ass hole.
Bakr is offline   Reply With Quote
Old 13/07/2013, 01:15 PM   #3
JEkvall95
Huge Clucker
 
Join Date: Jun 2012
Posts: 453
Reputation: -13
Default Re: Super easy Countdown command

Quote:
Originally Posted by Bakr View Post
Find the thread for the script and read how to use it...?
Its not a script... O_o
JEkvall95 is offline   Reply With Quote
Old 13/07/2013, 01:16 PM   #4
Bakr
Gangsta
 
Join Date: Apr 2011
Posts: 975
Reputation: 198
Default Re: Super easy Countdown command

An include is not a script? Interesting.
__________________

Looking for some people to help me with script testing. If you would be interested, send me a PM.

Quote:
Originally Posted by RiChArD_A
Bakr, what have done to you . You don't know me to be saying that I'm lazy. Your fucked ass mom is the only idiot here, ass hole.
Bakr is offline   Reply With Quote
Old 13/07/2013, 01:17 PM   #5
JEkvall95
Huge Clucker
 
Join Date: Jun 2012
Posts: 453
Reputation: -13
Default Re: Super easy Countdown command

Something like this?
http://forum.sa-mp.com/showthread.php?p=241101
pawn Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#include <a_samp>
#include <TextDrawCountDown>

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

#endif



public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/cd", cmdtext, true, 10) == 0)
    {
  TextDrawCountDownForAll(seconds)
    Parameters:
        seconds[]   how many seconds (max 30)
        return 1;
    }
    return 0;
}
JEkvall95 is offline   Reply With Quote
Old 13/07/2013, 01:22 PM   #6
Bakr
Gangsta
 
Join Date: Apr 2011
Posts: 975
Reputation: 198
Default Re: Super easy Countdown command

He gave you the functions of the include with documentation on what they use. There are even examples later in the thread.

If you don't know how to script at all, look at one of the MANY tutorials on getting started.
__________________

Looking for some people to help me with script testing. If you would be interested, send me a PM.

Quote:
Originally Posted by RiChArD_A
Bakr, what have done to you . You don't know me to be saying that I'm lazy. Your fucked ass mom is the only idiot here, ass hole.
Bakr is offline   Reply With Quote
Old 13/07/2013, 01:23 PM   #7
PHudson
Big Clucker
 
PHudson's Avatar
 
Join Date: Sep 2011
Location: Kingdom of Spain
Posts: 117
Reputation: 1
Default Respuesta: Super easy Countdown command

LOL, the function is just the first line. Parameters and seconds[] are an explanation of the code.

pawn Code:
if (strcmp("/cd", cmdtext, true) == 0)
{
    TextDrawCountDownForAll(seconds); // Replace "seconds" for the amount of seconds you want the countdown to last. Use TextDrawCountDownForPlayer(playerid, seconds) if you want to show it just to a player.
    return 1;
}
PHudson is offline   Reply With Quote
Old 13/07/2013, 01:27 PM   #8
JEkvall95
Huge Clucker
 
Join Date: Jun 2012
Posts: 453
Reputation: -13
Default Re: Super easy Countdown command

wow LOL so many errors
Code:
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(40) : error 017: undefined symbol "CreatePlayerTextDraw"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(40) : warning 213: tag mismatch
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(41) : warning 217: loose indentation
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(41) : error 017: undefined symbol "PlayerTextDrawTextSize"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(42) : error 017: undefined symbol "PlayerTextDrawAlignment"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(43) : error 017: undefined symbol "PlayerTextDrawFont"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(44) : error 017: undefined symbol "PlayerTextDrawLetterSize"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(45) : error 017: undefined symbol "PlayerTextDrawColor"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(46) : error 017: undefined symbol "PlayerTextDrawSetProportional"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(47) : error 017: undefined symbol "PlayerTextDrawSetShadow"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(48) : error 017: undefined symbol "PlayerTextDrawSetOutline"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(64) : warning 217: loose indentation
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(68) : warning 217: loose indentation
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(76) : error 017: undefined symbol "PlayerTextDrawSetString"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(77) : error 017: undefined symbol "PlayerTextDrawShow"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(91) : warning 217: loose indentation
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(102) : error 017: undefined symbol "PlayerTextDrawSetString"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(103) : error 017: undefined symbol "PlayerTextDrawShow"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(112) : error 017: undefined symbol "PlayerTextDrawHide"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(123) : error 017: undefined symbol "PlayerTextDrawHide"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(135) : warning 217: loose indentation
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(137) : warning 217: loose indentation
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(141) : error 017: undefined symbol "PlayerTextDrawSetString"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(142) : error 017: undefined symbol "PlayerTextDrawShow"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(154) : error 017: undefined symbol "PlayerTextDrawSetString"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(155) : error 017: undefined symbol "PlayerTextDrawShow"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(159) : warning 217: loose indentation
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(169) : error 017: undefined symbol "PlayerTextDrawSetString"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(170) : error 017: undefined symbol "PlayerTextDrawShow"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(177) : error 017: undefined symbol "PlayerTextDrawSetString"
C:\Users\Julius\Desktop\UltimateStunting\pawno\include\TextDrawCountDown.inc(178) : error 017: undefined symbol "PlayerTextDrawShow"
C:\Users\Julius\Desktop\UltimateStunting\filterscripts\cd.pwn(40) : error 017: undefined symbol "seconds"
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


24 Errors.
JEkvall95 is offline   Reply With Quote
Old 13/07/2013, 01:31 PM   #9
PHudson
Big Clucker
 
PHudson's Avatar
 
Join Date: Sep 2011
Location: Kingdom of Spain
Posts: 117
Reputation: 1
Default Respuesta: Super easy Countdown command

  • Did you modify something in the include file? Replace it with the original file.
  • Are all your server files updated to SA-MP 0.3x?
  • It could be the include's fault.
PHudson is offline   Reply With Quote
Old 13/07/2013, 02:16 PM   #10
JEkvall95
Huge Clucker
 
Join Date: Jun 2012
Posts: 453
Reputation: -13
Default Re: Respuesta: Super easy Countdown command

Quote:
Originally Posted by PHudson View Post
  • Did you modify something in the include file? Replace it with the original file.
  • Are all your server files updated to SA-MP 0.3x?
  • It could be the include's fault.
No I didn't and yes it is 0.3x
JEkvall95 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
High way SUPER speed SUPER cool (I don't know how to call it):) arie9000nerd Filterscripts 3 18/11/2013 08:51 AM
Super command (posssible or not) CBCandyBoy Scripting Help 2 22/03/2013 06:12 AM
CountDown Command NeeD OnE Plz >ReEd< Elmerz_com Help Archive 4 18/01/2011 10:03 PM
Super Easy Port Forward Vi3t102 Server Support 5 03/01/2011 09:48 PM


All times are GMT. The time now is 03:19 AM.


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