17.04.2014, 01:14
(
Последний раз редактировалось Brandon_More; 18.04.2014 в 12:29.
Причина: Updated: You can now /createhouse & /deletehouse
)
iHouse Ownership Sysem
Brand new 2014 ownership system for houses.
Brand new 2014 ownership system for houses.
Changelog:
Код:
You can now /createhouse & /deletehouse
About this project:
Well I started this a few months ago and well, it was a total disaster. It wasn't doing anything except sitting on my desktop so I started the development again like literally 7 days ago. Anyway, I wanted to create my own project from scratch and give it some unique features and I believe that is what I have done with this script. Anyway, without further a due....... Please enjoy and don't forget to give me REP+ or a comment if you used this <3 As always much appreciated.old version: https://sampforum.blast.hk/showthread.php?tid=483670
Features:
This script contains a bunch of new features that I have only just recently added and thought of.Some features:
- You can own a house
- You can rent at a house
- You can give your friend a key to the house (He can open & close)
- You can set rent price
- You can rent at a house
- You can store / take cash from house as long as it's open
- You can lock your house
- Set an owner with a simple command
- Give someone a dupekey / set dupekey
- Set rentprice
- Sell the house
- Set the houses amount of cash
- Open / close the house with a command
- Set the interior of the house with a command
Код:
/ahouse interior > Set's the current position to the interior of the house. move > Set's the exterior of the house to your position sell > Sells the house you're outside of to the price spcified. rentprice > Sets the rentprice of the house you are outside of the specified criteria Housecash > Set's the house cash to specified amount. Outside house. dupekey > Set's the dupekey to the owner of the house you are outside of. To set to nobody type in "None" lock > If the house is locked it will be unlocked. If it's unlocked it will be locked.
Код:
/ihouse Buy > If you are outside a house and it's for sale, you will buy the house given that you have the amount of cash Sell > If you and outside a house and you own it, you can sell the house with the specified amount. rentprice > If you are outside the house and you are owner. You can set rentprice to spcirfied. Rentroom > If you are outside a house and it's rentable. Youw ill be rtenting at it now. lock > If your the owner of the house you are outside, if it's locked it will be unlocked. If it's unlocked it will be locked. locker > If you type in /ihouse locker take 5000 it will give you the amount and take away from the house cash. dupekey > Type in the ID of the person you with to give the dupekey to. /ihouse dupekey 1. He needs to be close to you.
pawn Код:
/*
/*
/*
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
| | | | | | | | | | | |
|_ _ _ _ _ _| | | | | | _ _ _ _ _ | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | |_ _ _| | | | | | | | | |
| | | | | | | | | | | |
| | | _ _ _ | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
_ _ _| |_ _ _ | | | | | | _ _ _ _ | | | |_ _ _ _ _| |
| | | | | | | | | |
|_ _ _ _ _ _ _ _| |_ _ _| |_ _ _| |_ _ _ _ _ _ _ _ _| |_ _ _ _ _ _ _ _ _|
By your man GiGi! (Brandon More)
*/
#include <a_samp>
#include <a_mysql>
#include <string>
#include <streamer>
#include <a_zones>
#include <zcmd>
#define mysql_host "localhost" // MySQL host. Default set.
#define mysql_user "root" // MySQL user. Default set
#define mysql_password "" // Password. Default is set.
#define mysql_database "Sicilia-RP" // MySQL Database. (Change)
#define MAX_HOUSES 200
#define ALTCOMMAND:%1->%2; \
COMMAND:%1(playerid, params[]) \
return cmd_%2(playerid, params);
#define HouseLoop(%1) for(new %1 = 0; %1 < MAX_HOUSES; %1++)
#undef MAX_PLAYERS
#define MAX_PLAYERS 50 // Please change this to the criteria of your server. Set to default.
#define MaxPriceAHouseCanBeSold 5000000 // Change this to what ever.
new RentedHouse[MAX_PLAYERS] = -1;
enum iHouse
{
hID,
Float:outX, // Exterior
Float:outY, // Exterior
Float:outZ, // Exterior
Float:intX, // Interior
Float:intY, // Interior
Float:intZ, // Interior
intVW, // Interior
intINT, // Interior
Text3D:outLabel, // House Exterior label
owner[ 50 ], // House owner - displays on Label
sellprice, // If > than 0 it will be classed as on sale!
closed,
rentprice,
dupekey,
housecash,
hActive,
}
new House[MAX_HOUSES][iHouse];
forward mysql_start();
public mysql_start()
{
mysql_debug(1);
if(mysql_connect(mysql_host, mysql_user, mysql_database, mysql_password))
{
print("[MYSQL] Connection successful!");
}
else
{
print("[MYSQL] There was an error connecting to the MYSQL server");
}
return 1;
}
public OnFilterScriptInit()
{
mysql_start();
LoadHouse();
return 1;
}
public OnFilterScriptExit()
{
HouseLoop(h)
{
SaveHouses(h);
}
mysql_close();
return 1;
}
/*
From other people....
*/
stock myStrcpy(dest[], src[])
{
new i = 0;
while ((dest[i] = src[i])) i++;
}
stock IsNumeric(const string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] > '9' || string[i] < '0')
{
return 0;
}
}
return 1;
}
/*
Finish
*/
main()
{
print("\n---------------------------------------");
print(" Player house System by your boy GiGi!");
print("---------------------------------------\n");
}
stock CreateNewHouse(house, Float:posX, Float:posY, Float:posZ)
{
new query[250];
format(query,sizeof(query),"INSERT INTO `houseinfo` (hID) VALUES (%d);", house);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `intX` = '0.0' WHERE `hID`=%d",house);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `intY` = '0.0' WHERE `hID`=%d",house);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `intZ` = '0.0' WHERE `hID`=%d", house);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `outX` = '%f' WHERE `hID`=%d", posX, house);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `outY` = '%f' WHERE `hID`=%d", posY, house);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `outZ` = '%f' WHERE `hID`=%d", posZ, house);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `intINT` = 0 WHERE `hID`=%d", house);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `owner` = 'None' WHERE `hID`=%d", house);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `dupekey` = 'None' WHERE `hID`=%d", house);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `sellprice` = '0' WHERE `hID`=%d", house);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `rentprice` = '0' WHERE `hID`=%d", house);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `housecash` = '0' WHERE `hID`=%d", house);
mysql_query(query);
ReloadHouse(house);
return 1;
}
public OnPlayerSpawn(playerid)
{
if(RentedHouse[playerid] != -1)
{
new HouseToSpawn = RentedHouse[playerid];
SetPlayerVirtualWorld(playerid, House[HouseToSpawn][intVW]);
SetPlayerInterior(playerid, House[HouseToSpawn][intINT]);
SetPlayerPos(playerid, House[HouseToSpawn][intX], House[HouseToSpawn][intY], House[HouseToSpawn][intZ]);
}
return 1;
}
stock HouseExitOrEnter(playerid)
{
HouseLoop(h)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, House[h][intX], House[h][intY], House[h][intZ]))
{
new playerINT = GetPlayerInterior(playerid), playerVW = GetPlayerVirtualWorld(playerid);
if(playerINT == House[h][intINT])
{
if(playerVW == House[h][intVW])
{
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerPos(playerid, House[h][outX], House[h][outY], House[h][outZ]);
}
}
}
if(IsPlayerInRangeOfPoint(playerid, 2.0, House[h][outX], House[h][outY], House[h][outZ]))
{
new playerINT = GetPlayerInterior(playerid), playerVW = GetPlayerVirtualWorld(playerid);
if(playerINT == 0)
{
if(playerVW == 0)
{
if(House[h][closed] == 1) return GameTextForPlayer(playerid,"~r~Closed",3000,3);
SetPlayerInterior(playerid, House[h][intINT]);
SetPlayerVirtualWorld(playerid, House[h][intVW]);
SetPlayerPos(playerid, House[h][intX], House[h][intY], House[h][intZ]);
}
}
}
}
return 1;
}
stock SaveHouses(h) // Saved every variable sepratly. - More simple.
{
new query[750];
format(query, sizeof(query), "UPDATE `houseinfo` SET `outX`='%f' WHERE `hID`=%d", House[h][outX], h);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `outY`='%f' WHERE `hID`=%d", House[h][outY], h);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `outZ`='%f' WHERE `hID`=%d", House[h][outZ], h);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `intX`='%f' WHERE `hID`=%d", House[h][intX], h);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `intY`='%f' WHERE `hID`=%d", House[h][intY], h);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `intZ`='%f' WHERE `hID`=%d", House[h][intZ], h);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `intINT`='%d' WHERE `hID`=%d", House[h][intINT], h);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `owner`='%s' WHERE `hID`=%d", House[h][owner], h);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `sellprice`='%d' WHERE `hID`=%d", House[h][sellprice], h);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `dupekey`='%s' WHERE `hID`=%d", House[h][dupekey], h);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `housecash`='%d' WHERE `hID`=%d", House[h][housecash], h);
mysql_query(query);
format(query, sizeof(query), "UPDATE `houseinfo` SET `rentprice`='%d' WHERE `hID`=%d", House[h][rentprice], h);
mysql_query(query);
return 1;
}
stock UnusedHouse()
{
new Found = -1;
HouseLoop(h)
{
if(House[h][hActive] > 0)
return h;
}
return Found;
}
stock LoadHouse()
{
HouseLoop(h)
{
new query[250];
format(query, sizeof(query),"SELECT * FROM `houseinfo` WHERE `hID`=%d", h);
mysql_query(query);
mysql_store_result();
new rows = mysql_num_rows();
if(rows >= 1)
{
ReloadHouse(h);
House[h][hActive] = 1;
}
else
{
House[h][hActive] = 0;
}
mysql_free_result();
}
}
stock ReloadHouse(i) //FAILED!
{
DestroyDynamic3DTextLabel(House[i][outLabel]);
new query[300], savingstring[50];
format(query, sizeof(query), "SELECT * FROM `houseinfo` WHERE `hID`=%d", i);
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query,"|"))
{
mysql_fetch_field_row(savingstring, "hID");
House[i][hID] = strval(savingstring);
// Coordinated shit
//Exterior
mysql_fetch_field_row(savingstring, "outX");
House[i][outX] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "outY");
House[i][outY] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "outZ");
House[i][outZ] = floatstr(savingstring);
//Interior
mysql_fetch_field_row(savingstring, "intX");
House[i][intX] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "intY");
House[i][intY] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "intZ");
House[i][intZ] = floatstr(savingstring);
// Coordinated shit
mysql_fetch_field_row(savingstring, "intINT");
House[i][intINT] = strval(savingstring);
mysql_fetch_field_row(savingstring, "owner");
myStrcpy(House[i][owner], savingstring);
mysql_fetch_field_row(savingstring, "dupekey");
myStrcpy(House[i][dupekey], savingstring);
mysql_fetch_field_row(savingstring, "sellprice");
House[i][sellprice] = strval(savingstring);
mysql_fetch_field_row(savingstring, "rentprice");
House[i][rentprice] = strval(savingstring);
mysql_fetch_field_row(savingstring, "housecash");
House[i][housecash] = strval(savingstring);
House[i][closed] = 1;
}
mysql_free_result();
new avayable, string[250], tmps[100];
if(House[i][sellprice] >= 1) { avayable = House[i][sellprice]; }
else { avayable = 0; }
new zone[60];
GetZone(House[i][outX],House[i][outY],House[i][outZ], zone);
format(tmps, 256, "{FF0000}[ {FFDAB9}%d, %s{FF0000}]\n{FFDAB9}Owner: {FF0000}%s", i, zone, House[i][owner]);
format(string, sizeof(string), "\n{FFDAB9}For Sale: {FF0000}$%d", House[i][sellprice]);
if(avayable) { strcat(tmps, string); }
House[i][outLabel] = CreateDynamic3DTextLabel(tmps, -1, House[i][outX], House[i][outY], House[i][outZ]+0.3, 20.0);
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & 16 && !IsPlayerInAnyVehicle(playerid))
{
HouseExitOrEnter(playerid);
}
return 1;
}
// When a player performs a command
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(!success) return SendClientMessage(playerid, -1, "The command has not been found! Use /commands.");
return 1;
}
COMMAND:ahouse(playerid, params[]) // For server admnistators
{
new tmp[ 15 ], tmp2[ 15 ], tmp3[ 128 ], houseId = -1, query[250];
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You cannot perform this command.");
if(sscanf(params, "szz", tmp, tmp2, tmp3)) return SendClientMessage(playerid, -1, " /ahouse [ Move / Sell / Owner / Interior / Dupekey / Rentprice / housecash / lock ]");
//==============================================================================
new playerINT = GetPlayerInterior(playerid);
HouseLoop(h)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, House[h][outX], House[h][outY], House[h][outZ]))
{
houseId = h;
}
}
//==============================================================================
if(!strcmp(tmp, "move", true, 4))
{
if(!strlen(tmp2) || !IsNumeric(tmp2) || strlen(tmp2) > 2) return SendClientMessage(playerid, -1, "move [HouseID]");
new houseID = strval(tmp2);
new Float:iX, Float:iY, Float:iZ;
GetPlayerPos(playerid, iX, iY, iZ);
format(query, sizeof(query), "UPDATE `houseinfo` SET `outX` = '%f', `outY` = '%f', `outZ` = '%f' WHERE `hID` = %d", iX, iY, iZ, houseID);
mysql_query(query);
House[houseID][outX] = iX;
House[houseID][outY] = iY;
House[houseID][outZ] = iZ;
ReloadHouse(houseID);
}
else if(!strcmp(tmp, "sell", true, 4))
{
if(houseId < 0) return SendClientMessage(playerid, -1, "You arn't outside a house");
if(!strlen(tmp2) || !IsNumeric(tmp2) || strlen(tmp2) > 9) return SendClientMessage(playerid, -1, "sell [amount]");
format(query, sizeof(query), "UPDATE `houseinfo` SET `sellprice` = %d WHERE `hID` = %d", strval(tmp2), houseId);
mysql_query(query);
ReloadHouse(houseId);
}
else if(!strcmp(tmp, "owner", true, 5))
{
if(houseId < 0) return SendClientMessage(playerid, -1, "You arn't outside a house");
if(!strlen(tmp2) || IsNumeric(tmp2)) return SendClientMessage(playerid, -1, "owner [Who? (Fullnme, no ID's)]");
format(query, sizeof(query), "UPDATE `houseinfo` SET `owner` = '%s' WHERE `hID` = %d", tmp2, houseId);
mysql_query(query);
ReloadHouse(houseId);
}
else if(!strcmp(tmp, "dupekey", true, 7))
{
if(houseId < 0) return SendClientMessage(playerid, -1, "You arn't outside a house");
if(!strlen(tmp2) || IsNumeric(tmp2)) return SendClientMessage(playerid, -1, "dupekey [Who? (Fullnme, no ID's)]");
format(query, sizeof(query), "UPDATE `houseinfo` SET `dupekey` = '%s' WHERE `hID` = %d", tmp2, houseId);
mysql_query(query);
ReloadHouse(houseId);
}
else if(!strcmp(tmp, "interior", true, 8))
{
if(!strlen(tmp2) || !IsNumeric(tmp2)) return SendClientMessage(playerid, -1, "interior [HouseID]");
new ID = strval(tmp2);
new Float:iX, Float:iY, Float:iZ;
GetPlayerPos(playerid, iX, iY, iZ);
format(query, sizeof(query), "UPDATE `houseinfo` SET `intX` = '%f', `intY` = '%f', `intZ` = '%f', `intINT` = %d WHERE `hID` = %d", iX, iY, iZ, playerINT, ID);
mysql_query(query);
ReloadHouse(houseId);
}
else if(!strcmp(tmp, "rentprice", true, 9))
{
if(houseId < 0) return SendClientMessage(playerid, -1, "You arn't outside a house");
if(!strlen(tmp2) || !IsNumeric(tmp2) || strlen(tmp2) > 9) return SendClientMessage(playerid, -1, "rentprice [amount]");
format(query, sizeof(query), "UPDATE `houseinfo` SET `rentprice` = %d WHERE `hID` = %d", strval(tmp2), houseId);
mysql_query(query);
ReloadHouse(houseId);
}
else if(!strcmp(tmp, "housecash", true, 9))
{
if(houseId < 0) return SendClientMessage(playerid, -1, "You arn't outside a house");
if(!strlen(tmp2) || !IsNumeric(tmp2) || strlen(tmp2) > 9) return SendClientMessage(playerid, -1, "housecash [amount]");
format(query, sizeof(query), "UPDATE `houseinfo` SET `housecash` = %d WHERE `hID` = %d", strval(tmp2), houseId);
mysql_query(query);
ReloadHouse(houseId);
}
else if(!strcmp(tmp, "lock", true, 4))
{
if(houseId < 0) return SendClientMessage(playerid, -1, "You arn't outside a house");
if(House[houseId][closed] == 1)
{
House[houseId][closed] = 0;
GameTextForPlayer(playerid,"~g~Opened",3000,3);
return 1;
}
else
{
House[houseId][closed] = 1;
GameTextForPlayer(playerid,"~r~Closed",3000,3);
return 1;
}
}
else return SendClientMessage(playerid, -1, " /ahouse [ Move / Sell / Owner / Interior / Dupekey / Rentprice / housecash / lock ]");
return 1;
}
COMMAND:ihouse(playerid, params[]) // For owners of house
{
new tmp[ 15 ], tmp2[ 15 ], tmp3[ 128 ];
if(sscanf(params, "szz", tmp, tmp2, tmp3)) return SendClientMessage(playerid, -1, " /ihouse [ Buy / Sell / Lock / Rentprice / Locker / Dupekey ]");
new houseId = -1, query[250];
HouseLoop(h)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, House[h][outX], House[h][outY], House[h][outZ]))
{
houseId = h;
}
}
if(!strcmp(tmp, "buy", true, 3))
{
if(houseId < 0) return SendClientMessage(playerid, -1, "You arn't outside a house");
if(House[houseId][sellprice] < 1) return GameTextForPlayer(playerid,"~r~Not for sale",3000,3);
else
{
new PlayerCash = GetPlayerMoney(playerid);
if(PlayerCash >= House[houseId][sellprice])
{
GivePlayerMoney(playerid, -House[houseId][sellprice]);
GameTextForPlayer(playerid,"~g~Purchased",3000,3);
new pname[50];
GetPlayerName(playerid, pname, sizeof(pname));
format(query, sizeof(query), "UPDATE `houseinfo` SET `owner` = '%s', `sellprice` = 0 WHERE `hID` = %d", pname, houseId);
mysql_query(query);
ReloadHouse(houseId);
}
else return GameTextForPlayer(playerid,"~r~You do not have enough money",3000,3);
}
}
else if(!strcmp(tmp, "sell", true, 4))
{
if(houseId < 0) return SendClientMessage(playerid, -1, "You arn't outside a house");
new pname[24];
GetPlayerName(playerid, pname, sizeof(pname));
if(strcmp(pname, House[houseId][owner], true)) return GameTextForPlayer(playerid,"~r~You don't own this house",3000,3);
new MaxPrice = strval(tmp2);
new warning[50];
format(warning, sizeof(warning), "A house can only be sold for $%d, please change amount.", MaxPriceAHouseCanBeSold);
if(MaxPrice < 0 || MaxPrice > MaxPriceAHouseCanBeSold) return SendClientMessage(playerid, -1, warning);
format(query, sizeof(query),"UPDATE `houseinfo` SET `SellPrice` = %d WHERE `hID` = %d", MaxPrice, houseId);
mysql_query(query);
new iStr[50];
format(iStr, sizeof(iStr), "~g~$%d", MaxPrice);
GameTextForPlayer(playerid,iStr,3000,3);
ReloadHouse(houseId);
}
else if(!strcmp(tmp, "rentprice", true, 9))
{
if(houseId < 0) return SendClientMessage(playerid, -1, "You arn't outside a house");
new pname[24];
GetPlayerName(playerid, pname, sizeof(pname));
if(strcmp(pname, House[houseId][owner], true)) return GameTextForPlayer(playerid,"~r~You don't own this house",3000,3);
new Rent = strval(tmp2);
format(query, sizeof(query),"UPDATE `houseinfo` SET `RentPrice` = %d WHERE `hID` = %d", Rent, houseId);
mysql_query(query);
new iStr[50];
format(iStr, sizeof(iStr), "~g~$%d", Rent);
GameTextForPlayer(playerid,iStr,3000,3);
ReloadHouse(houseId);
}
else if(!strcmp(tmp, "rentroom", true, 8))
{
if(houseId < 0) return SendClientMessage(playerid, -1, "You arn't outside a house");
new Rent = House[houseId][rentprice], PlayerCash = GetPlayerMoney(playerid);
if(Rent == 0) return GameTextForPlayer(playerid,"~r~UnRentable",3000,3);
if(PlayerCash < Rent) return GameTextForPlayer(playerid,"~r~Not enough cash",3000,3);
else
{
RentedHouse[playerid] = houseId;
new iStr[50];
format(iStr, sizeof(iStr), "~g~Renting at %d for $%d", houseId, Rent);
GameTextForPlayer(playerid,iStr,3000,3);
GivePlayerMoney(playerid, -Rent);
}
}
else if(!strcmp(tmp, "locker", true, 6))
{
if(houseId < 0) return SendClientMessage(playerid, -1, "You arn't outside a house");
if(House[houseId][closed] == 1)
{
GameTextForPlayer(playerid,"~g~Locker is closed",3000,3);
return 1;
}
else
{
if(!strlen(tmp2) || IsNumeric(tmp2)) return SendClientMessage(playerid, -1, "locker [take / store]");
else if(!strcmp(tmp2, "take", true, 4))
{
if(!strlen(tmp3) || !IsNumeric(tmp3) || strlen(tmp3) > 9) return SendClientMessage(playerid, -1, "take [amount]");
new Amount = strval(tmp3);
if(Amount > House[houseId][housecash]) return GameTextForPlayer(playerid,"~r~Not enough in house",3000,3);
House[houseId][housecash] -= Amount;
GivePlayerMoney(playerid, Amount);
GameTextForPlayer(playerid,"~g~Taken cash",3000,3);
}
else if(!strcmp(tmp2, "store", true, 5))
{
}
else return SendClientMessage(playerid, -1, "locker [take / store]");
}
}
else if(!strcmp(tmp, "lock", true, 4))
{
if(houseId < 0) return SendClientMessage(playerid, -1, "You arn't outside a house");
new pname[24];
GetPlayerName(playerid, pname, sizeof(pname));
if(strcmp(pname, House[houseId][owner], true)) return GameTextForPlayer(playerid,"~r~You don't own this house",3000,3);
if(House[houseId][closed] == 1)
{
House[houseId][closed] = 0;
GameTextForPlayer(playerid,"~g~Opened",3000,3);
return 1;
}
else
{
House[houseId][closed] = 1;
GameTextForPlayer(playerid,"~r~Closed",3000,3);
return 1;
}
}
else if(!strcmp(tmp, "dupekey", true, 7))
{
if(houseId < 0) return SendClientMessage(playerid, -1, "You arn't outside a house");
new pname[24];
GetPlayerName(playerid, pname, sizeof(pname));
if(strcmp(pname, House[houseId][owner], true)) return GameTextForPlayer(playerid,"~r~You don't own this house",3000,3);
else
{
if(!strlen(tmp2) || IsNumeric(tmp2)) return SendClientMessage(playerid, -1, "dupekey [take / set]");
else if(!strcmp(tmp2, "take", true, 4))
{
GameTextForPlayer(playerid,"~g~Taken dupekey",3000,3);
format(query, sizeof(query), "UPDATE `houseinfo` SET `dupekey` = 'None' WHERE `hID` = %d", houseId);
mysql_query(query);
ReloadHouse(houseId);
}
else if(!strcmp(tmp2, "set", true, 3))
{
if(!strlen(tmp3) || !IsNumeric(tmp3) || strlen(tmp3) > MAX_PLAYERS) return SendClientMessage(playerid, -1, "set [playerid]");
new playerID = strval(tmp3);
if(!IsPlayerConnected(playerID)) return GameTextForPlayer(playerid,"~r~Player isn't connected",3000,3);
GetPlayerName(playerID, pname, sizeof(pname));
format(query, sizeof(query), "UPDATE `houseinfo` SET `dupekey` = '%s' WHERE `hID` = %d", pname, houseId);
mysql_query(query);
ReloadHouse(houseId);
}
else return SendClientMessage(playerid, -1, "dupekey [take / set]");
}
}
else return SendClientMessage(playerid, -1, " /ihouse [ Buy / Sell / Lock / Rentprice / Locker / Dupekey ]");
return 1;
}
COMMAND:unrent(playerid, params[])
{
if(RentedHouse[playerid] != -1)
{
GameTextForPlayer(playerid,"~r~Unrented",3000,3);
RentedHouse[playerid] = -1;
}
else
{
GameTextForPlayer(playerid,"~r~You arn't renting",3000,3);
}
return 1;
}
COMMAND:createhouse(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You cannot use this");
new Float:iX, Float:iY, Float:iZ;
GetPlayerPos(playerid, iX, iY, iZ);
new houseId = UnusedHouse();
CreateNewHouse(houseId, iX, iY, iZ);
return 1;
}
COMMAND:deletehouse(playerid)
{
new query[50];
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You cannot use this");
HouseLoop(h)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, House[h][outX], House[h][outY], House[h][outZ]))
{
format(query,sizeof(query), "DELETE FROM `HouseInfo` WHERE `hID` = %d", h);
mysql_query(query);
House[h][hActive] = 0;
ReloadHouse(h);
}
}
return 1;
}
Below I have add a zipped file with all things inside (Includes, plugins, Compiled, Source Code & Database.)