Gang Membername
#1

Hi.
I've scripted a gang.
Now i like that the gangmember names saves in a file.

I have this done:
pawn Код:
if(strcmp(cmd,"/gangcreate",true) == 0)
{
...
format(string, sizeof(string), "/Gangs/MemberName/%d.txt", playerGang[playerid]);
hFile = fopen(string, io_append);
format(string, sizeof(string), "%s\r\n", PlayerName(playerid));
fwrite(hFile, string);
fclose(hFile);
...
return 1;
}
pawn Код:
if(strcmp(cmd,"/gangjoin",true) == 0)
{
...
format(string, sizeof(string), "/Gangs/MemberName/%d.txt", playerGang[playerid]);
hFile = fopen(string, io_append);
format(string, sizeof(string), "%s\r\n", PlayerName(playerid));
fwrite(hFile, string);
fclose(hFile);
...
return 1;
}


but how can i delete the name from the player when he leaves the gang?
My Command is /gangleave.



pawn Код:
if(strcmp(cmd,"/gangleave",true) == 0)
{
...

...
return 1;
}


Please help, i dont know what to do :S
Reply
#2

you need to make a FOR loop and put all the names in an array.
Then just make another loop for adding them back to the same file, but not the one you want to delete . This time you file mode must be io_write.

Tell me if confused.

Thank You
-Abhinav
Reply
#3

first of all thx for help.
umm i read it many times hmm i dont understand because my english is crap
if is not to long, do you can me post the code please?
Reply
#4

Check this, and tell me if it works.. because i have not tested it yet..
Код:
new TempArray[1024][256],DataRead[256],string[256],i;
	format(string, sizeof(string), "/Gangs/MemberName/%d.txt", playerGang[playerid]);
	hFile = fopen(string, io_read);
	for(i=0;i<=1024;i++){
		fread(hFile,DataRead,256,true);
		format(TempArray[i],256,"%s",DataRead);
	}
	fclose(hFile);
	hFile = fopen(string, io_write);
	for(i=0;i<=1024;i++){
	  if(strcmp(TempArray[i],PlayerName(playerid),true) && strlen(TempArray[i]==strlen(PlayerName(playerid))) fwrite(hFile,TempArray[i]);
	}
	fclose(hFile);
	return 1;
Reply
#5

hi,
i become a error:

Код:
	new File:hFile1;
	new TempArray[1024][256],DataRead[256],i;
	format(string, sizeof(string), "/Gangs/MemberName/%d.txt", playerGang[playerid]);
	hFile1 = fopen(string, io_read);
	for(i=0;i<=1024;i++)
	{
	fread(hFile1,DataRead,256,true);
	format(TempArray[i],256,"%s",DataRead);
	}
	fclose(hFile1);
	hFile1 = fopen(string, io_write);
	for(i=0;i<=1024;i++)
	{
 	if(strcmp(TempArray[i],PlayerName(playerid),true) && strlen(TempArray[i]==strlen(PlayerName(playerid))) fwrite(hFile1,TempArray[i]);     //Line 1913
	}
	fclose(hFile1);
Quote:

error 033: array must be indexed (variable "TempArray")

Reply
#6

change this line
pawn Код:
if(strcmp(TempArray[i],PlayerName(playerid),true) && strlen(TempArray[i]==strlen(PlayerName(playerid))) fwrite(hFile1,TempArray[i]);
TO

pawn Код:
if(strcmp(TempArray[i][0],PlayerName(playerid),true) && strlen(TempArray[i]==strlen(PlayerName(playerid))) fwrite(hFile1,TempArray[i]);
Reply
#7

still error


//EDIT: Hmm i think it fixed :
Код:
if(strcmp(TempArray[i],PlayerName(playerid),true) && strlen(TempArray[i])==strlen(PlayerName(playerid)))
but dont work... i type /gangleave and than come you leaved the gang bla and under come "SERVER: Unknow Command." and the line dont delete to.
Reply
#8

oh ... i guess you should give it sometime and try to fix it ......... If you wont be able to fix it, then just let me know.
Reply
#9

hmm please fix i really need that.
Reply
#10

Show us the error.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)