INI_ParseFIle not working? [Rep+4]
#1

Recently I have run some tests on my server and found that none of my INI_ParseFile functions are working. I have just made a quick housing system which is not yet finished, but after I create my house, I try to load it under OnGameModeInit but I tried debugging it by adding print lines, however those do not show up.

Under OnGameModeInit()
pawn Код:
for(new i = 0; i < MAX_HOUSES; i++)
    {
        new string[30];
        format(string,sizeof(string),HOUSEPATH,i);
        if(fexist(string))
        {
            print("File exists."); //Debug
            INI_ParseFile(string, "LoadHouse_%s", .bExtra = true, .extra = i);
            if(House[i][Owned] == 0)
            {
                House[i][Pickup] = CreateDynamicPickup(1272, 1, House[i][PosX], House[i][PosY], House[i][PosZ]);
                print("Pickup Created"); //Debug
            }
            else
            {
                House[i][Pickup] = CreateDynamicPickup(1273, 1, House[i][PosX], House[i][PosY], House[i][PosZ]);
                print("Pickup Created Owned"); //Debug
            }
            format(string,sizeof(string),"House: %s\nOwner: %s\nID: %d",House[i][Name],House[i][OwnerName],i);
            House[i][Label] = CreateDynamic3DTextLabel(string, green, House[i][PosX], House[i][PosY], House[i][PosZ], 100.00);
            print("Text label created"); //Debug
            continue;
        }
        continue;
    }
Here's the function that's not working:
pawn Код:
forward LoadHouse_data(houseid,name[],value[]);
public LoadHouse_data(houseid,name[],value[])
{
    INI_Int("HouseName",House[houseid][Name]);
    printf("House id %d Name loaded", houseid); //Debug
    INI_Float("X",House[houseid][PosX]);
    INI_Float("Y",House[houseid][PosY]);
    INI_Float("Z",House[houseid][PosZ]);
    INI_Int("Owned",House[houseid][Owned]);
    INI_Int("OwnerName",House[houseid][OwnerName]);
    INI_Int("Key1",House[houseid][Key1]);
    INI_Int("Key2",House[houseid][Key2]);
    INI_Int("Key3",House[houseid][Key3]);
    return 1;
}
It should be saying 'House ID... Name loaded.'
This is what it currently says:
Код:
[23:30:53] Number of vehicle models: 0
[23:30:53] Text label created
[23:30:53] Pickup Created
[23:30:53] File exists.
[23:30:53] Text label created
[23:30:53] Pickup Created
[23:30:53] File exists.
[23:30:53] Text label created
[23:30:53] Pickup Created
[23:30:53] File exists.
[23:30:53] Text label created
[23:30:53] Pickup Created
[23:30:53] File exists.
[23:30:53] Text label created
[23:30:53] Pickup Created
[23:30:53] File exists.
[23:30:53] Text label created
[23:30:53] Pickup Created
[23:30:53] File exists.

[23:30:53]   Loaded 0 filterscripts.
[23:30:53] ---------------
[23:30:53] Filterscripts
[23:30:53] 
[23:30:53] 
[23:30:53]  Loaded: samp.ban
[23:30:53] --------
[23:30:53] Ban list
[23:30:53] 

[23:30:53]  Loaded 3 plugins.
[23:30:53]   Loaded.
[23:30:53]  
[23:30:53]  ==================
[23:30:53]  
[23:30:53]   Whirlpool loaded
[23:30:53]  
[23:30:53]  ==================
[23:30:53]  
[23:30:53]  Loading plugin: Whirlpool.so
[23:30:53]   Loaded.

*** Streamer Plugin v2.6.1 by Incognito loaded ***

[23:30:53] 
[23:30:53]  Loading plugin: streamer.so
[23:30:53]   Loaded.

[23:30:53]  ===============================

[23:30:53]    0.3d-R2 500 Players "dnee"

[23:30:53]    © 2009 Alex "******" Cole

[23:30:53]       sscanf plugin loaded.     

[23:30:53]  ===============================

[23:30:53] 
[23:30:53]  Loading plugin: sscanf.so
[23:30:53] --------------
[23:30:53] Server Plugins
[23:30:53] 

v0.3e-R2, ©2005-2012 SA-MP Team
----------------------
SA-MP Dedicated Server

