banmode
#1

hello
how to make a banmode when you get banned to show the player the dialog that you are baned
from XXX Admin
Reason : xxx
Date : xx/xx/xxxx ??

my script

Код:
CMD:ban(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 5 || PlayerInfo[playerid][pBanAppealer] >= 1)
	{
		new string[128], giveplayerid, reason[64];
		if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ban [playerid/partofname] [reason]");

        if(AntiAdv(playerid, params)) return 1;
		if(IsPlayerConnected(giveplayerid))
		{
			if(PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
			{
				if(AdminDuty[playerid] == 1)
				{
					new username[MAX_PLAYER_NAME];
					GetPVarString(playerid, "TempNameName", username, sizeof(username));
					SetPVarInt(playerid, "TempName", 0);
					SetPlayerName(playerid, username);
				}
				format(string, sizeof(string), "AdmCmd: %s has been auto-banned, reason: Trying to /ban a higher admin.", PlayerInfo[playerid][pAdminName]);
				ABroadCast(COLOR_YELLOW,string,2);
				PlayerInfo[playerid][pBanned] = 1;
				new ip[32];
				GetPlayerIp(playerid,ip,sizeof(ip));
				AddBan(ip);
				Kick(playerid);
				return 1;
			}
			else
			{
				new playerip[32];
				GetPlayerIp(giveplayerid, playerip, sizeof(playerip));

				if(AdminDuty[giveplayerid] == 1)
				{
					new username[MAX_PLAYER_NAME];
					GetPVarString(giveplayerid, "TempNameName", username, sizeof(username));
					SetPVarInt(giveplayerid, "TempName", 0);
					SetPlayerName(giveplayerid, username);

					format(string, sizeof(string), "AdmCmd: %s(IP:%s) Eshte Ber Ban Nga %s, Arsyja: %s", PlayerInfo[giveplayerid][pAdminName], playerip, GetPlayerNameEx(playerid), reason);
					Log("logs/ban.log", string);
					format(string, sizeof(string), "AdmCmd: %s Eshte Bere Ban Nga %s, Arsyja: %s", PlayerInfo[giveplayerid][pAdminName], GetPlayerNameEx(playerid), reason);
				}
				else
				{
					format(string, sizeof(string), "AdmCmd: %s(IP:%s) Eshte Bere Ban Nga %s, Arsyja: %s", GetPlayerNameEx(giveplayerid), playerip, GetPlayerNameEx(playerid), reason);
					Log("logs/ban.log", string);
					format(string, sizeof(string), "AdmCmd: %s Eshte Bere Ban Nga %s, Arsyja: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
				}


				SendClientMessageToAllEx(COLOR_LIGHTRED, string);
				PlayerInfo[giveplayerid][pBanned] = 1;
				new ip[32];
				GetPlayerIp(giveplayerid,ip,sizeof(ip));
				AddBan(ip);
				Kick(giveplayerid);
				return 1;
			}

		} else SendClientMessage(playerid, COLOR_GRAD1, "Invalid player specified.");
	}
	return 1;
}
Reply
#2

anyone ?
Reply
#3

It is very easy. Firstly, get all the required functions i.e GetPlayerIp and all. Put them all in a format like the example given below:

Код:
new string[128 + MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME], ip[20];
GetPlayerIp(playerid, ip, sizeof(ip));
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "You are banned from this server! \n Your IP: %i \n Your Name: %s", ip, pName);
ShowPlayerDialog(playerid, 32, DIALOG_STYLE_MSGBOX, "Ban Notice", string, "Ok", "");
This is just an example of the code!
Reply
#4

Function kick is a priority for server, therefore you need to delay it's priority if you want to show anything to player, if not the server will kick him before he gets his msg.
( that means calling it with a timer of at least 1 ms [I use it with 1 ms and it works, some ppl use it with 2x player's ping]) as for the dialog, ^^^ check top post.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)