|
Veteran Member
Join Date: Aug 2013
Location: Canada
|
12-11-2017
, 16:44
Re: Attaching a translation file to a vote menu
|
#9
|
Quote:
Originally Posted by Crasher_3637
I was able to make it work:
PHP Code:
public Action Command_Warp(int client, int args) { if(!l4d_ass_enable.BoolValue || !l4d_ass_teleport_enable.BoolValue || !l4d_ass_teleport_vote.BoolValue || l4d_ass_teleport_auto.BoolValue || NumTanks3) return; if(!l4d_ass_teleport_tank.BoolValue) CountTanks(); if(l4d_ass_teleport_vote.BoolValue) { char buffer[64]; int totalHumans, humanPlayers[MAXPLAYERS+1]; for(int i = 1; i <= MaxClients; i++) { if(!IsValidClient(i)) continue; humanPlayers[totalHumans++] = i; }
for(int i = 1; i <= MaxClients; i++) { if(IsValidClient(i)) { Menu chooseMenu = CreateMenu(chooseMenuHandler2); SetVoteResultCallback(chooseMenu, chooseMenuResults2); Format(buffer, sizeof(buffer), "%T", "TeleportSpeedrunners", i); chooseMenu.SetTitle(buffer); Format(buffer, sizeof(buffer), "%T", "YesOption", i); chooseMenu.AddItem("Yes", buffer); Format(buffer, sizeof(buffer), "%T", "NoOption", i); chooseMenu.AddItem("No", buffer); SetMenuPagination(chooseMenu, MENU_NO_PAGINATION); VoteMenu(chooseMenu, humanPlayers, totalHumans, 30); } } } }
Thank you for your help!
|
Here's what I believe is a cleaner version of your code:
PHP Code:
public Action Command_Warp(int client, int args) { if(!l4d_ass_enable.BoolValue || !l4d_ass_teleport_enable.BoolValue || !l4d_ass_teleport_vote.BoolValue || l4d_ass_teleport_auto.BoolValue || NumTanks3) return; if(!l4d_ass_teleport_tank.BoolValue) CountTanks(); if(l4d_ass_teleport_vote.BoolValue) { char buffer[64]; int totalHumans, humanPlayers[MAXPLAYERS+1]; for(int i = 1; i <= MaxClients; i++) { if(!IsValidClient(i)) continue; humanPlayers[totalHumans++] = i; }
for(int i = 1; i <= MaxClients; i++) { if(IsValidClient(i)) { Menu chooseMenu = CreateMenu(chooseMenuHandler2); SetVoteResultCallback(chooseMenu, chooseMenuResults2);
SetGlobalTransTarget(i); // Set translation target for "%t" translation format specifier.
Format(buffer, sizeof(buffer), "%t", "TeleportSpeedrunners"); chooseMenu.SetTitle(buffer); Format(buffer, sizeof(buffer), "%t", "YesOption"); chooseMenu.AddItem("Yes", buffer); Format(buffer, sizeof(buffer), "%t", "NoOption"); chooseMenu.AddItem("No", buffer);
SetMenuPagination(chooseMenu, MENU_NO_PAGINATION); VoteMenu(chooseMenu, humanPlayers, totalHumans, 30); } } SetGlobalTransTarget(LANG_SERVER); // If this fails compile, replace it with client #0 } }
__________________
Last edited by WildCard65; 12-11-2017 at 16:44.
|
|
|
|