Replace name in a file .txt
#1

Hi,

I have in my GM a file "test.txt" within some names. This file is called in OnPlayerConnect


Alex_Green
John_Smith
.
.
.

I want to create a commande who replace a name with another.
My code is:

Код:
gpname = old name
tmp = new name
file = fopen("test.txt", io_readwrite);   // open the file, read and write
   	while(fread(file,openf,sizeof(openf)))   
        {
            if (strfind(openf, gpname, true) != -1)   search a name
 	     {
			strmid(gpname, tmp, 0, strlen(tmp), 255);   replace this name by a new name
		        format(string, 256, "%s",tmp);                 
   	     }
    	}
   	fwrite(file, string); //write
   	fclose(file);
Example I want to remplace John_Smith by Will_Black with this code it check John_Smith but dont delete this name just add Will_Black In the end.

I know my code don't replace but I don't know how to make.

Thank to help.
Reply
#2

maybe strdel or Strins?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)