Skip to content

Commit

Permalink
Merge pull request #15 from hx-w/dev-1.3.0
Browse files Browse the repository at this point in the history
Dev 1.3.0 pre release
  • Loading branch information
hx-w authored May 18, 2021
2 parents 880c870 + b19b2d4 commit cb89804
Show file tree
Hide file tree
Showing 10 changed files with 561 additions and 257 deletions.
Binary file modified plugins/csgowiki-pack.smx
Binary file not shown.
17 changes: 14 additions & 3 deletions scripting/csgowiki-pack.sp
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
#pragma dynamic 131022
#include "global_define.inc"

#include "csgowiki/utils.sp"
#include "csgowiki/menus.sp"
#include "csgowiki/panel.sp"

#include "csgowiki/steam_bind.sp"
#include "csgowiki/utility_submit.sp"
Expand All @@ -15,7 +16,7 @@ public Plugin:myinfo = {
name = "[CSGO Wiki] Plugin-Pack",
author = "CarOL",
description = "Provide interactive method between www.csgowiki.top and game server",
version = "v1.2.3",
version = "v1.3.0",
url = "https://github.com/hx-w/CSGOWiki-Plugins"
};

Expand All @@ -33,10 +34,16 @@ public OnPluginStart() {
RegConsoleCmd("sm_modify", Command_Modify);
RegConsoleCmd("sm_abort", Command_SubmitAbort);

RegConsoleCmd("sm_proround", Command_ProRound);
RegConsoleCmd("sm_m", Command_Panel);

// RegConsoleCmd("sm_proround", Command_ProRound);

RegConsoleCmd("sm_qq", Command_QQchat);
RegConsoleCmd("sm_option", Command_Option);
RegConsoleCmd("sm_wikipro", Command_WikiPro);


RegAdminCmd("sm_wikiop", Command_Wikiop, ADMFLAG_CHEATS);
RegAdminCmd("sm_vel", Command_Velocity, ADMFLAG_GENERIC);

// post fix
Expand All @@ -56,6 +63,8 @@ public OnPluginStart() {
g_hChannelServerRemark = FindOrCreateConvar("sm_qqchat_remark", "", "Set server name shown in qqchat");
g_hChannelQQgroup = FindOrCreateConvar("sm_qqchat_qqgroup", "", "Bind qqgroup id to this server. ONE qqgroup only");

HookOpConVarChange();

AutoExecConfig(true, "csgowiki-pack");
}

Expand Down Expand Up @@ -88,6 +97,7 @@ public OnClientPutInServer(client) {
ResetSingleClientSubmitState(client);
ClearPlayerToken(client);
ResetReqLock(client);
ClearPlayerProMatchInfo(client);
}

public OnClientDisconnect(client) {
Expand All @@ -97,6 +107,7 @@ public OnClientDisconnect(client) {
ResetReqLock(client);
// reset bind_flag
ResetSteamBindFlag(client);
ClearPlayerProMatchInfo(client);
}

public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[DATA_DIM], Float:angles[DATA_DIM], &weapon) {
Expand Down
83 changes: 83 additions & 0 deletions scripting/csgowiki/menus/menu_option.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@

void GetAllProMatchStat(client) {
new Handle:menuhandle = CreateMenu(ProMatchInfoMenuCallback);
SetMenuTitle(menuhandle, "职业比赛合集");

for (new idx = 0; idx < g_aProMatchInfo.Length; idx++) {
char team1[LENGTH_NAME], team2[LENGTH_NAME], time[LENGTH_NAME];
char matchId[LENGTH_NAME];
JSON_Object arrval = g_aProMatchInfo.GetObject(idx);
JSON_Object teamInfo_1 = arrval.GetObject("team1");
JSON_Object teamInfo_2 = arrval.GetObject("team2");
teamInfo_1.GetString("name", team1, sizeof(team1));
teamInfo_2.GetString("name", team2, sizeof(team2));
int score1 = teamInfo_1.GetInt("result");
int score2 = teamInfo_2.GetInt("result");
arrval.GetString("time", time, sizeof(time));
arrval.GetString("matchId", matchId, sizeof(matchId));
char msg[LENGTH_NAME * 4];
Format(msg, sizeof(msg), "[%s] %d : %d [%s] (%s)", team1, score1, score2, team2, time);
AddMenuItem(menuhandle, matchId, msg);
}
SetMenuPagination(menuhandle, 7);
SetMenuExitBackButton(menuhandle, true);
SetMenuExitButton(menuhandle, true);
DisplayMenu(menuhandle, client, MENU_TIME_FOREVER);
}


public ProMatchInfoMenuCallback(Handle:menuhandle, MenuAction:action, client, Position) {
if (MenuAction_Select == action) {
decl String:matchId[LENGTH_NAME];
GetMenuItem(menuhandle, Position, matchId, sizeof(matchId));

// set index
for (new idx = 0; idx < g_aProMatchInfo.Length; idx++) {
char _matchId[LENGTH_NAME];
JSON_Object arrval = g_aProMatchInfo.GetObject(idx);
arrval.GetString("matchId", _matchId, sizeof(_matchId));
if (StrEqual(matchId, _matchId)) {
g_aProMatchIndex[client] = idx;
break;
}
}
ClientCommand(client, "sm_wikipro");
}
else if (MenuAction_Cancel == action) {
ClientCommand(client, "sm_m");
}
}

public Action:Command_Option(client, args) {
Panel panel = new Panel();

panel.SetTitle("个人设置")

panel.DrawItem("道具开启自动投掷:开", ITEMDRAW_DISABLED);
panel.DrawItem("快捷道具上传(双击E):开", ITEMDRAW_DISABLED);
panel.DrawItem("qq聊天触发方式:单次触发", ITEMDRAW_DISABLED);
panel.DrawItem("职业道具场次选择");
panel.DrawItem(" ", ITEMDRAW_SPACER);
panel.DrawItem(" ", ITEMDRAW_SPACER);
panel.DrawItem("返回", ITEMDRAW_CONTROL);
panel.DrawItem("退出", ITEMDRAW_CONTROL);

panel.Send(client, OptionPanelHandler, MENU_TIME_FOREVER);

delete panel;
return Plugin_Handled;
}

public OptionPanelHandler(Handle:menu, MenuAction:action, client, Position) {
if (action == MenuAction_Select) {
switch(Position) {
case 1: PrintToChat(client, "%s \x0E功能未开放,敬请期待...", PREFIX), ClientCommand(client, "sm_option");
case 2: PrintToChat(client, "%s \x0E功能未开放,敬请期待...", PREFIX), ClientCommand(client, "sm_option");
case 3: PrintToChat(client, "%s \x0E功能未开放,敬请期待...", PREFIX), ClientCommand(client, "sm_option");
case 4: GetAllProMatchStat(client);
case 7: ClientCommand(client, "sm_m");
case 8: CloseHandle(menu);
}
}
}

116 changes: 5 additions & 111 deletions scripting/csgowiki/menus.sp → scripting/csgowiki/menus/menu_wiki.sp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ void Menu_UtilityWiki_v1(client) {
AddMenuItem(menuhandle, "startspot", ">>附近起点道具<<");
AddMenuItem(menuhandle, "endspot", ">>附近落点道具<<");

AddMenuItem(menuhandle, "pro", "职业比赛道具记录")

// SetMenuPagination(menuhandle, 7);
SetMenuExitBackButton(menuhandle, true);
SetMenuExitButton(menuhandle, true);
DisplayMenu(menuhandle, client, MENU_TIME_FOREVER);
}
Expand All @@ -31,16 +29,13 @@ public Menu_UtilityWiki_v1_CallBack(Handle:menuhandle, MenuAction:action, client
else if (StrEqual(Item, "startspot")) {
GetFilterCollection(client, "start");
}
else if (StrEqual(Item, "pro")) {
Menu_UtilityWiki_pro_round_list(client);
if (g_iServerTickrate != 128) {
PrintToChat(client, "%s 当前服务器为\x02%d\x01tick,与职业比赛服务器tick不相符,可能会出现道具不准确的情况。", PREFIX, g_iServerTickrate)
}
}
else {
Menu_UtilityWiki_v2(client, Item);
}
}
else if (MenuAction_Cancel == action) {
ClientCommand(client, "sm_m");
}
}

// 单个道具汇总菜单
Expand Down Expand Up @@ -151,105 +146,4 @@ public Menu_UtilityWiki_v3_CallBack(Handle:menuhandle, MenuAction:action, client
else if (MenuAction_Cancel == action) {
Menu_UtilityWiki_v1(client);
}
}


void Menu_UtilityWiki_pro_round_list(client) {
new Handle:menuhandle = CreateMenu(Menu_UtilityWiki_pro_round_list_CallBack);
char team1[LENGTH_NAME], team2[LENGTH_NAME], match_time[LENGTH_NAME];
g_joProMatchInfo.GetString("team1", team1, sizeof(team1));
g_joProMatchInfo.GetString("team2", team2, sizeof(team2));
g_joProMatchInfo.GetString("match_time", match_time, sizeof(match_time));
char menuTitle[LENGTH_NAME * 3 + 10];
Format(menuTitle, sizeof(menuTitle), "[%s] vs [%s] (%s)", team1, team2, match_time);
SetMenuTitle(menuhandle, menuTitle);
int round = 0;

for (new idx = 0; idx < g_jaProUtilityInfo.Length; idx++) {
JSON_Array arrval = view_as<JSON_Array>(g_jaProUtilityInfo.GetObject(idx));
int cround = arrval.GetInt(3);
if (cround != round) {
round = cround;
char msg[LENGTH_NAME];
char round_str[LENGTH_STATUS];
IntToString(round, round_str, sizeof(round_str));
Format(msg, sizeof(msg), "%d回合", round);
AddMenuItem(menuhandle, round_str, msg);
}
}

SetMenuPagination(menuhandle, 7);
SetMenuExitBackButton(menuhandle, true);
SetMenuExitButton(menuhandle, true);
DisplayMenu(menuhandle, client, MENU_TIME_FOREVER);
}


public Menu_UtilityWiki_pro_round_list_CallBack(Handle:menuhandle, MenuAction:action, client, Position) {
if (MenuAction_Select == action) {
char round[LENGTH_STATUS];
GetMenuItem(menuhandle, Position, round, LENGTH_STATUS);
Menu_UtilityWiki_pro_in_round(client, round);
char command[LENGTH_NAME];
Format(command, sizeof(command), "sm_proround %s", round);
ClientCommand(client, command);
DisplayMenuAtItem(menuhandle, client, GetMenuSelectionPosition(), MENU_TIME_FOREVER);
}
else if (MenuAction_Cancel == action) {
Menu_UtilityWiki_v1(client);
}
}

public Action:Command_ProRound(client, args) {
char round[LENGTH_STATUS];
GetCmdArgString(round, LENGTH_STATUS);
TrimString(round);
Menu_UtilityWiki_pro_in_round(client, round);
}

void Menu_UtilityWiki_pro_in_round(client, char round[LENGTH_STATUS]) {
new Handle:menuhandle = CreateMenu(Menu_UtilityWiki_pro_in_round_CallBack);
char menuTitle[LENGTH_NAME];
int round_int = StringToInt(round);
Format(menuTitle, sizeof(menuTitle), "%s回合道具记录", round);
SetMenuTitle(menuhandle, menuTitle);
char playerName[LENGTH_NAME];
char utTinyName[LENGTH_UTILITY_TINY];
char utNameZh[LENGTH_UTILITY_ZH];
char proid_str[LENGTH_UTILITY_ID];
char msg[LENGTH_NAME * 4];
for (new idx = 0; idx < g_jaProUtilityInfo.Length; idx++) {
JSON_Array arrval = view_as<JSON_Array>(g_jaProUtilityInfo.GetObject(idx));
int cround = arrval.GetInt(3);
if (cround != round_int) continue;
int proid = arrval.GetInt(0);
arrval.GetString(1, playerName, sizeof(playerName));
arrval.GetString(2, utTinyName, sizeof(utTinyName));
int round_throw_time = arrval.GetInt(4);
int round_remain_secs = 55 + 60 - round_throw_time;
int round_remain_min = round_remain_secs / 60;
round_remain_secs %= 60;
Utility_TinyName2Zh(utTinyName, "%s", utNameZh);
IntToString(proid, proid_str, sizeof(proid_str));
Format(msg, sizeof(msg), "[%s] %2d:%2d <%s>投掷", utNameZh, round_remain_min, round_remain_secs, playerName);
// PrintToChat(client, proid_str);
AddMenuItem(menuhandle, proid_str, msg);
}

SetMenuPagination(menuhandle, 7);
SetMenuExitBackButton(menuhandle, true);
SetMenuExitButton(menuhandle, true);
DisplayMenu(menuhandle, client, MENU_TIME_FOREVER);
}

public Menu_UtilityWiki_pro_in_round_CallBack(Handle:menuhandle, MenuAction:action, client, Position) {
if (MenuAction_Select == action) {
decl String:proid_str[LENGTH_UTILITY_ID];
GetMenuItem(menuhandle, Position, proid_str, LENGTH_STATUS);
GetUtilityDetail(client, proid_str, "pro")
DisplayMenuAtItem(menuhandle, client, GetMenuSelectionPosition(), MENU_TIME_FOREVER);
}
else if (MenuAction_Cancel == action) {
Menu_UtilityWiki_pro_round_list(client);
}
}
}
58 changes: 58 additions & 0 deletions scripting/csgowiki/menus/menu_wikiop.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// csgowiki operator tools