----------
Loaded log file: "server_log.txt".
----------
Also, my user stats will not load, and I'm not sure why. Once again, the INI_ParseFile function is failing.
Function:
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",Player[playerid][Password]);
    print("Password Loaded"); //Debug
    INI_Int("Cash",Player[playerid][Cash]);
    print("Cash Loaded"); //Debug
    INI_Int("Admin",Player[playerid][Admin]);
    print("Admin Loaded"); //Debug
    INI_Int("Kills",Player[playerid][Kills]);
    INI_Int("Deaths",Player[playerid][Deaths]);
    INI_Int("VIP",Player[playerid][pVip]);
    INI_Int("Score",Player[playerid][Score]);
    INI_Int("Helper",Player[playerid][Helper]);
    INI_Int("Builder",Player[playerid][Builder]);
    INI_Int("Member",Player[playerid][Member]);
    print("Member Loaded"); //Debug
    INI_Int("BanReason",Player[playerid][BanReason]);
    INI_Int("LastLogin",Player[playerid][LastLogin]);
    INI_Int("Caged",Player[playerid][Caged]);
    INI_Int("Muted",Player[playerid][Muted]);
    INI_Int("Banned",Player[playerid][Banned]);
    print("Ban Loaded"); //Debug
    return 1;
}
Login and register dialogs:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case REGISTER:
        {
            if(!response)
            {
                new string[105];
                SendClientMessage(playerid, red, "You Have Been Kicked From The Server. You MUST Register And Login Before Playing.");
                format(string,sizeof(string),"** Player %s Has Been Kicked From The Server | Reason: Failed To Register/Login **",pName(playerid));
                SendClientMessageToAll(red, string);
                return Kick(playerid);
            }
            if(response)
            {
                if(strfind(pName(playerid), "[AWP]", true) != -1)
                {
                    if(Player[playerid][Member] < 1)
                    {
                        new string[105];
                        SendClientMessage(playerid, red, "Only Authorised AWP Clan Members Can Wear The [AWP] Tag.");
                        SendClientMessage(playerid, orange, "If You Think You Are Receiving This Message In Error, Please Contact An AWP Clan Administrator.");
                        format(string,sizeof(string),"%s Has Been Kicked From The Server Automatically | Reason: Unauthorised [AWP] Tag");
                        SendClientMessageToAll(red, string);
                        return Kick(playerid);
                    }
                }
                new buf[129];
                if(!strlen(inputtext) || strlen(inputtext) < 4 || strlen(inputtext) > 24) return ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_INPUT, "{FF0000}INVALID PASSWORD","{FF0000}You Have Entered An Invalid Password.\n{00FF00}Please Note: Passwords Must Be At Least 4 To 24 Characters Long.\n{00F0F0}Please Enter Your Desired Password Below:","Accept","Leave");
                WP_Hash(buf, sizeof(buf), inputtext);
                printf("String %s Created", buf); //Debug
                new INI:File = INI_Open(UserPath(playerid));
                printf("User File Opened"); //Debug
                INI_WriteString(File,"Password",buf);
                printf("String %s Saved to User File",buf); //Debug
                INI_Close(File);
                printf("File Closed."); //Debug
                INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                ResetUserStats(playerid);
                SaveStats(playerid);
                ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "{00FF00}CONFIRM PASSWORD","{00F0F0}Please Confirm Your Password By Typing It Below:","Accept","Leave");
            }
        }

        case LOGIN:
        {
            new string[130];
            if(!response)
            {
                SendClientMessage(playerid, red, "You Have Been Kicked From The Server. You MUST Register And Login Before Playing.");
                format(string,sizeof(string),"** Player %s Has Been Kicked From The Server | Reason: Failed To Register/Login **",pName(playerid));
                SendClientMessageToAll(red, string);
                return Kick(playerid);
            }
            if(response)
            {
                new buf[129];
                WP_Hash(buf, sizeof(buf), inputtext);
                if(strcmp(Player[playerid][Password], buf, false) == 0)
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    if(strfind(pName(playerid), "[AWP]", true) != -1)
                    {
                        if(Player[playerid][Member] < 1)
                        {
                            SendClientMessage(playerid, red, "Only Authorised AWP Clan Members Can Wear The [AWP] Tag.");
                            SendClientMessage(playerid, orange, "If You Think You Are Receiving This Message In Error, Please Contact An AWP Clan Administrator.");
                            format(string,sizeof(string),"%s Has Been Kicked From The Server Automatically | Reason: Unauthorised [AWP] Tag");
                            SendClientMessageToAll(red, string);
                            return Kick(playerid);
                        }
                    }
                    if(Player[playerid][LastLogin] != 0)
                    {
                        format(string,sizeof(string),"You Last Logged In: %s. Welcome Back.",Player[playerid][LastLogin]);
                        SendClientMessage(playerid, yellow, string);
                    }
                    new string1[30];
                    new day, month, year, hour, minute, second;
                    getdate(year, month, day);
                    gettime(hour, minute, second);
                    format(string1,sizeof(string1),"%d/%d/%d | %d:%d:%d",day,month,year,hour,minute,second);
                    Player[playerid][LastLogin] = string1;
                    SetPlayerMoney(playerid, Player[playerid][Cash]);
                    SetPlayerScore(playerid, Player[playerid][Score]);
                    Player[playerid][LoggedIn] = 1;
                    SaveStats(playerid);
                    if(ServerInfo[BetaMode] == 1)
                    {
                        if(Player[playerid][Admin] == 0 && !IsPlayerAdmin(playerid))
                        {
                            SendClientMessage(playerid, red, "ERROR: {FFFFFF}The Server Is Currently In BETA Mode. Once The Server's Map Name Is No Longer 'BETA', You Will Be Able To Join.");
                            SendClientMessage(playerid, orange, "Only Authorised BETA Testers, Administrators And RCON Administrators Can Access The Server During BETA Mode.");
                            return Kick(playerid);
                        }
                    }
                    SendClientMessage(playerid, green, "You Have Successfully Logged In And Your Current Stats Have Been Loaded.");
                    ShowPlayerDialog(playerid, RULES, DIALOG_STYLE_MSGBOX, "SERVER RULES", "This is {FF0000}just a test message {00FF00}that will later {0000FF}be replaced by {FFFF00}server rules.","Accept","Decline");
                }
                else
                {
                    if(Player[playerid][LoginWarn] >= 2)
                    {
                        SendClientMessage(playerid, red, "You Have Been Kicked From The Server. You MUST Enter The Correct Password When Logging In.");
                        SendClientMessage(playerid, orange, "If You Have Forgotten Your Password, Please Contact An Administrator At: 'WWW.AWPGAMING.COM/FORUMS'");
                        format(string,sizeof(string),"** Player %s Has Been Kicked From The Server | Reason: Failed To Login **",pName(playerid));
                        Kick(playerid);
                        SendClientMessageToAll(red, string);
                        return 1;
                    }
                    Player[playerid][LoginWarn]++;
                    format(string,sizeof(string),"You Have Entered An Incorrect Password. You Have A Maximum Of 3 Attempts Before You Are Automatically Kicked. %d/3 Attempts Used.",Player[playerid][LoginWarn]);
                    SendClientMessage(playerid, red, string);
                    return ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD,"{FF0000}INCORRECT PASSWORD","{FF0000}You Have Entered An Incorrect Password, Please Try Again, You Will Have 3 Attempts In Total Before Being Kicked.\n{00F0F0}Please Enter Your Current Password Below:","Accept","Leave");
                }
                return 1;
            }
        }
        //Code continues
