08.09.2012, 13:21
How can I use INI_String with offline users in y_ini?
Thanks,tyler.
Thanks,tyler.
you can make ban log... which logs all banned players... you wouldn't need to mess with thousands of files, only with one.
|
CMD:unban(playerid,params[])
{
new account[25];
if(!IsPlayerAdmin(playerid) && Player[playerid][Admin] < 7) return SendClientMessage(playerid, red, "ERROR: {FFFFFF}You Have Entered An Invalid Command. Please Read {00FF00}/CMDS{FFFFFF}.");
if(sscanf(params,"s[25]",account)) return SendClientMessage(playerid, red, "SYNTAX ERROR: {00FF00}/UNBAN {FFFF00}<Account>");
new string[45];
format(string,sizeof(string),PATH,account);
if(!fexist(string)) return SendClientMessage(playerid, red, "ERROR: {FFFFFF}This Player Account Does Not Exist.");
INI_ParseFile(string, "LoadBanCheck_%s", .bExtra = true, .extra = playerid);
if(Player[playerid][Banned] == 0) return SendClientMessage(playerid, red, "ERROR: {FFFFFF}This Player Account Is Not Banned.");
new INI:File = INI_Open(string);
INI_WriteInt(File, "Banned", 0);
INI_Close(File);
format(string,sizeof(string),"The Account Of %s Has Been Unbanned.",account);
SendClientMessage(playerid, yellow, string);
format(string,sizeof(string),"Administrator %s Has Unbanned The Account Of %s.",pName(playerid), account);
SendAdminMessage(orange, string);
Player[playerid][Banned] = 0;
Player[playerid][BanReason] = 0;
return 1;
}
forward LoadBanCheck_data(playerid,name[],value[]);
public LoadBanCheck_data(playerid,name[],value[])
{
INI_Int("Banned",Player[playerid][Banned]);
INI_Int("BanReason",Player[playerid][BanReason]);
return 1;
}
I know exactly what you mean, and the situation you're in. It took me a while to figure it out but I finally got it.
Here's an example of unbanning an offline account. pawn Код:
pawn Код:
|
CMD:isbanned(playerid,params[])
{
new account[25],string[25],msg[124];
if(sscanf(params,"s[25]",account)) return ShowUsageMessage(playerid,"/isbanned [name]");
format(string,sizeof(string),"Users/%s.ini",account);
if(!fexist(string)) return SendClientMessage(playerid,-1,"Account does not exist");
new INI:file = INI_Open(string);
INI_Int(file,"Banned",pInfo[playerid][Banned]);// I need to save if hes banned somewhere
INI_Close(file);
format(msg,sizeof(msg),"Account status:%d (1 - banned 0 - not banned",/*Where I saved if hes banned */);
SendClientMessage(playerid,-1,msg);
return 1;
}
CMD:isbanned(playerid,params[])
{
new account[25];
new string[40];
if(sscanf(params,"s[25]",account)) return ShowUsageMessage(playerid,"/isbanned [name]");
format(string,sizeof(string),"Users/%s.ini",account);
if(!fexist(string)) return SendClientMessage(playerid,-1,"Account does not exist");
INI_ParseFile(string, "CheckBan_%s", .bExtra = true, .extra = playerid);
new Status[15];
new msg[60];
if(pInfo[playerid][Banned] == 0)
{
Status = "Not Banned";
}
else if(pInfo[playerid][Banned] == 1)
{
Status = "Banned";
}
format(msg, sizeof(msg), "%s | Account Status: %s |",Status);
pInfo[playerid][Banned] = 0;
SendClientMessage(playerid,-1,msg);
return 1;
}
forward CheckBan_data(playerid,name[],value[]);
public CheckBan_data(playerid,name[],value[])
{
INI_Int("Banned",pInfo[playerid][Banned]);
}