Jump to content

Multi Language


holuzs

Recommended Posts

[EN] 

Hi, I want to make a multi language survival server, but I don't know how much lag cause the exporting. It would be a problem with exporting?

[HU]

Cső, szeretnék csinálni egy több nyelvű túlélő szervert, de nem tudom mennyi laggot okozna a folyamatos export. Mennyi laggot okozna ha mindenhova exportálnám?

 

Example/Példa:

 

texts = {
    ["hu"] = {
        --<[ DXhez használt szövegek ]>--
        ["ban.user"] = "Felhasználóneved",
        ["ban.admin"] = "Admin",
        ["ban.serial"] = "Serialod",
        ["ban.reason"] = "Ban indok",
        ["ban.date"] = "Ban időpontja",
        ["ban.expire"] = "Ban lejár",

        --<[ Chathez használt szövegek ]>--
    },
    ["en"] = {
        --<[ DXhez használt szövegek ]>--
        ["ban.user"] = "Username",
        ["ban.admin"] = "Admin",
        ["ban.serial"] = "Serial",
        ["ban.reason"] = "Ban reason",
        ["ban.date"] = "Ban date",
        ["ban.expire"] = "Expire date",

        --<[ Chathez használt szövegek ]>--
    },
    ["de"] = {
        
    }
    ["ro"] = {

    }
}

function getText(player, neededText)
    return texts[getElementData(player, "player->language")][neededText] or "Unknown text"
end

 

Link to comment
  • Moderators

@holuzs

As long as you do not use a database, it will be hardly noticeable.

This whole table + it's sub-tables are located in the ram and will be available without much delay.

And exporting will use a bit more CPU than a normal function call, but it will save RAM because you only have 1 location for the data.

 

 

  • Like 1
Link to comment

Due to the fact, that each of the scripts are running over an own virtual machine you need to avoid from call export functions often, like in a render loops for a better performance.
I suggest to get the language text on the resourceStart and store them  in each scripts. It will be costs more ram, but you will save CPU as @IIYAMA said. My experiences that we need to save more CPU usage rather than RAM for a better performance.

~o~

 

Arra a tényre alapozva, hogy a scriptjeid mindegyike egy külön Lua virtuális gépen futnak, a közöttük lévő kommunikáció viszonylag lassabb, ezért nem ajánlom az export funkciókat sokszor hívni, mint például egy onClientRender-rel megfuttatott funkcióban. Azt ajánlom, hogy kérd ki a szükséges szövegeket a resource indulásakor és tárold őket lokálisan. A tapasztalatom azt mutatja, hogy jobb teljesítményt lehet elérni akkor, ha inkább RAM-ot használsz mint CPU erőforrást.

  • Like 3
Link to comment
5 hours ago, holuzs said:

[EN] 

Hi, I want to make a multi language survival server, but I don't know how much lag cause the exporting. It would be a problem with exporting?

[HU]

Cső, szeretnék csinálni egy több nyelvű túlélő szervert, de nem tudom mennyi laggot okozna a folyamatos export. Mennyi laggot okozna ha mindenhova exportálnám?

 

Example/Példa:

 


texts = {
    ["hu"] = {
        --<[ DXhez használt szövegek ]>--
        ["ban.user"] = "Felhasználóneved",
        ["ban.admin"] = "Admin",
        ["ban.serial"] = "Serialod",
        ["ban.reason"] = "Ban indok",
        ["ban.date"] = "Ban időpontja",
        ["ban.expire"] = "Ban lejár",

        --<[ Chathez használt szövegek ]>--
    },
    ["en"] = {
        --<[ DXhez használt szövegek ]>--
        ["ban.user"] = "Username",
        ["ban.admin"] = "Admin",
        ["ban.serial"] = "Serial",
        ["ban.reason"] = "Ban reason",
        ["ban.date"] = "Ban date",
        ["ban.expire"] = "Expire date",

        --<[ Chathez használt szövegek ]>--
    },
    ["de"] = {
        
    }
    ["ro"] = {

    }
}

function getText(player, neededText)
    return texts[getElementData(player, "player->language")][neededText] or "Unknown text"
end

 

In my opinion you can attach this table to the resource using 

setElementData(getResourceRootElement(getThisResource()),"texts",texts,false)



-- keep this table client side

and then you can get this table from anywhere on the server using 

getElementData(getResourceRootElement(getResourceFromName("resource")),"texts")



-- client side

and i think it will take less CPU but more ram.

Edited by Ayush Rathore
  • Thanks 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...