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]); } }
dini_Create(file); dini_Set(file, "Password", inputtext); dini_Set(file, "BanReason", "None");
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; }
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; } |
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);
PlayerInfo[id][pBanReason]= reason;
PlayerInfo[id][pBanned] = 1;
BanEx(id, reason);
}
else
{
SCM(playerid, -1, "You are not an administrator!");
}
return 1;
}
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? |
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", "None");
}
}
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))
{
PlayerInfo[playerid][pBanReason] = dini_Get(file, "BanReason");
}
}
PlayerInfo[playerid][pBanReason] = dini_Get(file, "BanReason");
Код:
PlayerInfo[playerid][pBanReason] == dini_Get(file, "BanReason"); |
LOL
![]() |