Posts: 1,276
Threads: 6
Joined: Aug 2014
1st Read the ini file, find the ip then save it to a variable that is a string.
2nd No that would mean you imputted the 2 arguments, you would do INI_WriteString(File,"ReasonOfBan", ""); //I'm not familiar with Y_INI
Posts: 694
Threads: 2
Joined: Oct 2012
Reputation:
0
pretty much what the other reply you got said, although one thing
,) << means nothing, and almost always generates a argument type/count error, "" means empty/blank string, and 0 means empty variable ( or well you can define an empty string like "N/A" or w/e you like, and strcmp them to see if it's "blank", I usually use this option cuz I'm lazy and don't like checking both arguments of strcmp with isnull("string") )
Posts: 2,593
Threads: 34
Joined: Dec 2007
pawn Код:
new TempIP[16];
#define PATH "/Users/%s.ini"
forward OfflineIP(name[], value[]);
public OfflineIP(name[], value[])
{
INI_String("IP", TempIP, sizeof(TempIP));
return 1;
}
CMD:unbanip(playerid, params[])
{
if(isnull(params)) SendClientMessage(playerid,-1,"Usage: /unbanip [player nick]");
else if(!(2 < strlen(params) < MAX_PLAYER_NAME)) SendClientMessage(playerid,-1,"Error: Incorrect name lenght.");
else
{
new str[40];
format(str,sizeof(str),PATH,params);
if(!INI_ParseFile(str, "OfflineIP")) SendClientMessage(playerid,-1,"Error: Account doesn't exists.");
else
{
printf("unbanip %s",TempIP);
format(str, sizeof(str),"unbanip %s", TempIP);
SendRconCommand(str);
//SendRconCommand("reloadbans");
}
}
return 1;
}
Posts: 2,593
Threads: 34
Joined: Dec 2007
I'm using this and result is:
pawn Код:
[31/10/15 22:56:17] unbanip 127.105.22.109
file content
pawn Код:
[data]
Password = 234
Cash = 0
IP = 127.105.22.109
Kills = 0
Deaths = 0
y_ini verion very old (only for testing, i'm not using YSI)
YSI version 1.04.0000
Posts: 2,593
Threads: 34
Joined: Dec 2007
pawn Код:
CMD:ban(playerid,parmas[])
{
new tid,res[125];
if(sscanf(parmas,"us[125]",tid,res)) SendClientMessage(playerid,-1,"/ban [id] [reason]");
else if(tid == INVALID_PLAYER_ID) SendClientMessage(playerid,-1,"ID not connected.");
else
{
new ip[16],str[30];
GetPlayerIp(tid,ip,sizeof(ip));
new INI:File = INI_Open(UserPath(tid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Banned",1);
INI_WriteString(File,"BanAdmin",GetPlayerNameEx(playerid));
INI_WriteString(File,"BanReason",res);
INI_WriteString(File,"IP",ip);
INI_Close(File);
format(str, sizeof(str),"banip %s", ip);
SendRconCommand(str);
SendRconCommand("reloadbans");
}
return 1;
}