KUNT Posted July 12, 2017 Posted July 12, 2017 Cred ca va intrebati ce am mai pregatit !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. 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 forward TimeServer(playerid); //*Forward-ul public OnPlayerConnect(playerid) { Change_Clock[playerid] = false; return 1; } //*Resetare variabile 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. 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. public OnGameModeInit() { SetTimer("TimeServer", 10000, true); return 1; } //*Lansare timer. public 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.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now