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

Solved Help ban with server_cmd()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 04-17-2022 , 14:14   Help ban with server_cmd()
Reply With Quote #1

Guys please help, i've tried one milion combinations of codes to write a simple line .

I want to ban a player when he disconnect if he has a boolean true .

Idk what is the problem, i was thinking that he disconnect too soon so the server can't get his authid to banhim , i've scrooled all fucking topics i founded and nothing , the same result .

I added an debug message, wich is called properly . but the player doesn't get ban.

My last attempt was to ban him with addip but nothing works .


PHP Code:
public client_disconnectid )
{
    if( 
cs_get_user_team(id) == CS_TEAM_T )
    {
        
get_user_nameidgLastRetryNamecharsmax(gLastRetryName) );    
        
RetryOn true;

        if( 
BanHim[id] )
        {
            
server_cmd("amx_ban #%d 30 ^"ReasonTERO RETRY TWO TIMES!^""get_user_userid(id) )
            
client_print0print_chat"Jucatorul %s a primit ban 30 de minute pentru retry ca terorist!"gLastRetryName );
        }
    }

Please note that the message "Jucatorul %s.. " ( an debug message) is properly called, but the line where i'm trying to ban the player is simply isn't called .

Thank you . (the amxx version is higher than 1.8.2)

To make it easy for you, everything works only this part:

Code:
server_cmd("amx_ban #%d 30 ^"Reason: TERO RETRY TWO TIMES!^"", get_user_userid(id) )
__________________
Project: Among Us

Last edited by Craxor; 04-18-2022 at 14:23.
Craxor is offline
Send a message via ICQ to Craxor
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 04-17-2022 , 14:26   Re: Help ban with server_cmd()
Reply With Quote #2

Use amx_addban
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 04-17-2022 at 14:29.
Supremache is offline
zXCaptainXz
Member
Join Date: May 2017
Old 04-17-2022 , 14:53   Re: Help ban with server_cmd()
Reply With Quote #3

I am not sure if this will solve the issue, but maybe you can try calling server_exec() right after server_cmd("amx_ban etc..").
Are you using any ban system? Does it use a local file or SQL? Or just what comes with AMXX by default?
zXCaptainXz is offline
Dyaus
Member
Join Date: Aug 2021
Old 04-17-2022 , 15:53   Re: Help ban with server_cmd()
Reply With Quote #4

Quote:
Originally Posted by Supremache View Post
Use amx_addban
ye use this with his steam id and ip , don't ban by name
Dyaus is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 04-17-2022 , 15:57   Re: Help ban with server_cmd()
Reply With Quote #5

Quote:
Originally Posted by zXCaptainXz View Post
I am not sure if this will solve the issue, but maybe you can try calling server_exec() right after server_cmd("amx_ban etc..").
Are you using any ban system? Does it use a local file or SQL? Or just what comes with AMXX by default?
He has to use amx_addban , because amx_ban or amx_banip etc can't ban the player when he has disconnected so use amx_addban, also can use another method like creating a variable to save the player when disconnected from the server and check when the player tries to connect to the server again
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 04-17-2022 at 16:21.
Supremache is offline
zXCaptainXz
Member
Join Date: May 2017
Old 04-17-2022 , 16:24   Re: Help ban with server_cmd()
Reply With Quote #6

Quote:
Originally Posted by Supremache View Post
He has to use amx_addban , because amx_ban or amx_banip etc can't ban the player when he has disconnected so use amx_addban, also can use another method like creating a variable to save the player when disconnected from the server and check when the player tries to connect to the server again
I just tried it myself, it does work with amx_ban. I tried without server_exec(), it didn't work.

server_cmd() doesn't guarantee that the command is executed immediately, server_exec() has to be called in order to immediately execute whatever is inside server_cmd(). If it's not used, then the player will be fully disconnected and it will be too late to get his info.

PHP Code:
public client_disconnect(id)
{    
    
server_cmd("amx_ban #%d 5 test"get_user_userid(id))
    
server_exec();

Try it with and without server_exec() and see the difference

Last edited by zXCaptainXz; 04-17-2022 at 16:25. Reason: Added example
zXCaptainXz is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 04-18-2022 , 14:25   Re: Help ban with server_cmd()
Reply With Quote #7

Thank captain, the code server_exec() works perfectly, i had just to set BanHim on false after banning.him otherwise would ban.the player over 800 times until server crash, but i solved it,.thank you .
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
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 12:23.


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