05.01.2013, 20:02
(
Last edited by Sasino97; 23/10/2018 at 09:54 PM.
Reason: Addedd support link
)
Sasinosoft Houses 2.2
House, store and furniture system
Hello SA-MP community, after months of scripting nothing for SA-MP, I'm very happy to show you my newest filterscript, Sasinosoft Houses 2. , the second version of my Sasinosoft Houses filterscript.House, store and furniture system
I started to create this version from scratch, I didn't edit the version 1, and I started it about the 15~20 december.
Today, the 09/01/2013 I fixed a bug, in the new new zip file you can see a file containing the changes.
Today, the 24/01/2013 I fixed another bug. The owner of a store wasn't able to sell his store. I don't know why didn't I notice it first.
Description
It's different from all the other house/business system, this has some unique features that I didn't find before in any other released house/business filterscript:
- Integrated furniture system (buy, sell, edit position and rotation...)
- House visiting before buying (by default 60 seconds, but it can be changed with a define)
- Making store item lists that can be handled in the gamemode with a callback
- All in list dialogs, no commands like /buyhouse etc..
- 2 in 1, this system is houses + stores.
Then there are some other facts:
- Using Incognito's Streamer plugin for the furniture
- Using SII (Slick's Ini Include) for saving data
- 1540~ lines
- 1 line = one house
- 1 line* = one store/shop/business (call it what you want, I really don't know what's the most appropriate word)
- Stores have a "goods" system, when they finish the owner should buy them.
- Stores have a "cash register system", when a player buys something in a store his money goes there. You can also set a store to make the players pay at entrance.
- Works with no text commands**, there's only 1 key (that can be redefined) which opens all the menus.
- The owner of a house can lock, unlock, enter and sell his house. (note: if his house is locked he still can enter it, but other people can't)
- The owner of a store can lock (same as above), unlock, enter, sell, refill, collect money from cash register. He can also buy an item from his own store and get back his money again by collecting them from cash register.
- I forgot to say that the house owner when inside in his house he can store money, withdraw money, store weapons, collect weapons, buy furniture, sell furniture and place/edit furniture.
- When an user sells a house, a store or a furniture, the initial value will be multiplied by a value (that you can define in the source script) and the server will give him back that money. (default is 0.8 )
- You can add, change or remove furnitures from the script very easily.
* if you want to add an item list to a store you should handle a callback to respond.
** There are 2 text commands (only for RCon logged admins), /savehouse and /savestore, which allow you to save to a text file the coordinates of your current position in CreateHouse or CreateBusiness format instead of using SA-MP's /save command that saves them in AddPlayerClass format.
Setup
Unfortunately to set up this filterscript is a bit of work, but if you follow these steps it won't be hard
- Download the rar package
- Extract it on your desktop
- Move SasinosoftHouses_2.2.amx and .pwn to your server's filterscript directory
- If you already didn't, download Slick's Ini Include from here https://sampforum.blast.hk/showthread.php?tid=58458 and put it in your include folder
- Open SII.inc and change INI_MAX_LINES from 256 to 512. (House files are a little big lol)
- If you already didn't, download Incognito's Streamer Plugin from here https://sampforum.blast.hk/showthread.php?tid=102865 and follow its instructions to install it.
- Make sure that in the scriptfiles folder exists the folder "Sasinosoft", and into it the 2 folders "Houses" and "Shops".
- Open your server.cfg and add the filterscript to the filterscripts line.
- Optional: copy example.amx and .pwn to your gamemode and run it to see how it works
- Open SasinosoftHouses.pwn and you will notice a huge comment, in it there's this "PLACE THIS IN YOUR GAMEMODE:", copy all the code under it and paste it in your gamemode. If you don't want to create your houses and stores in your gamemode, you can also edit the filterscript and create them in it.
- Change the defines and the furniture list as you wish.
- Go to your gamemode again and start creating Houses and Businesses ! I created example.pwn mainly to show you how to use it, check it out !
I made a lot of screenshots. The gamemode running is example.pwn provided in the zip file.
http://imageshack.us/a/img266/8800/samp853.png
http://imageshack.us/a/img99/2731/samp854.png
http://imageshack.us/a/img600/3493/samp855g.png
http://imageshack.us/a/img526/6407/samp856b.png
http://imageshack.us/a/img842/9427/samp857on.png
http://imageshack.us/a/img560/1424/samp858q.png
http://imageshack.us/a/img837/1558/samp859z.png
http://imageshack.us/a/img341/5875/samp860o.png
http://imageshack.us/a/img99/6758/samp861y.png
http://imageshack.us/a/img853/2348/samp862d.png
http://imageshack.us/a/img542/5972/samp863e.png
http://imageshack.us/a/img21/2818/samp864f.png
http://imageshack.us/a/img6/589/samp865kx.png
http://imageshack.us/a/img20/2778/samp866hw.png
http://imageshack.us/a/img546/2973/samp867z.png
How to add a house
It's very simple:
- Connect to your server (with Sasinosoft Houses loaded)
- Login into rcon
- Go near a house door
- Write the command /savehouse [description], I suggest to be specific when writing the description if you are going to save a lot of houses
- Quit the server
- Go to scriptfiles/Sasinosoft/Houses
- There should be a file called SavedHouses.txt
- Cut all his content and paste it under your OnGameModeInit
- Search for house interiors (Useful links: https://sampwiki.blast.hk/wiki/InteriorIDs#Burglary_Houses https://sampforum.blast.hk/showthread.php?tid=71648)
- Insert the other parameters
- Done
- Connect to your server (with Sasinosoft Houses loaded)
- Login into rcon
- Go near a storee door
- Write the command /savestore [description]
- Quit the server
- Go to scriptfiles/Sasinosoft/Shops
- There should be a file called SavedShops.txt
- Cut all his content and paste it under your OnGameModeInit
- Search for store interiors (see the links above)
- Fill the other parameters
- Optional: Fill the "itemlist" parameter (see below)
This thing is not simple for all, you must have a little of scripting knowledge to do this:
First of all you have to fill the itemlist parameter in a store, the items are separed by a \n character. Example: "Item name 1 (price$)\nItem name 2 (price$)\nItem name 3 (price$)"...
Then you have to create a global variable to store the storeid. Example: biz1 = CreateBusiness(...);
At the end, go to your callback called OnPlayerBuyItem and write:
pawn Code:
public OnPlayerBuyItem(playerid, shopid, itemid)
{
if(shopid == store1_variable)
{
switch(itemid)
{
case 0: // Bought the first item in your list
{
new price = 20; // Write the price
new string[64];
if(GetPlayerMoney(playerid) < price) return MsgBox(playerid, BOX_STYLE_ERROR, NO_MONEY); // Rember to make these checks
if(!GiveBusinessGoods(shopid, -2)) return MsgBox(playerid, BOX_STYLE_ERROR, NO_STOCK); // You can change the number of goods an item requires, for example you can make that a pistol takes 2 goods, but a shotgun takes 4 etc...
GivePlayerMoney(playerid, -price); // Remember to subtract player's money
GiveBusinessMoney(shopid, price); // Remember to add money to the cash register
format(string, 64, "You bought a **** for %d$", price); // At the place of *** write the thing that the player just bought
MsgBox(playerid, BOX_STYLE_CMD, string);
// THEN HERE DO WHAT YOU WANT :)
// Example:
GivePlayerWeapon(playerid, 28, 300);
// Or
SetPVarInt(playerid, "Cellphone", 1);
// Or
ApplyAnimation(playerid, "FOOD", "EAT_Pizza", 2.0, false, true, true, true, 3000, true);
// You can do what you want :)
}
case 1:
{
// .....
}
}
}
else if(shopid == store2_variable)
{
}
return 1;
}
New: 2.2
To download the whole .zip archive click the link below
http://www.2shared.com/file/e-H2vd_0...ouses_22.html?
(Link updated: readded example.pwn and .amx, because when I switched to 2.2 I forgot them)
If you wish to see the code on pastebin click this other link (2.2)
http://pastebin.com/PABSEj5W
Common mistakes
Issue 1: When I select a list item in any dialog nothing happens
Solution 1: Make sure that in your gamemode and in all your loaded filterscripts OnDialogResponse (if exists) returns 0 (Recommended)
Solution 2: Move SasinosoftHouses_2.2 before all the other filterscripts in server.cfg (Not recommended because the other filterscripts that use dialogs won't work)
Issue 2: Furniture are getting saved only up to ID 31
Solution 1: Open your SII.inc and change MAX_INI_LINES to a bigger value (512 recommended), then open Sasinosoft Houses and recompile.
Solution 2: Open Sasinosoft Houses source file and decrease MAX_FURNITURE to 30.
If you have other problems ask in the comments, I'll put here your issue and the possible solutions
For the next version...
I could add a lot of new features for the next version (3.0), I was thinking things like house & store robbery system, housecar system, predefined interiors (so you don't have to search them on the sa-mp wiki), making a simpler way to respond to item clicks, and as many of you suggested, a dynamic creating system, so an admin can create houses from the server.
If you have more ideas please write them
Support me
If you want to support me for my work, you can buy me a coffee.