SA-MP Forums Archive
Enter/exit systems and looping through houses - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Enter/exit systems and looping through houses (/showthread.php?tid=658544)



Enter/exit systems and looping through houses - 0xAAAAAA - 06.09.2018

Hi. I've seen a lot of samp gamemodes (mostly roleplay), and in those gamemodes they nearly always use linear search for iterating through all houses on server in order to enter a house by a command or clicking ALT. When i started to make my own enter/exit system i had decided to use a special variable (which is in the player enum) for keeping the id of the house that a player is standing at, which is calculated by some simple pickup id division, and whether the player is at the exit or the entrance is calculated with mod(%). In the OnPlayerKeyStateChange function i only check whether the player is in range of the entrance/exit pickup of the house whose id is in the player's special variable. My question is why people use linear search? Isn't it going to have weak performance on a server with, say 1000 houses and the same number of players? And is my way of making enter/exit system reasonable for a roleplay server or not?