Any help with this is appreciated, like I said, everything EXCEPT the INI_ParseFile functions are working. All the correct files exist, all plugins and includes are updated and recompiled. I am only running one gamemode, no filterscripts. If you can help me solve this, I will definitely supply you with reputation points. Thanks in advance.

Regards,
clarencecuzz.
Reply
#2

As per ******'s instructions .. it can only work if INI_SetTag is used

And you are parsing 'data' (public LoadUser_data) data must be setted as tag in order to make the parsing work
so use INI_SetTag(/*file*/,"data");

It should not have any space and MUST be same as the one you are parsing!
It is written where you save your stats and where you create the account!
Reply
#3

@****** why shouldn't we use a tag called "data" ? ? .. is there any related bug with it or anything else?
Reply
#4

First of all, like ****** said, you mixed up strings with integers. For example:

pawn Код:
for(new i = 0; i < MAX_HOUSES; i++)
{
    new string[30];
    format(string,sizeof(string),HOUSEPATH,i);
    if(fexist(string))
    {
        print("File exists."); //Debug
        INI_ParseFile(string, "LoadHouse_%s", .bExtra = true, .extra = i); // %s means loading string and your extra parameter is i, which is integer. Change %s to %i
        if(House[i][Owned] == 0)
        {
            House[i][Pickup] = CreateDynamicPickup(1272, 1, House[i][PosX], House[i][PosY], House[i][PosZ]);
            print("Pickup Created"); //Debug
        }
        else
        {
            House[i][Pickup] = CreateDynamicPickup(1273, 1, House[i][PosX], House[i][PosY], House[i][PosZ]);
            print("Pickup Created Owned"); //Debug
        }
        format(string,sizeof(string),"House: %s\nOwner: %s\nID: %d",House[i][Name],House[i][OwnerName],i);
        House[i][Label] = CreateDynamic3DTextLabel(string, green, House[i][PosX], House[i][PosY], House[i][PosZ], 100.00);
        print("Text label created"); //Debug
        continue;
    }
    continue;
}

Next up, same thing, mixed strings with integer:
pawn Код:
forward LoadHouse_data(houseid,name[],value[]);
public LoadHouse_data(houseid,name[],value[])
{
    //INI_Int("HouseName",House[houseid][Name]); // Change INI_Int with INI_String since Name is a string
    INI_String("HouseName",House[houseid][Name], 64);
    printf("House id %d Name loaded", houseid); //Debug
    INI_Float("X",House[houseid][PosX]);
    INI_Float("Y",House[houseid][PosY]);
    INI_Float("Z",House[houseid][PosZ]);
    INI_Int("Owned",House[houseid][Owned]);
    //INI_Int("OwnerName",House[houseid][OwnerName]); Same here, used INI_Int instead of String
    //INI_String("OwnerName",House[houseid][Ownername], 24);
    INI_Int("Key1",House[houseid][Key1]);
    INI_Int("Key2",House[houseid][Key2]);
    INI_Int("Key3",House[houseid][Key3]);
    return 1;
}

That's for the HOUSE. Now, let's move on to the player load. Exactly the same thing, mixing strings with integers:
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    //INI_Int("Password",Player[playerid][Password]);
    INI_String("Password",Player[playerid][Password], 129); // Change 100 with your Password string length
    print("Password Loaded"); //Debug
    INI_Int("Cash",Player[playerid][Cash]);
    print("Cash Loaded"); //Debug
    INI_Int("Admin",Player[playerid][Admin]);
    print("Admin Loaded"); //Debug
    INI_Int("Kills",Player[playerid][Kills]);
    INI_Int("Deaths",Player[playerid][Deaths]);
    INI_Int("VIP",Player[playerid][pVip]);
    INI_Int("Score",Player[playerid][Score]);
    INI_Int("Helper",Player[playerid][Helper]);
    INI_Int("Builder",Player[playerid][Builder]);
    INI_Int("Member",Player[playerid][Member]);
    print("Member Loaded"); //Debug
    INI_Int("BanReason",Player[playerid][BanReason]);
    INI_Int("LastLogin",Player[playerid][LastLogin]);
    INI_Int("Caged",Player[playerid][Caged]);
    INI_Int("Muted",Player[playerid][Muted]);
    INI_Int("Banned",Player[playerid][Banned]);
    print("Ban Loaded"); //Debug
    return 1;
}
Next up, dialogs: In the REGISTER dialog I don't even see why you check if player variable 'Member' is smaller than 1. It's obvious that when you register, you won't have Member more than 0. So, no need for that.

