22.06.2011, 16:01
Quote:
i suggest you to waste some harddisc space for creating one file per number, and let the filesystem do the dirty work (sorting) for you:
Код:
new PhoneNumber[MAX_PLAYERS];//you already got an array for the phonenumbers. use yours indeed.. Код:
your code.. if i would get the number 11275 as "Babul", then the file "scriptfiles/PhoneNumbers/11275" would contain simply "Babul". if you want a /GetPhoneNumberFromPlayer <Name> command, its also a good idea to store the PhoneNumber in another file with the PlayerName as filename... |
pawn Код:
#define ALL_NUMBER_FILE "AllNumbers.txt" // on top
new string[128], Number; // when i buy a phone
Player[playerid][PhoneN] = 940+random(699);
format( string, sizeof( string ), "You have purchased a cellphone. Your number is %d.", Player[playerid][PhoneN]);
SendClientMessage( playerid, WHITE, string);
Number = Player[playerid][PhoneN];
AddNumberToFile(ALL_NUMBER_FILE, Number);
stock AddNumberToFile(DFileName[], Number) // a stock.
{
new File:NumFile, Line[128];
format(Line, sizeof(Line), "%i\r\n", Number);
NumFile = fopen(DFileName, io_append);
fwrite(NumFile, Line);
fclose(NumFile);
return 1;
}