public Action:Command_Wikiop(client, args) {
Panel panel = new Panel();

panel.SetTitle("CSGOWiki管理员工具")

if (GetConVarBool(g_hCSGOWikiEnable))
panel.DrawItem("CSGOWiki总开关:开");
else
panel.DrawItem("CSGOWiki总开关:关");

new Flag = ITEMDRAW_DEFAULT;
if (!GetConVarBool(g_hCSGOWikiEnable))
Flag = ITEMDRAW_DISABLED;

if (GetConVarBool(g_hOnUtilitySubmit))
panel.DrawItem("道具上传功能:开", Flag);
else
panel.DrawItem("道具上传功能:关", Flag);

if (GetConVarBool(g_hOnUtilityWiki))
panel.DrawItem("道具学习功能:开", Flag);
else
panel.DrawItem("道具学习功能:关", Flag);

if (GetConVarBool(g_hChannelEnable))
panel.DrawItem("QQ聊天功能:开", Flag);
else
panel.DrawItem("QQ聊天功能:关", Flag);

panel.DrawText(" ");
panel.DrawItem("第三方插件设置", ITEMDRAW_DISABLED);

panel.DrawItem(" ", ITEMDRAW_SPACER);
panel.DrawItem("返回", ITEMDRAW_CONTROL);
panel.DrawItem("退出", ITEMDRAW_CONTROL);

panel.Send(client, WikiopPanelHandler, MENU_TIME_FOREVER);

delete panel;
return Plugin_Handled;
}


public WikiopPanelHandler(Handle:menu, MenuAction:action, client, Position) {
if (action == MenuAction_Select) {
switch(Position) {
case 1: SetConVarBool(g_hCSGOWikiEnable, !GetConVarBool(g_hCSGOWikiEnable), true, true), ClientCommand(client, "sm_wikiop");
case 2: SetConVarBool(g_hOnUtilitySubmit, !GetConVarBool(g_hOnUtilitySubmit), true, true), ClientCommand(client, "sm_wikiop");
case 3: SetConVarBool(g_hOnUtilityWiki, !GetConVarBool(g_hOnUtilityWiki), true, true), ClientCommand(client, "sm_wikiop");
case 4: SetConVarBool(g_hChannelEnable, !GetConVarBool(g_hChannelEnable), true, true), ClientCommand(client, "sm_wikiop");
case 5: PrintToChat(client, "%s \x0E功能未开放,敬请期待...", PREFIX), ClientCommand(client, "sm_wikiop");
case 7: ClientCommand(client, "sm_m");
case 8: CloseHandle(menu);
}
}
}
Loading

0 comments on commit cb89804

Please sign in to comment.