You need another ParseFile for the password, which I can't find in your post. Here is an example:

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case REGISTER:
        {
            if(!response)
            {
                new string[105];
                SendClientMessage(playerid, red, "You Have Been Kicked From The Server. You MUST Register And Login Before Playing.");
                format(string,sizeof(string),"** Player %s Has Been Kicked From The Server | Reason: Failed To Register/Login **",pName(playerid));
                SendClientMessageToAll(red, string);
                return Kick(playerid);
            }
            if(response)
            {
                if(strfind(pName(playerid), "[AWP]", true) != -1)
                {
                    if(Player[playerid][Member] < 1)
                    {
                        new string[105];
                        SendClientMessage(playerid, red, "Only Authorised AWP Clan Members Can Wear The [AWP] Tag.");
                        SendClientMessage(playerid, orange, "If You Think You Are Receiving This Message In Error, Please Contact An AWP Clan Administrator.");
                        format(string,sizeof(string),"%s Has Been Kicked From The Server Automatically | Reason: Unauthorised [AWP] Tag");
                        SendClientMessageToAll(red, string);
                        return Kick(playerid);
                    }
                }
                new buf[129];
                if(!strlen(inputtext) || strlen(inputtext) < 4 || strlen(inputtext) > 24) return ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_INPUT, "{FF0000}INVALID PASSWORD","{FF0000}You Have Entered An Invalid Password.\n{00FF00}Please Note: Passwords Must Be At Least 4 To 24 Characters Long.\n{00F0F0}Please Enter Your Desired Password Below:","Accept","Leave");
                INI_ParseFile(UserPath(playerid), "LoadUserPass", false, true, playerid);
                WP_Hash(buf, sizeof(buf), inputtext);
                printf("String %s Created", buf); //Debug
                //new INI:File = INI_Open(UserPath(playerid));
                // printf("User File Opened"); //Debug
                // INI_WriteString(File,"Password",buf);
                // printf("String %s Saved to User File",buf); //Debug
                // INI_Close(File);
                // printf("File Closed."); //Debug
                if(strcmp(WP_Hash, Player[playerid][Password], false))
                {
                    // Here what you want to do if password is wrong.
                }
                else INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); // You load the player data
            }
        }

        case LOGIN:
        {
            new string[130];
            if(!response)
            {
                SendClientMessage(playerid, red, "You Have Been Kicked From The Server. You MUST Register And Login Before Playing.");
                format(string,sizeof(string),"** Player %s Has Been Kicked From The Server | Reason: Failed To Register/Login **",pName(playerid));
                SendClientMessageToAll(red, string);
                return Kick(playerid);
            }
            if(response)
            {
                new buf[129];
                WP_Hash(buf, sizeof(buf), inputtext);
                if(strcmp(Player[playerid][Password], buf, false) == 0)
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    if(strfind(pName(playerid), "[AWP]", true) != -1)
                    {
                        if(Player[playerid][Member] < 1)
                        {
                            SendClientMessage(playerid, red, "Only Authorised AWP Clan Members Can Wear The [AWP] Tag.");
                            SendClientMessage(playerid, orange, "If You Think You Are Receiving This Message In Error, Please Contact An AWP Clan Administrator.");
                            format(string,sizeof(string),"%s Has Been Kicked From The Server Automatically | Reason: Unauthorised [AWP] Tag");
                            SendClientMessageToAll(red, string);
                            return Kick(playerid);
                        }
                    }
                    if(Player[playerid][LastLogin] != 0)
                    {
                        format(string,sizeof(string),"You Last Logged In: %s. Welcome Back.",Player[playerid][LastLogin]);
                        SendClientMessage(playerid, yellow, string);
                    }
                    new string1[30];
                    new day, month, year, hour, minute, second;
                    getdate(year, month, day);
                    gettime(hour, minute, second);
                    format(string1,sizeof(string1),"%d/%d/%d | %d:%d:%d",day,month,year,hour,minute,second);
                    Player[playerid][LastLogin] = string1;
                    SetPlayerMoney(playerid, Player[playerid][Cash]);
                    SetPlayerScore(playerid, Player[playerid][Score]);
                    Player[playerid][LoggedIn] = 1;
                    SaveStats(playerid);
                    if(ServerInfo[BetaMode] == 1)
                    {
                        if(Player[playerid][Admin] == 0 && !IsPlayerAdmin(playerid))
                        {
                            SendClientMessage(playerid, red, "ERROR: {FFFFFF}The Server Is Currently In BETA Mode. Once The Server's Map Name Is No Longer 'BETA', You Will Be Able To Join.");
                            SendClientMessage(playerid, orange, "Only Authorised BETA Testers, Administrators And RCON Administrators Can Access The Server During BETA Mode.");
                            return Kick(playerid);
                        }
                    }
                    SendClientMessage(playerid, green, "You Have Successfully Logged In And Your Current Stats Have Been Loaded.");
                    ShowPlayerDialog(playerid, RULES, DIALOG_STYLE_MSGBOX, "SERVER RULES", "This is {FF0000}just a test message {00FF00}that will later {0000FF}be replaced by {FFFF00}server rules.","Accept","Decline");
                }
                else
                {
                    if(Player[playerid][LoginWarn] >= 2)
                    {
                        SendClientMessage(playerid, red, "You Have Been Kicked From The Server. You MUST Enter The Correct Password When Logging In.");
                        SendClientMessage(playerid, orange, "If You Have Forgotten Your Password, Please Contact An Administrator At: 'WWW.AWPGAMING.COM/FORUMS'");
                        format(string,sizeof(string),"** Player %s Has Been Kicked From The Server | Reason: Failed To Login **",pName(playerid));
                        Kick(playerid);
                        SendClientMessageToAll(red, string);
                        return 1;
                    }
                    Player[playerid][LoginWarn]++;
                    format(string,sizeof(string),"You Have Entered An Incorrect Password. You Have A Maximum Of 3 Attempts Before You Are Automatically Kicked. %d/3 Attempts Used.",Player[playerid][LoginWarn]);
                    SendClientMessage(playerid, red, string);
                    return ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD,"{FF0000}INCORRECT PASSWORD","{FF0000}You Have Entered An Incorrect Password, Please Try Again, You Will Have 3 Attempts In Total Before Being Kicked.\n{00F0F0}Please Enter Your Current Password Below:","Accept","Leave");
                }
                return 1;
            }
        }
        //Code continues
