Fremove.
#1

I have this code but the fremove function is not working ..
pawn Код:
new file[64];


    if(dialogid == DIALOG_REG2)
    {
      if(RegistrationStep[playerid] == 2)
        {
        if(!response) // If they clicked 'Cancel' or pressed esc
        {
        SendClientMessage(playerid, COLOR_RED, "Enter your age correctly next time.");
        format(file,sizeof(file),"/Users/%s.ini",GetName(playerid));
        if(fexist(file))
        {
        fremove(file);
        }
            Kick(playerid);
        }
        else // Pressed ENTER or clicked 'Login' button
        {
            new age = strval(inputtext);
            if(age < 16 || age > 80)
            {
                ShowPlayerDialog(playerid, DIALOG_REG2, DIALOG_STYLE_INPUT, "BLABLALBA", "BLABLALBA(BLABLALBA) ?", "Enter", "Exit");
                SendClientMessage(playerid, COLOR_RED, "Please enter your age(16-80).");
                return 0;
            }
            PlayerInfo[playerid][pAge] = age;
            format(string, sizeof(string), "BLABLALBA",PlayerInfo[playerid][pAge]);
            SendClientMessage(playerid, COLOR_LIGHTRED, string);
            RegistrationStep[playerid] = 3;
            ShowPlayerDialog(playerid, DIALOG_REG3, DIALOG_STYLE_LIST, " BLABLALBA", "Los Santos\nLas Venturas\nSan Fierro", "Select", "Exit");
            }
        }
        return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
    }
Can someone help me ?
Reply
#2

UP.....
Reply
#3

Try changeing:

PHP код:
 format(file,sizeof(file),"/Users/%s.ini",GetName(playerid)); 
to

PHP код:
 format(file,sizeof(file),"Users/%s.ini",GetName(playerid)); 
Reply
#4

Quote:
Originally Posted by Chenko
Посмотреть сообщение
Try changeing:

PHP код:
 format(file,sizeof(file),"/Users/%s.ini",GetName(playerid)); 
to

PHP код:
 format(file,sizeof(file),"Users/%s.ini",GetName(playerid)); 
Didn't worked bro ..
Reply
#5

Are you opening the file above that code somewhere? If you are trying using fclose before using fremove.
Reply
#6

You are using fremove correctly. Please verify that your directory is in fact "Users" and not "users" or "User". It must be exact.

Chances are, in the spot where the file was created you may be saving it to a different directory (probably something similar) as mentioned above. That's why when it goes to delete the file, it doesn't do anything because "Users" doesn't exist.

Otherwise, if you have the file opened and you have not closed it, you will not be able to delete the file. You need to use fclose in order to close the file.
Reply
#7

Quote:
Originally Posted by Chenko
Посмотреть сообщение
Are you opening the file above that code somewhere? If you are trying using fclose before using fremove.
Quote:
Originally Posted by RVRP
Посмотреть сообщение
You are using fremove correctly. Please verify that your directory is in fact "Users" and not "users" or "User". It must be exact.

Chances are, in the spot where the file was created you may be saving it to a different directory (probably something similar) as mentioned above. That's why when it goes to delete the file, it doesn't do anything because "Users" doesn't exist.

Otherwise, if you have the file opened and you have not closed it, you will not be able to delete the file. You need to use fclose in order to close the file.
How can I use this function in my script ?
Reply
#8

Which function, fclose? It's simeply fclose(file[]) so in your case it would be fclose(file); right above fremove(file);

So this:

PHP код:
fclose(file);
fremote(file); 
Reply
#9

pawn Код:
format(file,sizeof(file),"/Users/%s.ini",GetName(playerid));
//replace with  
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), "/Users/%s.ini", name);
replace the
Reply
#10

Quote:
Originally Posted by Glad2BeHere
Посмотреть сообщение
pawn Код:
format(file,sizeof(file),"/Users/%s.ini",GetName(playerid));
//replace with  
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), "/Users/%s.ini", name);
replace the
Quote:
Originally Posted by Chenko
Посмотреть сообщение
Which function, fclose? It's simeply fclose(file[]) so in your case it would be fclose(file); right above fremove(file);

So this:

PHP код:
fclose(file);
fremote(file); 
I did it and its not deleting the file :\\
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)