Raised This Month: $ Target: $400
 0% 

Menu translation problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Pawemol12
Member
Join Date: Jun 2012
Location: Poland - Wojnowice
Old 08-12-2012 , 09:41   Menu translation problem
Reply With Quote #1

Hi

I have rode:
http://wiki.alliedmods.net/Menu_API_...9#Translations

But this isnt work.

My code:
Code:
public Pokaz_Menu(Handle:menu, MenuAction:action, client, param2)
{
    /* If an option was selected, tell the client about the item. */
    if(Client_IsIngame(client))
    {    
        if (action == MenuAction_Select)
        {
            if (glosy[client] == -1)
            {
                if (param2 == 0)
                {
                    new glos = GetRandomInt(0, GetArraySize(nazwy_kampani) -1);
                    decl String:Wylosowana_Kampania[1064];
                    GetArrayString(nazwy_kampani, glos, Wylosowana_Kampania, sizeof(Wylosowana_Kampania));
                    PrintToChat(client, "\x04[AZK]\x03%t \x04%s", "Wylosowano", Wylosowana_Kampania);
                    SetArrayCell(kampania_punkty, glos, GetArrayCell(kampania_punkty, glos) + 1);
                    glosy[client] = glos;        
                }
                else if (param2 >= 1)
                {
                    new glos = param2 - 1;
                    decl String:Zaglosowano_Na[1064];
                    GetArrayString(nazwy_kampani, glos, Zaglosowano_Na, sizeof(Zaglosowano_Na));
                    PrintToChat(client, "\x04[AZK]\x03%t \x04%s", "Zaglosowano", Zaglosowano_Na);
                    SetArrayCell(kampania_punkty, glos, GetArrayCell(kampania_punkty, glos) + 1);
                    glosy[client] = glos;
                }    
            }
            else
            {        
                decl String:Zaglosowano_Na[1064];
                GetArrayString(nazwy_kampani, glosy[client], Zaglosowano_Na, sizeof(Zaglosowano_Na));
                PrintToChat(client, "\x04[AZK]\x03%t \x04%s", "Oddano", Zaglosowano_Na);        
            }
        }
        else if (action == MenuAction_Display) 
        {
            if (param2 == 0)
            {
                decl String:display[128];
                GetMenuItem(menu, param2, "", 0, _, display, sizeof(display));
                decl String:buffer[255];
                FormatEx(buffer, sizeof(buffer), "%t", display, client);
                RedrawMenuItem(buffer);
                PrintToChat(client, "Zmieniono: %s %s", display, buffer);
            }
            
        }
        else if (action == MenuAction_Cancel)
        {
            if (glosy[client] == -1)
            {
                new tryb = CheckGameMode(GameMode)
                if (tryb == COOP || tryb == VERSUS)
                {
                    PrintToChat(client, "%t %s", "Musisz2", NowaMapa);
                }
                else
                {
                    PrintToChat(client, "%t %s", "Musisz", NowaMapa);            
                }
            }    
        }
        /* If the menu has ended, destroy it */
        else if (action == MenuAction_End)
        {
            CloseHandle(menu);
        }
    }    
}
I wont translate first param and title but i cant
I can see in game name of translation. Btw. look at this:
Code:
 else if (action == MenuAction_Display)          {             if (param2 == 0)             {                 decl String:display[128];                 GetMenuItem(menu, param2, "", 0, _, display, sizeof(display));                 decl String:buffer[255];                 FormatEx(buffer, sizeof(buffer), "%t", display, client);                 RedrawMenuItem(buffer);                 PrintToChat(client, "Zmieniono: %s %s", display, buffer);             }                      }

@edit:

I found answer here: http://forums.alliedmods.net/showthr...nu+translation

This theard should be close.

Last edited by Pawemol12; 08-12-2012 at 10:28. Reason: find answer
Pawemol12 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-12-2012 , 17:48   Re: Menu translation problem
Reply With Quote #2

Translation should be done in the MenuAction_DisplayItem handler, not MenuAction_Display handler. MenuAction_DisplayItem is not called by default, you need to include it in the third argument to CreateMenu or CreateMenuEx.

You need to return the value returned by RedrawMenuItem, like this:

Code:
                PrintToChat(client, "Zmieniono: %s %s", display, buffer);
                return RedrawMenuItem(buffer);
You will also need to return 0; at the bottom of your menu handler to avoid warnings.

Side note: It's recommended that you check which item is being translated (or selected) using the item's info string rather than its position.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Pawemol12
Member
Join Date: Jun 2012
Location: Poland - Wojnowice
Old 08-13-2012 , 04:15   Re: Menu translation problem
Reply With Quote #3

Quote:
Originally Posted by Powerlord View Post
Translation should be done in the MenuAction_DisplayItem handler, not MenuAction_Display handler. MenuAction_DisplayItem is not called by default, you need to include it in the third argument to CreateMenu or CreateMenuEx.

You need to return the value returned by RedrawMenuItem, like this:

Code:
                PrintToChat(client, "Zmieniono: %s %s", display, buffer);
                return RedrawMenuItem(buffer);
You will also need to return 0; at the bottom of your menu handler to avoid warnings.

Side note: It's recommended that you check which item is being translated (or selected) using the item's info string rather than its position.
I tried as you say, but it did not work. Just did not do it:
You need to include it in the third argument is the CreateMenu

Maybe give an example.
Pawemol12 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-13-2012 , 08:58   Re: Menu translation problem
Reply With Quote #4

Quote:
Originally Posted by Pawemol12 View Post
I tried as you say, but it did not work. Just did not do it:
You need to include it in the third argument is the CreateMenu

Maybe give an example.
My mistake, it's the second argument to CreateMenu (or third argument to CreateMenuEx). So, something like this:

PHP Code:
CreateMenu(Pokaz_MenuMenuAction_Select MenuAction_End MenuAction_Cancel MenuAction_DisplayItem); 
Although, to be honest, all but MenuAction_DisplayItem are redundant there: Select, End, and Cancel are always called every if you don't specify them.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 08-13-2012 at 08:59.
Powerlord is offline
Pawemol12
Member
Join Date: Jun 2012
Location: Poland - Wojnowice
Old 08-13-2012 , 15:07   Re: Menu translation problem
Reply With Quote #5

Quote:
Originally Posted by Powerlord View Post
My mistake, it's the second argument to CreateMenu (or third argument to CreateMenuEx). So, something like this:

PHP Code:
CreateMenu(Pokaz_MenuMenuAction_Select MenuAction_End MenuAction_Cancel MenuAction_DisplayItem); 
Although, to be honest, all but MenuAction_DisplayItem are redundant there: Select, End, and Cancel are always called every if you don't specify them.
I still have a problem with a friend that the game does not display the menu. At once an action is final. U do not know why it is so. Can you help?

Last edited by Pawemol12; 08-13-2012 at 15:07.
Pawemol12 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 03:37.


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