15.08.2014, 16:06
Hello there is a command i have created which should unban-ip offline user, by getting IP from file. used many methods but the IP doesn't showup on the test prints..
This command doesn't print any IP.. can anyone tell me why?
pawn Код:
new uIP[16];
pawn Код:
forward LoadIP(name[],value[]);
public LoadIP(name[],value[])
{
INI_String("IP", uIP, 16);
return 1;
}
pawn Код:
CMD:unban(playerid, params[])
{
new playerb[32], str[256];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 5) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(sscanf(params, "s[32]", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /uban [name]");
//if(RPIDFN(playerb) != INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "Player is connected to the server.");
format(str, sizeof(str), "UserDB/%s.ini", playerb);
if(!dini_Exists(str)) return SendClientMessage(playerid, COLOR_GREY, "Player name not found.");
// Normal Unban
new INI:File = INI_Open(str);
INI_SetTag(File,"PlayerData");
INI_WriteString(File, "BanReason", "None");
INI_WriteString(File, "BannedBy", "None");
INI_WriteInt(File, "Banned", 0);
INI_Close(File);
// Ban.cfg Unban
INI_ParseFile(str, "LoadIP");
new File:ban = fopen("ban.cfg", io_read);
new idx = 1;
while(fread(ban, uIP))
{
if(!strcmp(uIP, str, true, strlen(uIP)))
{
fdeleteline("ban.cfg", idx);
//done = 1;
}
idx++;
}
fclose(ban);
//
// ban.samp Unban
format(str, sizeof(str), "unbanip %s", uIP);
SendRconCommand(str);
printf(str);
SendRconCommand("reloadbans");
format(str, sizeof(str), "{F81414}AdmWarn: %s has {DAE368}unbanned{F81414} %s. [IP: %s]", RPN(playerid), playerb, uIP);
SendClientMessageToAll(COLOR_YELLOW, str);
return 1;
}