Displaying timer in the right side of the screen.
#1

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:
Reply
#2

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


Forum Jump:


Users browsing this thread: 1 Guest(s)