AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Problerm with autokick (https://forums.alliedmods.net/showthread.php?t=326309)

Barlap 07-26-2020 10:09

Problerm with autokick
 
Hello, i have a plugin that sould autokick a player with a certain ip every 30 seconds, but instead the plugin kicks everybody. can you help me please guys?
Code:

#include <amxmodx>
#include <amxmisc>

#pragma semicolon 1

#define zIP    "178.138.33.138";

new const
PLUGIN_NAME[ ]                = "Autokick enemy",
PLUGIN_VERSION[ ]        = "1.0";

public plugin_init( )
{
       
        register_plugin( PLUGIN_NAME, PLUGIN_VERSION, "Barlap" );
       
        // Add your code here...
}

public client_putinserver( id ){
        new szIP[40];
        get_user_ip ( id, szIP, charsmax(szIP) , 1 ); // Get player's IP

        if( !task_exists( id + 1337 ) && !equal(szIP, "zIP")  )
        {
        set_task( 30.0, "task_NextPlayer", id + 1337 );
        }
        else
        return PLUGIN_HANDLED;
}

public task_NextPlayer( id )
{
        id -= 1337;
        if( !is_user_connected( id ) )
                return;
       
        server_cmd( "kick #%d ^"Bye loser^"", get_user_userid( id ) );
       
}


Shadows Adi 07-26-2020 10:45

Re: Problerm with autokick
 
1. You don't need a semicolon after preprocessors.
2. Indent your code proprely.
3. Check for player IP while is connecting.
Code:
#include <amxmodx> #include <amxmisc> #pragma semicolon 1 #define zIP    "178.138.33.138" public client_connect( id ) {     new szIP[40], players[32], num;     get_user_ip ( id, szIP, charsmax(szIP) , 1 ); // Get player's IP, without port.     if(equal(szIP, zIP)  )     {         server_cmd( "kick #%d ^"Bye loser^"", get_user_userid( id ) );     }     //else // You don't need an 'esle' situation, cuz you're stopping the function.     return PLUGIN_HANDLED; }

Your code is kicking all players, because...:
Code:
if( !task_exists( id + 1337 ) && !equal(szIP, "zIP")  ) // Checking if the task don't exists and  player's IP is not equal whit "zIP" ??? You defined zIP before, as constant, why you use it like a string?     {
        set_task( 30.0, "task_NextPlayer", id + 1337 );
    }

Code:
public task_NextPlayer( id ) {
    id -= 1337; // If you remove task, then your condition from putinserver phase will be false
    if( !is_user_connected( id ) )         return;         server_cmd( "kick #%d ^"Bye loser^"", get_user_userid( id ) );     }

Barlap 07-26-2020 11:47

Re: Problerm with autokick
 
I don't want to kick him instantly i want to kick him after a random number between 10 seconds -60 seconds

HamletEagle 07-26-2020 13:14

Re: Problerm with autokick
 
Quote:

Originally Posted by Barlap (Post 2711733)
how can i make the plugin choose randomly between 2 guys with same ip and choose random between 10 seconds-5 mins to execute the task?

You can't have 2 people with the same ip address connected at the same time.

Barlap 07-26-2020 13:35

Re: Problerm with autokick
 
ofcourse you can....for example me on pc and my brother on laptop...
EDIT: can somebody help me? i pay money for it if it needs

OciXCrom 07-26-2020 13:45

Re: Problerm with autokick
 
Quote:

Originally Posted by HamletEagle (Post 2711744)
You can't have 2 people with the same ip address connected at the same time.

You can, but the ports will be different.

HamletEagle 07-26-2020 14:02

Re: Problerm with autokick
 
Yeah, that's indeed the case. I got confused with the exploit where people can clone steamids on non steam servers. My bad.

Barlap 07-26-2020 15:48

Re: Problerm with autokick
 
up? can somebody help me fix the plugin?

OciXCrom 07-26-2020 15:53

Re: Problerm with autokick
 
Up after ~60 minutes? People don't sit in front of their monitors 24/7 you know.

set_task(random_float(10.0, 60.0)

Barlap 07-26-2020 17:04

Re: Problerm with autokick
 
Quote:

Originally Posted by OciXCrom (Post 2711769)
Up after ~60 minutes? People don't sit in front of their monitors 24/7 you know.

set_task(random_float(10.0, 60.0)

thanks but the plugin still don't search for the defined ip. :(


All times are GMT -4. The time now is 22:47.

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