AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Auto Ip Kick Plugin (https://forums.alliedmods.net/showthread.php?t=133118)

nikhilgupta345 07-22-2010 02:19

Auto Ip Kick Plugin
 
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.

Vechta 07-22-2010 03:24

Re: Auto Ip Kick Plugin
 
It didnt work if making

Code:

if get_user_ip(id) == 123.123.123.123)
{
      server_cmd(kick bla)
}


katna 07-22-2010 03:45

Re: Auto Ip Kick Plugin
 
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

nikhilgupta345 07-22-2010 11:09

Re: Auto Ip Kick Plugin
 
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)
           
        }
}
           
}


katna 07-22-2010 11:39

Re: Auto Ip Kick Plugin
 
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



nikhilgupta345 07-22-2010 16:28

Re: Auto Ip Kick Plugin
 
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?

fysiks 07-22-2010 18:43

Re: Auto Ip Kick Plugin
 
Quote:

Originally Posted by nikhilgupta345 (Post 1248276)
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 (Post 1247955)
Ok, so I edited it to make it kick by steamid.

No offense, I'm not sure that I believe you.

nikhilgupta345 07-23-2010 01:54

Re: Auto Ip Kick Plugin
 
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)?

fysiks 07-23-2010 19:37

Re: Auto Ip Kick Plugin
 
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.

nikhilgupta345 07-23-2010 19:43

Re: Auto Ip Kick Plugin
 
I got it to work using a file, but it only reads the first line. I used fgets.


All times are GMT -4. The time now is 00:07.

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