// SOmewhere in your script, to load the password
pawn Код:
forward LoadUserPass(playerid, name[], value[]);
public LoadUserPass(playerid, name[], value[])
{
    if(!strcmp(name, "Password"))
        INI_String("Password", Player[playerid][Password], 129;
}
Reply
#5

Ah thank you guys, I realised that I had to use SetTag before I noticed I had any replies in this thread. I remember trying to use INI_String once before but I received errors, and now I notice that it was because I didn't include any string length. A problem easily fixed by searching. Just to recap, are these all correct?

Register and Login Dialogs:
pawn Код:
case REGISTER:
        {
            if(!response)
            {
                new string[105];
                SendClientMessage(playerid, red, "You Have Been Kicked From The Server. You MUST Register And Login Before Playing.");
                format(string,sizeof(string),"** Player %s Has Been Kicked From The Server | Reason: Failed To Register/Login **",pName(playerid));
                SendClientMessageToAll(red, string);
                return Kick(playerid);
            }
            if(response)
            {
                new Name[MAX_PLAYER_NAME];
                GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
                if(strfind(Name, "[AWP]", true) != -1)
                {
                    if(Player[playerid][Member] < 1)
                    {
                        new string[105];
                        SendClientMessage(playerid, red, "Only Authorised AWP Clan Members Can Wear The [AWP] Tag.");
                        SendClientMessage(playerid, orange, "If You Think You Are Receiving This Message In Error, Please Contact An AWP Clan Administrator.");
                        format(string,sizeof(string),"%s Has Been Kicked From The Server Automatically | Reason: Unauthorised [AWP] Tag");
                        SendClientMessageToAll(red, string);
                        return Kick(playerid);
                    }
                }
                new buf[129];
                if(!strlen(inputtext) || strlen(inputtext) < 4 || strlen(inputtext) > 24) return ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_INPUT, "{FF0000}INVALID PASSWORD","{FF0000}You Have Entered An Invalid Password.\n{00FF00}Please Note: Passwords Must Be At Least 4 To 24 Characters Long.\n{00F0F0}Please Enter Your Desired Password Below:","Accept","Leave");
                WP_Hash(buf, sizeof(buf), inputtext);
                new INI:File = INI_Open(UserPath(playerid));
                INI_WriteString(File,"Password",buf);
                INI_Close(File);
                INI_ParseFile(UserPath(playerid), "LoadUserPass", false, true, playerid);
                ResetUserStats(playerid);
                SaveStats(playerid);
                ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "{00FF00}CONFIRM PASSWORD","{00F0F0}Please Confirm Your Password By Typing It Below:","Accept","Leave");
            }
        }

        case LOGIN:
        {
            new string[130];
            if(!response)
            {
                SendClientMessage(playerid, red, "You Have Been Kicked From The Server. You MUST Register And Login Before Playing.");
                format(string,sizeof(string),"** Player %s Has Been Kicked From The Server | Reason: Failed To Register/Login **",pName(playerid));
                SendClientMessageToAll(red, string);
                return Kick(playerid);
            }
            if(response)
            {
                INI_ParseFile(UserPath(playerid), "LoadUserPass", false, true, playerid);
                new buf[129];
                WP_Hash(buf, sizeof(buf), inputtext);
                if(strcmp(Player[playerid][Password], buf, false) == 0)
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    new Name[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
                    if(strfind(Name, "[AWP]", true) != -1)
                    {
                        if(Player[playerid][Member] < 1)
                        {
                            SendClientMessage(playerid, red, "Only Authorised AWP Clan Members Can Wear The [AWP] Tag.");
                            SendClientMessage(playerid, orange, "If You Think You Are Receiving This Message In Error, Please Contact An AWP Clan Administrator.");
                            format(string,sizeof(string),"%s Has Been Kicked From The Server Automatically | Reason: Unauthorised [AWP] Tag");
                            SendClientMessageToAll(red, string);
                            return Kick(playerid);
                        }
                    }
                    if(Player[playerid][LastLogin] != 0)
                    {
                        format(string,sizeof(string),"You Last Logged In: %s. Welcome Back.",Player[playerid][LastLogin]);
                        SendClientMessage(playerid, yellow, string);
                    }
                    new string1[30];
                    new day, month, year, hour, minute, second;
                    getdate(year, month, day);
                    gettime(hour, minute, second);
                    format(string1,sizeof(string1),"%02d/%02d/%02d | %02d:%02d:%02d",day,month,year,hour,minute,second);
                    Player[playerid][LastLogin] = string1;
                    SetPlayerMoney(playerid, Player[playerid][Cash]);
                    SetPlayerScore(playerid, Player[playerid][Score]);
                    Player[playerid][LoggedIn] = 1;
                    new IP[50];
                    GetPlayerIp(playerid, IP, 50);
                    Player[playerid][Ip] = IP;
                    new INI:File = INI_Open(UserPath(playerid));
                    INI_SetTag(File, "data");
                    INI_WriteString(File,"IP",IP);
                    INI_Close(File);
                    SaveStats(playerid);
                    if(ServerInfo[BetaMode] == 1)
                    {
                        if(Player[playerid][Admin] == 0 && !IsPlayerAdmin(playerid))
                        {
                            SendClientMessage(playerid, red, "ERROR: {FFFFFF}The Server Is Currently In BETA Mode. Once The Server's Map Name Is No Longer 'BETA', You Will Be Able To Join.");
                            SendClientMessage(playerid, orange, "Only Authorised BETA Testers, Administrators And RCON Administrators Can Access The Server During BETA Mode.");
                            return Kick(playerid);
                        }
                    }
                    SendClientMessage(playerid, green, "You Have Successfully Logged In And Your Current Stats Have Been Loaded.");
                    ShowPlayerDialog(playerid, RULES, DIALOG_STYLE_MSGBOX, "SERVER RULES", "This is {FF0000}just a test message {00FF00}that will later {0000FF}be replaced by {FFFF00}server rules.","Accept","Decline");
                }
                else
                {
                    if(Player[playerid][LoginWarn] >= 2)
                    {
                        SendClientMessage(playerid, red, "You Have Been Kicked From The Server. You MUST Enter The Correct Password When Logging In.");
                        SendClientMessage(playerid, orange, "If You Have Forgotten Your Password, Please Contact An Administrator At: 'WWW.AWPGAMING.COM/FORUMS'");
                        format(string,sizeof(string),"** Player %s Has Been Kicked From The Server | Reason: Failed To Login **",pName(playerid));
                        Kick(playerid);
                        SendClientMessageToAll(red, string);
                        return 1;
                    }
                    Player[playerid][LoginWarn]++;
                    format(string,sizeof(string),"You Have Entered An Incorrect Password. You Have A Maximum Of 3 Attempts Before You Are Automatically Kicked. %d/3 Attempts Used.",Player[playerid][LoginWarn]);
                    SendClientMessage(playerid, red, string);
                    return ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD,"{FF0000}INCORRECT PASSWORD","{FF0000}You Have Entered An Incorrect Password, Please Try Again, You Will Have 3 Attempts In Total Before Being Kicked.\n{00F0F0}Please Enter Your Current Password Below:","Accept","Leave");
                }
                return 1;
            }
        }
