admin_expired return UNIX time

Šiame forume rašomi vartotojų klausimai/problemos su kuriomis jie susidūrė kuriant pluginus.
Post Reply
User avatar
laimiukas3
Moderatorius
Posts: 4569
Joined: 2012 Aug 03 01:12
Skype: laimiukas3
Location: Vilnius
Contact:

admin_expired return UNIX time

Post by laimiukas3 »

kaip padaryti >> admin_expired return UNIX time :hm:

nes db man rodo kosmusa uzdeta ant 30d

Image

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)
Image
Image
Image

GoogleBot
Ar galit patikėti? Jis jau parašė 20 žinučių
Posts: 24
Joined: 2016 Nov 13 00:04
Skype: kasys123

Re: admin_expired return UNIX time

Post by GoogleBot »

Jeigu tinka, gali sql query pasiredaguot pvz.:
"from_unixtime( expired, '%Y-%m-%d' ) AS expire_date"

User avatar
laimiukas3
Moderatorius
Posts: 4569
Joined: 2012 Aug 03 01:12
Skype: laimiukas3
Location: Vilnius
Contact:

Re: admin_expired return UNIX time

Post 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!");}
Image
Image
Image

GoogleBot
Ar galit patikėti? Jis jau parašė 20 žinučių
Posts: 24
Joined: 2016 Nov 13 00:04
Skype: kasys123

Re: admin_expired return UNIX time

Post by GoogleBot »

As tai nerandu pawn funkcijos kuri grazintu date format, bet viską gali pasiverst sql užklausoj.

User avatar
psychical
Viršininkas
Posts: 2094
Joined: 2011 Mar 12 22:19
Skype: tautvydas11
Location: Linksmakalnis
Contact:

Re: admin_expired return UNIX time

Post 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!");    }}

InvIs2
Jau po truputį tampa savu
Posts: 149
Joined: 2013 Sep 29 12:47
Skype: pksoldierlt

Re: admin_expired return UNIX time

Post 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.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 7 guests