How to make GM with 2 languages?
#1

Well, i have GM in my language (serbian), buy, i want GM with 2 languages(serbian and english) so when player connect, server shows him dialog where he can choose Serbian or English etc.. so ill need to translate every command to 2 languages.. i want but dont know how..

is there any way to do this ?
Reply
#2

pawn Code:
#define LAN_SERBIAN 1
#define LAN_ENGLISH 2

//...
new iLanguage[ MAX_PLAYERS char ];


//...
public OnPlayerConnect( playerid )
{
    // Set the player's language somewhere here.
    if( iLanguage{ playerid } == LAN_SERBIAN )
    {
        SendClientMessage( playerid, 0xFFFFFF, "Something serbian here." );
    }

    else
    {
        SendClientMessage( playerid, 0xFFFFFF, "Something english here." );
    }

    return true;
}

// Another method
stock SendLanMessage( playerid, color, const serbianMsg[ ], const englishMsg[ ] )
{
    if( iLanguage{ playerid } == LAN_SERBIAN )
    {
        SendClientMessage( playerid, color, serbianMsg );
    }

    else
    {
        SendClientMessage( playerid, color, englishMsg );
    }

    return true;
}

//to use...
SendLanMessage( playerid, 0xFFFFFF, "serbian", "english" );
Reply
#3

https://sampforum.blast.hk/showthread.php?tid=64902
Reply
#4

thanks
Reply
#5

its not working, cannot make dialog when player connect
Reply
#6

If you want to show the dialog before they get to class selection, then show the dialog in OnPlayerConnect , and return '0' in OnPlayerRequestClass untill they have selected a language.

EG,
pawn Code:
#include <a_samp>

#define L_ENGLISH               (0)
#define L_SERBIAN               (1)

#define LANG_DIALOG             (500)

new bool:SelectedLang[MAX_PLAYERS];
new P_Language[MAX_PLAYERS];

public OnPlayerRequestClass(playerid, classid)
{
    if(!SelectedLang[ playerid ])
        return 0;
       
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    SelectedLang[ playerid ] = false;
    P_Language[ playerid ] = L_ENGLISH;
    ShowPlayerDialog(playerid, LANG_DIALOG, DIALOG_STYLE_LIST, "Languages", "English \nSerbian", "Accept", "Close");
    return 1;
}



public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case LANG_DIALOG:
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0://english
                    {
                        SelectedLang[ playerid ] = true;
                    }
                    case 1://serbian
                    {
                        SelectedLang[ playerid ] = true;
                        P_Language[ playerid ] = L_SERBIAN;
                    }
                }
            }
            else
            {
                SelectedLang[ playerid ] = true;
            }
        }
    }
    return 1;
}
Reply
#7

so how i can translate simple command (example: kill setplayerhealth and sendclientmessage) into 2 languages ?
Reply
#8

If you use Y_commands then use the function "Command_AddAltNamed("me", "mehe");" That will create an alternate name for the command.

If you use zcmd use the command clone thing eg,
pawn Code:
COMMAND:me(playerid, params[])
{
    //blah blah
    return 1;
}

COMMAND:mehe(playerid, params[])
{
    return cmd_me(playerid, params);
}
Reply
#9

tnx but u dont understand me, if i have command like this:
Quote:

if (strcmp("/kill", cmdtext, true, 10) == 0)
{
SetPlayerHealth(playerid,0);
SendClientMessage(playerid, You suck);

return 1;
}

how do i translate that simple command into 2 languages ?
Reply
#10

You realy shouldn 't use strcmp for commands, especially with multiple languages it mean alot more string comparisons.

pawn Code:
if (strcmp("/kill", cmdtext, true, 10) == 0 || strcmp("/killinanotherlanguage", cmdtext, true, 10) == 0)
{
    SetPlayerHealth(playerid,0);
    SendClientMessage(playerid, You suck);
    return 1;
}
Very unefficient compared to y_commands or zcmd.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)