Zcelo12 ProGamer HardCore
CMD:removebl(playerid,params[]) { if (PlayerOrg[playerid] == 0) return SendError(playerid," You aren't in any faction!"); if(IsLeader(playerid) || IsPlayerRank(playerid) > 2) { new id; if(sscanf(params,"u",id)) return SendUsage(playerid," /removebl [playerid]"); if(!IsPlayerConnected(id) || IsPlayerNPC(id)) return SendError(playerid," Player is not connected!"); if(Org_Blacklist(id,GetOrgID(oPlayerName(id)))) { new name[64]; format(name,sizeof(name),"%s.ini",GetOrgName(PlayerOrg[playerid])); new File: file = fopen(name, io_read); if(file) { new valtmp[MAX_PLAYER_NAME]; while (fread(file, valtmp)) { StripNewLine(valtmp); if (!strcmp(valtmp, oPlayerName(playerid), true, strlen(oPlayerName(playerid)))) { strdel(valtmp,0,24); fclose(file); return 1; } } } } } return 1; }
new
File: oFile,
filename[32];
format(filename, sizeof filename, "tmp%s.ini", GetOrgName(PlayerOrg[playerid]));
if((oFile = fopen(filename[3], io_read))) { // open the original file
new
File: tFile;
if((tFile = fopen(filename, io_write))) { // opens the temp file, "tmpORIGINAL.ini"
new
tmp[MAX_PLAYER_NAME + 2],
name[sizeof tmp];
strcat(name, oPlayerName(playerid)); // save the name into a variable
strcat(name, "\r\n"); // needed to prevent to call StripNewLine
while(fread(oFile, tmp)) {
if(strcmp(tmp, name, false) == 0) { // we found the line
while(fread(oFile, tmp)) { // skips the check, since we already found it
fwrite(tFile, tmp);
}
break;
}
fwrite(tFile, tmp);
}
fclose(oFile);
fclose(tFile);
tFile = fopen(filename, io_read);
oFile = fopen(filename[3], io_write);
while(fread(tFile, tmp)) { // put the data back into the original
fwrite(oFile, tmp);
}
fclose(tFile);
fremove(filename); // removes the temp file
}
fclose(oFile);
}
Big Thanks to you
But 'filename' does not remove with fremove(); |