Loading:
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Cash",Player[playerid][Cash]);
    INI_Int("Admin",Player[playerid][Admin]);
    INI_Int("Kills",Player[playerid][Kills]);
    INI_Int("Deaths",Player[playerid][Deaths]);
    INI_Int("VIP",Player[playerid][pVip]);
    INI_Int("Score",Player[playerid][Score]);
    INI_Int("Helper",Player[playerid][Helper]);
    INI_Int("Builder",Player[playerid][Builder]);
    INI_Int("Member",Player[playerid][Member]);
    INI_Int("BanReason",Player[playerid][BanReason]);
    INI_Int("LastLogin",Player[playerid][LastLogin]);
    INI_Int("Caged",Player[playerid][Caged]);
    INI_Int("Muted",Player[playerid][Muted]);
    INI_Int("Banned",Player[playerid][Banned]);
    return 1;
}

forward LoadUserPass(playerid,name[],value[]);
public LoadUserPass(playerid,name[],value[])
{
    INI_String("Password",Player[playerid][Password], 50);
    return 1;
}

forward LoadHouse_data(houseid,name[],value[]);
public LoadHouse_data(houseid,name[],value[])
{
    INI_String("HouseName",House[houseid][Name], 50);
    INI_Float("X",House[houseid][PosX]);
    INI_Float("Y",House[houseid][PosY]);
    INI_Float("Z",House[houseid][PosZ]);
    INI_Int("Owned",House[houseid][Owned]);
    INI_String("OwnerName",House[houseid][OwnerName], 50);
    INI_String("Key1",House[houseid][Key1], 50);
    INI_String("Key2",House[houseid][Key2], 50);
    INI_String("Key3",House[houseid][Key3], 50);
    return 1;
}
Thank you so much for your help
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
No, you still don't always set a tag after opening the file for writing.
Why is INI_SetTag so important? I mean, I'm not using it and everything works perfect. I'm not getting any errors either in script or in game. Files loads perfectly. Did I miss anything?
Reply
#7

I don't quite understand :S

Houses aren't loading, and when I register and try to enter my password again, it says it's wrong.

pawn Код:
forward LoadPass_pass(playerid,name[],value[]);
public LoadPass_pass(playerid,name[],value[])
{
    INI_String("Password",Player[playerid][Password], 129);
    return 1;
}

forward LoadHouse_data(houseid,name[],value[]);
public LoadHouse_data(houseid,name[],value[])
{
    INI_String("HouseName",House[houseid][Name], 50);
    INI_Float("X",House[houseid][PosX]);
    INI_Float("Y",House[houseid][PosY]);
    INI_Float("Z",House[houseid][PosZ]);
    INI_Int("Owned",House[houseid][Owned]);
    INI_String("OwnerName",House[houseid][OwnerName], 50);
    INI_String("Key1",House[houseid][Key1], 50);
    INI_String("Key2",House[houseid][Key2], 50);
    INI_String("Key3",House[houseid][Key3], 50);
    return 1;
}
pawn Код:
forward SaveHouse(houseid);
public SaveHouse(houseid)
{
    new string[30];
    format(string,sizeof(string),HOUSEPATH,houseid);
    new INI:File = INI_Open(string);
    INI_SetTag(File,"data");
    INI_WriteString(File,"HouseName",House[houseid][Name]);
    INI_WriteFloat(File,"X",House[houseid][PosX]);
    INI_WriteFloat(File,"Y",House[houseid][PosY]);
    INI_WriteFloat(File,"Z",House[houseid][PosZ]);
    INI_WriteInt(File,"Owned",House[houseid][Owned]);
    INI_WriteString(File,"OwnerName",House[houseid][OwnerName]);
    INI_WriteString(File,"Key1",House[houseid][Key1]);
    INI_WriteString(File,"Key2",House[houseid][Key2]);
    INI_WriteString(File,"Key3",House[houseid][Key3]);
    INI_Close(File);
    return 1;
}
   
