Raised This Month: $23 Target: $400
 5% 

Custom Votes Redux (v1.7 - 4/13/14)


Post New Thread Reply   
 
Thread Tools Display Modes
wyxls
Junior Member
Join Date: Jul 2010
Location: China
Old 02-16-2020 , 05:36   Re: Custom Votes Redux (v1.7 - 4/13/14)
Reply With Quote #291

Fix MAP and LIST vote type cooldown issue.


Updates
1. (2020-03-11) SourceMod 1.10 build 6478 may update its code checking and compiling will encounter error 047. Fixed


2. (2020-05-09) Left some Chinese characters in the plugin which can't be translated by phrases file. Seperate the plugin into Chinese version and English Version.


I debugged the plugin sourcecode and found why cooldown doesn't work. The key is g_iVoteLast[iVoter][iVote] value assignment failed.

Here's an example (List Vote Type):
Code:
public MenuHandler_ListVote(Handle:hMenu, MenuAction:iAction, iVoter, iParam2)
{
	if(iAction == MenuAction_End)
	{
		CloseHandle(hMenu);
		return;
	}

	if(iAction == MenuAction_Cancel && iParam2 == MenuCancel_ExitBack)
	{
		Menu_ChooseVote(iVoter);
		return;
	}

	if(iAction == MenuAction_Select)
	{
		decl String:strBuffer[MAX_NAME_LENGTH];
		GetMenuItem(hMenu, iParam2, strBuffer, sizeof(strBuffer));

		new iVote = g_iVoteCurrent[iVoter];
		if(iVote == -1)
		{
			PrintToChat(iVoter, "iVote = %i", iVote);
			return;
		}

		if(IsVoteInProgress())
		{
			CPrintToChat(iVoter, "[SM] %t", "Vote in Progress");
			return;
		}

		if(g_iVoteMaxCalls[iVote] > 0 && !CheckCommandAccess(iVoter, "customvotes_maxvotes", ADMFLAG_GENERIC))
		{
			g_iVoteRemaining[iVoter][iVote]--;
			CPrintToChat(iVoter, "%t", "Votes Remaining", g_iVoteRemaining[iVoter][iVote]);
		}

		new iOption = StringToInt(strBuffer);
		
		g_iVoteLast[iVoter][iVote] = GetTime();
		if(g_bVoteCallVote[iVote])                      <------------------------------ Check whether the vote type is "vote" "1" 
		{
			Vote_List(iVote, iVoter, iOption);     <------------------------------ Build Menu "Vote_List" and show it to iVoter
			return;                                   <- ---------------------------------Always Return here and skip GetTime() below
		}

		if(g_bVoteForOption[iVoter][iVote][iOption])
		{
			CPrintToChat(iVoter, "%t", "Already Voted");
			Menu_ChooseVote(iVoter);
			return;
		}

		g_bVoteForOption[iVoter][iVote][iOption] = true;
		if(!g_bVoteMultiple[iVote])
		{
			for(new iOptionList = 0; iOptionList < GetArraySize(g_hArrayVoteOptionName[iVote]); iOptionList++)
			{
				if(iOptionList != iOption)
					g_bVoteForOption[iVoter][iVote][iOptionList] = false;
			}
		}

		if(g_strVoteCallNotify[iVote][0])
		{
			decl String:strNotification[255];
			strcopy(strNotification, sizeof(strNotification), g_strVoteCallNotify[iVote]);

			FormatVoteString(iVote, iOption, strNotification, sizeof(strNotification));
			FormatVoterString(iVote, iVoter, strNotification, sizeof(strNotification));
			FormatOptionString(iVote, iOption, strNotification, sizeof(strNotification));

			ReplaceString(strNotification, sizeof(strNotification), "{Yes|No}", "Yes", true);
			ReplaceString(strNotification, sizeof(strNotification), "{yes|no}", "yes", true);

			CPrintToChatAll("%s", strNotification);
		}

		g_iVoteLast[iVoter][iVote] = GetTime();      <------------------------------------------Here the key line GetTime() to g_iVoteLast
		CheckVotesForOption(iVote, iOption);
		Menu_ChooseVote(iVoter);
	}
}
As showing above, the MenuHandler always return after building and showing "Vote_List", the value assignment is always outside of "if(iAction == MenuAction_Select)" and is skipped

So:
Code:
	g_iVoteLast[iVoter][iVote] = GetTime();    <- --------------------------------------------------Move GetTime() here
	if(g_bVoteCallVote[iVote]) 
	{
		Vote_List(iVote, iVoter, iOption);
		return;
	}
Only the PlayerVote's and SimpleVote's GetTime() put in the right place and cooldown work properly. So I fix the other two vote types ( Map and List).

In addition, the cooldown will be checked at the very beginning while players chat "!votemenu" and plugin showing Vote Menu which you can choose Vote Type from it. ( public Menu_ChooseVote )

For example, one player already called a Kick Player Vote and the cooldown is 60. The Vote Menu will blank out the Kick Player Option ( as the option being "iFlags = ITEMDRAW_DISABLED" ).

