/removeacc help.
#1

Hi I need help with a command, basicly I want to have a command that deletes an account from the users file.

Quote:

CMD:deleteacc(playerid, params[])
{
new deletename[24];
if(sscanf(params,"s[24]", deletename)) return SendClientMessage(playerid, -1 , "Correct Usage: /deleteacc [name of the account you want deleted]");
new filestring2[128];
format(filestring2, sizeof(filestring2), "/Users/%s.ini", deletename);
if(!fexist(filestring2)) return SendClientMessage(playerid, -1 , "That account name doesn't exist!");
if(fexist(filestring2))
fremove(deletename);
SendAdminMessage(-1, "%s was succefully deleted from the database.",deletename);
return 1;
}

Evrytime I type /deleteacc Name_Name I just get Correct Usage: /deleteacc [name of the account you want deleted in game.

stock
Quote:

fdeleteline(filename[], line[]){
if(fexist(filename)){
new temp[256];
new File:fhandle = fopen(filename,io_read);
fread(fhandle,temp,sizeof(temp),false);
if(strfind(temp,line,true)==-1){return 0;}
else{
fclose(fhandle);
fremove(filename);
for(new i=0;i<strlen(temp);i++){
new templine[256];
strmid(templine,temp,i,i+strlen(line));
if(equal(templine,line,true)){
strdel(temp,i,i+strlen(line));
fcreate(filename);
fhandle = fopen(filename,io_write);
fwrite(fhandle,temp);
fclose(fhandle);
return 1;
}
}
}
}
return 0;
}

#define PATH "/Users/%s.ini"
Reply
#2

try and put correct name, watch letter example:

you want delete "LeaN"

so don't do /deleteaccount "lean"

put it correct "LeaN"
Reply
#3

I already tryed that :/
Reply
#4

bumpp
Reply
#5

may be this:

pawn Код:
else if(fexist(filestring2))
{
fremove(deletename);
SendAdminMessage(-1, "%s was succefully deleted from the database.",deletename);
return 1;
}
Reply
#6

Hi, now I get the message

' was succefully deleted from the database.

Quote:

CMD:deleteacc(playerid, params[])
{
new deletename[36];
if(sscanf(params,"s[36]", deletename)) return SendClientMessage(playerid, -1 , "Correct Usage: /deleteacc [name of the account you want deleted]");
new filestring2[128];
format(filestring2, sizeof(filestring2), "/Users/%s.ini", deletename);
if(!fexist(filestring2)) return SendClientMessage(playerid, -1 , "That account name doesn't exist!");
if(fexist(filestring2))
{
fremove(deletename);
SendAdminMessage(COLOR_YELLOW, "%s was succefully deleted from the database.",deletename);
}
return 1;
}

Reply
#7

I am using this and it works perfectly:

pawn Код:
CMD:deleteaccount(playerid, params[])
{
    new accName[MAX_PLAYER_NAME], str[50], string[128];
    if(sscanf(params,"s[24]", accName)) return SendClientMessage(playerid, -1 , "Usage: /deleteaccount [Accountname]");
    format(str, sizeof(str), "Users/%s.ini", accName);
    if(!fexist(str)) return SendClientMessage(playerid, -1 , "That account name doesn't exist!");
    fremove(str);
    format(string, sizeof(string), "You have successfully deleted %s's account." ,accName);
    SendClientMessage(playerid, -1, string);
    return 1;
}
Reply
#8

Thank you Rafaellos, that works brilliant!
Reply
#9

You are welcome!
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)