Ban player can still connect
#1

My ban command :
Код:
CMD:ban(playerid,params[])
{
	if(pInfo[playerid][pAdmin] < 0 && pInfo[playerid][pRedeemedAdmin] <= 5) return 0;
	new id,reason,str[80],pname[MAX_PLAYER_NAME],pname2[MAX_PLAYER_NAME];
	if(sscanf(params,"ds",id,reason)) return SendClientMessage(playerid,colorexit," /ban <playerid> <reason>");
	if(!IsPlayerConnected(id)) return SendClientMessage(playerid,colorexit,"Invalid playerid.");
	if(id == playerid) return SendClientMessage(playerid,colorexit," Invalid playerid.");
	if(pInfo[playerid][pAdmin] < pInfo[id][pAdmin]) return SendClientMessage(playerid,colorexit,"[ ! ] You cannot ban this player.");
	if(pInfo[playerid][pRedeemedAdmin] == 6)
	{
		if(pInfo[id][pAdmin] >= 1)
		{
            return SendClientMessage(playerid,colorexit," You cannot ban this player.");
		}
	}
	GetPlayerName(playerid,pname,sizeof(pname));
	GetPlayerName(id,pname2,sizeof(pname2));
	new INI:File = INI_Open(UserPath(id));
	INI_SetTag(File,"data");
	INI_WriteInt(File,"Banned",1);
	INI_Close(File);
	pInfo[id][pIsBan] = 1;
	Ban(id);
	format(str,sizeof(str),"%s(%d) has been banned by %s(%d) for %d",pname2,id,pname2,playerid,reason);
	SendClientMessageToAll(admincolor,str);
	return 1;
}
OnPlayerConnect
Код:
if(pInfo[playerid][pIsBan] == 1)
	{
	    SendClientMessage(playerid,colorenter,"You are banned from the server!");
	    return Kick(playerid);
	}
    if(fexist(UserPath(playerid)))
	{
		INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login","{09B086}Type your password below to login.","Login","Quit");
	}
	else
	{
 		ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"REGISTER","{09B086}asdffadsfadf.","Register","Quit");
	}
But when player logs in he gets the login dialog. He doesn't get kicked as he is banned and he don't receives msg. let me know my mistake here. Thanks
Reply
#2

Make sure that the variable pIsBan is the same variable you write/load when you save/load the player.

Код:
pInfo[id][pIsBan] = 1;
new INI:File = INI_Open(UserPath(id));
INI_SetTag(File,"data");
INI_WriteInt(File,"Banned", pInfo[id][pIsBan]);
INI_Close(File);
Reply
#3

Show your LoadUser function.
Reply
#4

Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
        INI_Int("Banned",pInfo[playerid][pIsBan]);
 	return 1;
}
Reply
#5

PHP код:
if(sscanf(params,"[COLOR="Red"]ds[/COLOR]",id,reason)) return SendClientMessage(playerid,colorexit," /ban <playerid> <reason>"); 
You need to define U instead of D (D is a number, U is a userid) and define S length
Try it:
PHP код:
if(sscanf(params,"us[80]",id,reason)) return SendClientMessage(playerid,colorexit," /ban <playerid> <reason>"); 
Reply
#6

Your ban system is completely ineffective and designed very poorly it is not so much the code but the fundamental design.
Reply
#7

Quote:
Originally Posted by NeXoR
Посмотреть сообщение
PHP код:
if(sscanf(params,"[COLOR="Red"]ds[/COLOR]",id,reason)) return SendClientMessage(playerid,colorexit," /ban <playerid> <reason>"); 
You need to define U instead of D (D is a number, U is a userid) and define S length
Try it:
PHP код:
if(sscanf(params,"us[80]",id,reason)) return SendClientMessage(playerid,colorexit," /ban <playerid> <reason>"); 
d, u, and i can be used for the user id.
Reply
#8

Quote:
Originally Posted by itsCody
Посмотреть сообщение
d, u, and i can be used for the user id.
Well yeah, im also new just tried to help

Topic:
Try to debug it using
PHP код:
printf("Userid:%i"id); 
Just to test it
Reply
#9

PHP код:
    if(fexist(UserPath(playerid)))
    {
        
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
          
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD,"Login","{09B086}Type your password below to login.","Login","Quit");
    }
    else
    {
         
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD,"REGISTER","{09B086}asdffadsfadf.","Register","Quit");
    }
if(
pInfo[playerid][pIsBan] == 1)
    {
        
SendClientMessage(playerid,colorenter,"You are banned from the server!");
        return 
Kick(playerid);
    } 
Try loading your data first, then check if he should be kicked.
The other way around doesn't work that good (checking if he should be banned, then afterwards loading his data which holds that info).
Reply
#10

OnPlayerConnect
Код:
INI_ParseFile(UserPath(playerid), "BanLoad_%s", .bExtra = true, .extra = playerid);
if(fexist(UserPath(playerid)))
{
if(pInfo[playerid][pIsBan] == 1)
{
SendClientMessage(playerid,0xFF0000FF,"Banned, Good Byy);
SetTimerEx("Kicksz",20,false,"d",playerid);
return 1;
}
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login","{09B086}Type your password below to login.","Login","Quit");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"REGISTER","{09B086}asdffadsfadf.","Register","Quit");
}
Код:
forward BanLoad_data(playerid,name[],value[]);
public BanLoad_data(playerid,name[],value[])
{
INI_Int("Banned",pInfo[playerid][pIsBan]);
return 1;
}

forward Kicksz(playerid);
public Kicksz(playerid)
{
Kick(playerid);
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)