Anyway, now the CoolDown limit and those admin_overrides are all working! enjoy it!

PS: I change #include <colorvariables> in order to support custom color variables. You can modify the translation phrases with prefix {yelloe}, {lightgreen}, {green}, etc.

Please let me know if there's any issue. (Email:[email protected])
Attached Files
File Type: inc colorvariables.inc (32.9 KB, 58 views)
File Type: txt customvotes.phrases.txt (1.6 KB, 61 views)
File Type: sp Get Plugin or Get Source (customvotes_en.sp - 47 views - 69.8 KB)
File Type: sp Get Plugin or Get Source (customvotes_cn.sp - 11 views - 69.8 KB)

Last edited by wyxls; 05-09-2020 at 20:23.
wyxls is offline
drkratzig
New Member
Join Date: Aug 2013
Old 04-07-2020 , 18:37   Re: Custom Votes Redux (v1.7 - 4/13/14)
Reply With Quote #292

Only want to say thanks. Really nice plugin!
drkratzig is offline
tmwb.blood
New Member
Join Date: Dec 2019
Old 05-20-2020 , 20:01   Re: Custom Votes Redux (v1.7 - 4/13/14)
Reply With Quote #293

Hello. I have a CSS server and was wanting help with a vote. We currently have a knife round that is set through the admin menu, weapon restrictions. When selected, the next round is a knife round (for one round). I want to turn this into a vote that an admin starts, and would need something like 75% voting yes. I tried the Custom Votes v0.5.6 and I believe the command that is used is sm_knives. When the command runs, it does the knife round immediately (in the middle of the round) and then again for the following round. I just want it to run the next round only.

Any idea what the cfg might look to make this happen? Thank you!
tmwb.blood is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 07-09-2020 , 13:49   Re: Custom Votes Redux (v1.7 - 4/13/14)
Reply With Quote #294

In the public OnClientSayCmd, add this to avoid a bug which causes it to send a mute vote menu when you write nothing into the chat:

if(StrEqual(strText, ""))
return Plugin_Continue;
__________________
Accepting private work. Contact me if you're interested.
If you like my work, feel free to donate in appreciation with PayPal or CSGO Skins.

Total Donated: 10$
eyal282 is offline
enderandrew
Senior Member
Join Date: Jun 2020
Old 07-09-2020 , 21:29   Re: Custom Votes Redux (v1.7 - 4/13/14)
Reply With Quote #295

Quote:
Originally Posted by sneaK View Post
Hey guys, figured I'd update this plugin a bit since it's quite a useful tool.
Fork is quite active:

Download
Updated to new syntax. Compiles with no warnings.

Quote:
Originally Posted by wyxls View Post
Fix MAP and LIST vote type cooldown issue.

PS: I change #include <colorvariables> in order to support custom color variables. You can modify the translation phrases with prefix {yelloe}, {lightgreen}, {green}, etc.

Please let me know if there's any issue. (Email:[email protected])

This version also updated to new syntax.
Attached Files
File Type: sp Get Plugin or Get Source (customvotes_en.sp - 4 views - 69.6 KB)
File Type: inc kztimer.inc (3.9 KB, 1 views)
File Type: sp Get Plugin or Get Source (customvotes_en_redux.sp - 0 views - 92.1 KB)

Last edited by enderandrew; 07-30-2020 at 19:01.
enderandrew is offline
doroemon
Senior Member
Join Date: Dec 2009
Old 07-30-2020 , 11:53   Re: Custom Votes Redux (v1.7 - 4/13/14)
Reply With Quote #296

Quote:
Originally Posted by enderandrew View Post
Updated to new syntax. Compiles with no warnings.




This version also updated to new syntax.
__________________
I'm just a guy who's a server operator for fun.
https://steamcommunity.com/groups/cfmsg

Last edited by doroemon; 07-30-2020 at 11:55.
doroemon is offline
enderandrew
Senior Member
Join Date: Jun 2020
Old 07-30-2020 , 19:00   Re: Custom Votes Redux (v1.7 - 4/13/14)
Reply With Quote #297

Quote:
Originally Posted by doroemon View Post
Sorry, I uploaded the wrong file. Here you go:
Attached Files
File Type: sp Get Plugin or Get Source (customvotes_en.sp - 2 views - 69.6 KB)
enderandrew is offline
doroemon
Senior Member
Join Date: Dec 2009
Old 07-31-2020 , 03:07   Re: Custom Votes Redux (v1.7 - 4/13/14)
Reply With Quote #298

Quote:
Originally Posted by enderandrew View Post
Sorry, I uploaded the wrong file. Here you go:
So it doesn't have NativeVote Version?sadly
__________________
I'm just a guy who's a server operator for fun.
https://steamcommunity.com/groups/cfmsg
doroemon is offline
enderandrew
Senior Member
Join Date: Jun 2020
Old 08-01-2020 , 02:25   Re: Custom Votes Redux (v1.7 - 4/13/14)
Reply With Quote #299

