Don't get the same number!
#7

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:
Код:
new filename[64];
new filecontent[64];
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid,PlayerName,sizeof(PlayerName));
format(filename,sizeof(filename),"PhoneNumbers/%d",PhoneNumber[playerid]);
format(filecontent,sizeof(filecontent),"%s",PlayerName);
new File:PhoneFile=fopen(filename,io_readwrite);//open file "11275"..
fwrite(PhoneFile,filecontent);//write "Babul" into it,
fclose(PhoneFile);//and close the file. done.
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...
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: 4 Guest(s)