15.09.2011, 10:25
(
Last edited by PowerPC603; 31/01/2014 at 07:21 AM.
)
I've just completed my revised/updated housing system as a filterscript and it's finally here.
NOTE: Do NOT use this script together with the PPC_Trucking gamemode.
The gamemode has the housing system built-in and both systems will collide with eachother, as they both use the same commands and dialogs.
The system is quite easy to use.
Just install the script in your filterscripts folder and add it to your server.cfg file.
Also add a new folder called "PPC_Housing" in your scriptfiles folder, this is where the houses are saved and loaded.
If you don't have this folder and try to create a house, your server WILL crash.
Also, make sure ALL your other filterscripts and gamemode use "return 0;" under OnDialogResponse.
Otherwise the /housemenu won't work when you select an option from it.
Requirements:
The filterscript uses Incognito's streamer for the pickups and 3DText labels, so you need it for this script to work.
https://sampforum.blast.hk/showthread.php?tid=102865
It also uses sscanf:
https://sampforum.blast.hk/showthread.php?tid=120356
And zcmd is also required:
https://sampforum.blast.hk/showthread.php?tid=91354
If used together with my Speedometer script, both scripts communicate with eachother (you'll need the latest version for this).
Both scripts work separately too, so don't worry if you want to use only one of them.
This housing system has 2 different types of houses:
- normal houses (they work the same way as in my gamemode: PPC_Trucking):
Those houses start at level 1 when you buy them and they will have only 1 carslot.
Players can upgrade their houses to change their interior and to increase the amount of carslots.
Houses can have a maximum level of 10. When you create a house, you can set the maximum level to any value between 1 and 10.
- static houses:
These houses have a fixed interior (you set the interior when you create the house, they use the same interiors as the normal house's levels), so you could also say they have a fixed level. These houses cannot be upgraded.
They also have a fixed amount of carslots that can't be upgraded.
They have all the same features (rename house, open to public, close to public, buy housecars, ...) as normal houses, except for upgrading.
To create a normal (upgradable) house, use the command: /createhouse <price> <max-level (1-10)>
To create a static house, use the command: /createstatichouse <price> <carslots (1-10)> <interior (1-10)>
You can always use the /delhouse command to delete a house that's still for sale, you cannot delete a house that has an owner.
To buy a house, use the /buyhouse command. You need to stand within 2.5m of the entrance (green house-pickup).
To enter your house, stand near your house's entrance and use the command /enter.
To access all house-features, use the /housemenu command.
Exiting the house can also be done through the housemenu.
Car-tunings are also saved in your housefile, so no worries to lose all your vehiclecomponents when you logout.
All vehicles have a price of $50.000, adjust those prices to your needs in the ABuyableVehicles array, which starts at line 188.
Also, there are a few functions that you need to copy and modify to your gamemode or other filterscripts if you use server-sided money.
The filterscript normally has no access to your account-data that your gamemode might hold, but these functions allow the housing script to get data from your gamemode if you copy them to your gamemode.
They are near the bottom of the filterscript.
If you don't copy and edit them, the script will automatically use client-sided money.
The inner workings of these functions are pretty much self-explanatory.
You might need to edit the location of your data (pData[playerid][Money] for example, instead of APlayerData[playerid][PlayerMoney]).
Screenshot (normal house on the left, static house on the right):
Screenshot (inside the house, showing the housemenu):
Download it here:
http://users.telenet.be/vge/download...PC_Housing.pwn
NOTE: Do NOT use this script together with the PPC_Trucking gamemode.
The gamemode has the housing system built-in and both systems will collide with eachother, as they both use the same commands and dialogs.
The system is quite easy to use.
Just install the script in your filterscripts folder and add it to your server.cfg file.
Also add a new folder called "PPC_Housing" in your scriptfiles folder, this is where the houses are saved and loaded.
If you don't have this folder and try to create a house, your server WILL crash.
Also, make sure ALL your other filterscripts and gamemode use "return 0;" under OnDialogResponse.
Otherwise the /housemenu won't work when you select an option from it.
Requirements:
The filterscript uses Incognito's streamer for the pickups and 3DText labels, so you need it for this script to work.
https://sampforum.blast.hk/showthread.php?tid=102865
It also uses sscanf:
https://sampforum.blast.hk/showthread.php?tid=120356
And zcmd is also required:
https://sampforum.blast.hk/showthread.php?tid=91354
If used together with my Speedometer script, both scripts communicate with eachother (you'll need the latest version for this).
Both scripts work separately too, so don't worry if you want to use only one of them.
This housing system has 2 different types of houses:
- normal houses (they work the same way as in my gamemode: PPC_Trucking):
Those houses start at level 1 when you buy them and they will have only 1 carslot.
Players can upgrade their houses to change their interior and to increase the amount of carslots.
Houses can have a maximum level of 10. When you create a house, you can set the maximum level to any value between 1 and 10.
- static houses:
These houses have a fixed interior (you set the interior when you create the house, they use the same interiors as the normal house's levels), so you could also say they have a fixed level. These houses cannot be upgraded.
They also have a fixed amount of carslots that can't be upgraded.
They have all the same features (rename house, open to public, close to public, buy housecars, ...) as normal houses, except for upgrading.
To create a normal (upgradable) house, use the command: /createhouse <price> <max-level (1-10)>
To create a static house, use the command: /createstatichouse <price> <carslots (1-10)> <interior (1-10)>
You can always use the /delhouse command to delete a house that's still for sale, you cannot delete a house that has an owner.
To buy a house, use the /buyhouse command. You need to stand within 2.5m of the entrance (green house-pickup).
To enter your house, stand near your house's entrance and use the command /enter.
To access all house-features, use the /housemenu command.
Exiting the house can also be done through the housemenu.
Car-tunings are also saved in your housefile, so no worries to lose all your vehiclecomponents when you logout.
All vehicles have a price of $50.000, adjust those prices to your needs in the ABuyableVehicles array, which starts at line 188.
Also, there are a few functions that you need to copy and modify to your gamemode or other filterscripts if you use server-sided money.
The filterscript normally has no access to your account-data that your gamemode might hold, but these functions allow the housing script to get data from your gamemode if you copy them to your gamemode.
They are near the bottom of the filterscript.
If you don't copy and edit them, the script will automatically use client-sided money.
pawn Code:
// This function is used to get the player's money
forward EXT_GetPlayerMoney(playerid);
public EXT_GetPlayerMoney(playerid)
{
return APlayerData[playerid][PlayerMoney];
}
// This function is used to get the player's money
forward EXT_GivePlayerMoney(playerid, Money);
public EXT_GivePlayerMoney(playerid, Money)
{
// Add the given money to the player's account
APlayerData[playerid][PlayerMoney] = APlayerData[playerid][PlayerMoney] + Money;
// Return that the function had success (another script holds the player's money on the server-side)
return 1;
}
// This function is used to get the player's admin-level
forward EXT_GetPlayerAdminLevel(playerid);
public EXT_GetPlayerAdminLevel(playerid)
{
return APlayerData[playerid][AdminLevel];
}
// This function is used to determine if the player has logged in (he succesfully entered his password)
forward EXT_IsPlayerLoggedIn(playerid);
public EXT_IsPlayerLoggedIn(playerid)
{
if (APlayerData[playerid][LoggedIn] == true)
return 1; // The player has logged in succesfully
else
return -1; // The player hasn't logged in (yet)
}
You might need to edit the location of your data (pData[playerid][Money] for example, instead of APlayerData[playerid][PlayerMoney]).
Screenshot (normal house on the left, static house on the right):
Screenshot (inside the house, showing the housemenu):
Download it here:
http://users.telenet.be/vge/download...PC_Housing.pwn