2 Languages IN One Server!
#1

Hey all,

I was asking my self how to use 2 languages in one server.
I mean something like this:

When someone connect to the server, a dialog pop-up asking him about his language (English/Germany).
when he chooses, the whole server changing to his language.
I saw something like this in some servers.
how to do something like this? (Not The dialog stuff, the language replacing for players).

Thanks for helpers,
-PunisheR-.
Reply
#2

first of all u should make the dialogs then make something like that :

OnPlayerConnect(playerid)
{
if(IsPlayerGerman(playerid)) // which u will define in ur dialog
{
SendClientMessage(playerid,COLOR,"Msg");
}
else if(IsPlayerAmerican(playerid))
{
SendClientMessage(playerid,COLOR,"Msg");
}
return 1;
}
Reply
#3

Use a global variable for languages ? like:
pawn Код:
new pLanguage[MAX_PLAYERS];
Reply
#4

I'll try to make it...

pawn Код:
#include <dini>

new PlayerFile[128];
new PlayerLang[MAX_PLAYERS]; // Language (1 and 2)
new PlayerName[24];
pawn Код:
public OnPlayerConnect(playerid)
{
  GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
  format(PlayerFile, sizeof(PlayerFile), "%s.txt", PlayerName);
  if(!dini_Exists(PlayerFile))
  {
   dini_Create(PlayerFile);
   dini_IntSet(PlayerFile, "language", 0);
  }
  PlayerLang[playerid] = dini_Int(PlayerFile, "language");
  if(PlayerLang[playerid] == 0) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Language", "Which language do you want?", "First Language", "Second Language");
  // Change te First and Second Language ^^
  return 1;
}
And the response:

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
  GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
  format(PlayerFile, sizeof(PlayerFile), "%s.txt", PlayerName);
  if(dialogid == 1)
  {
    if(response)
    {
     PlayerLang[playerid] = 1;
     dini_IntSet(PlayerFile, "language", 1);
     SendClientMessage(playerid,0xFFFFFF, "You chosen the First Language"); // change this
   }
   else if(!response)
   {
     PlayerLang[playerid] = 2;
     dini_IntSet(PlayerFile, "language", 2);
     SendClientMessage(playerid,0xFFFFFF, "You chosen the Second Language"); // change this
   }
   return 1;
  }
  return 1;
}
And if you want to make a command wich must read wich language he has:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
  format(PlayerFile, sizeof(PlayerFile), "%s.txt", PlayerName);
  if(strcmp(cmd, "/command", true) == 0)
  {
     PlayerLang[playerid] = dini_Int(PlayerFile, "language");
     if(PlayerLang[playerid] == 1)
     {
      SendClientMessage(playerid, 0xFFFFFF, "This is what happens with language 1");
     }
     else if(PlayerLang[playerid] == 2)
     {
      SendClientMessage(playerid, 0xFFFFFF, "This is what happens with language 2");
     }
     return 1;
  }
  return 0;
}
Reply
#5

This whole thing:
pawn Код:
PlayerLang[playerid] = dini_Int(PlayerFile, "language");
     if(PlayerLang[playerid] == 1)
     {
      SendClientMessage(playerid, 0xFFFFFF, "This is what happens with language 1");
     }
     else if(PlayerLang[playerid] == 2)
     {
      SendClientMessage(playerid, 0xFFFFFF, "This is what happens with language 2");
     }
I can't short-cut it to smaller code?
something like one line (function)?
And thanks for the rest!
Reply
#6

Quote:
Originally Posted by -PunisheR-
This whole thing:
pawn Код:
PlayerLang[playerid] = dini_Int(PlayerFile, "language");
     if(PlayerLang[playerid] == 1)
     {
      SendClientMessage(playerid, 0xFFFFFF, "This is what happens with language 1");
     }
     else if(PlayerLang[playerid] == 2)
     {
      SendClientMessage(playerid, 0xFFFFFF, "This is what happens with language 2");
     }

I can't short-cut it to smaller code?
something like one line (function)?
And thanks for the rest!
You can make own function, that it uses 1 or 2 lines, i guess.
Reply
#7

I don't know exactly what you mean, but isn't it short enough?
Reply
#8

Check YSI.
https://sampwiki.blast.hk/wiki/YSI:Text#YSI_languages
Reply
#9

ok thanks, I created a function from your script.
I have a new probelm, how can I use the 2 languages in a format message?
Reply
#10

BUMP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)