12.12.2013, 23:34
Hey does anyone know what I am doing wrong here?
I am trying to load multiple names from a file, but it seems to only load one name and not the rest.
Ignore the print functions as they were used for debugging to find out why it was crashing, but that has been fixed.
Just need to know how I can load more then one name, and each name is seperated by a | hence why I have
I am trying to load multiple names from a file, but it seems to only load one name and not the rest.
Ignore the print functions as they were used for debugging to find out why it was crashing, but that has been fixed.
Just need to know how I can load more then one name, and each name is seperated by a | hence why I have
pawn Код:
split(string, SplitDiv, '|');
pawn Код:
stock LoadUserConnection(playerid)
{
new string[128], string2[128], name[100];
GetPlayerName(playerid, name, sizeof(name));
strreplace(name, '_', ' ');
format(string, sizeof(string), "/Users/%s.ini", name);
format(string2, sizeof(string2), "/Users/%s#.ini", name);
new File: file2 = fopen(string2, io_read);
if (file2)
{
fread(file2, string2);
friendly[playerid] = strval(string2);
print(string2);
}
else
{
print("FINDING #: File Reading Error!");
SendClientMessage(playerid, COLOR_RED, "File: Error Found!");
}
fclose(file2);
new File: file = fopen(string, io_read);
print("Open File");
new c = friendly[playerid];
print("Set c to friendly[playerid]");
new SplitDiv[1][80];
print("Create Split Div Variable");
if(file)
{
print("File Found!");
for(new i = 0; i < c; i++)
{
print(" In Loop");
fread(file, string);
split(string, SplitDiv, '|');
print(SplitDiv[0]);
strmid(PlayerInfo[playerid][pFriends][i], SplitDiv[0], 0, strlen(SplitDiv[0]), 255);
}
print("Finished Loop");
fclose(file);
print("Closed File");
}
else
{
print("RUNNING ELSE since FILE NOT FOUND");
print("File Writing Error!");
SendClientMessage(playerid, COLOR_RED, "File: Error Found!");
}
print("Closing File");
fclose(file);
print("File Closed");
return 1;
}