Raised This Month: $1951 Target: $400
 487% 

Solved Problerm with autokick


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Barlap
Member
Join Date: Apr 2016
Location: Romania
Old 07-26-2020 , 10:09   Problerm with autokick
Reply With Quote #1

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 ) );
	
}

Last edited by Barlap; 08-03-2020 at 14:19.
Barlap is offline
Send a message via Skype™ to Barlap
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 07-26-2020 , 10:45   Re: Problerm with autokick
Reply With Quote #2

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 ) );     }
__________________

Last edited by Shadows Adi; 07-26-2020 at 18:45. Reason: Added explaination why his code isn't workin'
Shadows Adi is offline
Barlap
Member
Join Date: Apr 2016
Location: Romania
Old 07-26-2020 , 11:47   Re: Problerm with autokick
Reply With Quote #3

I don't want to kick him instantly i want to kick him after a random number between 10 seconds -60 seconds

Last edited by Barlap; 07-26-2020 at 13:50.
Barlap is offline
Send a message via Skype™ to Barlap
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-26-2020 , 13:14   Re: Problerm with autokick
Reply With Quote #4

Quote:
Originally Posted by Barlap View Post
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.
__________________
HamletEagle is offline
Barlap
Member
Join Date: Apr 2016
Location: Romania
Old 07-26-2020 , 13:35   Re: Problerm with autokick
Reply With Quote #5

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

Last edited by Barlap; 07-26-2020 at 13:50.
Barlap is offline
Send a message via Skype™ to Barlap
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-26-2020 , 13:45   Re: Problerm with autokick
Reply With Quote #6

Quote:
Originally Posted by HamletEagle View Post
You can't have 2 people with the same ip address connected at the same time.
You can, but the ports will be different.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-26-2020 , 14:02   Re: Problerm with autokick
Reply With Quote #7

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

Last edited by HamletEagle; 07-26-2020 at 14:10.
HamletEagle is offline
Barlap
Member
Join Date: Apr 2016
Location: Romania
Old 07-26-2020 , 15:48   Re: Problerm with autokick
Reply With Quote #8

up? can somebody help me fix the plugin?
Barlap is offline
Send a message via Skype™ to Barlap
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-26-2020 , 15:53   Re: Problerm with autokick
Reply With Quote #9

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)
__________________

Last edited by OciXCrom; 07-26-2020 at 15:54.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Barlap
Member
Join Date: Apr 2016
Location: Romania
Old 07-26-2020 , 17:04   Re: Problerm with autokick
Reply With Quote #10

Quote:
Originally Posted by OciXCrom View Post
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.
Barlap is offline
Send a message via Skype™ to Barlap
Reply


Thread Tools
Display Modes

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 13:04.


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