Problem with Ban system
#1

Hi,
I have one problem. i think its not one yeah its two problems i'm facing.

PROBLEM: when i ban someone, it shows a dialog with details like :

Account name :
banned by :
Reason :
ban date:


now i want to show this dialog to the person who got banned not the guy who banned him. AT THIS MOMENT this dialog is appearing for the admin who banned a particular guy. i don't know how can i show the dialog to the guy who got banned.

AND

Same as OnPlayerConnect:
I want to show the same dialog to the banned guy if he tried to join the server again. here are the codes please correct them & give me ideas.


This is the COMMAND :
Код:
	if(strcmp(cmd, "/ban", true) == 0)
	{
		if(AccInfo[playerid][LoggedIn] == 1)
		{
			if(AccInfo[playerid][Level] >= 1)
			{
				new Index;
			    new tmp[256];  tmp  = strtok(params,Index);
				new tmp2[256]; tmp2 = strtok(params,Index);

			    if(!strlen(tmp)) return
				SendClientMessage(playerid, LIGHTBLUE, "[ USAGE: /ban (player<name/id>) (reason) ]") &&
				SendClientMessage(playerid, LIGHTBLUE2, "[ FUNCTION: Will Ban the specified player. ]");
				if(!strlen(tmp2))
				return SendClientMessage(playerid, red, "[ ERROR: Reason unspecified. ]");
				new player1;
		    	new string[128];
				new playername[MAX_PLAYER_NAME];
			 	new adminname [MAX_PLAYER_NAME];
				player1 = strval(tmp);

			 	if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (AccInfo[player1][Level] != ServerInfo[MaxAdminLevel]))
				{
					GetPlayerName(player1, playername, sizeof(playername));
					GetPlayerName(playerid, adminname, sizeof(adminname));
					new year,month,day; getdate(year, month, day);
					new hour,minuite,second; gettime(hour,minuite,second);
					SendCommandToAdmins(playerid,"Ban");
					format(string,sizeof(string),"[ %s has been Banned by Administrator %s | Reason: %s [Date: %d/%d/%d] [Time: %d:%d]. ]",playername,adminname,params[2],day,month,year,hour,minuite);
					SendClientMessageToAll(red,string);
	///////////////////////////////////////////////////////////////////////////////////////////////
                    new dialog[1000], string[128];
                    format(string, sizeof(string),"You are banned from this server :\n\n");
		            strcat(dialog,string);
		            format(string, sizeof(string),"{FF0000}» Reason: %s\n", params[2]);
		            strcat(dialog,string);
		            format(string, sizeof(string),"{FF0000}» Ban Date : %d/%d/%d\n", day, month, year);
		            strcat(dialog,string);
		            format(string, sizeof(string),"{FF0000}» Banned by : %s\n", adminname);
		            strcat(dialog,string);
		            format(string, sizeof(string),"{FF0000}» Account Name : %s\n", playername);
		            strcat(dialog,string);
                    ShowPlayerDialog(playerid, 7841, DIALOG_STYLE_LIST,"Account Banned!",dialog,"Close","");
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
					new str[128];
					format(str,sizeof(str),"[ %s has been Banned by Administrator %s | Reason: %s. ]",playername,adminname,params[2]);
					SaveIn("BanLog",str);
					print(string);
					if(udb_Exists(PlayerName2(player1)) && AccInfo[player1][LoggedIn] == 1)
					dUserSetINT(PlayerName2(player1)).("Banned",1);
					dUserSet(PlayerName2(player1)).("BannedBy",adminname);
					dUserSet(PlayerName2(player1)).("BannedReason",params[2]);
					format(str,sizeof(str),"%d/%d/%d",year, month, day);
					dUserSet(PlayerName2(player1)).("BannedDate",str);
 					PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
 					PlayerPlaySound(player1,1057,0.0,0.0,0.0);
					format(string,sizeof(string),"[ Banned by Administrator %s. | Reason: %s. ]",adminname,params[2]);
					return BanEx(player1, string);
				}
				else return SendClientMessage(playerid, red, "[ ERROR: Player is not connected or is yourself or is the highest level admin. ]");
			}
			else return ErrorMessages(playerid, 1);
		}
		else return SendClientMessage(playerid,red,"[ ERROR: You must be logged in to use this commands. ]");
	}
On player Connect Codes :
Код:
//==============================================================================
// If PlayerName is Banned
//==============================================================================
if (dUserINT(PlayerName2(playerid)).("Banned") == 1)
{
        new year,month,day; getdate(year, month, day);
        new reason[128], tmp[128], player1;
        new playername[MAX_PLAYER_NAME], adminname [MAX_PLAYER_NAME];
        player1 = strval(tmp);
        GetPlayerName(player1, playername, sizeof(playername));
        GetPlayerName(playerid, adminname, sizeof(adminname));
        new dialog[1000], string[128];
		format(string, sizeof(string),"You are banned from this server :\n\n");
		strcat(dialog,string);
		format(string, sizeof(string),"{FF0000}» Reason: %s\n", reason);
		strcat(dialog,string);
		format(string, sizeof(string),"{FF0000}» Ban Date : %d/%d/%d\n", day, month, year);
		strcat(dialog,string);
		format(string, sizeof(string),"{FF0000}» Banned by : %s\n", adminname);
		strcat(dialog,string);
		format(string, sizeof(string),"{FF0000}» Account Name : %s\n", playername);
		strcat(dialog,string);
        ShowPlayerDialog(playerid, 1234, DIALOG_STYLE_LIST,"Account Banned!",dialog,"Close","");
        SaveIn("KickLog",string);  Kick(playerid);
}
Reply
#2

In /ban command, you used:
pawn Код:
ShowPlayerDialog(playerid, 7841, DIALOG_STYLE_LIST,"Account Banned!",dialog,"Close","");
that of course will send the dialog to the admin, I changed it to:
pawn Код:
ShowPlayerDialog(player1, 7841, DIALOG_STYLE_LIST,"Account Banned!",dialog,"Close","");
but for onplayerconnect, well you should have saved the name of the admin that has banned him, instead of making a new name from playerid while he connects (I mean the banned player), player1 is useless atm, so I recommend that when you use the /ban command you should save the name of the admin who has banned the player, and load it on player connect.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)