Page 1 of 1
admin_expired return UNIX time
Posted: 2017 Apr 02 20:27
by laimiukas3
kaip padaryti >> admin_expired return UNIX time
nes db man rodo kosmusa uzdeta ant 30d
Code: Select all
displayMenu(id, pos){ if (pos < 0) return new menuBody[512] new b = 0 new start = pos * MENUITEMSPERPAGE new exp = admin_expired(id); new left[32] if(exp > 0) format(left, 31, "Indefinite") else num_to_str(exp, left, 31) if (start >= g_menusNumber) // MENUS_NUMBER start = pos = g_menuPosition[id] = 0 new len = format(menuBody, 511, g_coloredMenus ? "\yAMX Mod X Menu\R%d/%d^nAdmin expire, days.:\r %s^n^n\w" : "AMX Mod X Menu %d/%d^nAdmin expire, days:\r %s.^n^n\w" , pos + 1, (g_menusNumber / MENUITEMSPERPAGE) + (((g_menusNumber % MENUITEMSPERPAGE) > 0) ? 1 : 0), left)
Re: admin_expired return UNIX time
Posted: 2017 Apr 02 21:02
by GoogleBot
Jeigu tinka, gali sql query pasiredaguot pvz.:
"from_unixtime( expired, '%Y-%m-%d' ) AS expire_date"
Re: admin_expired return UNIX time
Posted: 2017 Apr 02 22:05
by laimiukas3
cia duotas pavyzdys kazkaip reiketu pritaikiti i mano coda dabar naudoju kita admin loaderi cj susipiso man ta vietele
Code: Select all
public SayExired(id){ new exp = admin_expired(id); if(exp > 0) { new sys = get_systime(); if(exp - sys > 0) { if((exp - sys) / 86400 > 0) client_print(id, print_chat, "* Left %d Days.!", (exp - sys) / 86400); else client_print(id, print_chat, "* Last day!"); } else client_print(id, print_chat, "* Rights expired!"); } else if(exp == 0) client_print(id, print_chat, "* The rights are not limited!"); else client_print(id, print_chat, "* You're not the admin!");}
Re: admin_expired return UNIX time
Posted: 2017 Apr 03 19:53
by GoogleBot
As tai nerandu pawn funkcijos kuri grazintu date format, bet viską gali pasiverst sql užklausoj.
Re: admin_expired return UNIX time
Posted: 2017 Apr 04 13:34
by psychical
https://forums.alliedmods.net/showthread.php?t=91915
Ko čia nerast?
-- 2017 Bal 04 13:37 --
https://www.amxmodx.org/api/amxmodx/format_time
ir dar čia
Realiai, šitas geresnis:
native format_time(output[], len, const format[], time = -1);
-- 2017 Bal 04 13:47 --
Nors tavo atveju, kaip suprantu, tu gauni UNIX formatu paskutinės sekundės laiką (nu tipo kada dar turi privilegijas)
Tai turėtų būt taip (negaliu garantuot, neturiu kur išbandyt):
Code: Select all
public SayExired(id){ new exp = admin_expired(id); if(exp > 0) { new daysLeft = floatround((get_systime()-exp)/60/60/24.0, floatround_ceil); if(daysLeft) { if(daysLeft > 1) { client_print(id, print_chat, "* Left %d Days.!", daysLeft); } else { client_print(id, print_chat, "* Last day!"); } } else { client_print(id, print_chat, "* Rights expired!"); } } else if(!exp) { client_print(id, print_chat, "* The rights are unlimited!"); } else { client_print(id, print_chat, "* You're not the admin!"); }}
Re: admin_expired return UNIX time
Posted: 2017 Apr 05 22:07
by InvIs2
Jeigu duomenų bazėje saugo tą skaičių, geriausia tiesiog pasiredaguoti mysql užklausą, kad išvestų kaip laiką dienom. Ir nereiks papildomai kodo rašyti.