Quote Originally Posted by Loud21
All I know about this system is that it was written by some guy named Nathan, if anyone could tell me who that is i'll post his name in this thread and give him proper credit.

I found this system a while ago in some source shared here on ac-web. I recently updated it to work with my trinity which is from April of 2017 I think. I know that there were some changes to creature scripting since then so I'm not sure if it will work on the latest revision, it would be cool if someone could comment how to update it
Recently I had the idea of making the whole system more database dependent, since on the old script you had to edit the code and recompile every time you wanted to add new creatures or new game objects
Short into in how the system works.

You have 2 usable commands, one is .house add the other is .house fix.
.house add will add a 10x10 house at the location you are currently standing in, adding a new house will also spawn an npc at that location, which the player will buy the house from.

You can place an NPC using the creature script "player_housing_npc" at the location of your main mall or whatever. The players can later talk to the NPC in the mall to preview or buy the houses which you created.
You should use the command .house fix whenever one of the houses is sold to fix the ids in the database since they get "distorted"
when someone buys a house.

I left a couple of entries in the player_house_spawns table in hope that it will explain how the whole database system works.

If not here's a short tutorial.

The maximum amount of creatures or objects you can add to each package is 15
So thats 30 entries for one package in total.


There are 5 columns in total in the player_house_spawns table.

id, CreaOrObjId, CreaOrObjName, CreatureOrObject, package.

In total the players can purchase up to 4 package upgrades from the NPC using the "player_housing_npc" script.

These upgrades will allow them to spawn more objects and creatures.

Theid column is the most confusing out of the bunch.
For example, if you have 1 creature and 1 object and they are both in the package 1 you can set both of their ids as 1,
but if you add one more creature or one more object into package 1, that new entry will have to have its id set to 2, the old object and creature will still have the number 1 in the entry column. If you add a creature or an object to package 2 you can set their id's as 1 again. (Idk if this makes any sense honestly for some reason its hard for me to explain this.)

CreaOrObjId is the entry of either the creature or the object from creature_template or object_template.
CreaOrObjName is the name of your object or creature, it doesnt have to be the same as the one in the creature_template or the object_template
CreatureOrObject determines if the entry is a creature or the object, the value 0 is used for creatures the value 1 is used for objects.
packages determines which package the creature and the object belong to.


SQL Part
SQL



C++ Part
Player Housing Npc
Player Housing <- The one I "rewrote"

SQL For the needed creatures.
Code:
INSERT INTO `creature_template` VALUES (535535, 0, 0, 0, 0, 0, 20291, 0, 0, 0, 'Player Housing', 'Purchase a Home', '', 68, 80, 80, 2, 35, 129, 1, 1, 0.3, 0, 0, 2000, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 7, 4096, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', 0, 3, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 'player_housing_npc', 12340, 0, 0, NULL);
INSERT INTO `creature_template` VALUES (555555, 0, 0, 0, 0, 0, 22209, 0, 0, 0, 'Buy this Land', 'House', '', 68, 80, 80, 2, 35, 1, 1, 1, 1.5, 0, 0, 2000, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 7, 4096, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', 0, 3, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 'player_housing_npc_guide', 12340, 0, 0, NULL);
SQL For the needed items.
Code:
INSERT INTO `item_template` VALUES (351270, 15, 0, -1, 'House Controller', 32300, 6, 0, 0, 1, 35000, 0, 0, -1, -1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 2000, 2000, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 70522, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 1, 'Proud owner of an Astral House.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 'npc_player_house', 0, 0, 0, 0, 0, 0, 350, 0, 0, 0, 0, 0, 0, 0, 0, 15595);
INSERT INTO `item_template` VALUES (351290, 15, 0, -1, 'House Token', 32300, 6, 0, 0, 1, 0, 0, 0, -1, -1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 2000, 2000, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 'This item is used for purchasing and upgrading houses. It\'s price is 1 000 MG.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, '', 0, 0, 0, 0, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15595);
Add to custom_script_loader
Code:
void AddSC_PlayerHousing();
void AddSC_npc_player_house();
And
AddSC_PlayerHousing();
AddSC_npc_player_house();
Original Maker : Unknown
Update credits : Loud21


› See More: Player Housing Updated and "rewritten"