Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language update #621

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions gamemodes/sss/core/admin/player-list.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,21 @@ GetPlayerInfo(name[])
spawntime,
totalspawns,
warnings,
language,
lang_name[MAX_LANGUAGE_NAME],
hash[41],
active;

GetAccountData(name, pass, ipv4, alive, regdate, lastlog, spawntime, totalspawns, warnings, hash, active);
GetAccountData(name, pass, ipv4, alive, regdate, lastlog, spawntime, totalspawns, warnings, language, hash, active);

ip = IpIntToStr(ipv4);
// TODO: use a different country service
// GetIPCountry(ip, country);

dayslived = (gettime() > spawntime) ? (0) : ((gettime() - spawntime) / 86400);

GetLanguageName(language, lang_name);

format(info, sizeof(info), "\
IP:\t\t\t%s\n\
Country:\t\t%s\n\
Expand All @@ -130,7 +134,8 @@ GetPlayerInfo(name[])
Last Login:\t\t%s\n\
Days Survived:\t%d\n\
Lives Lived:\t\t%d\n\
Warnings:\t\t%d",
Warnings:\t\t%d\n\
Language:\t\t%s",

ip,
country,
Expand All @@ -139,7 +144,8 @@ GetPlayerInfo(name[])
TimestampToDateTime(lastlog),
dayslived,
totalspawns,
warnings);
warnings,
lang_name);

return info;
}
Expand Down
2 changes: 1 addition & 1 deletion gamemodes/sss/core/item/tent.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ StartRemovingTent(playerid, Item:itemid)
{
StartHoldAction(playerid, 15000);
ApplyAnimation(playerid, "BOMBER", "BOM_Plant_Loop", 4.0, 1, 0, 0, 0, 0);
ShowActionText(playerid, ls(playerid, "TENTREMOVE"));
ShowActionText(playerid, ls(playerid, "TENTREMOVE", true));
tnt_CurrentTentItem[playerid] = itemid;
}

Expand Down
32 changes: 16 additions & 16 deletions gamemodes/sss/core/itemtype/defences.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ StartBuildingDefence(playerid, Item:itemid)
def_CurrentDefenceItem[playerid] = itemid;
StartHoldAction(playerid, GetPlayerSkillTimeModifier(playerid, 10000, "Construction"));
ApplyAnimation(playerid, "BOMBER", "BOM_Plant_Loop", 4.0, 1, 0, 0, 0, 0);
ShowActionText(playerid, sprintf(ls(playerid, "DEFBUILDING"), itemtypename));
ShowActionText(playerid, sprintf(ls(playerid, "DEFBUILDING", true), itemtypename));

return 1;
}
Expand Down Expand Up @@ -364,7 +364,7 @@ _InteractDefence(playerid, Item:itemid)
}
else
{
ShowActionText(playerid, ls(playerid, "DEFMOVINGIT"), 3000);
ShowActionText(playerid, ls(playerid, "DEFMOVINGIT", true), 3000);
defer MoveDefence(_:itemid, playerid);
}
}
Expand Down Expand Up @@ -402,7 +402,7 @@ _InteractDefenceWithItem(playerid, Item:itemid, Item:tool)
def_CurrentDefenceEdit[playerid] = itemid;
StartHoldAction(playerid, GetPlayerSkillTimeModifier(playerid, 10000, "Construction"));
ApplyAnimation(playerid, "COP_AMBIENT", "COPBROWSE_LOOP", 4.0, 1, 0, 0, 0, 0);
ShowActionText(playerid, sprintf(ls(playerid, "DEFREMOVING"), itemtypename));
ShowActionText(playerid, sprintf(ls(playerid, "DEFREMOVING", true), itemtypename));

return 1;
}
Expand All @@ -411,7 +411,7 @@ _InteractDefenceWithItem(playerid, Item:itemid, Item:tool)
{
if(!def_TypeData[defencetype][def_movable])
{
ShowActionText(playerid, ls(playerid, "DEFNOTMOVAB"));
ShowActionText(playerid, ls(playerid, "DEFNOTMOVAB", true));
return 1;
}

Expand All @@ -423,7 +423,7 @@ _InteractDefenceWithItem(playerid, Item:itemid, Item:tool)
StartHoldAction(playerid, GetPlayerSkillTimeModifier(playerid, 6000, "Construction"));
ApplyAnimation(playerid, "COP_AMBIENT", "COPBROWSE_LOOP", 4.0, 1, 0, 0, 0, 0);

ShowActionText(playerid, sprintf(ls(playerid, "DEFMODIFYIN"), itemtypename));
ShowActionText(playerid, sprintf(ls(playerid, "DEFMODIFYIN", true), itemtypename));

return 1;
}
Expand All @@ -434,7 +434,7 @@ _InteractDefenceWithItem(playerid, Item:itemid, Item:tool)
GetItemArrayDataAtCell(itemid, hasmotor, _:def_motor);
if(!hasmotor)
{
ShowActionText(playerid, ls(playerid, "DEFNEEDMOTO"));
ShowActionText(playerid, ls(playerid, "DEFNEEDMOTO", true));
return 1;
}

