Ban reason help
#1

Код:
enum pInfo
{
	bReason[128],

}
Код:
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(PlayerInfo[playerid][bReason], 50, params[2]);
				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");
}
OnPlayerConnect

Код:
    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),"Name: %s \nID:%d was auto kicked. \nReason: %s \n",PlayerName,playerid,PlayerInfo[playerid][bReason]);
		ShowPlayerDialog(playerid,6990,DIALOG_STYLE_MSGBOX,"Account Info",string,"Quit","");
		SaveToFile("KickLog",string);  SetTimerEx("KickPlayer",150,false,"i",playerid);// Kicks player in 500ms
    }
it wont show banned reason

Reply
#2

Try to replace PlayerInfo[playerid][bReason] with Params[2]
Reply
#3

Quote:
Originally Posted by Hunud
Посмотреть сообщение
Try to replace PlayerInfo[playerid][bReason] with Params[2]
so,what should i do on playerconnect?
Reply
#4

Use sscanf.
Reply
#5

You can't do it this way. PlayerInfo is a temporary array.
Store the ban reason inside player user and load it from there instead.
Reply
#6

Quote:
Originally Posted by jlalt
Посмотреть сообщение
You can't do it this way. PlayerInfo is a temporary array.
Store the ban reason inside player user and load it from there instead.
how

Location : ladmin\users


ip=192.168.0.101
registered=1
RegisteredDate=5/1/2018
loggedin=0
banned=1
bReason=PadanMuka
level=0
vip=0
RFClevel=0
AGlevel=0
B2Klevel=0
BAlevel=0
BMFlevel=0
COPlevel=0
PHlevel=0
KODlevel=0
XEFlevel=0
OSlevel=0
TPKlevel=0
hours=0
minutes=0
seconds=6
Blevel=0
LastOn=5.1.2018
money=100000
Scores=0
kills=0
deaths=0
Cookies=0
Bank=0
weed=0
Gang=0
Condoms=0
inalcatraz=0
x1=0
y1=0
z1=0
interior1=0
weap1=0
weap1ammo=0
weap2=0
weap2ammo=0
weap3=0
weap3ammo=0
weap4=0
weap4ammo=0
weap5=0
weap5ammo=0
weap6=0
weap6ammo=0
health=0
armour=0
TimesOnServer=1
bowner=0
bowned=0
vowned=0
vowner=0
vowned2=0
vowner2=0
vowned3=0
vowner3=0
vowned4=0
vowner4=0
vowned5=0
vowner5=0
vowned6=0
vowner6=0
vowned7=0
vowner7=0
vowned8=0
vowner8=0
vowned9=0
vowner9=0
vowned10=0
vowner10=0
vowned11=0
vowner11=0
vowned12=0
vowner12=0
vowned13=0
vowner13=0
vowned14=0
vowner14=0
vowned15=0
vowner15=0
Houseid=-255
Rentid=-255
SpawnX=0
SpawnY=0
SpawnZ=0
SpawnInt=0
Reply
#7

Im not sure how you are saving PlayerInfo[playerid][bReason]

But you can call the data like this: INI_Get(PlayerFile,"Reason")

code:
Код:
new PlayerFile[50];
format(PlayerFile,sizeof(PlayerFile),"Accounts/%s.ini",params);

format(string,sizeof(string),"Name: %s \nID:%d was auto kicked. \nReason: %s \n",PlayerName,playerid,INI_Get(PlayerFile,"Reason"));
Reply
#8

Quote:
Originally Posted by jasperschellekens
Посмотреть сообщение
Im not sure how you are saving PlayerInfo[playerid][bReason]

But you can call the data like this: INI_Get(PlayerFile,"Reason")

code:
Код:
new PlayerFile[50];
format(PlayerFile,sizeof(PlayerFile),"Accounts/%s.ini",params);

format(string,sizeof(string),"Name: %s \nID:%d was auto kicked. \nReason: %s \n",PlayerName,playerid,INI_Get(PlayerFile,"Reason"));
how,.where can i learn
Reply
#9

Quote:
Originally Posted by KyNe
Посмотреть сообщение
how,.where can i learn
so as i understand correctly you don't save this reason?
When it isn't saved, you can not get this data. is has to be saved somewhere.

example on saving in y_ini: (requires folder Banishments in scriptfiles)

PHP код:
SaveBanishments(playerid)
{
new 
file[64];
format(filesizeof(file), "Banishments/%s.ini"GetName(playerid));
INI_IntSet(file,"bReason",PlayerInfo[playerid][bReason]);
return 
1;

Onplayerdisconnect:
PHP код:
SaveBanishments(playerid); 
Example on loading it into your script.

PHP код:
new PlayerFile[50];
format(PlayerFile,sizeof(PlayerFile),"Banishments/%s.ini",params);
format(string,sizeof(string),"Name: %s \nID:%d was auto kicked. \nReason: %s \n",PlayerName,playerid,INI_Get(PlayerFile,"bReason")); 
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)