storing offline player ip into a variable -
SalmaN97 - 23.10.2015
hello guys i want to know if its possible to get an offline player ip with yini i already stored the ip i just want to store the ip into a variable so i can unban the ip like:
PHP код:
format(string, sizeof(string),"unbanip %s", IpStoreVariable); //
SendRconCommand(unbanstring);
SendRconCommand("reloadbans");
One more question, if i want to make a saving string blank should i do it like
PHP код:
INI_WriteString(File,"ReasonOfBan", );
Re: storing offline player ip into a variable -
J0sh... - 23.10.2015
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
Re: storing offline player ip into a variable -
PrO.GameR - 23.10.2015
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") )
Re: storing offline player ip into a variable -
SalmaN97 - 29.10.2015
Quote:
Originally Posted by Jamester
1st Read the ini file, find the ip then save it to a variable that is a string.
|
Thats what i dont know if you can show example ill appreciate that
Re: storing offline player ip into a variable -
SalmaN97 - 29.10.2015
no one?
Re: storing offline player ip into a variable -
Jefff - 29.10.2015
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;
}
Re: storing offline player ip into a variable -
SalmaN97 - 31.10.2015
Quote:
Originally Posted by Jefff
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; }
|
hey jeff thanks for trying to help but its not working it will not unban the ip i also tried this
PHP код:
format(str, sizeof(str),"unbanip %s", TempIP);
SendClientMessage(playerid,-1 , str);
but i did not see the ip only " unbanip "
Re: storing offline player ip into a variable -
Jefff - 31.10.2015
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
Re: storing offline player ip into a variable -
SalmaN97 - 01.11.2015
Quote:
Originally Posted by Jefff
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
|
Its looks like my ban command not saving ban reason and banned player ip this is my command
PHP код:
CMD:ban(playerid,parmas[])
{
new tid,res[90],ppp[50], banstring[50];
if(sscanf(parmas,"us",tid,res) || isnull(parmas))return SendClientMessage(playerid,-1,"/ban [id] [reason]");
GetPlayerIp(tid,ppp,sizeof(ppp));
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",ppp);
INI_Close(File);
format(banstring, sizeof(banstring),"banip %s", ppp);
SendRconCommand(banstring);
SendRconCommand("reloadbans");
return 1;
}
And i get this:
Код:
Banned = 0
BanAdmin =
BanReason =
IP =
Re: storing offline player ip into a variable -
Jefff - 01.11.2015
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;
}