Don't get the same number!
#9

Quote:
Originally Posted by Babul
Посмотреть сообщение
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..
heres a sort of PhoneNumer saving snippet:
Код:
your code..
a /call or /GetPlayerFromPhoneNumber <number> command is possible very easy this way...
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...
Oh ive made it like this:
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;
}
This only uses one txt file but maybe your way is better ill try playing around with it.
Reply


Messages In This Thread
Don't get the same number! - by The Woody - 22.06.2011, 14:47
Re: Don't get the same number! - by Jeffry - 22.06.2011, 14:50
Re: Don't get the same number! - by The Woody - 22.06.2011, 14:56
Re: Don't get the same number! - by Jeffry - 22.06.2011, 15:04
Re: Don't get the same number! - by The Woody - 22.06.2011, 15:19
Re: Don't get the same number! - by Jeffry - 22.06.2011, 15:23
Re: Don't get the same number! - by Babul - 22.06.2011, 15:40
Re: Don't get the same number! - by Jeffry - 22.06.2011, 15:44
Re: Don't get the same number! - by The Woody - 22.06.2011, 16:01
Re: Don't get the same number! - by Jeffry - 22.06.2011, 17:13

Forum Jump:


Users browsing this thread: 2 Guest(s)