INSIDE RESURSE

Resurse pentru toate jocurile online! samp, csgo, mape, muzica, filme, ps, divertisment, geforce, fzarea, muzica, clan, coduri, cfg, inside, resurse, servere, gata, facute, war, zone, pgl, long, nvid


Nu sunteti conectat. Conectati-va sau inregistrati-va

[Tutorial:SAMP]Timp variabil(Ora|Data)

Por favor, faça o login para responder

Vezi subiectul anterior Vezi subiectul urmator In jos  Mesaj [Pagina 1 din 1]

#1vendME 

la data de Joi Mai 04, 2017 12:14 am

avatar

Fondator
Fondator
Ei bine, un tutorial simplu,consta in depistarea orei si a datei din viata reala in joc(viata virtuala).
Poate ma ve-ti critica ca sunt o gramada de tutoriale pe aceasta tema,dar acesta are ceva mai special sa spun asa.
 
Specialul consta in:
    - simplitate si stil.
    - textdraw
 
Propun sa incepem, deoarece timpul costa bani.
 
 




Cod:
new Text:Clock[MAX_PLAYERS];
new Text:DataClock[MAX_PLAYERS];
new Text:YearClock[MAX_PLAYERS];
 
new bool:Change_Clock[MAX_PLAYERS];
 
new const MonthName[][12] =
{
    "Ianuarie", "Februarie", "Martie", "Aprilie", "Mai", "Iunie",
    "Iulie", "August", "Septembrie", "Octombrie", "Noiembrie", "Decembrie"
};

//*Variabilele



 
 
 

Cod:
forward TimeServer(playerid);
//*Forward-ul



 
 
 

Cod:
public OnPlayerConnect(playerid)
{
    Change_Clock[playerid] = false;
   return 1;
}
//*Resetare variabile



 
 
 

Cod:
public OnPlayerSpawn(playerid)
{
    Clock[playerid] = TextDrawCreate(550.000000, 30.000000, "22:55");
    TextDrawBackgroundColor(Clock[playerid], 255);
    TextDrawFont(Clock[playerid], 1);
    TextDrawLetterSize(Clock[playerid], 0.500000, 1.000000);
    TextDrawColor(Clock[playerid], -1);
    TextDrawSetOutline(Clock[playerid], 0);
    TextDrawSetProportional(Clock[playerid], 1);
    TextDrawSetShadow(Clock[playerid], 1);
    TextDrawSetSelectable(Clock[playerid], 0);
 
    DataClock[playerid] = TextDrawCreate(547.000000, 24.000000, "22 decembrie");
    TextDrawBackgroundColor(DataClock[playerid], 255);
    TextDrawFont(DataClock[playerid], 1);
    TextDrawLetterSize(DataClock[playerid], 0.270000, 1.300000);
    TextDrawColor(DataClock[playerid], -1);
    TextDrawSetOutline(DataClock[playerid], 0);
    TextDrawSetProportional(DataClock[playerid], 1);
    TextDrawSetShadow(DataClock[playerid], 1);
    TextDrawSetSelectable(DataClock[playerid], 0);
 
    YearClock[playerid] = TextDrawCreate(565.000000, 33.000000, "2016");
    TextDrawBackgroundColor(YearClock[playerid], 255);
    TextDrawFont(YearClock[playerid], 1);
    TextDrawLetterSize(YearClock[playerid], 0.270000, 1.300000);
    TextDrawColor(YearClock[playerid], -1);
    TextDrawSetOutline(YearClock[playerid], 0);
    TextDrawSetProportional(YearClock[playerid], 1);
    TextDrawSetShadow(YearClock[playerid], 1);
    TextDrawSetSelectable(YearClock[playerid], 0);
    return 1;
}
//*Textdraw-urile propriu-zise.



 
 
 

Cod:
public OnPlayerDeath(playerid, killerid, reason)
{
    for(new t = 0; t < MAX_TEXT_DRAWS; t++)
    {
        TextDrawHideForPlayer(playerid, Text:t);
    }
    return 1;
}
//*Ascunde toate textdraw-urile afisate.



 
 
 

Cod:
public OnGameModeInit()
{
    SetTimer("TimeServer", 10000, true);
    return 1;
}
//*Lansare timer.



 
 
 
[ltr]p
[/ltr]
Cod:
ublic TimeServer(playerid)
{
    new string[2][256],
           str_year[4],
           hour,
           minute,
           second,
           year,
           month,
           day;
    getdate(year, month, day);
    gettime(hour, minute, second);
    SetWorldTime(hour);
    if(Change_Clock[playerid]) {
        format(str_year, 4, "%d", year);
        format(string[0], 256, "%d %s", day, MonthName[month-1]);
        TextDrawSetString(DataClock[playerid], string[0]);
        TextDrawShowForPlayer(playerid, DataClock[playerid]);
        TextDrawShowForPlayer(playerid, YearClock[playerid]);
        TextDrawHideForPlayer(playerid, Clock[playerid]);
        Change_Clock[playerid] = false;
    }
    else {
        format(string[1], 256, "%s%d:%s%d", (hour < 10) ? ("0") : (""), hour, (minute < 10) ? ("0") : (""), minute);
        TextDrawSetString(Clock[playerid], string[1]);
        TextDrawShowForPlayer(playerid, Clock[playerid]);
        TextDrawHideForPlayer(playerid, DataClock[playerid]);
        TextDrawHideForPlayer(playerid, YearClock[playerid]);
        Change_Clock[playerid] = true;
    }
    return 1;
}

//*Actiunea public-ului actionata de timer.


_________________

INSIDE RESURSE











http://resurseinside.forumgratuit.ro

Vezi subiectul anterior Vezi subiectul urmator Sus  Mesaj [Pagina 1 din 1]

Por favor, faça o login para responder

Permisiunile acestui forum:
Nu puteti raspunde la subiectele acestui forum