Whats Wrong in This Gameday GameTime System?
#8

pawn Код:
#include <a_samp>

#define COLOR_TIME 0xFFFFFFFF
#define COLOR_DAY  0xFFFFFFFF
#define MINUTE 1000

new Text:GameDay, Text:GameTime;
new gTimeMinutes, gTimeHours, gTimeDay;

public OnGameModeInit()
{
    gTimeMinutes = gTimeHours = gTimeDay = 0;
    SetTimer("GameTimeUpdate", MINUTE, true);
    GameTime = TextDrawCreate(605.000000, 25.000000, "00:00");
    TextDrawAlignment(GameTime, 3);
    TextDrawBackgroundColor(GameTime, 0x000000FF);
    TextDrawFont(GameTime, 3);
    TextDrawLetterSize(GameTime, 0.535, 2.2);
    TextDrawColor(GameTime, COLOR_TIME);
    TextDrawSetOutline(GameTime, 2);
    TextDrawSetProportional(GameTime, 1);
    TextDrawSetShadow(GameTime, 1);

    GameDay = TextDrawCreate(610.000000, 7.000000, "Sunday");
    TextDrawUseBox(GameDay, 0);
    TextDrawFont(GameDay, 3);
    TextDrawLetterSize(GameDay, 0.6, 1.5);
    TextDrawSetShadow(GameDay, 1);
    TextDrawSetOutline(GameDay, 0);
    TextDrawBackgroundColor(GameDay, 0x000000FF);
    TextDrawBoxColor(GameDay, 0x00000066);
    TextDrawColor(GameDay, COLOR_DAY);
    TextDrawTextSize(GameDay, -1880.0, -1880.0);
    TextDrawAlignment(GameDay, 3);
    TextDrawSetOutline(GameDay, 1);
    return 1;
}

forward GameTimeUpdate();
public GameTimeUpdate()
{
    if((gTimeMinutes++) >= 59)
    {
        gTimeMinutes -= 60;
        //New hour
        if((gTimeHours++) >= 23)
        {
            gTimeHours -= 24;
            //New day
            if((gTimeDay++) >= 6)
            {
                gTimeDay = 0;
                //New week
            }
        }
    }
    new timestring[15];
    format(timestring, sizeof(timestring), "   %02d:%02d", gTimeHours, gTimeMinutes);
    TextDrawSetString(GameTime, timestring);
    TextDrawShowForAll(GameTime);
    format(timestring, sizeof(timestring), "%s", GetDayName());
    TextDrawSetString(GameDay, timestring);
    TextDrawShowForAll(GameDay);
    SetWorldTime(gTimeHours);
    return 1;
}

GetDayName()
{
    new day[10];
    switch(gTimeDay)
    {
        case 1: day = "Monday";
        case 2: day = "Tuesday";
        case 3: day = "Wednesday";
        case 4: day = "Thursday";
        case 5: day = "Friday";
        case 6: day = "Saturday";
        default: day = "Sunday";
    }
    return day;
}
Already gave him a runthrough of this code, so don't start lecturing me about 'Just posting code'.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)