Global variables confusion -
OdgFox - 03.02.2018
I have some doubts about the global variables, I hope that someone can answer me, greetings.
I have the following variable in my gamemode (at least 10 equals)
I use it to give you the id of a house
Код:
HouseID = i; (i = GetNearestHouseID(playerid))
So, if player X is using this variable (at least it is in 5 consecutive house functions) and player Y uses the /house command at the same time the value of HouseID would change completely to the house closest to it, so both the HouseID value of player X will not be worth the same as when he use the command .. right?
Then, the solution to that would be the following:
Код:
new HouseID[MAX_PLAYERS];
And
Код:
HouseID[playerid] = i (i = GetNearestHouseID(playerid))
But, if I want to add sell the house by dialogues, I can not use HouseID [playerid] since in the playerid dialog it would be the id of the player Y (to whom the house will be sold)
What can I do in this case? .. the same thing happens to me in 3 different opportunities, not only with the system of houses .. can someone help me ?, thanks!
Re: Global variables confusion -
jasperschellekens - 03.02.2018
Im not sure if i inderstood you correctly but
You can do something like on top of script :
New h_id = HouseID[playerid];
Re: Global variables confusion -
OdgFox - 03.02.2018
Quote:
Originally Posted by jasperschellekens
Im not sure if i inderstood you correctly but
You can do something like on top of script :
New h_id = HouseID[playerid];
|
It would not be useful to add that in the code, since I would only be changing the name practically: /
Re: Global variables confusion -
Mugala - 03.02.2018
if I correctly understand, u can add one more variable or u can just use PVar's
for example if player Y wants to sell a house to player X, you ucan use PVars like this:
SetPVarInt(X,"House",House[Y]);
and than u can adjust it after the purchase, like this:
HouseID[X] = GetPVarInt(X,"House");
HouseID[Y] = 0;
Re: Global variables confusion -
OdgFox - 03.02.2018
Quote:
Originally Posted by Mugalito
if I correctly understand, u can add one more variable or u can just use PVar's
for example if player Y wants to sell a house to player X, you ucan use PVars like this:
SetPVarInt(X,"House",House[Y]);
and than u can adjust it after the purchase, like this:
HouseID[X] = GetPVarInt(X,"House");
HouseID[Y] = 0;
|
Using then, if another player also agrees to sell the house to another person, would not the value change at all?
That is, at the same time
X sells to Y and
X2 sells to Y2
Re: Global variables confusion -
Mugala - 03.02.2018
Quote:
Originally Posted by OdgFox
Using then, if another player also agrees to sell the house to another person, would not the value change at all?
That is, at the same time X sells to Y and X2 sells to Y2
|
no there's not a swap, the one player is standing without house but if u want a swap, than just make it like this:
PHP код:
// when offers
SetPVarInt(X,"House",House[Y]);
SetPVarInt(Y,"House",House[X]);
// when accepts or idk.
HouseID[X] = GetPVarInt(X,"House");
HouseID[Y] = GetPVarInt(Y,"House");
I dont understand what u want
try to explain better.
Re: Global variables confusion -
OdgFox - 03.02.2018
Quote:
Originally Posted by Mugalito
no there's not a swap, the one player is standing without house but if u want a swap, than just make it like this:
PHP код:
// when offers
SetPVarInt(X,"House",House[Y]);
SetPVarInt(Y,"House",House[X]);
// when accepts or idk.
HouseID[X] = GetPVarInt(X,"House");
HouseID[Y] = GetPVarInt(Y,"House");
I dont understand what u want try to explain better.
|
Thanks, that help me so much... ♥