SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 30/04/2014, 12:54 PM   #1
AndySedeyn
High-roller
 
AndySedeyn's Avatar
 
Join Date: Feb 2014
Location: Belgium
Posts: 1,207
Reputation: 681
Default Server error when deleting a user.ini file

So, basically what I want to do is delete a user's file when he quits the server during or before the registration process.

I get this funny error in my server.log and the .ini is not deleted afterwards:
Code:
[14:55:33] *** YSI Info: Invalid line in INI file "/Users/Bible.ini": /Users/Bible.ini =
It even shows a smiley face at the end of the error code (in my server prompt window).

How can I solve this?
This is the code where it deletes the file if the player quits (during the registration process):
pawn Code:
new INI:File = INI_Open(UserPath(playerid));
INI_RemoveEntry(File, UserPath(playerid));
INI_Close(File);

Help is much appreciated.

If you require more information about my script, let me know.
AndySedeyn is offline   Reply With Quote
Old 30/04/2014, 01:12 PM   #2
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,068
Reputation: 2658
Default Re: Server error when deleting a user.ini file

I don't use YSI, but shouldn't a file be closed before you attempt to delete it?
__________________
Vince is offline   Reply With Quote
Old 30/04/2014, 01:19 PM   #3
AndySedeyn
High-roller
 
AndySedeyn's Avatar
 
Join Date: Feb 2014
Location: Belgium
Posts: 1,207
Reputation: 681
Default Re: Server error when deleting a user.ini file

Quote:
Originally Posted by Vince View Post
I don't use YSI, but shouldn't a file be closed before you attempt to delete it?
That makes sense, so what I did is kick the player before deleting the file.
Same error.
AndySedeyn is offline   Reply With Quote
Old 30/04/2014, 01:22 PM   #4
Galletziz
Huge Clucker
 
Galletziz's Avatar
 
Join Date: Mar 2013
Posts: 275
Reputation: 10
Default Re: Server error when deleting a user.ini file

Quote:
Also, that is used to delete a line FROM a file, not delete the file itself.
pawn Code:
if(fexist(UserPath(playerid))
{
     fremove(UserPath(playerid));
}
Galletziz is offline   Reply With Quote
Old 30/04/2014, 01:25 PM   #5
AndySedeyn
High-roller
 
AndySedeyn's Avatar
 
Join Date: Feb 2014
Location: Belgium
Posts: 1,207
Reputation: 681
Default Re: Server error when deleting a user.ini file

Thanks for the help, guys!

Last edited by AndySedeyn; 30/04/2014 at 01:58 PM.
AndySedeyn is offline   Reply With Quote
Old 30/04/2014, 01:58 PM   #6
AndySedeyn
High-roller
 
AndySedeyn's Avatar
 
Join Date: Feb 2014
Location: Belgium
Posts: 1,207
Reputation: 681
Default Re: Server error when deleting a user.ini file

I'm still doing something wrong.. The file is not getting remove even after I replaced the Entry edit to:
pawn Code:
if(fexist(UserPath(playerid)))
                {
                    fremove(UserPath(playerid));
                }
AndySedeyn is offline   Reply With Quote
Old 30/04/2014, 03:27 PM   #7
Galletziz
Huge Clucker
 
Galletziz's Avatar
 
Join Date: Mar 2013
Posts: 275
Reputation: 10
Default Re: Server error when deleting a user.ini file

Post all your code that regards removing file.
Galletziz is offline   Reply With Quote
Old 30/04/2014, 03:47 PM   #8
AndySedeyn
High-roller
 
AndySedeyn's Avatar
 
Join Date: Feb 2014
Location: Belgium
Posts: 1,207
Reputation: 681
Default Re: Server error when deleting a user.ini file

Define of PATH:
pawn Code:
#define     PATH                "/Users/%s.ini"

Stock of UserPath
pawn Code:
stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}

OnPlayerConnect (IsValidName)
pawn Code:
public OnPlayerConnect(playerid)
{
    if(!IsValidName(playerid))
    {
        format(kstring, sizeof(kstring), "[AdmCMD] %s has been kicked from the server by THE SERVER, reason: [Inappropiate name]", name1);
        SCMTA(COLOR_LIGHTRED, kstring);
        format(kstring, sizeof(kstring), "[AdmCMD] You have been kicked from the server by THE SERVER, reason: [Inappropiate name]");
        SCM(playerid, COLOR_LIGHTRED, kstring);
        SetTimerEx("kickbugfixer", 1000, false, "i", playerid);
        if(fexist(UserPath(playerid)))
        {
            new INI:File = INI_Open(UserPath(playerid));
            INI_Close(File);
            fremove(UserPath(playerid));
        }
    }
    return 1;
}

if(!response) - This comes back in every register dialog
pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
/* This if(!response) comes back in every register dialog */
            if(!response)
            {
                format(qstring, sizeof(qstring), "[AdmCMD] You have chosen to 'Quit', you're always welcome to come back!");
                SCM(playerid, COLOR_LIGHTRED, qstring);
                if(fexist(UserPath(playerid)))
                {
                    new INI:File = INI_Open(UserPath(playerid));
                    INI_Close(File);
                    fremove(UserPath(playerid));
                }
                SetTimerEx("kickbugfix", 1000, false, "i", playerid);
            }
AndySedeyn is offline   Reply With Quote
Old 30/04/2014, 05:28 PM   #9
Galletziz
Huge Clucker
 
Galletziz's Avatar
 
Join Date: Mar 2013
Posts: 275
Reputation: 10
Default Re: Server error when deleting a user.ini file

don't declare new INI:File, Just put fremove function.
Galletziz is offline   Reply With Quote
Old 30/04/2014, 05:32 PM   #10
AndySedeyn
High-roller
 
AndySedeyn's Avatar
 
Join Date: Feb 2014
Location: Belgium
Posts: 1,207
Reputation: 681
Default Re: Server error when deleting a user.ini file

Quote:
Originally Posted by Galletziz View Post
don't declare new INI:File, Just put fremove function.
That was the first thing I did, but it doesn't work that way.
AndySedeyn is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[HELP] deleting file Luca12 Scripting Help 11 11/10/2013 09:25 AM
Deleting a file 2KY Scripting Help 6 12/02/2012 09:08 PM
Is there a way? - Deleting line of file. Jeffry Help Archive 5 15/08/2010 01:48 PM
Deleting a line from a file? (.Aztec); Help Archive 4 09/08/2010 11:24 PM
3d Labels not deleting on user disconnect ded Help Archive 6 05/12/2009 02:42 PM


All times are GMT. The time now is 10:45 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.