Member name saving in a file -
hhaaoo123 - 31.05.2015
When I invited someone to join a faction, I want his name to be auto written in a file. For example, I invited John_Smith into LSPD and his name will be written in "factions/LSPDMembers.ini". I have no idea how those function does because most of the thing got deleted...
Can anyone teach me??
Код:
stock Facmembersave() {
new
szFileStr[30],
File: iFileHandle = fopen("factions/LSPD.ini", io_write);
What should I write here???????????
fclose(iFileHandle);
}
And how to write the name when he got invited into the file?
Re: Member name saving in a file -
amirm3hdi - 31.05.2015
I never did INI, but you should do this:
Код:
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
printf("[TEST] Player's name is: %s", pname);
I guess you should save the name (string) like this:
Код:
INI_WriteString(iFileHandle, "string_data", "pname"); // Saving string
And this is how it saves: string_data = John
Re: Member name saving in a file -
hhaaoo123 - 31.05.2015
Why I need to print it?
Re: Member name saving in a file -
amirm3hdi - 31.05.2015
You don't, it's for testing to see if it works...
Re: Member name saving in a file -
hhaaoo123 - 31.05.2015
Well... undefined symbol INI_WriteString...
EDIT: The whole server crashed...
Re: Member name saving in a file -
hhaaoo123 - 31.05.2015
-DELETE-
AW: Member name saving in a file -
Nero_3D - 31.05.2015
Open the file with io_append and write the name to it
pawn Код:
stock AddTextToFile(filename[], text[]) {
if(text[0] == EOS) {
return false;
}
new
File: file = fopen(filename, (fexist(filename) ? io_append : io_write))
;
if(!file) {
return false;
}
fwrite(file, text);
fclose(file);
return true;
}
That will add the text to the file
pawn Код:
stock FacAddMemberToFile(playerid) {
new
tmp[MAX_PLAYER_NAME + 2]
;
if(GetPlayerName(playerid, tmp, MAX_PLAYER_NAME)) {
strcat(tmp, "\r\n"); // new line after the name
return AddTextToFile("factions/LSPDMembers.ini", tmp);
}
return false;
}