Displaying timer in the right side of the screen. - 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: Displaying timer in the right side of the screen. (
/showthread.php?tid=551227)
Displaying timer in the right side of the screen. -
GuitarMan - 17.12.2014
Basicly what i want to do is, print timers in the left side of my screen.
Im doing gangwar server and i would like to make some timers to display so that player knows, when his gang can fight for a territory again.
For example if theres a timer called CanFightForGangZone[i]=60.
I would like it to make a countdown thats visible for everyone and counts form 60 till 0. when its 0, it stays like that.
something like these clocks:
Re: Displaying timer in the right side of the screen. -
Banana_Ghost - 17.12.2014
pawn Код:
//This Is An Example Of How You Can Do What You Want It To Do.
//It's not perfect, but it will give you an example.
#include <a_samp>
#include <YSI\y_commands>
#include <foreach>
#define COLOR_WHITE 0xFFFFFFFF
new Text:Timer;
forward CanGangwar(playerid);
new CanFightForGangZone[MAX_PLAYERS];
public OnFilterScriptInit()
{
Timer = TextDrawCreate(605.000000,25.000000,"00:00");
TextDrawAlignment(Timer,3);
TextDrawBackgroundColor(Timer,0x000000FF);
TextDrawFont(Timer,3);
TextDrawLetterSize(Timer,0.535,2.2);
TextDrawColor(Timer,COLOR_WHITE);
TextDrawSetOutline(Timer,2);
TextDrawSetProportional(Timer,1);
TextDrawSetShadow(Timer,1);
return 1;
}
public OnFilterScriptExit()
{
TextDrawDestroy(Timer);
return 1;
}
//Used To Count Down The Timer.
//Set the Amount Of CanFightForGangZone, then count down this timer in intervals of 1 seconds
public CanGangwar(playerid)
{
new str1[10];
CanFightForGangZone[playerid]--;
format(str1,sizeof(str1),"%s",TimeConvert(CanFightForGangZone[playerid]));
TextDrawSetString(Timer,str1);
TextDrawShowForAll(Timer);
return 1;
}
//This Is A Stock Made By Someone On The SA-MP Forums (Thanks to whoever made it), that will convert seconds to actual Minutes and Seconds.
TimeConvert(time) {
new minutes;
new seconds;
new string[128];
if(time > 59){
minutes = floatround(time/60);
seconds = floatround(time - minutes*60);
if(seconds>9)format(string,sizeof(string),"%d:%d",minutes,seconds);
else format(string,sizeof(string),"%d:0%d",minutes,seconds);
}
else{
seconds = floatround(time);
if(seconds>9)format(string,sizeof(string),"0:%d",seconds);
else format(string,sizeof(string),"0:0%d",seconds);
}
return string;
}