Raised This Month: $ Target: $400
 0% 

time translation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
vedoi
Junior Member
Join Date: Jul 2011
Old 12-28-2011 , 06:40   time translation
Reply With Quote #1

Since this topic http://forums.alliedmods.net/showthread.php?t=80858 looks dead i decided to post here .

PHP Code:
GetBanTime(const bantimelength[], len)
{
    new 
minutes bantime;
    new 
hours 0;
    new 
days 0;
    
    while( 
minutes >= 60 )
    {
        
minutes -= 60;
        
hours++;
    }
    
    while( 
hours >= 24 )
    {
        
hours -= 24;
        
days++;
    }
    
    new 
bool:add_before;
    if( 
minutes )
    {
        
formatex(lengthlen"%i minute%s"minutesminutes == "" "s");
        
        
add_before true;
    }
    if( 
hours )
    {
        if( 
add_before )
        {
            
format(lengthlen"%i hour%s, %s"hourshours == "" "s"length);
        }
        else
        {
            
formatex(lengthlen"%i hour%s"hourshours == "" "s");
            
            
add_before true;
        }
    }
    if( 
days )
    {
        if( 
add_before )
        {
            
format(lengthlen"%i day%s, %s"daysdays == "" "s"length);
        }
        else
        {
            
formatex(lengthlen"%i day%s"daysdays == "" "s");
            
            
add_before true;
        }
    }
    if( !
add_before )
    {
        
// minutes, hours, and days = 0
        // assume permanent ban
        
copy(lengthlen"Permanent Ban");
    }

i tried to translate minutes,hours,days and get error on display (only shows first argument eg hours or days ~) Cant this get translation from ML , time file ?
[IMG]http://img696.**************/img696/4175/timewv.jpg[/IMG]

my lang ( hour - ora ; hours - ore ; day - zi ; days - zile )
vedoi is offline
vedoi
Junior Member
Join Date: Jul 2011
Old 12-29-2011 , 18:57   Re: time translation
Reply With Quote #2

i hope Exolent[jNr] can help , since is his plugin , and he's back on forum

Last edited by vedoi; 12-29-2011 at 18:58.
vedoi is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 12-29-2011 , 20:07   Re: time translation
Reply With Quote #3

You may want to analyze this (time.inc):
PHP Code:
/* Stock by Brad */
stock get_time_length(idunitCnttypeoutput[], outputLen)
{
// IMPORTANT:     You must add register_dictionary("time.txt") in plugin_init()

// id:          The player whose language the length should be translated to (or 0 for server language).
// unitCnt:     The number of time units you want translated into verbose text.
// type:        The type of unit (i.e. seconds, minutes, hours, days, weeks) that you are passing in.
// output:      The variable you want the verbose text to be placed in.
// outputLen:    The length of the output variable.

    
if (unitCnt 0)
    {
        
// determine the number of each time unit there are
        
new weekCnt 0dayCnt 0hourCnt 0minuteCnt 0secondCnt 0;

        switch (
type)
        {
            case 
timeunit_secondssecondCnt unitCnt;
            case 
timeunit_minutessecondCnt unitCnt SECONDS_IN_MINUTE;
            case 
timeunit_hours:   secondCnt unitCnt SECONDS_IN_HOUR;
            case 
timeunit_days:    secondCnt unitCnt SECONDS_IN_DAY;
            case 
timeunit_weeks:   secondCnt unitCnt SECONDS_IN_WEEK;
        }

        
weekCnt secondCnt SECONDS_IN_WEEK;
        
secondCnt -= (weekCnt SECONDS_IN_WEEK);

        
dayCnt secondCnt SECONDS_IN_DAY;
        
secondCnt -= (dayCnt SECONDS_IN_DAY);

        
hourCnt secondCnt SECONDS_IN_HOUR;
        
secondCnt -= (hourCnt SECONDS_IN_HOUR);

        
minuteCnt secondCnt SECONDS_IN_MINUTE;
        
secondCnt -= (minuteCnt SECONDS_IN_MINUTE);

        
// translate the unit counts into verbose text
        
new maxElementIdx = -1;
        new 
timeElement[5][33];

        if (
weekCnt 0)
            
format(timeElement[++maxElementIdx], 32"%i %L"weekCntid, (weekCnt == 1) ? "TIME_ELEMENT_WEEK" "TIME_ELEMENT_WEEKS");
        if (
dayCnt 0)
            
format(timeElement[++maxElementIdx], 32"%i %L"dayCntid, (dayCnt == 1) ? "TIME_ELEMENT_DAY" "TIME_ELEMENT_DAYS");
        if (
hourCnt 0)
            
format(timeElement[++maxElementIdx], 32"%i %L"hourCntid, (hourCnt == 1) ? "TIME_ELEMENT_HOUR" "TIME_ELEMENT_HOURS");
        if (
minuteCnt 0)
            
format(timeElement[++maxElementIdx], 32"%i %L"minuteCntid, (minuteCnt == 1) ? "TIME_ELEMENT_MINUTE" "TIME_ELEMENT_MINUTES");
        if (
secondCnt 0)
            
format(timeElement[++maxElementIdx], 32"%i %L"secondCntid, (secondCnt == 1) ? "TIME_ELEMENT_SECOND" "TIME_ELEMENT_SECONDS");

        switch(
maxElementIdx)
        {
            case 
0format(outputoutputLen"%s"timeElement[0]);
            case 
1format(outputoutputLen"%s %L %s"timeElement[0], id"TIME_ELEMENT_AND"timeElement[1]);
            case 
2format(outputoutputLen"%s, %s %L %s"timeElement[0], timeElement[1], id"TIME_ELEMENT_AND"timeElement[2]);
            case 
3format(outputoutputLen"%s, %s, %s %L %s"timeElement[0], timeElement[1], timeElement[2], id"TIME_ELEMENT_AND"timeElement[3]);
            case 
4format(outputoutputLen"%s, %s, %s, %s %L %s"timeElement[0], timeElement[1], timeElement[2], timeElement[3], id"TIME_ELEMENT_AND"timeElement[4]);
        }
    }

__________________

Last edited by hleV; 12-29-2011 at 20:07.
hleV is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 12-29-2011 , 20:25   Re: time translation
Reply With Quote #4

Btw :

Code:
formatex(length, len, "%i minute%s", minutes, minutes == 1 ? "" : "s");


->

Code:
formatex(length, len, "%i minute%s", minutes, minutes <= 1 ? "" : "s");
__________________
You can do anything you set your mind to, man.

Devil259 is offline
vedoi
Junior Member
Join Date: Jul 2011
Old 01-02-2012 , 09:04   Re: time translation
Reply With Quote #5

time.inc its ok , i mean default , i didn't changed anything .

i was reffering to use time ml file

instead of :

PHP Code:
formatex(lengthlen"%i minute%s" 
>
PHP Code:
formatex(lengthlen"%i TIME_ELEMENT_MINUTES" 
and so on for hours ,days etc ; then , maybe , would show properly on chat

if this method doesnt work , what to do else
vedoi is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-02-2012 , 16:02   Re: time translation
Reply With Quote #6

http://wiki.amxmodx.org/Advanced_Scr...ingual_Support
__________________
fysiks is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:38.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode