Files
2HUCardTDGame/content/panorama/scripts/custom_game/display_error.js
2021-11-10 08:48:00 -05:00

53 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// steamid至accountidDota2数字账户的转换字符串
function GetAccountID () {
var playerInfo = Game.GetPlayerInfo(Game.GetLocalPlayerID());
var steamID64 = playerInfo.player_steamid,
steamIDPart = Number(steamID64.substring(3)),
steamID32 = String(steamIDPart - 61197960265728);
return steamID32;
}
// 只能使用kv本地化文件中定义的标签
function Errors(data)
{
GameEvents.SendEventClientSide("dota_hud_error_message", {
"splitscreenplayer": 0,
"reason": 80,
"message": data.msg
});
}
// 在聊天频道显示,队友可见
function Chat(data)
{
// 注意 $.Localize 首次使用时必须带第二个参数,之后不需要。
// var text = $.Localize(, $.GetContextPanel());
var params = data.params;
var msgPanel = $.CreatePanel("Panel", $.GetContextPanel(), "");
msgPanel.visible = false;
var label = $.CreatePanel("Label", msgPanel, "");
if (params) {
for(var i in params) {
var v = params[i];
if (typeof v === 'number') {
label.SetDialogVariableInt(i, v);
} else {
label.SetDialogVariable(i, $.Localize(String(v)));
}
}
}
label.text = $.Localize(data.msg, label).replace(/%%/g,"%");
GameEvents.SendCustomGameEventToServer("custom_game_chat_msg", {'msg':label.text});
msgPanel.DeleteAsync(0);
}
(function()
{
GameEvents.Subscribe("display_custom_error", Errors);
GameEvents.Subscribe("display_chat_msg", Chat);
})();