help with textdraw!!
#1

im using satdm v9(i download it from forum) and im trying to put time and date textdraw the problem is the date textdraw works fine
but the time textdraw shows only when im in a vehicule i can't find a sloution for it to show all the time (on foot+in vehicule)
here's the filterscript im using
pawn Код:
#include <a_samp>

#define foreach(%1,%2) \
        for(new %1;%1<%2;%1++) if(IsPlayerConnected(%1))

#define COLOR_RED        (0xAA3333AA)
#define COLOR_YELLOW (0xFFFF00AA)

#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

forward ClockSystem();
forward PlayersTime();
forward PlayersHour();
forward settime(playerid);
new Text:Date77;
new hour, hours, minute, minutes, second;
new Text: Clock;
new clocktimer, bigclocktimer, minutetimer, hourtimer;
new bool: StartClock = true;
new bool: ManualClock = false;
new HighestID = 0;

public OnFilterScriptInit()
{
        SetTimer("settime",1000,true);
        print("   *** Clock system loaded! by [_PGB_]Spatrik");

        Clock = TextDrawCreate(548, 23.5, "--:--");
        TextDrawLetterSize(Clock, 0.57, 2.05);
        TextDrawFont(Clock, 3);
        TextDrawColor(Clock,0xd6bc11FF);
       

        clocktimer = SetTimer("ClockSystem", 1000, true);

        Date77 = TextDrawCreate(547.000000,11.000000,"--");
        TextDrawFont(Date77,3);
        TextDrawLetterSize(Date77,0.399999,1.600000);
        TextDrawColor(Date77,0xffffffff);
        for(new i; i < MAX_PLAYERS; i ++)
        {
        if(IsPlayerConnected(i))
        {
            TextDrawShowForPlayer(i, Date77);
        }
        }
        for(new i; i < MAX_PLAYERS; i ++)
        {
        if(IsPlayerConnected(i))
        {
            TextDrawShowForPlayer(i, Clock);
        }
        }
        return 1;
}

public OnFilterScriptExit()
{
    TextDrawHideForAll(Clock);
    TextDrawDestroy(Text: Clock);
    if(ManualClock == false)
    {
        if(StartClock == true)
        {
                KillTimer(clocktimer);
                } else {
                KillTimer(bigclocktimer);
                }
            } else {
            KillTimer(minutetimer);
            KillTimer(hourtimer);
            }
    print("   *** Clock system unloaded! by [_PGB_]Spatrik");
    TextDrawHideForAll(Date77);
    TextDrawDestroy(Date77);
    return 1;
}
public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid, Clock);
    TextDrawShowForPlayer(playerid, Date77);
    return 1;
}

public OnPlayerConnect(playerid)
{
    if(HighestID < playerid)
    {
                HighestID = playerid;
        }
   
    return 1;
}
public OnPlayerRequestClass(playerid, classid)
{

    TextDrawHideForPlayer(playerid, Clock);
}
public OnPlayerDisconnect(playerid, reason)
{
    if(HighestID == playerid)
        {
                for(new i = playerid-1; i >= 0; i--)
                {
                        if(IsPlayerConnected(i))
                        {
                                HighestID = i;
                                break;
                        }
                }
        }
    TextDrawDestroy(Clock);
    TextDrawDestroy(Date77);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
        dcmd(setclock, 8, cmdtext);
        dcmd(defaultclock, 12, cmdtext);
        return 0;
}

dcmd_setclock(playerid, params[])
{
                new number, number2;

   
                if(sscanf(params, "dd",number,number2))
                {
                        return SendClientMessage(playerid, COLOR_RED, "USAGE:  /setclock [hour][minute]");
                }
                else if(number < 0 || number > 24 || number2 < 0 || number2 > 60)
                {
                        return SendClientMessage(playerid, COLOR_RED, "*** Clock System: Invalid time!");
                }
                else if(ManualClock == false)
                {
                        new string[8];
                        ManualClock = true;
                        if(StartClock == true)
                        {
                        KillTimer(clocktimer);
                        } else {
                        KillTimer(bigclocktimer);
                        StartClock = true;
                        }
                        format(string, sizeof(string), "%d:%d", number, number2);
                        TextDrawSetString(Text: Clock, string);
                        for(new i = 0; i < HighestID; i++)
                        {
                                SetPlayerTime(i, number, number2);
                        }
                        minutetimer = SetTimer("PlayersTime", 1000*60, true);
                        hourtimer = SetTimer("PlayersHour", (1000*60)*60, true);
                        } else {
                        new string[8];
                        format(string, sizeof(string), "%d:%d", number, number2);
                        TextDrawSetString(Text: Clock, string);
                        for(new i = 0; i < HighestID; i++)
                        {
                                SetPlayerTime(i, number, number2);
                        }
                }
               
       
                return 1;
}