Expand All @@ -446,7 +446,7 @@ _InteractDefenceWithItem(playerid, Item:itemid, Item:tool)
StartHoldAction(playerid, GetPlayerSkillTimeModifier(playerid, 6000, "Construction"));
ApplyAnimation(playerid, "COP_AMBIENT", "COPBROWSE_LOOP", 4.0, 1, 0, 0, 0, 0);

ShowActionText(playerid, sprintf(ls(playerid, "DEFMODIFYIN"), itemtypename));
ShowActionText(playerid, sprintf(ls(playerid, "DEFMODIFYIN", true), itemtypename));

return 1;
}
Expand All @@ -457,7 +457,7 @@ _InteractDefenceWithItem(playerid, Item:itemid, Item:tool)
GetItemArrayDataAtCell(itemid, hasmotor, _:def_motor);
if(!hasmotor)
{
ShowActionText(playerid, ls(playerid, "DEFNEEDMOTO"));
ShowActionText(playerid, ls(playerid, "DEFNEEDMOTO", true));
return 0;
}

Expand All @@ -469,7 +469,7 @@ _InteractDefenceWithItem(playerid, Item:itemid, Item:tool)
StartHoldAction(playerid, GetPlayerSkillTimeModifier(playerid, 6000, "Construction"));
ApplyAnimation(playerid, "COP_AMBIENT", "COPBROWSE_LOOP", 4.0, 1, 0, 0, 0, 0);

ShowActionText(playerid, sprintf(ls(playerid, "DEFMODIFYIN"), itemtypename));
ShowActionText(playerid, sprintf(ls(playerid, "DEFMODIFYIN", true), itemtypename));

return 1;
}
Expand Down Expand Up @@ -539,7 +539,7 @@ hook OnHoldActionFinish(playerid)
_UpdateDefenceTweakArrow(playerid, itemid);
PlayerGainSkillExperience(playerid, "Construction");

ShowHelpTip(playerid, ls(playerid, "TIPTWEAKDEF"));
ShowHelpTip(playerid, ls(playerid, "TIPTWEAKDEF", true));

return Y_HOOKS_BREAK_RETURN_0;
}
Expand All @@ -555,7 +555,7 @@ hook OnHoldActionFinish(playerid)

