varmenu=newPanoramaVote("#SFUI_vote_panorama_vote_default","Hold on, Let me Cook",VoteResultCallback,VoteHandlerCallback,this){VoteCaller=player// null is the server.};menu.DisplayVoteToAll(20);
回调
publicboolVoteResultCallback(YesNoVoteInfoinfo){/* public int TotalVotes; public int YesVotes; public int NoVotes; public int TotalClients; public Dictionary<int, (int, int)> ClientInfo = []; */if(info.YesVotes>info.NoVotes){Server.PrintToChatAll("Vote passed!");returntrue;}Server.PrintToChatAll("Vote failed!");returnfalse;}publicvoidVoteHandlerCallback(YesNoVoteActionaction,intparam1,CastVoteparam2){switch(action){caseYesNoVoteAction.VoteAction_Start:Server.PrintToChatAll("Vote started!");break;caseYesNoVoteAction.VoteAction_Vote:varplayer=Utilities.GetPlayerFromSlot(param1);if(player==null)return;player.PrintToChat("You voted: "+(param2==CastVote.VOTE_OPTION1?"Yes":"No"));break;caseYesNoVoteAction.VoteAction_End:switch((YesNoVoteEndReason)param1){caseYesNoVoteEndReason.VoteEnd_Cancelled:Server.PrintToChatAll("Vote Ended! Cancelled");break;caseYesNoVoteEndReason.VoteEnd_AllVotes:Server.PrintToChatAll("Vote Ended! Thank you for participating.");break;caseYesNoVoteEndReason.VoteEnd_TimeUp:Server.PrintToChatAll("Vote Ended! Time is up.");break;}break;}}