Y_ini help with my ban system
#1

So I am currently making a DM server for a client , he requested it in Y_ini , I had no problem because I just started learning MySQL a couple weeks ago, anyways I made a ip ban system for him and this is how it works, it sets the players account to banned and then saves the ip address in another folder but save the reason/admin name/date to the account folder(two different folders) and when a player joins a ban check gets done on the account and ifthe IP is found in the IP ban folder(IP Bans in scriptfiles) it then returns the reason/admin name/ date of ban(located in the User folder), it works perfectly as intended, but now I want to unban the players ip but I don't know if it is possible to be done this way. I want when the admin enters the players Ip address it would then checks the Users folder to see if any of the players account that Is registered is linked to the inputted ip address and if so , it should edit the players account file to set the account as unbanned.

MAJOR UPDATE:

I changed the saving method to save in 1 folder as a smart person would do but now iv'e worked with loading saved y_ini strings for years now in many projects anyways, I wonder why this one is not loading as you can see in the screen shot but yet it writes to the player's file successfully but wont load.

PHP код:

//writing the data to the saved file
//Under the /banip command
new INI:IPFile INI_Open(IPPath(targetid));
INI_SetTag(IPFile,"IPData");
INI_WriteString(IPFile,"IPBannedBy",aname);
INI_WriteString(IPFile,"IPBannedRea",reason);
INI_WriteString(IPFile,"IPBannedDate",string);
INI_Close(IPFile);
//loading the stored data to the following (admin/date/rea)
forward LoadIPBan(playerid,name[],value[]);
public 
LoadIPBan(playerid,name[],value[])
{
    
INI_String("IPBannedBy",admin,24);
    
INI_String("IPBannedRea",rea,64);
    
INI_String("IPBannedDate",bdate,64);
    return 
1;
}
//calling the LoadIPBan function here
//Under loadacc function
INI_ParseFile(IPPath(playerid), "LoadIPBan_%s", .bExtra true, .extra playerid); 
If you need to see more code just ask and I will post it as soon as possibly



Please ignore the fact that it should have been written as "IPBannedBy","IPBannedDate","IPBannedRea", but yet in the file it says "BannedRea","BannedDate","BannedBy", because I have updated it to the right format

Reply
#2

bump
Reply
#3

PHP код:
function LoadAcc(playerid)
{
    
NameCheck(playerid);
    if(
fexist(UserPath(playerid)))
    {
        
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
            
INI_ParseFile(IPPath(playerid), "LoadIPBan_%s", .bExtra true, .extra playerid);
        if(!
strcmp(RPIP(playerid), pInfo[playerid][pIP]))
        {
             
BanCheck(playerid);
            if(
tInfo[playerid][ClearLog] == 0)
            {
                
SendClientMessage(playerid,COL_NOTIFY,"Your account has been automatically logged in.");
                
SendClientMessage(playerid,-1,"{F52C2C}=========================================================");
                
SendClientMSG(playerid,-1,"{F52C2C}[MOTD]:{D17777} %s",MOTDInfo[MOTDstr]);
                
SendClientMessage(playerid,-1,"{F52C2C}=========================================================");
                if(
pInfo[playerid][Email] == 0)
                {
                    
SendClientMessage(playerid,COL_NOTIFY,"Your account doesn't have an assigned Email Address. Use /assignemail to link one to this account.");
                    
SendClientMessage(playerid,COL_NOTIFY,"This Email Address will only be used for account recovery purposes ONLY.");
                }
             }
        }
        else
          {
            
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""COL_WHITE"...Login...",""COL_WHITE"This account is registered.Please enter your password below","Login","Quit");
           }
    }
    else
    {
         
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT,""COL_WHITE"...Registration...",""COL_WHITE"To register this account please enter your desired password below.","Register","Quit");
    }
    return 
1;
}
//banchecks here
        
if(fexist(IPPath(playerid)))
        {
            
tInfo[playerid][ClearLog] = 1;
            
SendClientMessage(playeridCOLOR_SERVER"Your account has been IP Banned from the server.");
            
SendClientMessage(playeridCOL_ERROR,"============"SERVER_NAME"=============");
            
SendClientMSG(playeridCOLOR_SERVER,"Account Name: %s(ID:%d) ",ReturnPlayerName(playerid),playerid);
            
SendClientMSG(playeridCOLOR_SERVER,"IP Address: %s ",RPIP(playerid));
            
SendClientMSG(playeridCOLOR_SERVER,"Banned By: %s ",IPinfo[IPBannedBy]);
            
SendClientMSG(playeridCOLOR_SERVER,"Banned Date: %s ",IPinfo[IPBannedDate]);
            
SendClientMSG(playeridCOLOR_SERVER,"Reason: %s ",IPinfo[IPBannedRea]);
            
SendClientMessage(playeridCOL_ERROR,"======================================");
            
SendServerMSG(COLOR_SERVER,"%s(ID:%d) has been kicked from the server. [Reason: IP Banned] ",ReturnPlayerName(playerid),playerid);
            
GameTextForPlayer(playerid"~r~Banned",2500,3);
            
SetTimerEx("KickPlayer",50,false,"d",playerid);
        }
//the update version
functionLoadIPBan(playerid,name[],value[])
{
    
INI_String("IPBannedBy",IPinfo[IPBannedBy],64);
    
INI_String("IPBannedRea",IPinfo[IPBannedRea],128);
    
INI_String("IPBannedDate",IPinfo[IPBannedDate],128);
    return 
1;

Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
You are calling `INI_ParseFile` with the function name `LoadIPBan_%s`, but the function itself is just called `LoadIPBan`. They need to match with tags, so the function should be called `LoadIPBan_IPData`.
I had solved this I realized the same thing a couple hours after my last reply. Anyways that's for the help and I will still rep+ you because it seem to be a big thing on forums to rep+ , but thank u mate.

Also I have another question, How would I go about retrieving information from offline players, for example I want to know your IP address which is saved in the server User files, how would I go about doing such thing with y_ini

NICE TO MEET U ******
Reply
#5

bump
Reply
#6

pawn Код:
new BanReason[70], BanIP[24], AdminName[MAX_PLAYER_NAME];

public LoadBanData(name[], value[])
{
    INI_String("Reason", BanReason, sizeof(BanReason));
    INI_String("AdminBan", AdminName, sizeof(AdminName));
    INI_String("BanIP", BanIP, sizeof(BanIP));
    return 1;
}
Usage:

pawn Код:
INI_ParseFile(UserPath(playerid), "LoadBanData");
{
    printf("* %d is banned. Reason: %s - By admin %s - Player banned IP: %s.", playerid, BanReason, AdminName, BanIP);
}
Not tested.

Obviously you have to change the value in the quotes with your ban informations.
Reply
#7

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
pawn Код:
new BanReason[70], BanIP[24], AdminName[MAX_PLAYER_NAME];

public LoadBanData(name[], value[])
{
    INI_String("Reason", BanReason, sizeof(BanReason));
    INI_String("AdminBan", AdminName, sizeof(AdminName));
    INI_String("BanIP", BanIP, sizeof(BanIP));
    return 1;
}
Usage:

pawn Код:
INI_ParseFile(UserPath(playerid), "LoadBanData");
{
    printf("* %d is banned. Reason: %s - By admin %s - Player banned IP: %s.", playerid, BanReason, AdminName, BanIP);
}
Not tested.

Obviously you have to change the value in the quotes with your ban informations.
Not sure if you realise but I had already solve this issue. I just want to know how to get information of an offline player to show to admins In game when they cause a command like /getinfo [username] (player must be offline)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)