Problem BanReason DINI
#1

I create the account and the file is created PlayerName.ini with BanReason=None. How to enter /q this removed "None" BanReason= . If he bans someone, BanReason saves and load(BanReason=TestBan). Only there is a problem. The player is not banned and has BanReason=None. But when the player types /q, is removed "None" and is saved BanReason= . Only "None" is not saved w BanReason when leaving the server /q . How to repair?

Код:
enum pInfo
{
    pBanReason[50]
   
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Код:
LoadAccounts(playerid)
{
    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    if(dini_Exists(file))
    {
        format(PlayerInfo[playerid][pBanReason], 50, "%s", dini_Get(file, "BanReason"));
    }
}
SaveAccounts(playerid)
{
    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    if(dini_Exists(file))
    {
      	dini_Set(file, "BanReason", PlayerInfo[playerid][pBanReason]);
    }
}
OnDialogResponse
Код:
dini_Create(file);
dini_Set(file, "Password", inputtext);
dini_Set(file, "BanReason", "None");
Reply
#2

Hey!

Can you show us your ban command, please?
Reply
#3

It's good for me. Only there is a problem, the player leaves /q and changes from BanReason=None to BanReason=
Код:
CMD:ban(playerid,params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 1)
	{
		new string[256], id, reason[50];
		if(sscanf(params, "us[50]", id, reason)) return SendClientMessage(playerid, COLOR_GREY, "Usage /ban [ID] [Reason]");
		if(!IsPlayerConnected(id) || id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "There is no such player.");
		format(string, sizeof(string), "AdmCmd: %s has been banned from Admin %s, Reason: %s.", pName(id), pName(playerid), reason);
		SendClientMessageToAll(COLOR_LIGHTRED, string);
		format(PlayerInfo[playerid][pBanReason], 128, "%s", reason);
		PlayerInfo[id][pBanned] = 1;
		BanEx(id, reason);
	}
	else
	{
		SCM(playerid, -1, "You are not an administrator!");
	}
	return 1;
}
Reply
#4

Quote:
Originally Posted by KamilPolska
Посмотреть сообщение
It's good for me. Only there is a problem, the player leaves /q and changes from BanReason=None to BanReason=
Код:
CMD:ban(playerid,params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 1)
	{
		new string[256], id, reason[50];
		if(sscanf(params, "us[50]", id, reason)) return SendClientMessage(playerid, COLOR_GREY, "Usage /ban [ID] [Reason]");
		if(!IsPlayerConnected(id) || id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "There is no such player.");
		format(string, sizeof(string), "AdmCmd: %s has been banned from Admin %s, Reason: %s.", pName(id), pName(playerid), reason);
		SendClientMessageToAll(COLOR_LIGHTRED, string);
		format(PlayerInfo[id][pBanReason], 128, "%s", reason);
		PlayerInfo[id][pBanned] = 1;
		BanEx(id, reason);
	}
	else
	{
		SCM(playerid, -1, "You are not an administrator!");
	}
	return 1;
}
try this
PHP код:
CMD:ban(playerid,params[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 1)
    {
        new 
string[256], idreason[50];
        if(
sscanf(params"us[50]"idreason)) return SendClientMessage(playeridCOLOR_GREY"Usage /ban [ID] [Reason]");
        if(!
IsPlayerConnected(id) || id == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_GREY"There is no such player.");
        
format(stringsizeof(string), "AdmCmd: %s has been banned from Admin %s, Reason: %s."pName(id), pName(playerid), reason);
        
SendClientMessageToAll(COLOR_LIGHTREDstring);
        
PlayerInfo[id][pBanReason]= reason;
        
PlayerInfo[id][pBanned] = 1;
        
BanEx(idreason);
    }
    else
    {
        
SCM(playerid, -1"You are not an administrator!");
    }
    return 
1;

Reply
#5

Okay. It works. CMD:ban works well with BanReason. Only there is a problem. Player will register and the PlayerName.ini file is created.
Ban=0
BanReason=None
As a player leaves the server /q
This is so:
Ban=0
BanReason=
Removed "None". How to repair?
Reply
#6

Quote:
Originally Posted by KamilPolska
Посмотреть сообщение
Okay. It works. CMD:ban works well with BanReason. Only there is a problem. Player will register and the PlayerName.ini file is created.
Ban=0
BanReason=None
As a player leaves the server /q
This is so:
Ban=0
BanReason=
Removed "None". How to repair?
PHP код:
SaveAccounts(playerid)
{
    new 
name[MAX_PLAYER_NAME], file[256];
    
GetPlayerName(playeridnamesizeof(name));
    
format(filesizeof(file), SERVER_USER_FILEname);
    if(
dini_Exists(file))
    {
          
dini_Set(file"BanReason""None");
    }
}
LoadAccounts(playerid)
{
    new 
name[MAX_PLAYER_NAME], file[256];
    
GetPlayerName(playeridnamesizeof(name));
    
format(filesizeof(file), SERVER_USER_FILEname);
    if(
dini_Exists(file))
    {
        
PlayerInfo[playerid][pBanReason] = dini_Get(file"BanReason");
    }

Reply
#7

Error: error 047: array sizes do not match, or destination array is too small
Код:
PlayerInfo[playerid][pBanReason] = dini_Get(file, "BanReason");
Reply
#8

Quote:
Originally Posted by ProScripter
Посмотреть сообщение
Код:
PlayerInfo[playerid][pBanReason] == dini_Get(file, "BanReason");
LOL? I hope you're not serious, that's not how you store values into arrays.
Reply
#9

Quote:
Originally Posted by fiki574
Посмотреть сообщение
LOL? I hope you're not serious, that's not how you store values into arrays.
No, no. Only I can not solve the problem.
The player registers and creates BanReason=None
When the player leaves /q it saves: BanReason=
How to change eg. on BanReason=Test_None this saves and loads.
with CMD:ban works fine, gives some reason it saves and loads.
He only wants to be on BanReason=None all the time when the player leaves
Reply
#10

Do you set pBanReason when player registers?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)