forward SaveStats(playerid);
public SaveStats(playerid)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",Player[playerid][Cash]);
    INI_WriteInt(File,"Admin",Player[playerid][Admin]);
    INI_WriteInt(File,"Kills",Player[playerid][Kills]);
    INI_WriteInt(File,"Deaths",Player[playerid][Deaths]);
    INI_WriteInt(File,"VIP",Player[playerid][pVip]);
    INI_WriteInt(File,"Score",Player[playerid][Score]);
    INI_WriteString(File,"LastLogin",Player[playerid][LastLogin]);
    INI_WriteString(File,"BanReason",Player[playerid][BanReason]);
    INI_WriteInt(File,"Helper",Player[playerid][Helper]);
    INI_WriteInt(File,"Member",Player[playerid][Member]);
    INI_WriteInt(File,"Builder",Player[playerid][Builder]);
    INI_WriteInt(File,"Caged",Player[playerid][Caged]);
    INI_WriteInt(File,"Muted",Player[playerid][Muted]);
    INI_WriteInt(File,"Banned",Player[playerid][Banned]);
    INI_Close(File);
    return 1;
}

forward SavePass(playerid);
public SavePass(playerid)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File, "pass");
    INI_WriteString(File,"Password",Player[playerid][Password]);
    INI_Close(File);
    return 1;
}
Can you guys show me where I've gone wrong?
Once again... Register and login dialog:
pawn Код:
case REGISTER:
        {
            if(!response)
            {
                new string[105];
                SendClientMessage(playerid, red, "You Have Been Kicked From The Server. You MUST Register And Login Before Playing.");
                format(string,sizeof(string),"** Player %s Has Been Kicked From The Server | Reason: Failed To Register/Login **",pName(playerid));
                SendClientMessageToAll(red, string);
                return Kick(playerid);
            }
            if(response)
            {
                new PlayersName[MAX_PLAYER_NAME];
                GetPlayerName(playerid, PlayersName, MAX_PLAYER_NAME);
                if(strfind(PlayersName, "[AWP]", true) != -1)
                {
                    if(Player[playerid][Member] < 1)
                    {
                        new string[105];
                        SendClientMessage(playerid, red, "Only Authorised AWP Clan Members Can Wear The [AWP] Tag.");
                        SendClientMessage(playerid, orange, "If You Think You Are Receiving This Message In Error, Please Contact An AWP Clan Administrator.");
                        format(string,sizeof(string),"%s Has Been Kicked From The Server Automatically | Reason: Unauthorised [AWP] Tag");
                        SendClientMessageToAll(red, string);
                        return Kick(playerid);
                    }
                }
                new buf[129];
                if(!strlen(inputtext) || strlen(inputtext) < 4 || strlen(inputtext) > 24) return ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_INPUT, "{FF0000}INVALID PASSWORD","{FF0000}You Have Entered An Invalid Password.\n{00FF00}Please Note: Passwords Must Be At Least 4 To 24 Characters Long.\n{00F0F0}Please Enter Your Desired Password Below:","Accept","Leave");
                WP_Hash(buf, sizeof(buf), inputtext);
                Player[playerid][Password] = buf;
                SavePass(playerid);
                INI_ParseFile(UserPath(playerid), "LoadPass_%s", .bExtra = true, .extra = playerid);
                ResetUserStats(playerid);
                SaveStats(playerid);
                ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "{00FF00}CONFIRM PASSWORD","{00F0F0}Please Confirm Your Password By Typing It Below:","Accept","Leave");
            }
        }

        case LOGIN:
        {
            new string[130];
            if(!response)
            {
                SendClientMessage(playerid, red, "You Have Been Kicked From The Server. You MUST Register And Login Before Playing.");
                format(string,sizeof(string),"** Player %s Has Been Kicked From The Server | Reason: Failed To Register/Login **",pName(playerid));
                SendClientMessageToAll(red, string);
                return Kick(playerid);
            }
            if(response)
            {
                INI_ParseFile(UserPath(playerid), "LoadPass_%s", .bExtra = true, .extra = playerid);
                new buf[129];
                WP_Hash(buf, sizeof(buf), inputtext);
                if(strcmp(Player[playerid][Password], buf, false) == 0)
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    new PlayersName[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, PlayersName, MAX_PLAYER_NAME);
                    if(strfind(PlayersName, "[AWP]", true) != -1)
                    {
                        if(Player[playerid][Member] < 1)
                        {
                            SendClientMessage(playerid, red, "Only Authorised AWP Clan Members Can Wear The [AWP] Tag.");
                            SendClientMessage(playerid, orange, "If You Think You Are Receiving This Message In Error, Please Contact An AWP Clan Administrator.");
                            format(string,sizeof(string),"%s Has Been Kicked From The Server Automatically | Reason: Unauthorised [AWP] Tag");
                            SendClientMessageToAll(red, string);
                            return Kick(playerid);
                        }
                    }
                    if(Player[playerid][LastLogin] != 0)
                    {
                        format(string,sizeof(string),"You Last Logged In: %s. Welcome Back.",Player[playerid][LastLogin]);
                        SendClientMessage(playerid, yellow, string);
                    }
                    new string1[30];
                    new day, month, year, hour, minute, second;
                    getdate(year, month, day);
                    gettime(hour, minute, second);
                    format(string1,sizeof(string1),"%02d/%02d/%02d | %02d:%02d:%02d",day,month,year,hour,minute,second);
                    Player[playerid][LastLogin] = string1;
                    SetPlayerMoney(playerid, Player[playerid][Cash]);
                    SetPlayerScore(playerid, Player[playerid][Score]);
                    Player[playerid][LoggedIn] = 1;
                    new IP[50];
                    GetPlayerIp(playerid, IP, 50);
                    Player[playerid][Ip] = IP;
                    new INI:File = INI_Open(UserPath(playerid));
                    INI_SetTag(File, "data");
                    INI_WriteString(File,"IP",IP);
                    INI_Close(File);
                    SaveStats(playerid);
                    SavePass(playerid);
                    if(ServerInfo[BetaMode] == 1)
                    {
                        if(Player[playerid][Admin] == 0 && !IsPlayerAdmin(playerid))
                        {
                            SendClientMessage(playerid, red, "ERROR: {FFFFFF}The Server Is Currently In BETA Mode. Once The Server's Map Name Is No Longer 'BETA', You Will Be Able To Join.");
                            SendClientMessage(playerid, orange, "Only Authorised BETA Testers, Administrators And RCON Administrators Can Access The Server During BETA Mode.");
                            return Kick(playerid);
                        }
                    }
                    SendClientMessage(playerid, green, "You Have Successfully Logged In And Your Current Stats Have Been Loaded.");
                    ShowPlayerDialog(playerid, RULES, DIALOG_STYLE_MSGBOX, "SERVER RULES", "This is {FF0000}just a test message {00FF00}that will later {0000FF}be replaced by {FFFF00}server rules.","Accept","Decline");
                }
                else
                {
                    if(Player[playerid][LoginWarn] >= 2)
                    {
                        SendClientMessage(playerid, red, "You Have Been Kicked From The Server. You MUST Enter The Correct Password When Logging In.");
                        SendClientMessage(playerid, orange, "If You Have Forgotten Your Password, Please Contact An Administrator At: 'WWW.AWPGAMING.COM/FORUMS'");
                        format(string,sizeof(string),"** Player %s Has Been Kicked From The Server | Reason: Failed To Login **",pName(playerid));
                        Kick(playerid);
                        SendClientMessageToAll(red, string);
                        return 1;
                    }
                    Player[playerid][LoginWarn]++;
                    format(string,sizeof(string),"You Have Entered An Incorrect Password. You Have A Maximum Of 3 Attempts Before You Are Automatically Kicked. %d/3 Attempts Used.",Player[playerid][LoginWarn]);
                    SendClientMessage(playerid, red, string);
                    return ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD,"{FF0000}INCORRECT PASSWORD","{FF0000}You Have Entered An Incorrect Password, Please Try Again, You Will Have 3 Attempts In Total Before Being Kicked.\n{00F0F0}Please Enter Your Current Password Below:","Accept","Leave");
                }
                return 1;
            }
        }
