Raised This Month: $32 Target: $400
 8% 

Vote scripting (builtinvotes extension)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JLmelenchon
Senior Member
Join Date: Mar 2019
Old 08-21-2022 , 14:43   Vote scripting (builtinvotes extension)
Reply With Quote #1

How can i change that in a way that all players (total eight) have to accept the vote to validate it ?
If one player refuse it will be canceled.

For game left 4 dead 2.

Code:
public void CustomVoteResultHandler(Handle vote, int num_votes, int num_clients, const int[][] client_info, int num_items, const int[][] item_info)
{
	for (new i=0; i<num_items; i++)
	{
		if (item_info[i][BUILTINVOTEINFO_ITEM_INDEX] == BUILTINVOTES_VOTE_YES)
		{
			if (item_info[i][BUILTINVOTEINFO_ITEM_VOTES] > (num_votes / 2))
			{
				// One last check.
				if (RoundStarted())  {
					DisplayBuiltinVoteFail(vote, BuiltinVoteFail_Loses);
					CPrintToChatAll("%t", "round_started");
					RankedVoteDenied = false;
					return;
				}
				
				else
				{
				    DisplayBuiltinVotePass(vote, "The vote is accepted");
				    ServerCommand("sm_dothings");
				    CPrintToChatAll("%t", "vote_accepted");
				    return;
				}
			}
		}
	}
	DisplayBuiltinVoteFail(vote, BuiltinVoteFail_Loses);
	//RankedVoteDenied = true;
	return;
}

Last edited by JLmelenchon; 08-21-2022 at 14:53.
JLmelenchon is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 08-21-2022 , 17:19   Re: Vote scripting (builtinvotes extension)
Reply With Quote #2

*edit
Dam, you have multiple vote options... let me edit post
- No wait. Nevermind. item_info[0] is WINNER options from vote if there were total 1 num_items .



I did not test, but should work.
This example is not limited to exactly 8 players, you can change that.
But when vote is cast, all players currently in server need vote, and vote same option.

VoteHandler


Code:
 
public void Handle_VoteResults(Menu menu, 
        int num_votes, 
        int num_clients, 
        const int[][] client_info, 
        int num_items, 
        const int[][] item_info)
{
    /* See if there were multiple winners */
    int winner = 0;

    //if (num_items > 1
    //&& (item_info[0][VOTEINFO_ITEM_VOTES] == item_info[1][VOTEINFO_ITEM_VOTES]))
    //{
    //    winner = GetRandomInt(0, 1);
    //}

	if (num_items == 1
	&& num_clients == num_votes)
	{
		char votedisplayname[30];
		menu.GetItem(item_info[0][VOTEINFO_ITEM_INDEX], votedisplayname, sizeof(votedisplayname));
		PrintToChatAll("All %i players voted vote %s", num_clients, votedisplayname);
	}

 
    //char map[64];
    //menu.GetItem(item_info[winner][VOTEINFO_ITEM_INDEX], map, sizeof(map));
    //ServerCommand("changelevel %s", map);
}
__________________
Do not Private Message @me

Last edited by Bacardi; 08-21-2022 at 17:36.
Bacardi is offline
JLmelenchon
Senior Member
Join Date: Mar 2019
Old 08-21-2022 , 18:18   Re: Vote scripting (builtinvotes extension)
Reply With Quote #3

Thanks you man you are on fire, i'll try later.
JLmelenchon is offline
JLmelenchon
Senior Member
Join Date: Mar 2019
Old 08-21-2022 , 19:19   Re: Vote scripting (builtinvotes extension)
Reply With Quote #4

Oh wait. I was not talking about sourcemod voting system but about that: https://github.com/SirPlease/L4D2-Co...iltinvotes.inc

This is an extension with which you can create a custom vote in L4D2.

Last edited by JLmelenchon; 08-21-2022 at 19:20.
JLmelenchon is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 08-21-2022 , 21:31   Re: Vote scripting (builtinvotes extension)
Reply With Quote #5

Yes, Powerlord extension
https://forums.alliedmods.net/showthread.php?t=162164

But function callback is very similiar. I would guess he wont reinvent wheel again.

If you read and compare both callbacks, no much difference.
You can replace VOTEINFO_ITEM_INDEX to BUILTINVOTEINFO_ITEM_VOTES or to 0
Bacardi is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 08-25-2022 , 08:24   Re: Vote scripting (builtinvotes extension)
Reply With Quote #6

I'm not as attached to the built in votes as I'm attached to the karma system, so I hope someone can take it and repost it.

!startvote allows an admin to start a custom vote, so I can even make unanimous votes.

By editing the plugin in the right way, you can treat failure to vote as F1
Attached Files
File Type: sp Get Plugin or Get Source (sm_vote.sp - 50 views - 14.3 KB)
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
Reply



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 00:33.


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