Comparing the playerid to child table
#1

Hi, so, I have my 'player_accounts' table with the primary key on the field 'ID' and my child table 'player_house' with the primary key set on 'Userid', the relation is set and working. I would like to know when a player perform a command like /lockhouse by example, how to compare both PlayerInfo[playerid][pID] with the Userid from the child table ?

In simple words, how to know if he owns a house ?

With enums it would be:
PHP код:
if(PlayerInfo[playerid][pID] == HouseInfo[houseid][hID
but how with a child table ?
Reply
#2

I wouldn't use a child table at all.

The main table for houses should have the primary key to its house ID so it can be able to update data whenever you want and have a column like "Owner" that is set to 0 if no owner or the user ID if it is owned.

EDIT: On second tought, this way is better.

When a player connects to the server and after logging, sending a query such (an example):
pawn Код:
"SELECT houseid FROM houses WHERE Owner=%i"
would select all the house IDs that player owns.

No need to have per-player variables. Have the Owner (user ID or 0) stored in a variable and then comparing would be really easy.
Reply
#3

You can use a variable who's setting the house id on /buyhouse.

For example, pHouseKey.. when a player buy a house, the variable gets the value of that house id.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)