INI_ParseFile(string, "LoadHouse_%i", .bExtra = true, .extra = i);
INI_ParseFile(UserPath(id), "LoadPass_%s", .bExtra = true, .extra = id);
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);

Thanks for wasting your time on me guys
Reply
#8

Quote:
Originally Posted by ******
Посмотреть сообщение
In theory files SHOULD work with no tags (as in dini style ini files), but sometimes they don't and I've never had time to debug it. If they work without then great, don't use them if you don't want.
Alright, I understood. Thanks. If I'll have any problems, I'll set a tag.
Reply
#9

Okay guys, well I have managed to fix the login system etc., but I am still confused about why my houses aren't loading properly. The labels and pickups are being created, but for some reason it's not reading the X, Y and Z positions of the house. Does this have any relevance to using INI_Float? The /addhouse command works fine, but when the server is restarted, all pickups and labels are spawning at 0, 0, 0. Which I am guessing, means that it isn't loading the PosX, PosY and PosZ variables with INI_ParseFile.

Addhouse command:
pawn Код:
CMD:addhouse(playerid,params[])
{
    if(!IsPlayerAdmin(playerid) || Player[playerid][Admin] < 10) return SendClientMessage(playerid, red, "ERROR: {FFFFFF}You Have Entered An Invalid Command. Please Read {00FF00}/CMDS{FFFFFF}.");
    for(new i = 0; i < MAX_HOUSES; i++)
    {
        new string[50];
        format(string,sizeof(string),HOUSEPATH,i);
        if(!fexist(string))
        {
            new Float:X, Float:Y, Float:Z;
            GetPlayerPos(playerid, X, Y, Z);
            INI_ParseFile(string, "LoadHouse_%i", .bExtra = true, .extra = i);
            House[i][Pickup] = CreateDynamicPickup(1272, 1, X, Y, Z);
            House[i][PosX] = X;
            House[i][PosY] = Y;
            House[i][PosZ] = Z;
            House[i][Owned] = 0;
            format(string,sizeof(string),"For Sale");
            House[i][OwnerName] = string;
            format(string,sizeof(string),"House ID %d", i);
            House[i][Name] = string;
            format(string,sizeof(string),"No Key Holder");
            House[i][Key1] = string;
            House[i][Key2] = string;
            House[i][Key3] = string;
            format(string,sizeof(string),"House: %s\nOwner: %s\nID: %d",House[i][Name],House[i][OwnerName],i);
            House[i][Label] = CreateDynamic3DTextLabel(string, green, House[i][PosX], House[i][PosY], House[i][PosZ], 100.00);
            format(string,sizeof(string),"You Have Successfully Created House ID %d", i);
            SendClientMessage(playerid, green, string);
            SaveHouse(i);
            break;
        }
        continue;
    }
    return 1;
}
Reply
#10

It was included in the first post of the thread.
pawn Код:
forward LoadHouse_data(houseid,name[],value[]);
public LoadHouse_data(houseid,name[],value[])
{    
    INI_String("HouseName",House[houseid][Name], 50);    
    printf("House id %d Name loaded", houseid); //Debug    
    INI_Float("X",House[houseid][PosX]);    
    INI_Float("Y",House[houseid][PosY]);    
    INI_Float("Z",House[houseid][PosZ]);    
    INI_Int("Owned",House[houseid][Owned]);    
    INI_String("OwnerName",House[houseid][OwnerName], 50);    
    INI_String("Key1",House[houseid][Key1], 50);    
    INI_String("Key2",House[houseid][Key2], 50);    
    INI_String("Key3",House[houseid][Key3], 50);    
    return 1;
}
How would I make sure it loads properly using INI_ParseFile?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)