Looking for vote limiting script (server side)

I'm looking for a simple script to either place a mandatory time limit between votes called on a server or perhaps only allowing 1 vote per player per map. Or BOTH would be excellent as well.

Anyone know of an existing script to do this... or know how to write it themselves?

Comments

  • It's rather easy to do either...
    Just gets troublesome when you need to add exceptions to the rule (i.e. kicking players, time limit, etc)
  • So if you don't add exceptions (I'm not sure why you would?), is it easy enough that someone here could whip one up?
  • Well, I wouldn't need to kick someone. Can the server not just ignore the request (from someone who already voted/someone calling a vote before the timelimit is up) and then send them a centerprint with "hey dummy, be patient"?
  • Something like this might suit you:
    $Host::RestrictionTime = 5;  //time in minutes
    package LimitVoteStarting {
    function serverCmdStartNewVote(%client, %typeName, %arg1, %arg2, %arg3, %arg4, %playerVote)
    {
    	%restTime = (%client.voteStart $= "") ? 0 : ($Host::RestrictionTime * 60 * 1000) - (getSimTime() - %client.voteStart);
    	if (%restTime > 0) {
    		messageClient( %client, 'voteAlreadyRunning', '\c2Cool it, bub.' );	
    		return;
    	} else %client.voteStart = "";
    	parent::serverCmdStartNewVote(%client, %typeName, %arg1, %arg2, %arg3, %arg4, %playerVote);
    	%client.voteStart = getSimTime();
    }
    
    }; activatePackage(LimitVoteStarting);
    
    Of course I just threw it together here, so I can't say I've tested it.
  • You might want to add an exception for admins, since admin actions (kicks/bans/map changes/etc.) count as votes.

    Here's one that does that:
    $Host::RestrictionTime = 5;  //time in minutes
    package LimitVoteStarting {
    function serverCmdStartNewVote(%client, %typeName, %arg1, %arg2, %arg3, %arg4, %playerVote)
    {
    	%restTime = (%client.voteStart $= "") ? 0 : ($Host::RestrictionTime * 60 * 1000) - (getSimTime() - %client.voteStart);
    	if (%restTime > 0 && !%client.isAdmin) {
    		messageClient( %client, 'voteAlreadyRunning', '\c2Cool it, bub.' );	
    		return;
    	} else %client.voteStart = "";
    	parent::serverCmdStartNewVote(%client, %typeName, %arg1, %arg2, %arg3, %arg4, %playerVote);
    	%client.voteStart = getSimTime();
    }
    
    }; activatePackage(LimitVoteStarting);
    
  • Sweet. Thanks guys.
  • //HomeLANVoteFixGame.cs - 5/3/01
    //By [*HF] Lofar, HomeLAN Federation - http://www.homelanfed.com
    // Place in tribes2/GameData/base/scripts to auto-execute on server startup.
    // Prevent vote hacks by checking the %typeName against the %actionMsg in serverCmdStartNewVote (admin.cs).
    // If they don't match (based on defaultgame.cs), we don't allow the vote. If we catch someone trying
    // to spoof an admin vote, deny them, tell the server, and kick them for $Host::KickBanTime. Also echo's votes
    // to the logfile for later review. If you wanted to block certain votes manually, delete the "if" statement with
    // the %typeName of the vote you want to remove.
    //
    // 5/6/01 - Updated to fix Tourney votes
    
    
    function serverCmdStartNewVote(%client, %typeName, %actionMsg, %arg1, %arg2, %arg3, %arg4, %playerVote)
    {
     if (%typeName $= "VoteKickPlayer")
     {
      if (%actionMsg !$= "KICK player")
      {
       echo("DeniedVote:", %client, " (", getTaggedString(%client.name), ",", %client.getAddress(), ",", %client.guid, ") ¿T=", %typename, " ¿M=", %actionMsg, " ¿A1=", %arg1, " ¿A2=", %arg2, " ¿P=", %playerVote);
       messageClient(%client, "", "\c5Vote Not Allowed.");
       return;
      }
     }
     else if (%typeName $= "VoteBanPlayer")
     {
      if (%actionMsg !$= "BAN player")
      {
       echo("DeniedVote:", %client, " (", getTaggedString(%client.name), ",", %client.getAddress(), ",", %client.guid, ") ¿T=", %typename, " ¿M=", %actionMsg, " ¿A1=", %arg1, " ¿A2=", %arg2, " ¿P=", %playerVote);
       messageClient(%client, "", "\c5Vote Not Allowed.");
       return;
      }
     }
     else if (%typeName $= "VoteChangeMission")
     {
      if (%actionMsg !$= "change the mission to")
      {
       echo("DeniedVote:", %client, " (", getTaggedString(%client.name), ",", %client.getAddress(), ",", %client.guid, ") ¿T=", %typename, " ¿M=", %actionMsg, " ¿A1=", %arg1, " ¿A2=", %arg2, " ¿P=", %playerVote);
       messageClient(%client, "", "\c5Vote Not Allowed.");
       return;
      }
     }
     else if (%typeName $= "VoteFFAMode")
     {
      if (%actionMsg !$= "Change server to Free For All.")
      {
       echo("DeniedVote:", %client, " (", getTaggedString(%client.name), ",", %client.getAddress(), ",", %client.guid, ") ¿T=", %typename, " ¿M=", %actionMsg, " ¿A1=", %arg1, " ¿A2=", %arg2, " ¿P=", %playerVote);
       messageClient(%client, "", "\c5Vote Not Allowed.");
       return;
      }
     }
     else if (%typeName $= "VoteTournamentMode")
     {
      if (%actionMsg !$= "change the server to")
      {
       echo("DeniedVote:", %client, " (", getTaggedString(%client.name), ",", %client.getAddress(), ",", %client.guid, ") ¿T=", %typename, " ¿M=", %actionMsg, " ¿A1=", %arg1, " ¿A2=", %arg2, " ¿P=", %playerVote);
       messageClient(%client, "", "\c5Vote Not Allowed.");
       return;
      }
     }
     else if (%typeName $= "VoteMatchStart")
     {
      if (%actionMsg !$= "Start Match")
      {
       echo("DeniedVote:", %client, " (", getTaggedString(%client.name), ",", %client.getAddress(), ",", %client.guid, ") ¿T=", %typename, " ¿M=", %actionMsg, " ¿A1=", %arg1, " ¿A2=", %arg2, " ¿P=", %playerVote);
       messageClient(%client, "", "\c5Vote Not Allowed.");
       return;
      }
     }
     else if (%typeName $= "VoteTeamDamage")
     {
      if ((%actionMsg !$= "disable team damage") && (%actionMsg !$= "enable team damage"))
      {
       echo("DeniedVote:", %client, " (", getTaggedString(%client.name), ",", %client.getAddress(), ",", %client.guid, ") ¿T=", %typename, " ¿M=", %actionMsg, " ¿A1=", %arg1, " ¿A2=", %arg2, " ¿P=", %playerVote);
       messageClient(%client, "", "\c5Vote Not Allowed.");
       return;
      }
     }
     else if (%typeName $= "VoteChangeTimeLimit")
     {
      if (%actionMsg !$= "change the time limit to")
      {
       echo("DeniedVote:", %client, " (", getTaggedString(%client.name), ",", %client.getAddress(), ",", %client.guid, ") ¿T=", %typename, " ¿M=", %actionMsg, " ¿A1=", %arg1, " ¿A2=", %arg2, " ¿P=", %playerVote);
       messageClient(%client, "", "\c5Vote Not Allowed.");
       return;
      }
     }
     else if (%typeName $= "VoteResetServer")
     {
      if (%actionMsg !$= "reset server defaults")
      {
       echo("DeniedVote:", %client, " (", getTaggedString(%client.name), ",", %client.getAddress(), ",", %client.guid, ") ¿T=", %typename, " ¿M=", %actionMsg, " ¿A1=", %arg1, " ¿A2=", %arg2, " ¿P=", %playerVote);
       messageClient(%client, "", "\c5Vote Not Allowed.");
       return;
      }
     }
     else if (%typeName $= "VoteGreedMode")
     {
      if ((%actionMsg !$= "disable greed mode") && (%actionMsg !$= "enable greed mode"))
      {
       echo("DeniedVote:", %client, " (", getTaggedString(%client.name), ",", %client.getAddress(), ",", %client.guid, ") ¿T=", %typename, " ¿M=", %actionMsg, " ¿A1=", %arg1, " ¿A2=", %arg2, " ¿P=", %playerVote);
       messageClient(%client, "", "\c5Vote Not Allowed.");
       return;
      }
     }
     else if (%typeName $= "VoteHoardMode")
     {
      if ((%actionMsg !$= "disable hoard mode") && (%actionMsg !$= "enable hoard mode"))
      {
       echo("DeniedVote:", %client, " (", getTaggedString(%client.name), ",", %client.getAddress(), ",", %client.guid, ") ¿T=", %typename, " ¿M=", %actionMsg, " ¿A1=", %arg1, " ¿A2=", %arg2, " ¿P=", %playerVote);
       messageClient(%client, "", "\c5Vote Not Allowed.");
       return;
      }
     }
     else if (%typeName $= "VoteAdminPlayer")
     {
      if (%actionMsg !$= "ADMIN player")
      {
       echo("DeniedVote:", %client, " (", getTaggedString(%client.name), ",", %client.getAddress(), ",", %client.guid, ") ¿T=", %typename, " ¿M=", %actionMsg, " ¿A1=", %arg1, " ¿A2=", %arg2, " ¿P=", %playerVote);
       bottomPrintAll("\c5" @ getTaggedString(%client.name) @ " tried an admin cheat and failed, please notify an admin.", 10, 1);
       messageClient(%client, "", "\c5Vote Not Allowed.");
    
       messageClient(%client, 'onClientKicked', "");
       messageAllExcept( %client, -1, 'MsgClientDrop', "", %client.name, %client );
    
       if( isObject(%client.player) ) %client.player.scriptKill(0);
       %client.schedule(700, "delete");
       BanList::add( %client.guid, %client.getAddress(), $Host::KickBanTime );
       return;
      }
     }
     else
     {
      echo("DeniedVote:", %client, " (", getTaggedString(%client.name), ",", %client.getAddress(), ",", %client.guid, ") ¿T=", %typename, " ¿M=", %actionMsg, " ¿A1=", %arg1, " ¿A2=", %arg2, " ¿P=", %playerVote);
      messageClient(%client, "", "\c5Vote Not Allowed.");
      return;
     }
    
     echo("AllowedVote:", %client, " (", getTaggedString(%client.name), ",", %client.getAddress(), ",", %client.guid, ") ¿T=", %typename, " ¿M=", %actionMsg, " ¿A1=", %arg1, " ¿A2=", %arg2, " ¿P=", %playerVote);
    
       if ( !%client.isAdmin || ( ( %arg1.isAdmin && ( %client != %arg1 ) ) ) )
       {
          %teamSpecific = false;
    	   %gender = (%client.sex $= "Male" ? 'he' : 'she');
          if ( Game.scheduleVote $= "" ) 
          {
    			//send a message to everyone about the vote...
             if (%playerVote)
    	      {   
                if((%client.team != %arg1.team && Game.numTeams > 1) && %typeName !$= "VoteAdminPlayer")
                {
                   messageClient(%client, '', "\c2Player votes must be team based.");
                   return;
                }
                
                // kicking and banning are team specific
                if(%typeName $= "VoteKickPlayer" || %typeName $= "VoteBanPlayer")
                {
                   if(%arg1.isSuperAdmin)
                   {
                      messageClient(%client, '', '\c2You can not %1 %2, %3 is a Super Admin!', %actionMsg, %arg1.name, %gender);
                      return;
                   }
                   
                   Game.kickClient = %arg1;
                   %clientsVoting = 0;
                   %teamSpecific = Game.numTeams > 1;
                   if(%arg1.team != 0 && %teamSpecific)
                   {   
                      for ( %clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++ ) 
                      {
                         %cl = ClientGroup.getObject( %clientIndex );
                
                         if(%cl.team == %client.team)
                         {   
                            %clients[%clientsVoting++] = %clientIndex;
                            messageClient( %client, 'VoteStarted', '\c2%1 initiated a vote to %2 %3.', %client.name, %actionMsg, %arg1.name); 
                         }
                      }
                   }
                   else
                      messageAll( 'VoteStarted', '\c2%1 initiated a vote to %2 %3.', %client.name, %actionMsg, %arg1.name); 
                }
                else
                {
                   messageAll( 'VoteStarted', '\c2%1 initiated a vote to %2 %3.', %client.name, %actionMsg, %arg1.name); 
                }   
             }
             else if ( %typeName $= "VoteChangeMission" )
                messageAll( 'VoteStarted', '\c2%1 initiated a vote to %2 %3 (%4).', %client.name, %actionMsg, %arg1, %arg2 );
             else if (%arg1 !$= 0)
             {
    				if (%arg2 !$= 0)
    		      {   
                   if(%typeName $= "VoteTournamentMode")
                   {   
                      %admin = getAdmin();
                      if(%admin > 0)
                         messageAll( 'VoteStarted', '\c2%1 initiated a vote to %2 Tournament Mode (%3).', %client.name, %actionMsg, %arg1); 
                      else
                      {   
                         messageClient( %client, 'clientMsg', 'There must be a server admin to play in Tournament Mode.');
                         return; 
                      }
                   }
                   else
                      messageAll( 'VoteStarted', '\c2%1 initiated a vote to %2 %3 %4.', %client.name, %actionMsg, %arg1, %arg2); 
    				
                }
                else
    		         messageAll( 'VoteStarted', '\c2%1 initiated a vote to %2 %3.', %client.name, %actionMsg, %arg1);
             }
    			else
    	         messageAll( 'VoteStarted', '\c2%1 initiated a vote to %2.', %client.name, %actionMsg); 
    
             // open the vote hud for all clients that will participate in this vote
             if(%teamSpecific)
             {
                for(%i = 0; %i < %clientsVoting; %i++)
                {   
                   %cl = ClientGroup.getObject(%clients[%i]);
                   messageClient(%cl, 'openVoteHud', "", %clientsVoting, ($Host::VotePassPercent / 100));    
                }
             }
             else
             {
                for ( %clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++ ) 
                {
                   %cl = ClientGroup.getObject( %clientIndex );
                   messageClient(%cl, 'openVoteHud', "", $HostGamePlayerCount, ($Host::VotePassPercent / 100));    
                }
             }
             
             clearVotes();
             Game.voteType = %typeName;
             Game.scheduleVote = schedule( ($Host::VoteTime * 1000), 0, "calcVotes", %typeName, %arg1, %arg2, %arg3, %arg4 );
             %client.vote = true;
             messageAll('addYesVote', "");
             
             if(!%client.team == 0)
                clearBottomPrint(%client);
          }
          else
             messageClient( %client, 'voteAlreadyRunning', '\c2A vote is already in progress.' );	                       
       }
       else 
       {
          if ( Game.scheduleVote !$= "" && Game.voteType $= %typeName ) 
          {
             messageAll('closeVoteHud', "");
             cancel(Game.scheduleVote);
             Game.scheduleVote = "";
          }
          
          // if this is a superAdmin, don't kick or ban
          if(%arg1 != %client)
          {   
             if(!%arg1.isSuperAdmin)
                eval( "Game." @ %typeName @ "(true,\"" @ %arg1 @ "\",\"" @ %arg2 @ "\",\"" @ %arg3 @ "\",\"" @ %arg4 @ "\");" );
             else
                messageClient(%client, '', '\c2You can not %1 %2, %3 is a Super Admin!', %actionMsg, %arg1.name, %gender);
          }      
       }
    }[code]
    
    [/code]
  • I'm looking for a simple script to either place a mandatory time limit between votes called on a server or perhaps only allowing 1 vote per player per map. Or BOTH would be excellent as well.

    Anyone know of an existing script to do this... or know how to write it themselves?

    Will this mean the end of vote to change map spamming?

    :D

    One can hope!
  • You might want to add an exception for admins,

    Whoops! Good catch. :p

    If you're looking to stop fake votes you could do something similar to that Blak, but I wouldn't replace the entire function unless you know exactly what you're doing.
Sign In or Register to comment.