if(itemtype == item_Motor)
{
ShowActionText(playerid, ls(playerid, "DEFINSTMOTO"));
ShowActionText(playerid, ls(playerid, "DEFINSTMOTO", true));
SetItemArrayDataAtCell(def_CurrentDefenceEdit[playerid], true, def_motor);
CallLocalFunction("OnDefenceModified", "d", _:def_CurrentDefenceEdit[playerid]);

Expand All @@ -565,7 +565,7 @@ hook OnHoldActionFinish(playerid)

if(itemtype == item_Keypad)
{
ShowActionText(playerid, ls(playerid, "DEFINSTKEYP"));
ShowActionText(playerid, ls(playerid, "DEFINSTKEYP", true));
ShowSetPassDialog_Keypad(playerid);
SetItemArrayDataAtCell(def_CurrentDefenceEdit[playerid], 1, def_keypad);
CallLocalFunction("OnDefenceModified", "d", _:def_CurrentDefenceEdit[playerid]);
Expand All @@ -576,7 +576,7 @@ hook OnHoldActionFinish(playerid)

if(itemtype == item_AdvancedKeypad)
{
ShowActionText(playerid, ls(playerid, "DEFINSTADKP"));
ShowActionText(playerid, ls(playerid, "DEFINSTADKP", true));
ShowSetPassDialog_KeypadAdv(playerid);
SetItemArrayDataAtCell(def_CurrentDefenceEdit[playerid], 2, def_keypad);
CallLocalFunction("OnDefenceModified", "d", _:def_CurrentDefenceEdit[playerid]);
Expand All @@ -600,7 +600,7 @@ hook OnHoldActionFinish(playerid)
GetItemUUID(def_CurrentDefenceEdit[playerid], uuid);
GetItemPos(def_CurrentDefenceEdit[playerid], x, y, z);
GetItemRot(def_CurrentDefenceEdit[playerid], rz, rz, rz);
ShowActionText(playerid, ls(playerid, "DEFDISMANTL"));
ShowActionText(playerid, ls(playerid, "DEFDISMANTL", true));
GetItemTypeModel(GetItemType(def_CurrentDefenceEdit[playerid]), model);

DeconstructDefence(def_CurrentDefenceEdit[playerid]);
Expand Down Expand Up @@ -650,7 +650,7 @@ hook OnPlayerKeypadEnter(playerid, keypadid, code, match)
{
if(code == match)
{
ShowActionText(playerid, ls(playerid, "DEFMOVINGIT"), 3000);
ShowActionText(playerid, ls(playerid, "DEFMOVINGIT", true), 3000);
defer MoveDefence(_:def_CurrentDefenceOpen[playerid], playerid);
def_CurrentDefenceOpen[playerid] = INVALID_ITEM_ID;
}
Expand Down Expand Up @@ -875,7 +875,7 @@ ShowEnterPassDialog_KeypadAdv(playerid, msg = 0)

if(pass == defpass && strlen(inputtext) >= 4)
{
ShowActionText(playerid, ls(playerid, "DEFMOVINGIT"), 3000);
ShowActionText(playerid, ls(playerid, "DEFMOVINGIT", true), 3000);
defer MoveDefence(_:def_CurrentDefenceOpen[playerid], playerid);
def_CurrentDefenceOpen[playerid] = INVALID_ITEM_ID;
}
Expand Down
45 changes: 40 additions & 5 deletions gamemodes/sss/core/player/accounts.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
#define FIELD_PLAYER_SPAWNTIME "spawntime" // 06
#define FIELD_PLAYER_TOTALSPAWNS "spawns" // 07
#define FIELD_PLAYER_WARNINGS "warnings" // 08
#define FIELD_PLAYER_GPCI "gpci" // 19
#define FIELD_PLAYER_ACTIVE "active" // 10
#define FIELD_PLAYER_GPCI "gpci" // 09
#define FIELD_PLAYER_LANG "lang" // 10
#define FIELD_PLAYER_ACTIVE "active" // 11

enum
{
Expand All @@ -41,6 +42,7 @@ enum
FIELD_ID_PLAYER_TOTALSPAWNS,
FIELD_ID_PLAYER_WARNINGS,
FIELD_ID_PLAYER_GPCI,
FIELD_ID_PLAYER_LANG,
FIELD_ID_PLAYER_ACTIVE
}

Expand Down Expand Up @@ -84,6 +86,9 @@ DBStatement: stmt_AccountSetWarnings,
DBStatement: stmt_AccountGetGpci,
DBStatement: stmt_AccountSetGpci,

DBStatement: stmt_AccountGetLanguage,
DBStatement: stmt_AccountSetLanguage,

DBStatement: stmt_AccountGetActiveState,
DBStatement: stmt_AccountSetActiveState,

Expand All @@ -108,14 +113,15 @@ hook OnGameModeInit()
"FIELD_PLAYER_TOTALSPAWNS" INTEGER,\
"FIELD_PLAYER_WARNINGS" INTEGER,\
"FIELD_PLAYER_GPCI" TEXT,\
"FIELD_PLAYER_LANG" INTEGER,\
"FIELD_PLAYER_ACTIVE")");

db_query(gAccounts, "CREATE INDEX IF NOT EXISTS "ACCOUNTS_TABLE_PLAYER"_index ON "ACCOUNTS_TABLE_PLAYER"("FIELD_PLAYER_NAME")");

DatabaseTableCheck(gAccounts, ACCOUNTS_TABLE_PLAYER, 11);
DatabaseTableCheck(gAccounts, ACCOUNTS_TABLE_PLAYER, 12);

stmt_AccountExists = db_prepare(gAccounts, "SELECT COUNT(*) FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_NAME"=? COLLATE NOCASE");
stmt_AccountCreate = db_prepare(gAccounts, "INSERT INTO "ACCOUNTS_TABLE_PLAYER" VALUES(?,?,?,1,?,?,0,0,0,?,1)");
stmt_AccountCreate = db_prepare(gAccounts, "INSERT INTO "ACCOUNTS_TABLE_PLAYER" VALUES(?,?,?,1,?,?,0,0,0,0,?,1)");
stmt_AccountLoad = db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_NAME"=? COLLATE NOCASE");
stmt_AccountUpdate = db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_ALIVE"=?, "FIELD_PLAYER_WARNINGS"=? WHERE "FIELD_PLAYER_NAME"=? COLLATE NOCASE");

Expand Down Expand Up @@ -146,6 +152,9 @@ hook OnGameModeInit()
stmt_AccountGetGpci = db_prepare(gAccounts, "SELECT "FIELD_PLAYER_GPCI" FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_NAME"=? COLLATE NOCASE");
stmt_AccountSetGpci = db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_GPCI"=? WHERE "FIELD_PLAYER_NAME"=? COLLATE NOCASE");

stmt_AccountGetLanguage = db_prepare(gAccounts, "SELECT "FIELD_PLAYER_LANG" FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_NAME"=? COLLATE NOCASE");
stmt_AccountSetLanguage = db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_LANG"=? WHERE "FIELD_PLAYER_NAME"=? COLLATE NOCASE");

stmt_AccountGetActiveState = db_prepare(gAccounts, "SELECT "FIELD_PLAYER_ACTIVE" FROM "ACCOUNTS_TABLE_PLAYER" WHERE "FIELD_PLAYER_NAME"=? COLLATE NOCASE");
stmt_AccountSetActiveState = db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_PLAYER" SET "FIELD_PLAYER_ACTIVE"=? WHERE "FIELD_PLAYER_NAME"=? COLLATE NOCASE");

Expand Down Expand Up @@ -186,6 +195,7 @@ Error:LoadAccount(playerid)
spawntime,
spawns,
warnings,
language,
active;

GetPlayerName(playerid, name, MAX_PLAYER_NAME);
Expand Down Expand Up @@ -220,6 +230,7 @@ Error:LoadAccount(playerid)
stmt_bind_result_field(stmt_AccountLoad, FIELD_ID_PLAYER_SPAWNTIME, DB::TYPE_INTEGER, spawntime);
stmt_bind_result_field(stmt_AccountLoad, FIELD_ID_PLAYER_TOTALSPAWNS, DB::TYPE_INTEGER, spawns);
stmt_bind_result_field(stmt_AccountLoad, FIELD_ID_PLAYER_WARNINGS, DB::TYPE_INTEGER, warnings);
stmt_bind_result_field(stmt_AccountLoad, FIELD_ID_PLAYER_LANG, DB::TYPE_INTEGER, language);
stmt_bind_result_field(stmt_AccountLoad, FIELD_ID_PLAYER_ACTIVE, DB::TYPE_INTEGER, active);

if(!stmt_execute(stmt_AccountLoad))
Expand Down Expand Up @@ -249,6 +260,7 @@ Error:LoadAccount(playerid)
}