Quote:
Originally Posted by doroemon View Post
So it doesn't have NativeVote Version?sadly
Here you go.
Attached Files
File Type: smx customvotes-nativevotes.smx (56.3 KB, 1 views)
File Type: sp Get Plugin or Get Source (customvotes-nativevotes.sp - 4 views - 69.2 KB)
enderandrew is offline
doroemon
Senior Member
Join Date: Dec 2009
Old 08-02-2020 , 09:18   Re: Custom Votes Redux (v1.7 - 4/13/14)
Reply With Quote #300

Quote:
Originally Posted by enderandrew View Post
Here you go.
PHP Code:
L 08/02/2020 21:15:30: [SMException reported: Array index out-of-bounds (index -1limit 32)
L 08/02/2020 21:15:30: [SMBlamingcustomvotes-nativevotes.smx
L 08
/02/2020 21:15:30: [SMCall stack trace:
L 08/02/2020 21:15:30: [SM]   [1Line 2014C:\Users\dora\Desktop\srcds manager\ServerFile\TF2SlenderServer\tf\addons\sourcemod\scripting\customvotes-nativevotes.sp::GetVotesForOption
L 08
/02/2020 21:15:30: [SM]   [2Line 1905C:\Users\dora\Desktop\srcds manager\ServerFile\TF2SlenderServer\tf\addons\sourcemod\scripting\customvotes-nativevotes.sp::CheckVotesForOption
L 08
/02/2020 21:15:30: [SM]   [3Line 1325C:\Users\dora\Desktop\srcds manager\ServerFile\TF2SlenderServer\tf\addons\sourcemod\scripting\customvotes-nativevotes.sp::VoteHandler_List
L 08
/02/2020 21:15:30: [SM]   [5Call_Finish
L 08
/02/2020 21:15:30: [SM]   [6Line 833C:\Users\dora\Desktop\srcds manager\ServerFile\TF2SlenderServer\tf\addons\sourcemod\scripting\nativevotes.sp::DoAction
L 08
/02/2020 21:15:30: [SM]   [7Line 871C:\Users\dora\Desktop\srcds manager\ServerFile\TF2SlenderServer\tf\addons\sourcemod\scripting\nativevotes.sp::OnVoteResults
L 08
/02/2020 21:15:30: [SM]   [8Line 1123C:\Users\dora\Desktop\srcds manager\ServerFile\TF2SlenderServer\tf\addons\sourcemod\scripting\nativevotes.sp::EndVoting
L 08
/02/2020 21:15:30: [SM]   [9Line 1063C:\Users\dora\Desktop\srcds manager\ServerFile\TF2SlenderServer\tf\addons\sourcemod\scripting\nativevotes.sp::DecrementPlayerCount
L 08
/02/2020 21:15:30: [SM]   [10Line 817C:\Users\dora\Desktop\srcds manager\ServerFile\TF2SlenderServer\tf\addons\sourcemod\scripting\nativevotes.sp::OnClientEnd
L 08
/02/2020 21:15:30: [SM]   [11Line 694C:\Users\dora\Desktop\srcds manager\ServerFile\TF2SlenderServer\tf\addons\sourcemod\scripting\nativevotes.sp::Command_Vote
L 08
/02/2020 21:15:30: [SM]   [13FakeClientCommand
L 08
/02/2020 21:15:30: [SM]   [14Line 957nativevotes/game.sp::Game_VoteYes
L 08
/02/2020 21:15:30: [SM]   [15Line 1285C:\Users\dora\Desktop\srcds manager\ServerFile\TF2SlenderServer\tf\addons\sourcemod\scripting\nativevotes.sp::StartVoting
L 08
/02/2020 21:15:30: [SM]   [16Line 1174C:\Users\dora\Desktop\srcds manager\ServerFile\TF2SlenderServer\tf\addons\sourcemod\scripting\nativevotes.sp::StartVote
L 08
/02/2020 21:15:30: [SM]   [17Line 1631C:\Users\dora\Desktop\srcds manager\ServerFile\TF2SlenderServer\tf\addons\sourcemod\scripting\nativevotes.sp::Native_Display
L 08
/02/2020 21:15:30: [SM]   [19NativeVotes_Display
L 08
/02/2020 21:15:30: [SM]   [20Line 958C:\Users\dora\Desktop\srcds manager\ServerFile\TF2SlenderServer\tf\addons\sourcemod\scripting\include\nativevotes.inc::NativeVotes_DisplayToAll
L 08
/02/2020 21:15:30: [SM]   [21Line 1270C:\Users\dora\Desktop\srcds manager\ServerFile\TF2SlenderServer\tf\addons\sourcemod\scripting\customvotes-nativevotes.sp::Vote_List
L 08
/02/2020 21:15:30: [SM]   [22Line 1165C:\Users\dora\Desktop\srcds manager\ServerFile\TF2SlenderServer\tf\addons\sourcemod\scripting\customvotes-nativevotes.sp::MenuHandler_ListVote 
__________________
I'm just a guy who's a server operator for fun.
https://steamcommunity.com/groups/cfmsg
doroemon is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:09.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode