SA-MP Forums Archive
About Searching in files? - Printable Version

+- SA-MP Forums Archive (
+-- Forum: SA-MP Scripting and Plugins (
+--- Forum: Scripting Help (
+---- Forum: Help Archive (
+---- Thread: About Searching in files? (/showthread.php?tid=140019)

About Searching in files? - falor - 07.04.2010

Hey guys,
I am actually coding the phone system for my rp server, but actually, when someone make a /call it's with playerid, not roleplay for announce for exemple.
That's why i need your help, how to make a phone system with /call phonenr
I have already made the command /buyphone, and it gives you a phonenr (PlayerInfo[playerid][phonenr] )
But i have no idea how to do when a player write /call phonenr , how the system can find the phonenr and call it (instead of playerid)

Re: About Searching in files? - Babul - 07.04.2010

good question, it deserves some good answers, ill try one:
lets presume that each phonenumber can be associated only once to a player...
if you want to search in a large pool of numbers (100,000 to 999,999) == 899,999 then i suggest to first SORT them. if you got the list sorted (PhoneNumber -> PlayerName), then you can do a binary search in it, which is faster than doing a linear search...
for checking if the desired player is online, you need to loop through each player and check if the Name matches the Name pointed by the PhoneNumber, OR sort the players online aswell, then you can also do a binary search.
i didnt try to script a thing like that, but its a neat feature to think about.