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

Auto Ip Kick Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-22-2010 , 02:19   Auto Ip Kick Plugin
Reply With Quote #1

Im completely new at coding, been learning for about 2 days I think? Anyways, I'm trying to make a plugin where the admin sets the cvar as an ip, and then whenever someone joins with that ip, they are autokicked when the round starts. I know it basically a ban, I'm just trying to make some basic plugins. I get these errors, and I don't know how to fix them.


Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "AutoKick IP"
#define VERSION "1.0"
#define AUTHOR "H3avY Ra1n"


public plugin_init() {
    //Register Plugin
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_logevent("round_start", 2, "1=Round_Start")
    register_cvar("amx_firstip", "none")
    register_cvar("amx_secondip", "none")
    register_cvar("amx_thirdip", "none")
    register_cvar("amx_fourthip", "none")
}

public round_start()
{
    new firstip, secondip, thirdip, fourthip;
    new players[32], num, player;
    get_players(players, num);
    firstip=get_cvar_num("amx_firstip")
    secondip=get_cvar_num("amx_secondip")
    thirdip=get_cvar_num("amx_thirdip")
    fourthip=get_cvar_num("fourthip")
    for(new i; i < num; i++)
    {
        new ip[9]
        player=players[i]
        new ipnum= get_user_ip(player, ip, 9, 1);
        if(firstip=str_to_num(ipnum) ||secondip=str_to_num(ipnum) || thirdip=str_to_num(ipnum) || fourthip=str_to_num(ipnum) 
        {
        server_cmd(kick %s, player)
        }
    }
Warning: Possibly unintended assignment on line 36
Error: Must be lvalue (non-constant) on line 36
Error: Argument type mismatch (argument 1) on line 36
Error: Argument type mismatch (argument 1) on line 36
Error: Too many error messages on one line on line 36


That's the error message I get.


Also, I'm curious to know, how could I make it to read ip's from a file. Haven't learned how to have plugins read from files yet.

Last edited by nikhilgupta345; 07-22-2010 at 03:05.
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
Vechta
Veteran Member
Join Date: Jun 2010
Old 07-22-2010 , 03:24   Re: Auto Ip Kick Plugin
Reply With Quote #2

It didnt work if making

Code:
if get_user_ip(id) == 123.123.123.123)
{
      server_cmd(kick bla)
}
Vechta is offline
katna
Senior Member
Join Date: May 2010
Old 07-22-2010 , 03:45   Re: Auto Ip Kick Plugin
Reply With Quote #3

PHP Code:
new ip[22];
get_user_ip(idipcharsmax(ip));
if(!
equal("123.123.123.123"ip))
{
// do w.e you want

But Non-steam is not supported here. so you should use Authid
katna is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-22-2010 , 11:09   Re: Auto Ip Kick Plugin
Reply With Quote #4

Ok, so I edited it to make it kick by steamid. Now I put my steamid as the cvar, but whenever the round starts, I don't get kicked. I'm pretty sure It has to do something with the arrays firstid and authid, but I don't know what's wrong.

Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "AutoSteamID Kicker"
#define VERSION "1.0"
#define AUTHOR "H3avY Ra1n"


public plugin_init() {
    //Register Plugin
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_logevent("round_start", 2, "1=Round_Start")
    register_cvar("amx_firstid", "none")
    register_cvar("amx_secondid", "none")
    register_cvar("amx_thirdid", "none")
    register_cvar("amx_fourthid", "none")
}

public round_start(id)
{
new num
new players[32]
new firstid[32]
get_players(players, num)
for(new i; i<num; i++)
    {
        new player=players[i]
        new userid=get_user_userid(player)
        firstid=get_cvar_num("amx_firstid")
        new authid[32]
        get_user_authid(id, authid, 31)
        if(firstid[11]==authid[11] && firstid[12]==authid[12])
        {
            server_cmd("kick #%s", userid)
            
        }
}
            
}
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
katna
Senior Member
Join Date: May 2010
Old 07-22-2010 , 11:39   Re: Auto Ip Kick Plugin
Reply With Quote #5

I just look up at the code very quickly but if you want to compare strings you need to use
equal/equali
PHP Code:
if(equali(a,b)) {
// some stuff

katna is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-22-2010 , 16:28   Re: Auto Ip Kick Plugin
Reply With Quote #6

Are you allowed to use the or operator when using equali?

If so, would it be like this?

Code:
if(equali(a,b) || equali(c,d) || equali(e,f))
{
//some code here
}
Also, what's the difference between equal and equali?
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-22-2010 , 18:43   Re: Auto Ip Kick Plugin
Reply With Quote #7

Quote:
Originally Posted by nikhilgupta345 View Post
Are you allowed to use the or operator when using equali?

If so, would it be like this?

Code:
if(equali(a,b) || equali(c,d) || equali(e,f))
{
//some code here
}
Also, what's the difference between equal and equali?
Yes, you can use the OR operator like that but you don't need to use it.

"i" means case insensitive.

You need to realize that your cvars are strings, not numbers. I would suggest that you write tbe plugin without any cvars first. Get it working with a single SteamID: new const szSteamID[] = "STEAM_0:0:1234". When you get it working with one SteamID then you can expand it to more and I would not recommend cvars either.

Quote:
Originally Posted by nikhilgupta345 View Post
Ok, so I edited it to make it kick by steamid.
No offense, I'm not sure that I believe you.
__________________
fysiks is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-23-2010 , 01:54   Re: Auto Ip Kick Plugin
Reply With Quote #8

I got it to kick myself with steamid, with the steamid placed as a const. Could someone show me how I would make it be read from a text file (the steamids)?
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-23-2010 , 19:37   Re: Auto Ip Kick Plugin
Reply With Quote #9

Now that you have it working with one SteamID you should first make it work with several SteamIDs using:

PHP Code:
new const SteamID_list[][] = {
    
"steam1",
    
"steam2"

Then after that you can add in reading from a file.
__________________
fysiks is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-23-2010 , 19:43   Re: Auto Ip Kick Plugin
Reply With Quote #10

I got it to work using a file, but it only reads the first line. I used fgets.
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
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:36.


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