Teach me how to make ban with reason
#1

Код:
CMD:ban(playerid,params[]) {
	if(PlayerInfo[playerid][LoggedIn] == 1) {
		if(PlayerInfo[playerid][Level] >= 2) {
		    new tmp[128], tmp2[128], Index;		tmp = strtok(params,Index), tmp2 = strtok(params,Index);
		    if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /ban [playerid] [reason]");
			if(isnull(tmp2)) return SendClientMessage(playerid, red, "ERROR: You must give a reason");
	    	new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
			player1 = strval(tmp);
		 	if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (PlayerInfo[player1][Level] != ServerInfo[MaxAdminLevel]) ) {
				GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
				new year,month,day,hour,minuite,second; getdate(year, month, day); gettime(hour,minuite,second);
				CMDMessageToAdmins(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(grey,string);
				SaveToFile("BanLog",string);
				aresetpall(player1);
				print(string);
				if(udb_Exists(PlayerName2(player1)) && PlayerInfo[player1][LoggedIn] == 1) dUserSetINT(PlayerName2(player1)).("banned",1);
				format(string,sizeof(string),"banned by Administrator %s. Reason: %s", adminname, params[2] );
				return BanEx(player1, string);
			} else return SendClientMessage(playerid, red, "Player is not connected or is yourself or is the highest level admin");
		} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
	} else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
Код:
public OnPlayerConnect(playerid)
{
	new PlayerName[128],string[128], file[256];
	GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
	new tmp3[50]; GetPlayerIp(playerid,tmp3,50);

    if (dUserINT(PlayerName2(playerid)).("banned") == 1)
    {
        SendClientMessage(playerid, red, "This name is banned from this server!");
        SendClientMessage(playerid, red, "If You Think,Its Mistake,Please Make Appeal Here , Http://wx-play.cf");
		format(string,sizeof(string),"%s ID:%d was auto kicked. Reason: Name banned from server",PlayerName,playerid);
		SendClientMessageToAll(grey, string);  print(string);
		SaveToFile("KickLog",string);  Kick(playerid);
    }
when i ban someone

/ban id reason

i want when he connect to server

it said,Your account has been banned by Administrator %s [ Reason ]

how ?
Reply
#2

This part is already available in the code you posted?
Код:
  if (dUserINT(PlayerName2(playerid)).("banned") == 1)
    {
        SendClientMessage(playerid, red, "This name is banned from this server!");
        SendClientMessage(playerid, red, "If You Think,Its Mistake,Please Make Appeal Here , Http://wx-play.cf");
		format(string,sizeof(string),"%s ID:%d was auto kicked. Reason: Name banned from server",PlayerName,playerid);
		SendClientMessageToAll(grey, string);  print(string);
		SaveToFile("KickLog",string);  Kick(playerid);
    }
Reply
#3

Quote:
Originally Posted by Ritzy
Посмотреть сообщение
This part is already available in the code you posted?
Код:
  if (dUserINT(PlayerName2(playerid)).("banned") == 1)
    {
        SendClientMessage(playerid, red, "This name is banned from this server!");
        SendClientMessage(playerid, red, "If You Think,Its Mistake,Please Make Appeal Here , Http://wx-play.cf");
		format(string,sizeof(string),"%s ID:%d was auto kicked. Reason: Name banned from server",PlayerName,playerid);
		SendClientMessageToAll(grey, string);  print(string);
		SaveToFile("KickLog",string);  Kick(playerid);
    }
yes,but when i joined with banned account

it just said,server closed connection...
Reply
#4

Kick will kick them before they get the message.

Put it on a timer or something so it gets sent, then kicks them a second later.
Reply
#5

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Kick will kick them before they get the message.

Put it on a timer or something so it gets sent, then kicks them a second later.
i didnt found it
where can i found?

just found this

Код:
forward AutoKick(playerid);
public AutoKick(playerid)
{
	if( IsPlayerConnected(playerid) && ServerInfo[Locked] == 1 && PlayerInfo[playerid][AllowedIn] == false) {
		new string[128];
		SendClientMessage(playerid,grey,"You have been automatically kicked. Reason: Server Locked");
		format(string,sizeof(string),"%s ID:%d has been automatically kicked. Reason: Server Locked",PlayerName2(playerid),playerid);
		SaveToFile("KickLog",string);  Kick(playerid);
		SendClientMessageToAll(grey, string); print(string);
	}
	return 1;
}
Reply
#6

You can make a function that sets a timer to call a function that kicks the player without it disconnecting you first.

pawn Код:
KickPlayerFunc(playerid)
{
    Kick(playerid);
    return 1;
}

KickPlayer(playerid)
{
    SetTimerEx("KickPlayerFunc",500,false,"i",playerid);
    return 1;
}
Reply
#7

Quote:
Originally Posted by DTV
Посмотреть сообщение
You can make a function that sets a timer to call a function that kicks the player without it disconnecting you first.

pawn Код:
KickPlayerFunc(playerid)
{
    Kick(playerid);
    return 1;
}

KickPlayer(playerid)
{
    SetTimerEx("KickPlayerFunc",500,false,"i",playerid);
    return 1;
}
where should i put this thing at onplayerconnect?

SOLVED

back to my q uestion,how can i make

onplayerconnect

your account has been banned by Administrator : Reason?
Reply
#8

up

p/s: will delete after finished
Reply
#9

Код:
if (dUserINT(PlayerName2(playerid)).("banned") == 1)
    {
        format(string, sizeof(string), "Your account has been banned by an Admin. Reason: %s", <Your reason variable here>);
        SendClientMessage(playerid, -1, string);
        Kick(playerid);
    }
Don't just copy paste, I'm not sure what your banned reason variable is, in your enum.
Reply
#10

Quote:
Originally Posted by Ritzy
Посмотреть сообщение
Код:
if (dUserINT(PlayerName2(playerid)).("banned") == 1)
    {
        format(string, sizeof(string), "Your account has been banned by an Admin. Reason: %s", <Your reason variable here>);
        SendClientMessage(playerid, -1, string);
        Kick(playerid);
    }
Don't just copy paste, I'm not sure what your banned reason variable is, in your enum.
where can i find it

just found this

PHP код:
enum pInfo
{
    
name[MAX_PLAYER_NAME],
    
bowner,
    
bowned,
    
pass,
    
pcash,
    
bank,
    
team,
    
Jailed,
    
vhpb,
    
weed,
    
gang,
    
condoms,
    
inalcatraz,
    
RFCLevel,
    
AGLevel,
    
B2KLevel,
    
BALevel,
    
BMFLevel,
    
COPLevel,
    
BLevel,
    
PHLevel,
    
KODLevel,
    
XEFLevel,
    
TPKLevel,
    
OSLevel,
    
Registered,
    
LoggedIn,
    
Level,
    
Vip,
    
Muted,
    
Caps,
    
LJailTime,
    
Frozen,
    
FreezeTime,
    
Scores,
    
Kills,
    
Deaths,
    
hours,
    
mins,
    
secs,
    
Cookies,
    
TotalTime,
    
ConnectTime,
     
MuteWarnings,
    
Warnings,
    
Spawned,
    
TimesSpawned,
    
God,
    
DoorsLocked,
    
SpamCount,
    
SpamTime,
    
PingCount,
    
PingTime,
    
BotPing,
    
pPing[PING_MAX_EXCEEDS],
    
blip,
    
blipS,
    
pColour,
    
SpecID,
    
SpecType,
    
bool:AllowedIn,
    
FailLogin,
    
vowned,
    
vowner,
    
vowned2,
    
vowner2,
    
vowned3,
    
vowner3,
    
vowned4,
    
vowner4,
    
vowned5,
    
vowner5,
    
vowned6,
    
vowner6,
    
vowned7,
    
vowner7,
    
vowned8,
    
vowner8,
    
vowned9,
    
vowner9,
    
vowned10,
    
vowner10,
    
vowned11,
    
vowner11,
    
vowned12,
    
vowner12,
    
vowned13,
    
vowner13,
    
vowned14,
    
vowner14,
    
vowned15,
    
vowner15,

PHP код:
dUserSetINT(PlayerName2(playerid)).("banned",0); 
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)