SetPlayerAliveState(playerid, alive);
SetPlayerLanguage(playerid, language);
acc_IsNewPlayer[playerid] = false;
acc_HasAccount[playerid] = true;

Expand Down Expand Up @@ -768,7 +780,7 @@ SavePlayerData(playerid)
==============================================================================*/


stock GetAccountData(name[], pass[], &ipv4, &alive, &regdate, &lastlog, &spawntime, &totalspawns, &warnings, gpci[], &active)
stock GetAccountData(name[], pass[], &ipv4, &alive, &regdate, &lastlog, &spawntime, &totalspawns, &warnings, &language, gpci[], &active)
{
stmt_bind_value(stmt_AccountLoad, 0, DB::TYPE_STRING, name, MAX_PLAYER_NAME);
stmt_bind_result_field(stmt_AccountLoad, FIELD_ID_PLAYER_PASS, DB::TYPE_STRING, pass, MAX_PASSWORD_LEN);
Expand All @@ -779,6 +791,7 @@ stock GetAccountData(name[], pass[], &ipv4, &alive, &regdate, &lastlog, &spawnti
stmt_bind_result_field(stmt_AccountLoad, FIELD_ID_PLAYER_SPAWNTIME, DB::TYPE_INTEGER, spawntime);
stmt_bind_result_field(stmt_AccountLoad, FIELD_ID_PLAYER_TOTALSPAWNS, DB::TYPE_INTEGER, totalspawns);
stmt_bind_result_field(stmt_AccountLoad, FIELD_ID_PLAYER_WARNINGS, DB::TYPE_INTEGER, warnings);
stmt_bind_result_field(stmt_AccountLoad, FIELD_ID_PLAYER_LANG, DB::TYPE_INTEGER, language);
stmt_bind_result_field(stmt_AccountLoad, FIELD_ID_PLAYER_GPCI, DB::TYPE_STRING, gpci, 41);
stmt_bind_result_field(stmt_AccountLoad, FIELD_ID_PLAYER_ACTIVE, DB::TYPE_INTEGER, active);

Expand Down Expand Up @@ -1010,6 +1023,28 @@ stock SetAccountGPCI(const name[], gpci[MAX_GPCI_LEN])
return stmt_execute(stmt_AccountSetGpci);
}

// FIELD_ID_PLAYER_LANG
stock GetAccountLanguage(const name[], &languageid)
{
stmt_bind_result_field(stmt_AccountGetLanguage, 0, DB::TYPE_INTEGER, languageid);
stmt_bind_value(stmt_AccountGetLanguage, 0, DB::TYPE_STRING, name, MAX_PLAYER_NAME);

if(!stmt_execute(stmt_AccountGetLanguage))
return 0;

stmt_fetch_row(stmt_AccountGetLanguage);

return 1;
}

stock SetAccountLanguage(const name[], languageid)
{
stmt_bind_value(stmt_AccountSetLanguage, 0, DB::TYPE_INTEGER, languageid);
stmt_bind_value(stmt_AccountSetLanguage, 1, DB::TYPE_STRING, name, MAX_PLAYER_NAME);

return stmt_execute(stmt_AccountSetLanguage);
}

// FIELD_ID_PLAYER_ACTIVE
stock GetAccountActiveState(const name[], &active)
{
Expand Down
4 changes: 2 additions & 2 deletions gamemodes/sss/core/player/commands.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ CMD:restartinfo(playerid, params[])
{
gBigString[playerid][0] = EOS;

strcat(gBigString[playerid], sprintf(ls(playerid, "GENCOMDRES1"), floatround(gServerMaxUptime / 3600)));
strcat(gBigString[playerid], ls(playerid, "GENCOMDRES2"));
strcat(gBigString[playerid], sprintf(ls(playerid, "GENCOMDRES1", false), floatround(gServerMaxUptime / 3600)));
strcat(gBigString[playerid], ls(playerid, "GENCOMDRES2", false));

Dialog_Show(playerid, DIALOG_STYLE_MSGBOX, "Information about "C_BLUE"Server Restarts", gBigString[playerid], "Close", "");

Expand Down
32 changes: 30 additions & 2 deletions gamemodes/sss/core/player/language.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static
lang_PlayerLanguage[MAX_PLAYERS];


#define ls(%0,%1) GetLanguageString(GetPlayerLanguage(%0), %1)
#define ls(%0,%1,%2) GetLanguageString(GetPlayerLanguage(%0), %1, %2)

hook OnPlayerConnect(playerid)
{
Expand All @@ -33,6 +33,15 @@ stock GetPlayerLanguage(playerid)
return lang_PlayerLanguage[playerid];
}

stock SetPlayerLanguage(playerid, languageid)
{
if(!IsPlayerConnected(playerid))
return -1;

lang_PlayerLanguage[playerid] = languageid;
return 1;
}

ShowLanguageMenu(playerid)
{
new
Expand All @@ -54,12 +63,31 @@ ShowLanguageMenu(playerid)
if(response)
{
lang_PlayerLanguage[playerid] = listitem;
ChatMsgLang(playerid, YELLOW, "LANGCHANGE");

new lang_name[MAX_LANGUAGE_NAME];

GetLanguageName(listitem, lang_name);

ChatMsgLang(playerid, BLUE, "LANGCHANGE", lang_name);

if(!IsPlayerRegistered(playerid)) {
DisplayRegisterPrompt(playerid);
} else {
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
SetAccountLanguage(name, listitem);
}
}
}
Dialog_ShowCallback(playerid, using inline Response, DIALOG_STYLE_LIST, "Choose language:", langlist, "Select", "Cancel");
}

hook OnPlayerRegister(playerid) {
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
SetAccountLanguage(name, lang_PlayerLanguage[playerid]);
}

hook OnPlayerSave(playerid, filename[])
{
new data[1];
Expand Down
Loading