Global variables confusion
#1

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)

Код:
new HouseID;
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!
Reply
#2

Im not sure if i inderstood you correctly but

You can do something like on top of script :
New h_id = HouseID[playerid];
Reply
#3

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: /
Reply
#4

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;
Reply
#5

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
Reply
#6

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.
Reply
#7

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... ♥
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)