[HELP] Removing a name from .txt file.
#1

Hello, im using a command /showdisables (means show banned players on my server)..

Those who get disabled are listed in a disable.txt file, which is shown by (/showdisables) in a dialog.

the problem is, when those players are undisabled, there name stay on .txt file? how to remove it after they got undisabled (unbanned).

here is some code:
PHP код:

COMMAND
:showdisables(playerid,parmas[])
{
    new 
read[200],ss[1008],op[1000],bool:NextDialog false;
    if(
PlayerInfo[playerid][pAdminlevel] < 1)
    {
    
SendClientMessage(playerid,COLOR_ERROR,""ERROR_MSG"");
    return 
1;
    }
    
format(op,sizeof(op),"");
    new 
File:log fopen("DisabledPlayers.txt",io_read);
    while(
fread(log,read))
    {
    
strcat(read,"\n",200);
    
strcat(op,read,1000);
    
ln[playerid]++;
    if(
ln[playerid] == 110)
    {
    
NextDialog true;
    break;
    }
    }
    
fclose(log);
    if(
strlen(op) <= 3)
    {
    
SendClientMessage(playerid,-1,"{ff0000}No Players are Currently Disabled.");
    return 
1;
    }
    
format(ss,sizeof(ss),""WHITE"%s",op);
    if(
NextDialog == false)ShowPlayerDialog(playerid110,  DIALOG_STYLE_LIST"Disabled Players",ss"Select""Cancel");
    else
    
ShowPlayerDialog(playerid111,  DIALOG_STYLE_LIST"Disabled Players",ss"Select""Next Page");
    return 
1;

And here's the /removedisable
PHP код:
COMMAND:removedisable(playeridparmas[])
{
    if(
PlayerInfo[playerid][pSpawned] == 1)
    {
    new 
TargetID[MAX_PLAYER_NAME];
    new 
string[256];
    new 
path[100];
    
    if(
PlayerInfo[playerid][pAdminlevel] < 1)
    {
    
SendClientMessage(playerid,COLOR_ERROR,""ERROR_MSG"");
    return 
1;
    }
    if(
sscanf(parmas,"s[128]",TargetID) || isnull(parmas))
    {
    
SendClientMessage(playeridCOLOR_ERROR"USAGE: /removedisable (Name)");
    return 
1;
    }
    
format(path,sizeof(path),"Disables/%s.ini",TargetID);
    
    if(!
fexist(path))
    {
    
format(string,sizeof(string),"There Is No User Named as "YELLOW"%s "RED"Disabled.",TargetID);
    
SendClientMessage(playerid,COLOR_ERROR,string);
    return 
1;
    }
    
fremove(path);
    
format(string,sizeof(string),"%s's Disable Has Been Removed Sucessfully.",TargetID);
    
SendClientMessage(playerid,COLOR_ADMIN,string);
    
printf("%s's Disable Has Been Removed By %s",TargetID,PlayerInfo[playerid][pName]);
    
fdeleteline("DisabledPlayers.txt"TargetID); // it doesn't deletes the targetname? why?? 
    
}
    else
    {
    
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Use This Command While You're Dead.");
    }
    return 
1;

Reply
#2

Get the position of the user's name with strfind and then delete it with strdel.

https://sampwiki.blast.hk/wiki/Strfind
https://sampwiki.blast.hk/wiki/Strdel
Reply
#3

How can i make it with strfind, strdel? any help
Reply
#4

mySQL is more suited to this sort of thing.
Reply
#5

And Can You Please Stop Writing Like This? Unprofessional.
Reply
#6

you can save and replace the text "playername" By " "
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)