dcmd_defaultclock(playerid, params[])
{
    #pragma unused params
        if(!IsPlayerAdmin(playerid))
        {
                if(ManualClock == true)
                {
                    KillTimer(minutetimer);
                    KillTimer(hourtimer);
                    clocktimer = SetTimer("ClockSystem", 1000, true);
                }
                else if(StartClock == true)
                {
                        KillTimer(clocktimer);
                        } else {
                        KillTimer(bigclocktimer);
                        StartClock = true;
                }
                clocktimer=SetTimer("ClockSystem", 1000, true);
                SendClientMessage(playerid, COLOR_YELLOW, "*** Clock System: Configuring Done!");
                } else {
                SendClientMessage(playerid, COLOR_RED, "You are not an administrator!");
        }
        return 1;
}

public ClockSystem()
{
    new string[8];
    gettime(hour, minute, second);
    if(StartClock == true)
    {
    if(minute == 00)
    {
    KillTimer(clocktimer);
    bigclocktimer = SetTimer("ClockSystem", 1000*60, true);
    StartClock = true;
    }
    }
    format(string, sizeof(string), "%d:%d", hour, minute);
    TextDrawSetString(Text: Clock, string);
    for(new i = 0; i < HighestID; i++)
    {
    SetPlayerTime(i, hour, minute);
    }
    return 1;
}

public PlayersTime()
{
    for(new i = 0; i < HighestID; i++)
        {
            new string[8];
            GetPlayerTime(i, hours, minutes);
            SetPlayerTime(i, hours, minutes +1);
            format(string, sizeof(string), "%d:%d", hours, minutes +1);
            TextDrawSetString(Text: Clock, string);
        }
    return 1;
}

public PlayersHour()
{
    for(new i = 0; i < HighestID; i++)
        {
            new string[8];
            GetPlayerTime(i, hours, minutes);
            SetPlayerTime(i, hours +1, minutes);
            format(string, sizeof(string), "%d:%d", hours +1, minutes);
            TextDrawSetString(Text: Clock, string);
        }
    return 1;
}

