Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- TDCountDown by Gappy
- */
- #if defined _TDCountDown_included
- #endinput
- #endif
- #include <a_samp>
- #define _TDCountDown_included
- #pragma library TDCountDown
- /*Natives
- native TDCountDown(minutes, seconds, Float:x, Float:y)
- native TDCDSetTime(minutes, seconds)
- native TDCDShowForPlayer(playerid)
- native TDCDHideForPlayer(playerid)
- native TDCDShowForAll()
- native TDCDHideForAll()
- */
- new Text:CDTD;
- new CDsec;
- new CDmin;
- new Float:TDPx;
- new Float:TDPy;
- new TDTimer;
- forward CDTimer();
- forward OnCountDownEnd();
- stock TDCountDown(minutes, seconds, Float:x, Float:y)
- {
- CDmin = minutes;
- CDsec = seconds;
- TDPx = x;
- TDPy = y;
- if(CDmin == 0 && CDsec == 0)
- {
- return 1;
- }
- CDTD = TextDrawCreate(TDPx,TDPy, "CDTD");
- TextDrawTextSize(CDTD,636.000000,824.000000);
- TextDrawAlignment(CDTD, 2);
- TextDrawFont(CDTD,3);
- TextDrawLetterSize(CDTD,0.499999,1.800000);
- TextDrawColor(CDTD,0xffffffff);
- TextDrawSetProportional(CDTD,2);
- TextDrawSetShadow(CDTD,1);
- TextDrawSetOutline(CDTD, 1);
- TDTimer = SetTimer("CDTimer",1000,1);
- return 1;
- }
- public CDTimer()
- {
- new string[128];
- if(CDsec >= 1)
- {
- format(string,sizeof(string), "~w~%02d:%02d",CDmin, CDsec);
- TextDrawSetString(CDTD, string);
- CDsec--;
- }
- else if(CDsec == 0 && CDmin != 0)
- {
- format(string,sizeof(string), "~w~%02d:%02d",CDmin, CDsec);
- TextDrawSetString(CDTD, string);
- CDsec = 59;
- CDmin--;
- }
- else if(CDmin == 0 && CDsec == 0)
- {
- TextDrawSetString(CDTD, "00:00");
- KillTimer(TDTimer);
- OnCountDownEnd();
- }
- return 1;
- }
- stock TDCDSetTime(minutes, seconds)
- {
- new string[128];
- CDmin = minutes;
- CDsec = seconds;
- format(string,sizeof(string), "~w~%02d:%02d",CDmin, CDsec);
- TextDrawSetString(CDTD, string);
- KillTimer(TDTimer);
- TDTimer = SetTimer("CDTimer",1000,1);
- return 1;
- }
- stock TDCDShowForPlayer(playerid)
- {
- TextDrawShowForPlayer(playerid, CDTD);
- return 1;
- }
- stock TDCDHideForPlayer(playerid)
- {
- TextDrawHideForPlayer(playerid, CDTD);
- return 1;
- }
- stock TDCDHideForAll()
- {
- TextDrawHideForAll(CDTD);
- return 1;
- }
- stock TDCDShowForAll()
- {
- TextDrawShowForAll(CDTD);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement