| 522 | } |
| 523 | |
| 524 | void VoteMenuHandler::OnMenuSelect(IBaseMenu *menu, int client, unsigned int item) |
| 525 | { |
| 526 | /* Check by our item count, NOT the vote array size */ |
| 527 | if (item < m_Items) |
| 528 | { |
| 529 | unsigned int index = menu->GetRealItemIndex(client, item); |
| 530 | m_ClientVotes[client] = index; |
| 531 | m_Votes[index]++; |
| 532 | m_NumVotes++; |
| 533 | |
| 534 | if (sm_vote_chat.GetBool() || sm_vote_console.GetBool() || sm_vote_client_console.GetBool()) |
| 535 | { |
| 536 | static char buffer[1024]; |
| 537 | ItemDrawInfo dr; |
| 538 | menu->GetItemInfo(item, &dr, client); |
| 539 | |
| 540 | if (sm_vote_console.GetBool()) |
| 541 | { |
| 542 | int target = SOURCEMOD_SERVER_LANGUAGE; |
| 543 | logicore.CoreTranslate(buffer, sizeof(buffer), "[SM] %T", 4, NULL, "Voted For", |
| 544 | &target, g_Players.GetPlayerByIndex(client)->GetName(), dr.display); |
| 545 | Engine_LogPrintWrapper(buffer); |
| 546 | } |
| 547 | |
| 548 | if (sm_vote_chat.GetBool() || sm_vote_client_console.GetBool()) |
| 549 | { |
| 550 | int maxclients = g_Players.GetMaxClients(); |
| 551 | for (int i=1; i<=maxclients; i++) |
| 552 | { |
| 553 | CPlayer *pPlayer = g_Players.GetPlayerByIndex(i); |
| 554 | assert(pPlayer); |
| 555 | |
| 556 | if (pPlayer->IsInGame() && !pPlayer->IsFakeClient()) |
| 557 | { |
| 558 | if (m_Revoting[client]) |
| 559 | { |
| 560 | logicore.CoreTranslate(buffer, sizeof(buffer), "[SM] %T", 4, NULL, "Changed Vote", |
| 561 | &i, g_Players.GetPlayerByIndex(client)->GetName(), dr.display); |
| 562 | } |
| 563 | else |
| 564 | { |
| 565 | logicore.CoreTranslate(buffer, sizeof(buffer), "[SM] %T", 4, NULL, "Voted For", |
| 566 | &i, g_Players.GetPlayerByIndex(client)->GetName(), dr.display); |
| 567 | } |
| 568 | |
| 569 | if (sm_vote_chat.GetBool()) |
| 570 | { |
| 571 | g_HL2.TextMsg(i, HUD_PRINTTALK, buffer); |
| 572 | } |
| 573 | |
| 574 | if (sm_vote_client_console.GetBool()) |
| 575 | { |
| 576 | ClientConsolePrint(pPlayer->GetEdict(), "%s", buffer); |
| 577 | } |
| 578 | } |
| 579 | } |
| 580 | } |
| 581 | } |
no test coverage detected