stock sscanf(string[], format[], {Float,_}:...)
{
        #if defined isnull
                if (isnull(string))
        #else
                if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
        #endif
                {
                        return format[0];
                }
        #pragma tabsize 4
        new
                formatPos = 0,
                stringPos = 0,
                paramPos = 2,
                paramCount = numargs(),
                delim = ' ';
        while (string[stringPos] && string[stringPos] <= ' ')
        {
                stringPos++;
        }
        while (paramPos < paramCount && string[stringPos])
        {
                switch (format[formatPos++])
                {
                        case '\0':
                        {
                                return 0;
                        }
                        case 'i', 'd':
                        {
                                new
                                        neg = 1,
                                        num = 0,
                                        ch = string[stringPos];
                                if (ch == '-')
                                {
                                        neg = -1;
                                        ch = string[++stringPos];
                                }
                                do
                                {
                                        stringPos++;
                                        if ('0' <= ch <= '9')
                                        {
                                                num = (num * 10) + (ch - '0');
                                        }
                                        else
                                        {
                                                return -1;
                                        }
                                }
                                while ((ch = string[stringPos]) > ' ' && ch != delim);
                                setarg(paramPos, 0, num * neg);
                        }
                        case 'h', 'x':
                        {
                                new
                                        ch,
                                        num = 0;
                                while ((ch = string[stringPos]) > ' ' && ch != delim)
                                {
                                        switch (ch)
                                        {
                                                case 'x', 'X':
                                                {
                                                        num = 0;
                                                        continue;
                                                }
                                                case '0' .. '9':
                                                {
                                                        num = (num << 4) | (ch - '0');
                                                }
                                                case 'a' .. 'f':
                                                {
                                                        num = (num << 4) | (ch - ('a' - 10));
                                                }
                                                case 'A' .. 'F':
                                                {
                                                        num = (num << 4) | (ch - ('A' - 10));
                                                }
                                                default:
                                                {
                                                        return -1;
                                                }
                                        }
                                }
                                setarg(paramPos, 0, num);
                        }
                        case 'c':
                        {
                                setarg(paramPos, 0, string[stringPos++]);
                        }
                        case 'f':
                        {
                                setarg(paramPos, 0, _:floatstr(string[stringPos]));
                        }
                        case 'p':
                        {
                                delim = format[formatPos++];
                                continue;
                        }
                        case '\'':
                        {
                                new
                                        end = formatPos - 1,
                                        ch;
                                while ((ch = format[++end]) && ch != '\'') {}
                                if (!ch)
                                {
                                        return -1;
                                }
                                format[end] = '\0';
                                if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
                                {
                                        if (format[end + 1])
                                        {
                                                return -1;
                                        }
                                        return 0;
                                }
                                format[end] = '\'';
                                stringPos = ch + (end - formatPos);
                                formatPos = end + 1;
                        }
                        case 'u':
                        {
                                new
                                        end = stringPos - 1,
                                        id = 0,
                                        bool:num = true,
                                        ch;
                                while ((ch = string[++end]) && ch != delim)
                                {
                                        if (num)
                                        {
                                                if ('0' <= ch <= '9')
                                                {
                                                        id = (id * 10) + (ch - '0');
                                                }
                                                else
                                                {
                                                        num = false;
                                                }
                                        }
                                }
                                if (num && IsPlayerConnected(id))
                                {
                                        setarg(paramPos, 0, id);
                                }
                                else
                                {
                                        string[end] = '\0';
                                        num = false;
                                        new
                                                name[MAX_PLAYER_NAME];
                                        id = end - stringPos;
                                        foreach(playerid,200)
                                        {
                                                GetPlayerName(playerid, name, sizeof (name));
                                                if (!strcmp(name, string[stringPos], true, id))
                                                {
                                                        setarg(paramPos, 0, playerid);
                                                        num = true;
                                                        break;
                                                }
                                        }
                                        if (!num)
                                        {
                                                setarg(paramPos, 0, INVALID_PLAYER_ID);
                                        }
                                        string[end] = ch;
                                }
                                stringPos = end;
                        }
                        case 's', 'z':
                        {
                                new
                                        i = 0,
                                        ch;
                                if (format[formatPos])
                                {
                                        while ((ch = string[stringPos++]) && ch != delim)
                                        {
                                                setarg(paramPos, i++, ch);
                                        }
                                        if (!i)
                                        {
                                                return -1;
                                        }
                                }
                                else
                                {
                                        while ((ch = string[stringPos++]))
                                        {
                                                setarg(paramPos, i++, ch);
                                        }
                                }
                                stringPos--;
                                setarg(paramPos, i, '\0');
                        }
                        default:
                        {
                                continue;
                        }
                }
                while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
                {
                        stringPos++;
                }
                while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
                {
                        stringPos++;
                }
                paramPos++;
        }
        do
        {
                if ((delim = format[formatPos++]) > ' ')
                {
                        if (delim == '\'')
                        {
                                while ((delim = format[formatPos++]) && delim != '\'') {}
                        }
                        else if (delim != 'z')
                        {
                                return delim;
                        }
                }
        }
        while (delim > ' ');
        return 0;
}
public settime(playerid)
{
    new string[256],year,month,day;
    getdate(year, month, day);
    format(string, sizeof string, "%d/%s%d/%s%d", day, ((month < 10) ? ("0") : ("")), month, (year < 10) ? ("0") : (""), year);
    TextDrawSetString(Date77, string);
}
Reply
#2

i tried everything and the textdraw position is all ok but i can't fix it
Reply
#3

I tested it, and it works ... Kinda.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)