I have a problem
#1

Guys i made a members saving system in .txt with their names with command /setmember in my organization script but when i use /setmember id its only saving my name if i use /setmember 1 then saving my name and if i use /setmember 2 then saving my name
like

IceBilizard
IceBilizard

this this is my code see and tell what is worng
pawn Код:
CMD:setmember(playerid, params[])
{
if (!IsLeader(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not the leader of an organization");
new ID;
if (sscanf(params, "u", ID)) return SendClientMessage(playerid,COLOR_WHITE,"Usage: /setmember [playerid]");
if (!IsPlayerConnected(ID) || ID == playerid) return 1;
new org = PlayerOrg[playerid];
if (PlayerOrg[ID]) return SendClientMessage(playerid, COLOR_RED,"That player already belongs to an organization");
if (Requesting[ID] != org) return SendClientMessage(playerid, COLOR_RED,"That player is not requesting to join your organization!");
new string[120];
format(string,sizeof(string),"%s has set you as a member of %s", PlayerName(playerid), GetOrgName(org));
SendClientMessage(ID, COLOR_YELLOW, string);
format(string,sizeof(string),"You have set %s a member of %s", PlayerName(ID), GetOrgName(org));
SendClientMessage(playerid, COLOR_YELLOW, string);
PlayerOrg[ID] = org;
GiveOrgFeatures(ID);
Requesting[ID] = 0;
if (PlayerOrg[ID] == 1)
{
        new pname[24], File:ftw=fopen("GSFMembers.txt", io_append);
        if(ftw)
        {
        GetPlayerName(ID, pname, 24);
        format(string, 300, "%s\r\n", pname); // formatting the string with the escape codes
        fwrite(ftw, string);
        fclose(ftw);
        }

}
return 1;
}
Reply
#2

You have a problem? Okay....
So, I think you used ****** Translate partly or something like that, anyway
It appears that your code just keeps adding lines everytime u use the command.
That is what io_append does, I believe there are two things you could do.
1. Make a function that will save all your details, using io_write (this clears the file before writing) so basically rewriting everything in the userconfig. Since file.inc is like the slowest reading/writing files method, this will definatelly take some time.

2. Delete the previous line, adding the new one.
Using this function: https://sampwiki.blast.hk/wiki/Fdelete_code, you are able to delete the line before writing it again.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)