08.02.2013, 11:30
Hi I need help with a command, basicly I want to have a command that deletes an account from the users file.
Evrytime I type /deleteacc Name_Name I just get Correct Usage: /deleteacc [name of the account you want deleted in game.
stock
#define PATH "/Users/%s.ini"
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; } |
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; } |