AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   voteban (https://forums.alliedmods.net/showthread.php?t=43568)

hjvl 08-20-2006 17:14

voteban
 
1 Attachment(s)
As requested bij Switchie.
(request: http://forums.alliedmods.net/showthread.php?t=42127 )
This is my second plugin that i post here, so please shoot.


When there are no admins on the server, players can say "/voteban" en start a vote to ban a player for a surtain time.

The plugin is depending on the following cvars:
amxx_voteban_delaytime Time between votes (defaults to 600 seconds)

amxx_voteban_ratio Vote ratio (defaults to 0.50)

amxx_voteban_minvoters Min voters/players who have to vote to let the vote count(defaults to 0.0)

amxx_voteban_bf_ratio Back fire ratio for the vote starter :), if the for voters/ against voters is less then this, the vote starter is banned(defaults to 0.0)

amxx_voteban_bantime Duration of the ban (defaults to 5 minutes)

amxx_voteban_disable Disable the plugin

An admin can start a vote any time, the delaytime is of no influence on this.


EDIT:
Changed "access(id,ADMIN_USER)" in "is_user_admin(id)"

EDIT:
As requested by neogeo:
cvar amxx_voteban_ip Ban by ip instead of steam-id (defaults to 0)

EDIT:
As sugested by Suicid3, some changes.

EDIT:(again)(and again)
The cvar amxx_voteban_ip has changed into amxx_voteban_type.
If this cvar is set to 0, the ban is made on the steam_id.
If this cvar is set to 1, the ban is made on the ip address.
If this cvar is set to 2, amxbans is triggered.

neogeo 08-22-2006 11:10

Re: voteban
 
hi
can you add ban by ip ?
thanks

SweatyBanana 08-22-2006 11:28

Re: voteban
 
This has already been made in the base amxmodx code.

hjvl 08-22-2006 12:20

Re: voteban
 
Quote:

Originally Posted by SweatyBanana (Post 371241)
This has already been made in the base amxmodx code.

Could you please show me how this can be done with standard commands?
I realy cracked my brain on this, before i decided to write this plugin.

My objectives for this where:
* Easy sellection by menu
* "Normal" player access
* When there is an admin, normal players are blocked from using it
* votedelay byond mapchange
* "Back fire" at the person wh started the vote

It is as a respond to a request and for my personal use.
At this moment it serves it purpes and it was a nice programming "training".
Therfore it is not my intention to make any changes.

neogeo 08-24-2006 05:41

Re: voteban
 
hi
can you add ban by ip ?
thanks

Switchie 08-24-2006 11:45

Re: voteban
 
Ooooh Yeah thx , nice work and thx :-)

Lets test this :p

hjvl 08-24-2006 15:47

Re: voteban
 
Quote:

Originally Posted by neogeo (Post 372141)
hi
can you add ban by ip ?
thanks

Done.

neogeo 08-25-2006 04:35

Re: voteban
 
thanks :D

Xanimos 08-25-2006 07:53

Re: voteban
 
I have a few suggestions.
  1. Use pcvars instead of cvars - They are much faster.
  2. The way you have the get_systime() and the cvar for nexttime won't work. You have a define of the offset so that value never changes. Either fix it by using a global and setting it afterwards.
  3. In that same function you are converting the float to a string just to remove the decimal and what's left. Just use floatround() to get it as an integer and then use %d in the format.
  4. In your for() loop with get_players() instead of using Players[i] each time set a variable to that and use it. - This is an optimization that cuts off on run time. You won't be able to see the difference but it does cut back on unneeded calls.
  5. I was going to say make a way so that the menu can only be accessed by one person at a time. You can still do this, but the SystemTimeOffset as changed by the #3 suggestion kind of does this.

Here is an updated SayIt() function that uses suggestion #2, #3, and #4
PHP Code:

//Change
#define SysTimeOffset 3341654
//to
new SysTimeOffset

//...Rest of plugin

public SayIt(id)
{
  if(
get_cvar_num("amxx_voteban_disable"))
  {
    
client_print(id,print_chat,"[AMXX]amx_votaban disabled")
    return 
0
  
}
  new 
Time get_systime(SysTimeOffset);

  if( (
get_cvar_float("amx_voteban_nexttime") > Time) && !is_user_admin(id) )
  {
    new 
str[32];
    new 
seconds floatround((get_cvar_float("amx_voteban_nexttime")-Time);
    
client_print(id,print_chat,"[AMXX] You have to wait %d seconds before a new voteban can be started"seconds)
    return 
0
  
}

  
get_playersPlayerIDTotalPlayers )
  new 
TempID
  
for(i=0i<TotalPlayersi++)
  {
    
TempID PlayerID[i]
    
get_user_nameTempIDPlayerName[i], 31 )
    
get_user_authidTempIDPlayerAuthID[i], 34 )
    
get_user_ipTempIDPlayerIP[i], 15)

    if( 
is_user_admin(TempID))
    {
      if(!
is_user_admin(id))
      {
        
client_print(id,print_chat,"There is an admin on the server, voting is disabled!")
        return 
0
      
}
    }
  }

  
SysTimeOffset get_systime();

  
BanTime get_cvar_num("amxx_voteban_bantime")
  
get_user_nameidVoteStarter31)
  
get_user_authididVoteStarterAuthID34 )
  
get_user_ipidVoteStarterIP15)
  
MenuPosition 0

  ShowPlayerMenu
(id)

  return 
0



hjvl 08-25-2006 15:04

Re: voteban
 
Thanks for the suggestions.
Good advices thanks :D

I'm only not sure What you mean about #2 of your list.
The plugin is working with SysTimeOffset being a static

So I have tested get_systime with the following script:
Code:

#include <amxmodx>
#include <amxmisc>

#define SysTimeOffset 3333333
new SysTimeOffset2 = 5


public plugin_init()
{
  register_plugin("test get_systime","1.0","hjvl")
  register_clcmd("say /test","SayIt" )
}

public SayIt(id)
{
  client_print(id,print_chat,"SysTimeOffset(offset=static) %d",SysTimeOffset)
  client_print(id,print_chat,"SysTimeOffset2 %d",SysTimeOffset2)

  new Time = get_systime(SysTimeOffset)
  new Time2 = get_systime(SysTimeOffset2)

  client_print(id,print_chat,"SysTimeOffset(static) %d",SysTimeOffset)
  client_print(id,print_chat,"SysTimeOffset2 %d",SysTimeOffset2)
  client_print(id,print_chat,"Time(offset=static) %d",Time)
  client_print(id,print_chat,"Time2 %d",Time2)
  return 0
}

The result of my test is that the function get_systime does not change SysTimeOffset.
It simply returns the amount of seconds that have past since 00:00:00 01/01/1970 minus the offset
(this is also what i understood from the documentation)

You are right if you say make it a non static to avoid an overflow and change it every time the script is run.(or started)


All times are GMT -4. The time now is 11:30.

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