Raised This Month: $51 Target: $400
 12% 

voteban


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Admin Commands        Approver:   Emp` (115)
hjvl
Member
Join Date: Oct 2005
Location: Almere
Old 08-20-2006 , 17:14   voteban
Reply With Quote #1

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.

EDITagain)(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.
Attached Files
File Type: sma Get Plugin or Get Source (voteban1_2.sma - 39367 views - 5.8 KB)

Last edited by hjvl; 08-30-2006 at 06:35.
hjvl is offline
neogeo
Senior Member
Join Date: Jul 2005
Old 08-22-2006 , 11:10   Re: voteban
Reply With Quote #2

hi
can you add ban by ip ?
thanks
neogeo is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 08-22-2006 , 11:28   Re: voteban
Reply With Quote #3

This has already been made in the base amxmodx code.
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
hjvl
Member
Join Date: Oct 2005
Location: Almere
Old 08-22-2006 , 12:20   Re: voteban
Reply With Quote #4

Quote:
Originally Posted by SweatyBanana View Post
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.
hjvl is offline
neogeo
Senior Member
Join Date: Jul 2005
Old 08-24-2006 , 05:41   Re: voteban
Reply With Quote #5

hi
can you add ban by ip ?
thanks
neogeo is offline
Switchie
Senior Member
Join Date: Mar 2006
Location: Belgium
Old 08-24-2006 , 11:45   Re: voteban
Reply With Quote #6

Ooooh Yeah thx , nice work and thx :-)

Lets test this :p
__________________
Switchie is offline
hjvl
Member
Join Date: Oct 2005
Location: Almere
Old 08-24-2006 , 15:47   Re: voteban
Reply With Quote #7

Quote:
Originally Posted by neogeo View Post
hi
can you add ban by ip ?
thanks
Done.
hjvl is offline
neogeo
Senior Member
Join Date: Jul 2005
Old 08-25-2006 , 04:35   Re: voteban
Reply With Quote #8

thanks
neogeo is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 08-25-2006 , 07:53   Re: voteban
Reply With Quote #9

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

Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
hjvl
Member
Join Date: Oct 2005
Location: Almere
Old 08-25-2006 , 15:04   Re: voteban
Reply With Quote #10

Thanks for the suggestions.
Good advices thanks

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)

Last edited by hjvl; 08-25-2006 at 17:14.
hjvl 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 10:30.


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