20.09.2018, 08:00
Hello. In a house system, when player stands near the entrance pickup of a house, and types /buyhouse, he gets a dialog, which he should either submit or cancel, if player submits it, then on response of this dialog there should be all the stuff with money and mysql queries. The problem is that when player types /buyhouse, server loops through all houses (which might be over 2000 on a server), to find at which house's entrance the player is at, then on respone of the dialog there is the same loop, to get id of the house again. So this is kind of ineficcient to do those 2 loops, a solution that comes to my mind is to store the id of the house in a special variable in player's enum when he types /buyhouse, then use the value in it in the ondialogresponse function, but is this a bad practice?
P.S. by id of house i mean the index of it in the array of houses, and i obviously need to change variables in it after it's purchased.
P.S. by id of house i mean the index of it in the array of houses, and i obviously need to change variables in it after it's purchased.