AlliedModders

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

Craxor 04-17-2022 14:14

Help ban with server_cmd()
 
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) )

Supremache 04-17-2022 14:26

Re: Help ban with server_cmd()
 
Use amx_addban

zXCaptainXz 04-17-2022 14:53

Re: Help ban with server_cmd()
 
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?

Dyaus 04-17-2022 15:53

Re: Help ban with server_cmd()
 
Quote:

Originally Posted by Supremache (Post 2777056)
Use amx_addban

ye use this with his steam id and ip , don't ban by name

Supremache 04-17-2022 15:57

Re: Help ban with server_cmd()
 
Quote:

Originally Posted by zXCaptainXz (Post 2777058)
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

zXCaptainXz 04-17-2022 16:24

Re: Help ban with server_cmd()
 
Quote:

Originally Posted by Supremache (Post 2777062)
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

Craxor 04-18-2022 14:25

Re: Help ban with server_cmd()
 
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 .


All times are GMT -4. The time now is 21:19.

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