Sziasztok le tudnátok nekem ezt fordtítani magyarra? köszönöm! lehetõleg értelmes legyen!
/*
* S32_House - Create house with just one line (MySQL)!
* Copyright(c)System32
* This file is provided as is (no warranties)
* I started developing this include a 2-3 months ago but I had a big problems, now it\'s fixed and everything works!
* Functions: 52
* Commands: 18
* Callbacks: 4
* Credits:
* System32 - Almost everything!
* The Guy - Helped me a lot, thank you!
* Y_Less - y_hooks, y_commands, sscanf & foreach!
* G-Stylezz (BlueG) - MySQL plugin!
* Some guy on forums like wups, Y_Less - helped me with some things!
* That is basically it, have fun with this include and easy scripting!
*/
#if !defined _inc_a_samp
#include
#endif
#if !defined _inc_a_mysql
#include
#endif
#if !defined _inc_foreach
#include
#endif
#include
#include
#define MAX_HOUSES 150
#define MAX_CURRENT_HOUSES 50
#define house_version \"v2.0.0\"
#if !defined MAX_HOUSES
#error Please define the max houses (#define MAX_HOUSES)
#endif
#define COLOR_LIME 0x10F441AA
#define COLOR_KRED 0xFF0000FF
#define COLOR_YELLOW 0xFFFF00AA
enum hInfo
{
hOwner[24],
Float: hEnterX,
Float: hEnterY,
Float: hEnterZ,
Float: hExitX,
Float: hExitY,
Float: hExitZ,
hInterior,
hPrice,
hVirtualWorld,
hOwned,
hLocked,
Text3D: hLabel,
hPickup,
hWeaponID1,
hWeaponID2,
hWeaponID3,
hWeaponID1Ammo,
hWeaponID2Ammo,
hWeaponID3Ammo,
hMoney,
hRentUser[24],
hRentPrice,
hRented,
hRentDisabled,
hAlarm,
hCar,
hVehicleID,
Float: hCarX,
Float: hCarY,
Float: hCarZ,
Float: hCarA,
hCarColor1,
hCarColor2,
hCarLocked,
hCarOwner[24],
hCarWeaponID1,
hCarWeaponID2,
hCarWeaponID1Ammo,
hCarWeaponID2Ammo,
hCarMoney
};
new HouseInfo[MAX_HOUSES][hInfo];
enum hcInfo
{
Float: hcEnterX,
Float: hcEnterY,
Float: hcEnterZ,
Float: hcExitX,
Float: hcExitY,
Float: hcExitZ,
hcInterior,
hcVirtualWorld,
hcPrice,
hcRentPrice,
Text3D: hcLabel,
hcPickup
}
new CurrentHouseInfo[MAX_CURRENT_HOUSES][hcInfo];
new Iterator:Houses, hstring[128], HQuery[1000], HouseID, hsavingstring[3000], House_Weapon[MAX_PLAYERS][13], House_Ammo[MAX_PLAYERS][13], RentFeeTimer, Float: PPos[4], CurrentHouseID;
new bool: PlayerEnteredHisHouse[MAX_PLAYERS] = false, bool: PlayerEnteredHisHouseCar[MAX_PLAYERS] = false, bool: PlayerCanRobHouse[MAX_PLAYERS] = true, HouseLockBreaking[MAX_PLAYERS], HouseRobbing[MAX_PLAYERS], CanRobHouseTimer[MAX_PLAYERS];
forward OnPlayerEnterHouse(playerid, houseid);
forward OnPlayerExitHouse(playerid, houseid);
forward OnPlayerEnterHouseVehicle(playerid);
forward OnPlayerExitHouseVehicle(playerid);
forward RentFeeUp();
forward BreakingLock(playerid);
forward RobbingHouse(playerid);
forward CanRobHouse(playerid);
//***************************** *****************************
//***************************** FUNCTIONS *****************************
//***************************** *****************************
/*
• Function: CreateHouse(Float: EnterX, Float: EnterY, Float: EnterZ, Interior, Float: InteriorX, Float: InteriorY, Float: InteriorZ, Price, VirtualWorld, RentPrice)
• Data storage: MySQL (G-Stylezzz\'s plugin)
• Usage: Creating house, use this in OnGameModeInit or OnFilterScriptInit!
• Parameters:
EnterX, EnterY, EnterZ: Coordinates where you can enter house, also on that coordiantes will create pickup and 3D text!
ExitX, ExitY, ExitZ: Coordinates where you can exit house, this coordinates are coordiantes of interior, you can find interiors on http://weedarr.wikidot.com/interior or http://wiki.sa-mp.com/wiki/InteriorIDs
Interior: ID od interior you want, see the web page on the parameter above
Price: Price for buying house
VirtulWorld: Always increase this because if you have 2 same interior and player are in the (Example one is in his house, second is in his too) they will see themself, It will look that they have same house! (Bad explained :/)
RentPrice: Price for renting house, when player buy house maximum rent price is 10000 so, if you put it 20000 than he change it, he won\'t be able to set it again on 20000
• Example: CreateHouse(-2521.3315,-623.4722,132.7717, 3, 1527.229980,-11.574499,1002.097106, 1000, 0, 5000);
*/
stock CreateHouse(Float: EnterX, Float: EnterY, Float: EnterZ, Interior, Float: ExitX, Float: ExitY, Float: ExitZ, Price, VirtualWorld, RentPrice, VehicleID = 0, Float: CarX = 0.0, Float: CarY = 0.0, Float: CarZ = 0.0, Float: CarA = 0.0, CarColor1 = 0, CarColor2 = 0)
{
format(HQuery, sizeof(HQuery), \"SELECT * FROM `house` WHERE `HouseID` = %d\", HouseID);
mysql_query(HQuery);
mysql_store_result();
if(mysql_num_rows() == 0)
{
format(HouseInfo[HouseID][hOwner], 24, \"None\");
format(HouseInfo[HouseID][hRentUser], 24, \"None\");
format(HouseInfo[HouseID][hCarOwner], 24, \"None\");
HouseInfo[HouseID][hEnterX] = EnterX;
HouseInfo[HouseID][hEnterY] = EnterY;
HouseInfo[HouseID][hEnterZ] = EnterZ;
HouseInfo[HouseID][hExitX] = ExitX;
HouseInfo[HouseID][hExitY] = ExitY;
HouseInfo[HouseID][hExitZ] = ExitZ;
HouseInfo[HouseID][hInterior] = Interior;
HouseInfo[HouseID][hVirtualWorld] = VirtualWorld;
HouseInfo[HouseID][hPrice] = Price;
HouseInfo[HouseID][hRentPrice] = RentPrice;
HouseInfo[HouseID][hVehicleID] = VehicleID;
HouseInfo[HouseID][hCarX] = CarX;
HouseInfo[HouseID][hCarY] = CarY;
HouseInfo[HouseID][hCarZ] = CarZ;
HouseInfo[HouseID][hCarA] = CarA;
HouseInfo[HouseID][hCarColor1] = CarColor1;
HouseInfo[HouseID][hCarColor2] = CarColor2;
format(hstring, sizeof(hstring), \"For sale!\\nPrice: %d\\nHouse ID: %d\\nType /buyhouse to buy house!\", Price, HouseID);
format(HQuery, sizeof(HQuery), \"INSERT INTO `house` (`User`, `EnterX`, `EnterY`, `EnterZ`, `ExitX`, `ExitY`, `ExitZ`, `Interior`, `Price`, `VirtualWorld`, `Owned`, `Locked`, `Alarm`, `Weapon ID 1`, `Weapon ID 2`, `Weapon ID 3`, `Weapon ID 1 Ammo`, `Weapon ID 2 Ammo`, `Weapon ID 3 Ammo`, `Money`,\");
format(HQuery, sizeof(HQuery), \"%s `Rent User`, `Rent Price`, `Rented`, `Rent Disabled`, `VehicleID`, `CarX`, `CarY`, `CarZ`, `CarA`, `Color1`, `Color2`, `Car Locked`, `Car Owner`, `Car Weapon ID 1`, `Car Weapon ID 2`, `Car Weapon ID 1 Ammo`, `Car Weapon ID 2 Ammo`, `Car Money`, `HouseID`) VALUES\", HQuery);
format(HQuery, sizeof(HQuery), \"%s (\'None\', %f, %f, %f, %f, %f, %f, %d, %d, %d, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \'None\', %d, 0, 0, %d, %f, %f, %f, %f, %d, %d, 0, \'None\', 0, 0, 0, 0, 0, %d)\", HQuery, HouseInfo[HouseID][hEnterX], HouseInfo[HouseID][hEnterY], HouseInfo[HouseID][hEnterZ], HouseInfo[HouseID][hExitX], HouseInfo[HouseID][hExitY],
HouseInfo[HouseID][hExitZ], HouseInfo[HouseID][hInterior], HouseInfo[HouseID][hPrice], HouseInfo[HouseID][hVirtualWorld], HouseInfo[HouseID][hRentPrice], HouseInfo[HouseID][hVehicleID], HouseInfo[HouseID][hCarX], HouseInfo[HouseID][hCarY], HouseInfo[HouseID][hCarZ], HouseInfo[HouseID][hCarA], HouseInfo[HouseID][hCarColor1], HouseInfo[HouseID][hCarColor2], HouseID);
mysql_query(HQuery);
HouseInfo[HouseID][hLabel] = Create3DTextLabel(hstring, 0x21DD00FF, EnterX, EnterY, EnterZ, 40.0, 0);
HouseInfo[HouseID][hPickup] = CreatePickup(1273, 23, EnterX, EnterY, EnterZ, 0);
if(HouseInfo[HouseID][hVehicleID] != 0 && HouseInfo[HouseID][hCarX] != 0.0 && HouseInfo[HouseID][hCarY] != 0.0 && HouseInfo[HouseID][hCarZ] != 0.0 && HouseInfo[HouseID][hCarA] > 0.0)
{
HouseInfo[HouseID][hCar] = AddStaticVehicle(VehicleID, CarX, CarY, CarZ, CarA, CarColor1, CarColor2);
}
}
else
{
if(mysql_fetch_row_format(HQuery, \"|\"))
{
mysql_fetch_field_row(hsavingstring, \"User\"); format(HouseInfo[HouseID][hOwner], 24, \"%s\", hsavingstring);
mysql_fetch_field_row(hsavingstring, \"EnterX\"); HouseInfo[HouseID][hEnterX] = floatstr(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"EnterY\"); HouseInfo[HouseID][hEnterY] = floatstr(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"EnterZ\"); HouseInfo[HouseID][hEnterZ] = floatstr(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"ExitX\"); HouseInfo[HouseID][hExitX] = floatstr(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"ExitY\"); HouseInfo[HouseID][hExitY] = floatstr(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"ExitZ\"); HouseInfo[HouseID][hExitZ] = floatstr(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Interior\"); HouseInfo[HouseID][hInterior] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Price\"); HouseInfo[HouseID][hPrice] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"VirtualWorld\"); HouseInfo[HouseID][hVirtualWorld] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Owned\"); HouseInfo[HouseID][hOwned] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Locked\"); HouseInfo[HouseID][hLocked] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Weapon ID 1\"); HouseInfo[HouseID][hWeaponID1] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Weapon ID 2\"); HouseInfo[HouseID][hWeaponID2] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Weapon ID 3\"); HouseInfo[HouseID][hWeaponID3] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Weapon ID 1 Ammo\"); HouseInfo[HouseID][hWeaponID1Ammo] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Weapon ID 2 Ammo\"); HouseInfo[HouseID][hWeaponID2Ammo] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Weapon ID 3 Ammo\"); HouseInfo[HouseID][hWeaponID3Ammo] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Money\"); HouseInfo[HouseID][hMoney] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Rent User\"); format(HouseInfo[HouseID][hRentUser], 24, \"%s\", hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Rent Price\"); HouseInfo[HouseID][hRentPrice] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Rented\"); HouseInfo[HouseID][hRented] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Rent Disabled\"); HouseInfo[HouseID][hRentDisabled] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Alarm\"); HouseInfo[HouseID][hAlarm] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"VehicleID\"); HouseInfo[HouseID][hVehicleID] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"CarX\"); HouseInfo[HouseID][hCarX] = floatstr(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"CarY\"); HouseInfo[HouseID][hCarY] = floatstr(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"CarZ\"); HouseInfo[HouseID][hCarZ] = floatstr(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"CarA\"); HouseInfo[HouseID][hCarA] = floatstr(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Color1\"); HouseInfo[HouseID][hCarColor1] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Color2\"); HouseInfo[HouseID][hCarColor2] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Car Locked\"); HouseInfo[HouseID][hCarLocked] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Car Owner\"); format(HouseInfo[HouseID][hCarOwner], 24, \"%s\", hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Car Weapon ID 1\"); HouseInfo[HouseID][hCarWeaponID1] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Car Weapon ID 2\"); HouseInfo[HouseID][hCarWeaponID2] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Car Weapon ID 1 Ammo\"); HouseInfo[HouseID][hCarWeaponID1Ammo] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Car Weapon ID 2 Ammo\"); HouseInfo[HouseID][hCarWeaponID2Ammo] = strval(hsavingstring);
mysql_fetch_field_row(hsavingstring, \"Car Money\"); HouseInfo[HouseID][hCarMoney] = strval(hsavingstring);
if(HouseInfo[HouseID][hOwned] == 1)
{
if(HouseInfo[HouseID][hRentDisabled] == 0)
{
format(hstring, sizeof(hstring), \"Owner: %s\\nHouse ID: %d\\nRent User: %s\\nRent Price: %d\", HouseInfo[HouseID][hOwner], HouseID, HouseInfo[HouseID][hRentUser], HouseInfo[HouseID][hRentPrice]);
HouseInfo[HouseID][hLabel] = Create3DTextLabel(hstring, 0x21DD00FF, HouseInfo[HouseID][hEnterX], HouseInfo[HouseID][hEnterY], HouseInfo[HouseID][hEnterZ], 40.0, 0);
HouseInfo[HouseID][hPickup] = CreatePickup(1239, 23, HouseInfo[HouseID][hEnterX], HouseInfo[HouseID][hEnterY], HouseInfo[HouseID][hEnterZ], 0);
}
else
{
format(hstring, sizeof(hstring), \"Owner: %s\\nHouse ID: %d\\nRent Disabled\", HouseInfo[HouseID][hOwner], HouseID);
HouseInfo[HouseID][hLabel] = Create3DTextLabel(hstring, 0x21DD00FF, HouseInfo[HouseID][hEnterX], HouseInfo[HouseID][hEnterY], HouseInfo[HouseID][hEnterZ], 40.0, 0);
HouseInfo[HouseID][hPickup] = CreatePickup(1239, 23, HouseInfo[HouseID][hEnterX], HouseInfo[HouseID][hEnterY], HouseInfo[HouseID][hEnterZ], 0);
}
}
else
{
format(hstring, sizeof(hstring), \"For sale!\\nPrice: %d\\nHouse ID: %d\\nType /buyhouse to buy house!\", Price, HouseID);
HouseInfo[HouseID][hLabel] = Create3DTextLabel(hstring, 0x21DD00FF, HouseInfo[HouseID][hEnterX], HouseInfo[HouseID][hEnterY], HouseInfo[HouseID][hEnterZ], 40.0, 0);
HouseInfo[HouseID][hPickup] = CreatePickup(1273, 23, HouseInfo[HouseID][hEnterX], HouseInfo[HouseID][hEnterY], HouseInfo[HouseID][hEnterZ], 0);
}
}
if(HouseInfo[HouseID][hVehicleID] != 0 && HouseInfo[HouseID][hCarX] != 0.0 && HouseInfo[HouseID][hCarY] != 0.0 && HouseInfo[HouseID][hCarZ] != 0.0 && HouseInfo[HouseID][hCarA] > 0.0)
{
HouseInfo[HouseID][hCar] = AddStaticVehicle(HouseInfo[HouseID][hVehicleID], HouseInfo[HouseID][hCarX], HouseInfo[HouseID][hCarY], HouseInfo[HouseID][hCarZ], HouseInfo[HouseID][hCarA], HouseInfo[HouseID][hCarColor1], HouseInfo[HouseID][hCarColor2]);
}
}
mysql_free_result();
Iter_Add(Houses, HouseID);
HouseID++;
if(HouseID > MAX_HOUSES)
{
print(\"You reached maximum number of houses! Please enlarge the #define MAX_HOUSES\\nin S32_House.inc! If you don\'t enlarge it, some houses won\'t work properly!\");
}
return 1;
}
/*
• Function: GetHouseUser(houseid)
• Usage: Getting name of user of specific house!
• Parameters:
houseid: ID of house that you want to get user (owner)
• Example: format(string, sizeof(string), \"House user of house id %d is %s\", houseid, GetHouseUser(houseid));
*/
stock GetHouseUser(houseid)
{
new howner[24];
format(howner, sizeof(howner), \"%s\", HouseInfo[houseid][hOwner]);
return howner;
}
/*
• Function: GetHouseRentUser(houseid)
• Usage: Getting name of rent user of specific house!
• Parameters:
houseid: ID of house that you want to get rent user
• Example: format(string, sizeof(string), \"House rent user of house id %d is %s\", houseid, GetHouseRentUser(houseid));
*/
stock GetHouseRentUser(houseid)
{
new howner[24];
format(howner, sizeof(howner), \"%s\", HouseInfo[houseid][hRentUser]);
return howner;
}
/*
• Function: GetHouseEnterPos(houseid)
• Usage: Getting the enter position (XYZ) of specific house!
• Parameters:
houseid: ID of house that you want to get enter position
• Example: format(string, sizeof(string), \"House enter XYZ of house id %d is %s\", houseid, GetHouseEnterPos(houseid));
*/
stock GetHouseEnterPos(houseid)
{
new getxyz[128];
format(getxyz, sizeof(getxyz), \"%f, %f, %f\", HouseInfo[houseid][hEnterX], HouseInfo[houseid][hEnterY], HouseInfo[houseid][hEnterZ]);
return getxyz;
}
/*
• Function: GetHouseExitPos(houseid)
• Usage: Getting the exit position (XYZ) of specific house!
• Parameters:
houseid: ID of house that you want to get exit position
• Example: format(string, sizeof(string), \"House exit XYZ of house id %d is %s\", houseid, GetHouseExitPos(houseid));
*/
stock GetHouseExitPos(houseid)
{
new getxyz[128];
format(getxyz, sizeof(getxyz), \"%f, %f, %f\", HouseInfo[houseid][hExitX], HouseInfo[houseid][hExitY], HouseInfo[houseid][hExitZ]);
return getxyz;
}
/*
• Function: GetHouseEnterX(houseid)
• Usage: Getting the enter X position of specific house!
• Parameters:
houseid: ID of house that you want to get enter X position
• Example: format(string, sizeof(string), \"House enter X of house id %d is %s\", houseid, GetHouseEnterX(houseid));
*/
stock GetHouseEnterX(houseid)
{
new getx[128];
format(getx, sizeof(getx), \"%f\", HouseInfo[houseid][hEnterX]);
return getx;
}
/*
• Function: GetHouseEnterY(houseid)
• Usage: Getting the enter Y position of specific house!
• Parameters:
houseid: ID of house that you want to get enter Y position
• Example: format(string, sizeof(string), \"House enter Y of house id %d is %s\", houseid, GetHouseEnterY(houseid));
*/
stock GetHouseEnterY(houseid)
{
new gety[128];
format(gety, sizeof(gety), \"%f\", HouseInfo[houseid][hEnterY]);
return gety;
}
/*
• Function: GetHouseEnterZ(houseid)
• Usage: Getting the enter Z position of specific house!
• Parameters:
houseid: ID of house that you want to get enter Z position
• Example: format(string, sizeof(string), \"House enter Z of house id %d is %s\", houseid, GetHouseEnterZ(houseid));
*/
stock GetHouseEnterZ(houseid)
{
new getz[128];
format(getz, sizeof(getz), \"%f\", HouseInfo[houseid][hEnterZ]);
return getz;
}
/*
• Function: GetHouseExitX(houseid)
• Usage: Getting the enter X position of specific house!
• Parameters:
houseid: ID of house that you want to get enter X position
• Example: format(string, sizeof(string), \"House exit X of house id %d is %s\", houseid, GetHouseExitX(houseid));
*/
stock GetHouseExitX(houseid)
{
new getx[128];
format(getx, sizeof(getx), \"%f\", HouseInfo[houseid][hExitX]);
return getx;
}
/*
• Function: GetHouseExitY(houseid)
• Usage: Getting the enter Y position of specific house!
• Parameters:
houseid: ID of house that you want to get enter Y position
• Example: format(string, sizeof(string), \"House exit Y of house id %d is %s\", houseid, GetHouseExitY(houseid));
*/
stock GetHouseExitY(houseid)
{
new gety[128];
format(gety, sizeof(gety), \"%f\", HouseInfo[houseid][hExitY]);
return gety;
}
/*
• Function: GetHouseExitZ(houseid)
• Usage: Getting the enter Z position of specific house!
• Parameters:
houseid: ID of house that you want to get enter Z position
• Example: format(string, sizeof(string), \"House exit Z of house id %d is %s\", houseid, GetHouseExitZ(houseid));
*/
stock GetHouseExitZ(houseid)
{
new getz[128];
format(getz, sizeof(getz), \"%f\", HouseInfo[houseid][hExitZ]);
return getz;
}
/*
• Function: GetHousePrice(houseid)
• Usage: Getting the price of specific house!
• Parameters:
houseid: ID of house that you want to get price
• Example: format(string, sizeof(string), \"House price of house id %d is %d\", houseid, GetHousePrice(houseid));
*/
stock GetHousePrice(houseid) return HouseInfo[houseid][hPrice];
/*
• Function: GetHouseInterior(houseid)
• Usage: Getting the interior of specific house!
• Parameters:
houseid: ID of house that you want to get interior
• Example: format(string, sizeof(string), \"House interior of house id %d is %d\", houseid, GetHouseInterior(houseid));
*/
stock GetHouseInterior(houseid) return HouseInfo[houseid][hInterior];
/*
• Function: GetHouseVirtualWorld(houseid)
• Usage: Getting the virtualworld of specific house!
• Parameters:
houseid: ID of house that you want to get virtualworld
• Example: format(string, sizeof(string), \"House virtualworld of house id %d is %d\", houseid, GetHouseVirtualWorld(houseid));
*/
stock GetHouseVirtualWorld(houseid) return HouseInfo[houseid][hVirtualWorld];
/*
• Function: GetHouseRentPrice(houseid)
• Usage: Getting the rent price of specific house!
• Parameters:
houseid: ID of house that you want to get rent price
• Example: format(string, sizeof(string), \"House rent priceof house id %d is %d\", houseid, GetHouseRentPrice(houseid));
*/
stock GetHouseRentPrice(houseid) return HouseInfo[houseid][hRentPrice];
/*
• Function: GetHouseMoney(houseid)
• Usage: Getting the money (stored money) of specific house!
• Parameters:
houseid: ID of house that you want to get money
• Example: format(string, sizeof(string), \"House money of house id %d is %d\", houseid, GetHouseMoney(houseid));
*/
stock GetHouseMoney(houseid) return HouseInfo[houseid][hMoney];
/*
• Function: GetHouseWeaponID1(houseid)
• Usage: Getting the weapon id 1 of specific house!
• Parameters:
houseid: ID of house that you want to get the weapon id 1
• Example: format(string, sizeof(string), \"House weapon id 1 of house id %d is %d\", houseid, GetHouseWeaponID1(houseid));
*/
stock GetHouseWeaponID1(houseid) return HouseInfo[houseid][hWeaponID1];
/*
• Function: GetHouseWeaponID2(houseid)
• Usage: Getting the weapon id 2 of specific house!
• Parameters:
houseid: ID of house that you want to get the weapon id 2
• Example: format(string, sizeof(string), \"House weapon id 2 of house id %d is %d\", houseid, GetHouseWeaponID2(houseid));
*/
stock GetHouseWeaponID2(houseid) return HouseInfo[houseid][hWeaponID2];
/*
• Function: GetHouseWeaponID3(houseid)
• Usage: Getting the weapon id 3 of specific house!
• Parameters:
houseid: ID of house that you want to get the weapon id 3
• Example: format(string, sizeof(string), \"House weapon id 3 of house id %d is %d\", houseid, GetHouseWeaponID3(houseid));
*/
stock GetHouseWeaponID3(houseid) return HouseInfo[houseid][hWeaponID3];
/*
• Function: GetHouseWeaponID1Ammo(houseid)
• Usage: Getting the weapon id 1 of specific house!
• Parameters:
houseid: ID of house that you want to get the weapon id 1 ammo
• Example: format(string, sizeof(string), \"House weapon id 1 ammo of house id %d is %d\", houseid, GetHouseWeaponID1Ammo(houseid));
*/
stock GetHouseWeaponID1Ammo(houseid) return HouseInfo[houseid][hWeaponID1Ammo];
/*
• Function: GetHouseWeaponID2Ammo(houseid)
• Usage: Getting the weapon id 2 of specific house!
• Parameters:
houseid: ID of house that you want to get the weapon id 2 ammo
• Example: format(string, sizeof(string), \"House weapon id 2 ammo of house id %d is %d\", houseid, GetHouseWeaponID2Ammo(houseid));
*/
stock GetHouseWeaponID2Ammo(houseid) return HouseInfo[houseid][hWeaponID2Ammo];
/*
• Function: GetHouseWeaponID3Ammo(houseid)
• Usage: Getting the weapon id 3 of specific house!
• Parameters:
houseid: ID of house that you want to get the weapon id 3 ammo
• Example: format(string, sizeof(string), \"House weapon id 3 ammo of house id %d is %d\", houseid, GetHouseWeaponID3Ammo(houseid));
*/
stock GetHouseWeaponID3Ammo(houseid) return HouseInfo[houseid][hWeaponID3Ammo];
/*
• Function: GetHouseWeaponID1Name(houseid)
• Usage: Getting the name of weapon id 1 of specific house!
• Parameters:
houseid: ID of house that you want to get the name of weapon id 1
• Example: format(string, sizeof(string), \"House name of weapon id 1 of house id %d is %d\", houseid, GetHouseWeaponID1Name(houseid));
*/
stock GetHouseWeaponID1Name(houseid)
{
new weaponid[128], weaponid2[128];
format(weaponid, sizeof(weaponid), \"%s\", GetWeapon(HouseInfo[houseid][hWeaponID1]));
format(weaponid2, sizeof(weaponid2), \"Nothing\");
if(HouseInfo[houseid][hWeaponID1] > 0) return weaponid;
else return weaponid2;
}
/*
• Function: GetHouseWeaponID2Name(houseid)
• Usage: Getting the name of weapon id 2 of specific house!
• Parameters:
houseid: ID of house that you want to get the name of weapon id 2
• Example: format(string, sizeof(string), \"House name of weapon id 2 of house id %d is %d\", houseid, GetHouseWeaponID2Name(houseid));
*/
stock GetHouseWeaponID2Name(houseid)
{
new weaponid[128], weaponid2[128];
format(weaponid, sizeof(weaponid), \"%s\", GetWeapon(HouseInfo[houseid][hWeaponID2]));
format(weaponid2, sizeof(weaponid2), \"Nothing\");
if(HouseInfo[houseid][hWeaponID2] > 0) return weaponid;
else return weaponid2;
}
/*
• Function: GetHouseWeaponID13Name(houseid)
• Usage: Getting the name of weapon id 3 of specific house!
• Parameters:
houseid: ID of house that you want to get the name of weapon id 3
• Example: format(string, sizeof(string), \"House name of weapon id 3 of house id %d is %d\", houseid, GetHouseWeaponID3Name(houseid));
*/
stock GetHouseWeaponID3Name(houseid)
{
new weaponid[128], weaponid2[128];
format(weaponid, sizeof(weaponid), \"%s\", GetWeapon(HouseInfo[houseid][hWeaponID3]));
format(weaponid2, sizeof(weaponid2), \"Nothing\");
if(HouseInfo[houseid][hWeaponID3] > 0) return weaponid;
else return weaponid2;
}
/*
• Function: IsHouseOwned(houseid)
• Usage: Checking if is house owned of specific house!
• Parameters:
houseid: ID of house that you want to check if is owned
• Example: if(IsHouseOwned(houseid)) return SendClientMessage(playerid, -1, \"House is owned!\");
else SendClientMessage(playerid, -1, \"House is not owned!\");
*/
stock IsHouseOwned(houseid)
{
if(HouseInfo[houseid][hOwned] == 1) return 1;
else return 0;
}
/*
• Function: IsHouseLocked(houseid)
• Usage: Checking if is house locked of specific house!
• Parameters:
houseid: ID of house that you want to check if is locked
• Example: if(IsHouseLocked(houseid)) return SendClientMessage(playerid, -1, \"House is locked!\");
else SendClientMessage(playerid, -1, \"House is not locked!\");
*/
stock IsHouseLocked(houseid)
{
if(HouseInfo[houseid][hLocked] == 1) return 1;
else return 0;
}
/*
• Function: IsHouseRented(houseid)
• Usage: Checking if is house owned of specific house!
• Parameters:
houseid: ID of house that you want to check if is rented
• Example: if(IsHouseRented(houseid)) return SendClientMessage(playerid, -1, \"House is rented!\");
else SendClientMessage(playerid, -1, \"House is not rented!\");
*/
stock IsHouseRented(houseid)
{
if(HouseInfo[houseid][hRented] == 1) return 1;
else return 0;
}
/*
• Function: IsHouseRentDisabled(houseid)
• Usage: Checking if is house owned of specific house!
• Parameters:
houseid: ID of house that you want to check if is rent disabled
• Example: if(IsHouseRentDisabled(houseid)) return SendClientMessage(playerid, -1, \"House rent is disabled!\");
else SendClientMessage(playerid, -1, \"House rent is not disabled!\");
*/
stock IsHouseRentDisabled(houseid)
{
if(HouseInfo[houseid][hRentDisabled] == 1) return 1;
else return 0;
}
/*
• Function: IsHouseHaveAlarm(houseid)
• Usage: Checking if is house have an alarm!
• Parameters:
houseid: ID of house that you want to check if it have an alarm
• Example: if(IsHouseHaveAlarm(houseid)) return SendClientMessage(playerid, -1, \"House have an alarm!\");
else SendClientMessage(playerid, -1, \"House doesn\'t have an alarm!\");
*/
stock IsHouseHaveAlarm(houseid)
{
if(HouseInfo[houseid][hAlarm] == 1) return 1;
else return 0;
}
/*
• Function: IsPlayerHouseOwner(playerid, houseid)
• Usage: Checking if is player owner of specific house!
• Parameters:
playerid: ID of player that you want preform check
houseid: ID of house that you want to check if is player owner
• Example: if(IsPlayerHouseOwner(playerid, houseid)) return SendClientMessage(playerid, -1, \"You are owner of the house!\");
else SendClientMessage(playerid, -1, \"You are not owner of the house!\");
*/
stock IsPlayerHouseOwner(playerid, houseid)
{
if(!strcmp(HouseInfo[houseid][hOwner], GetName(playerid), false)) return 1;
else return 0;
}
/*
• Function: IsPlayerBuyAnyHouse(playerid)
• Usage: Checking if is player buyed house and he is owner of any house (used when you try to rent room but you already have house)!
• Parameters:
playerid: ID of player that you want preform check
• Example: if(IsPlayerBuyAnyHouse(playerid)) return SendClientMessage(playerid, -1, \"You have house already!\");
else SendClientMessage(playerid, -1, \"You don\'t have house!\");
*/
stock IsPlayerBuyAnyHouse(playerid)
{
new HQuery2[200];
format(HQuery2, sizeof(HQuery2), \"SELECT User FROM `house` WHERE `User` = \'%s\'\", GetName(playerid));
mysql_query(HQuery2);
mysql_store_result();
if(mysql_num_rows() == 1)
{
mysql_free_result();
return 1;
}
else
{
mysql_free_result();
return 0;
}
}
/*
• Function: IsPlayerRentAnyHouse(playerid)
• Usage: Checking if is player rented house and he is rent user of any house (used when you try to rent room but you already rented some house)!
• Parameters:
playerid: ID of player that you want preform check
• Example: if(IsPlayerRentAnyHouse(playerid)) return SendClientMessage(playerid, -1, \"You rent house already!\");
else SendClientMessage(playerid, -1, \"You don\'t rent house!\");
*/
stock IsPlayerRentAnyHouse(playerid)
{
new HQuery2[200];
format(HQuery2, sizeof(HQuery2), \"SELECT `Rent User` FROM `house` WHERE `Rent User` = \'%s\'\", GetName(playerid));
mysql_query(HQuery2);
mysql_store_result();
if(mysql_num_rows() == 1)
{
mysql_free_result();
return 1;
}
else
{
mysql_free_result();
return 0;
}
}
/*
• Function: IsPlayerBuyHouse(playerid, houseid)
• Usage: Checking if is player rented house and he is rent user of any house (used when you try to rent room but you already rented some house)!
• Parameters:
playerid: ID of player that you want preform check
houseid: ID of house that you want to check if is player buy house
• Example: if(IsPlayerBuyHouse(playerid, houseid)) return SendClientMessage(playerid, -1, \"You buy this house already!\");
else SendClientMessage(playerid, -1, \"You didn\'t buy rent this house!\");
*/
stock IsPlayerBuyHouse(playerid, houseid)
{
new HQuery2[200];
format(HQuery2, sizeof(HQuery2), \"SELECT User FROM `house` WHERE `User` = \'%s\' AND `HouseID` = %d\", GetName(playerid), houseid);
mysql_query(HQuery2);
mysql_store_result();
if(mysql_num_rows() == 1)
{
mysql_free_result();
return 1;
}
else
{
mysql_free_result();
return 0;
}
}
/*
• Function: IsPlayerRentHouse(playerid, houseid)
• Usage: Checking if is player rented house and he is rent user of any house (used when you try to rent room but you already rented some house)!
• Parameters:
playerid: ID of player that you want preform check
houseid: ID of house that you want to check if is player rented user
• Example: if(IsPlayerRentAnyHouse(playerid, houseid)) return SendClientMessage(playerid, -1, \"You rent this house already!\");
else SendClientMessage(playerid, -1, \"You don\'t rent this house!\");
*/
stock IsPlayerRentHouse(playerid, houseid)
{
new HQuery2[200];
format(HQuery2, sizeof(HQuery2), \"SELECT `Rent User` FROM `house` WHERE `Rent User` = \'%s\' AND `HouseID` = %d\", GetName(playerid), houseid);
mysql_query(HQuery2);
mysql_store_result();
if(mysql_num_rows() == 1)
{
mysql_free_result();
return 1;
}
else
{
mysql_free_result();
return 0;
}
}
/*
• Function: IsHouseExist(houseid)
• Usage: Checking if is player rented house and he is rent user of any house (used when you try to rent room but you already rented some house)!
• Parameters:
houseid: ID of house that you want to check if is exist
• Example: if(IsHouseExist(houseid)) return SendClientMessage(playerid, -1, \"House exist!\");
else SendClientMessage(playerid, -1, \"House doesn\'t exist!\");
*/
stock IsHouseExist(houseid)
{
new HQuery2[200];
format(HQuery2, sizeof(HQuery2), \"SELECT HouseID FROM `house` WHERE `HouseID` = \'%d\'\", houseid);
mysql_query(HQuery2);
mysql_store_result();
if(mysql_num_rows() == 1)
{
mysql_free_result();
return 1;
}
else
{
mysql_free_result();
return 0;
}
}
/*
• Function: IsPlayerHouseRentUser(playerid, houseid)
• Usage: Checking if is player rent user of specific house!
• Parameters:
playerid: ID of player that you want preform check
houseid: ID of house that you want to check if is player rent user
• Example: if(IsPlayerHouseRentUser(playerid, houseid)) return SendClientMessage(playerid, -1, \"You are rent user of the house!\");
else SendClientMessage(playerid, -1, \"You are not rent user of the house!\");
*/
stock IsPlayerHouseRentUser(playerid, houseid)
{
if(!strcmp(HouseInfo[houseid][hRentUser], GetName(playerid), false)) return 1;
else return 0;
}
/*
• Function: GetTotalHouses(playerid, houseid)
• Usage: Getting all houses, easiser than counting line etc.! Use this in OnGameModeInit after all houses!
• Example: printf(\"Total houses: %d\", GetTotalHouses());
*/
stock GetTotalHouses() return Iter_Count(Houses);
/*
• Function: IsHouseWeaponSlotFree(houseid, slot)
• Usage: Checking if is slot free in stored weapons of specific house!
• Parameters:
houseid: ID of house that you want to check if is slot free
slot: Slot of stored weapons from 1-3!
• Example: if(IsHouseWeaponSlotFree(houseid, 1)) return SendClientMessage(playerid, -1, \"Slot 1 is free!\");
else SendClientMessage(playerid, -1, \"Slot 1 is not free!\");
*/
stock IsHouseWeaponSlotFree(houseid, slot)
{
switch(slot)
{
case 1:
{
if(HouseInfo[houseid][hWeaponID1] < 1) return 1;
else return 0;
}
case 2:
{
if(HouseInfo[houseid][hWeaponID2] < 1) return 1;
else return 0;
}
case 3:
{
if(HouseInfo[houseid][hWeaponID3] < 1) return 1;
else return 0;
}
}
return slot;
}
/*
• Function: SpawnPlayerAtHouse(playerid)
• Usage: Spawning player at his house, use this in OnPlayerSpawn!
• Parameters:
playerid: ID of player that you want to spawn!
• Example: SpawnPlayerAtHouse(playerid);
*/
stock SpawnPlayerAtHouse(playerid)
{
foreach(Houses, i)
{
if(!strcmp(HouseInfo[hOwner], GetName(playerid), false) || !strcmp(HouseInfo[hRentUser], GetName(playerid), false) && HouseInfo[hOwned] == 1)
{
new HQuery2[200];
format(HQuery2, sizeof(HQuery2), \"SELECT HouseID FROM `house` WHERE `HouseID` = \'%d\'\", i);
mysql_query(HQuery2);
mysql_store_result();
if(mysql_num_rows() == 1)
{
SetPlayerPos(playerid, HouseInfo[hExitX], HouseInfo[hExitY], HouseInfo[hExitZ]);
SetPlayerInterior(playerid, HouseInfo[hInterior]);
SetPlayerVirtualWorld(playerid, HouseInfo[hVirtualWorld]);
PlayerEnteredHisHouse[playerid] = true;
mysql_free_result();
return 1;
}
}
}
return 0;
}
/*
• Function: GetHouseCarID(houseid)
• Usage: Getting vehicle ID of house car
• Parameters:
houseid: ID of house that you want to get vehicle ID
• Example: format(string, sizeof(string), \"Vehicle ID of House ID %d: %d\", houseid, GetHouseCar(houseid));
*/
stock GetHouseCarID(houseid) return HouseInfo[houseid][hVehicleID];
/*
• Function: GetHouseCarPos(houseid)
• Usage: Getting vehicle pos of house car
• Parameters:
houseid: ID of house that you want to get vehicle pos
• Example: format(string, sizeof(string), \"Vehicle pos of House ID %d: %s\", houseid, GetHouseCarPos(houseid));
*/
stock GetHouseCarPos(houseid)
{
new getxyz[128];
format(getxyz, sizeof(getxyz), \"%f, %f, %f\", HouseInfo[houseid][hCarX], HouseInfo[houseid][hCarY], HouseInfo[houseid][hCarZ]);
return getxyz;
}
/*
• Function: GetHouseCarAngle(houseid)
• Usage: Getting vehicle angle of house car
• Parameters:
houseid: ID of house that you want to get vehicle angle
• Example: format(string, sizeof(string), \"Vehicle angle of House ID %d: %s\", houseid, GetHouseCarAngle(houseid));
*/
stock GetHouseCarAngle(houseid)
{
new geta[128];
format(geta, sizeof(geta), \"%f\", HouseInfo[houseid][hCarA]);
return geta;
}
/*
• Function: GetHouseCarColor1(houseid)
• Usage: Getting vehicle color 1 of house car
• Parameters:
houseid: ID of house that you want to get vehicle color 1
• Example: format(string, sizeof(string), \"Vehicle color 1 of House ID %d: %d\", houseid, GetHouseCarColor1(houseid));
*/
stock GetHouseCarColor1(houseid) return HouseInfo[houseid][hCarColor1];
/*
• Function: GetHouseCarColor2(houseid)
• Usage: Getting vehicle color 2 of house car
• Parameters:
houseid: ID of house that you want to get vehicle color 2
• Example: format(string, sizeof(string), \"Vehicle color 2 of House ID %d: %d\", houseid, GetHouseCarColor2(houseid));
*/
stock GetHouseCarColor2(houseid) return HouseInfo[houseid][hCarColor2];
/*
• Function: GetHouseCarWeaponID1(houseid)
• Usage: Getting weapon id 1 of house car
• Parameters:
houseid: ID of house that you want to get vehicle weapon id 1
• Example: format(string, sizeof(string), \"Vehicle weapon id 1 of House ID %d: %d\", houseid, GetHouseCarWeaponID1(houseid));
*/
stock GetHouseCarWeaponID1(houseid) return HouseInfo[houseid][hCarWeaponID1];
/*
• Function: GetHouseCarWeaponID2(houseid)
• Usage: Getting weapon id 2 of house car
• Parameters:
houseid: ID of house that you want to get vehicle weapon id 2
• Example: format(string, sizeof(string), \"Vehicle weapon id 2 of House ID %d: %d\", houseid, GetHouseCarWeaponID2(houseid));
*/
stock GetHouseCarWeaponID2(houseid) return HouseInfo[houseid][hCarWeaponID2];
/*
• Function: GetHouseCarWeaponID1Ammo(houseid)
• Usage: Getting weapon id 1 ammo of house car
• Parameters:
houseid: ID of house that you want to get vehicle weapon id 1 ammo
• Example: format(string, sizeof(string), \"Vehicle weapon id 1 ammo of House ID %d: %d\", houseid, GetHouseCarWeaponID1Ammo(houseid));
*/
stock GetHouseCarWeaponID1Ammo(houseid) return HouseInfo[houseid][hCarWeaponID1Ammo];
/*
• Function: GetHouseCarWeaponID2Ammo(houseid)
• Usage: Getting weapon id 2 ammo of house car
• Parameters:
houseid: ID of house that you want to get vehicle weapon id 2 ammo
• Example: format(string, sizeof(string), \"Vehicle weapon id 2 ammo of House ID %d: %d\", houseid, GetHouseCarWeaponID2Ammo(houseid));
*/
stock GetHouseCarWeaponID2Ammo(houseid) return HouseInfo[houseid][hCarWeaponID2Ammo];
/*
• Function: GetHouseCarWeaponID1Name(houseid)
• Usage: Getting name of weapon id 1 of house car
• Parameters:
houseid: ID of house that you want to get vehicle name of weapon id 1
• Example: format(string, sizeof(string), \"Vehicle weapon id 1 name of House ID %d: %s\", houseid, GetHouseCarWeaponID1Name(houseid));
*/
stock GetHouseCarWeaponID1Name(houseid)
{
new weaponid[128], weaponid2[128];
format(weaponid, sizeof(weaponid), \"%s\", GetWeapon(HouseInfo[houseid][hCarWeaponID1]));
format(weaponid2, sizeof(weaponid2), \"Nothing\");
if(HouseInfo[houseid][hCarWeaponID1] > 0) return weaponid;
else return weaponid2;
}
/*
• Function: GetHouseCarWeaponID2Name(houseid)
• Usage: Getting name of weapon id 2 of house car
• Parameters:
houseid: ID of house that you want to get vehicle name of weapon id 2
• Example: format(string, sizeof(string), \"Vehicle weapon id 2 name of House ID %d: %s\", houseid, GetHouseCarWeaponID2Name(houseid));
*/
stock GetHouseCarWeaponID2Name(houseid)
{
new weaponid[128], weaponid2[128];
format(weaponid, sizeof(weaponid), \"%s\", GetWeapon(HouseInfo[houseid][hCarWeaponID2]));
format(weaponid2, sizeof(weaponid2), \"Nothing\");
if(HouseInfo[houseid][hCarWeaponID2] > 0) return weaponid;
else return weaponid2;
}
/*
• Function: GetHouseCarMoney(houseid)
• Usage: Getting money of house car
• Parameters:
houseid: ID of house that you want to get vehicle money
• Example: format(string, sizeof(string), \"Vehicle money of House ID %d: %d\", houseid, GetHouseCarMoney(houseid));
*/
stock GetHouseCarMoney(houseid) return HouseInfo[houseid][hCarMoney];
/*
• Function: IsHouseCarLocked(houseid)
• Usage: Checking if is hosue car locked
• Parameters:
houseid: ID of house that you want to check if is house car locked
• Example: if(IsHouseCarLocked(houseid)) SendClientMessae(playerid, -1, \"House car is locked!\");
else SendClientMessage(playerid, -1, \"House car is not locked!\");
*/
stock IsHouseCarLocked(houseid)
{
if(HouseInfo[houseid][hCarLocked] == 1) return 1;
else return 0;
}
//----Stocks for easier scripting!----
/*stock GetName(playerid)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
return pName;
}
stock GetWeapon(weaponid)
{
new gunname[32];
GetWeaponName(weaponid, gunname, sizeof(gunname));
return gunname;
}*/
stock Custom_GetPlayerWeapon(playerid)
{
for(new w = 0; w < 13; w++)
{
GetPlayerWeaponData(playerid, w, House_Weapon[playerid][w], House_Ammo[playerid][w]);
}
return 1;
}
stock Custom_GetSlot(weaponid)
{
new slot;
if(weaponid == 0 || weaponid == 1){slot = 0;}
else if(weaponid > 8 && weaponid < 10){slot = 1;}
else if(weaponid > 9 && weaponid < 16){slot = 10;}
else if(weaponid > 15 && weaponid < 20){slot = 8;}
else if(weaponid > 21 && weaponid < 25){slot = 2;}
else if(weaponid > 24 && weaponid < 28){slot = 3;}
else if(weaponid == 28 || weaponid == 29 || weaponid == 32){slot = 4;}
else if(weaponid == 30 || weaponid == 31){slot = 5;}
else if(weaponid == 33 || weaponid == 34){slot = 6;}
else if(weaponid > 34 || weaponid < 39){slot = 7;}
return slot;
}
stock IsPlayerNearPlayer(playerid, playerid2, Float: radius)
{
new Float: pPos[4];
GetPlayerPos(playerid2, pPos[0], pPos[1], pPos[2]);
if(IsPlayerInRangeOfPoint(playerid, radius, pPos[0], pPos[1], pPos[2])) return 1;
return 0;
}
//----End of stocks!----
//***************************** *****************************
//***************************** COMMANDS *****************************
//***************************** *****************************
/*
• Command: /buyhouse
• Processor: y_commands (YCMD)
• Usage: Buying house (Player must be in range of house he want to buy!)
*/
YCMD:buyhouse(playerid, params[], help)
{
#pragma unused help
#pragma unused params
foreach(Houses, i)
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[hEnterX], HouseInfo[hEnterY], HouseInfo[hEnterZ]))
{
if(HouseInfo[hOwned] == 1) return SendClientMessage(playerid, COLOR_KRED, \"House is already owned!\");
if(GetPlayerMoney(playerid) < HouseInfo[hPrice]) return SendClientMessage(playerid, COLOR_KRED, \"You don\'t have enough money!\");
new HQuery2[200];
format(HQuery2, sizeof(HQuery2), \"SELECT User FROM `house` WHERE `User` = \'%s\'\", GetName(playerid));
mysql_query(HQuery2);
mysql_store_result();
if(mysql_num_rows() == 1) return SendClientMessage(playerid, COLOR_KRED, \"You have house already!\");
mysql_free_result();
format(HouseInfo[hOwner], 24, \"%s\", GetName(playerid));
format(HouseInfo[hCarOwner], 24, \"%s\", GetName(playerid));
HouseInfo[hOwned] = 1;
DestroyPickup(HouseInfo[hPickup]);
HouseInfo[hPickup] = CreatePickup(1239, 23, HouseInfo[hEnterX], HouseInfo[hEnterY], HouseInfo[hEnterZ], 0);
format(hstring, sizeof(hstring), \"Owner: %s\\nHouse ID: %d\\nRent User: %s\\nRent Price: %d\", HouseInfo[hOwner], i, HouseInfo[hRentUser], HouseInfo[hRentPrice]);
Update3DTextLabelText(HouseInfo[hLabel], 0x21DD00FF, hstring);
GivePlayerMoney(playerid, -HouseInfo[hPrice]);
SendClientMessage(playerid, COLOR_LIME, \"House bought!\");
format(HQuery, sizeof(HQuery), \"UPDATE `house` SET `User` = \'%s\', `Car Owner` = \'%s\', `Owned` = 1 WHERE `HouseID` = %d\", GetName(playerid), GetName(playerid), i);
mysql_query(HQuery);
}
}
return 1;
}
/*
• Command: /sellhouse
• Processor: y_commands (YCMD)
• Usage: Selling house (Player must be in range of house he want to sell!)
*/
YCMD:sellhouse(playerid, params[], help)
{
#pragma unused help
#pragma unused params
foreach(Houses, i)
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[hEnterX], HouseInfo[hEnterY], HouseInfo[hEnterZ]))
{
if(!strcmp(HouseInfo[hOwner], GetName(playerid), false))
{
format(HouseInfo[hOwner], 24, \"None\");
format(HouseInfo[hRentUser], 24, \"None\");
format(HouseInfo[hCarOwner], 24, \"None\");
HouseInfo[hOwned] = 0;
HouseInfo[hLocked] = 0;
HouseInfo[hRented] = 0;
DestroyPickup(HouseInfo[hPickup]);
HouseInfo[hPickup] = CreatePickup(1273, 23, HouseInfo[hEnterX], HouseInfo[hEnterY], HouseInfo[hEnterZ], 0);
format(hstring, sizeof(hstring), \"For sale!\\nPrice: %d\\nHouse ID: %d\\nType /buyhouse to buy house!\", HouseInfo[hPrice], i);
Update3DTextLabelText(HouseInfo[hLabel], 0x21DD00FF, hstring);
GivePlayerMoney(playerid, HouseInfo[hPrice]);
SendClientMessage(playerid, COLOR_LIME, \"House sold!\");
format(HQuery, sizeof(HQuery), \"UPDATE `house` SET `User` = \'None\', `Owned` = 0, `Locked` = 0, `Rent User` = \'None\', `Rented` = 0 WHERE `HouseID` = %d\", i);
mysql_query(HQuery);
}
}
}
return 1;
}
/*
• Command: /sellhouseto
• Processor: y_commands (YCMD)
• Usage: Selling house to other player (must be near you!)
• Parameters:
id: The id of player you want to sell house
*/
YCMD:sellhouseto(playerid, params[], help)
{
#pragma unused help
#pragma unused params
new id, selltostring[128];
foreach(Houses, i)
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[hEnterX], HouseInfo[hEnterY], HouseInfo[hEnterZ]))
{
if(!strcmp(HouseInfo[hOwner], GetName(playerid), false))
{
if(sscanf(params, \"i\", id)) return SendClientMessage(playerid, -1, \"Usage: /sellhouseto [iD]\");
else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, \"Invalid ID\");
else if(id == playerid) return SendClientMessage(playerid, -1, \"You can\'t sell house to yourself!\");
if(!IsPlayerNearPlayer(playerid, id, 7.0)) return SendClientMessage(playerid, -1, \"Player is not near you!\");
format(selltostring, sizeof(selltostring), \"Do you want to buy house from player %s for %d$?\", GetName(playerid), HouseInfo[hPrice]);
ShowPlayerDialog(id, 5688, DIALOG_STYLE_MSGBOX, \" Buy house\", selltostring, \"Yes\", \"No\");
SetPVarInt(id, \"Seller\", playerid);
}
}
}
return 1;
}
/*
• Command: /lockhouse
• Processor: y_commands (YCMD)
• Usage: Locking house (Player must be in range of his house to lock it!)
*/
YCMD:lockhouse(playerid, params[], help)
{
#pragma unused help
#pragma unused params
foreach(Houses, i)
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[hEnterX], HouseInfo[hEnterY], HouseInfo[hEnterZ]) || IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[hExitX], HouseInfo[hExitY], HouseInfo[hExitZ]))
{
if(!strcmp(HouseInfo[hOwner], GetName(playerid), false) || !strcmp(HouseInfo[hRentUser], GetName(playerid), false))
{
HouseInfo[hLocked] = 1;
GameTextForPlayer(playerid, \"House ~r~locked!\", 2000, 5);
format(HQuery, sizeof(HQuery), \"UPDATE `house` SET `Locked` = 1 WHERE `HouseID` = %d\", i);
mysql_query(HQuery);
}
}
}
return 1;
}
/*
• Command: /unlockhouse
• Processor: y_commands (YCMD)
• Usage: Unlocking house (Player must be in range of his house to unlock it!)
*/
YCMD:unlockhouse(playerid, params[], help)
{
#pragma unused help
#pragma unused params
foreach(Houses, i)
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[hEnterX], HouseInfo[hEnterY], HouseInfo[hEnterZ]) || IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[hExitX], HouseInfo[hExitY], HouseInfo[hExitZ]))
{
if(!strcmp(HouseInfo[hOwner], GetName(playerid), false) || !strcmp(HouseInfo[hRentUser], GetName(playerid), false))
{
HouseInfo[hLocked] = 0;
GameTextForPlayer(playerid, \"House ~g~unlocked!\", 2000, 5);
format(HQuery, sizeof(HQuery), \"UPDATE `house` SET `Locked` = 0 WHERE `HouseID` = %d\", i);
mysql_query(HQuery);
}
}
}
return 1;
}
/*
• Command: /rentroom
• Processor: y_commands (YCMD)
• Usage: Renting room (house) (Player must be in range of house that he want to rent it!)
*/
YCMD:rentroom(playerid, params[], help)
{
#pragma unused help
#pragma unused params
foreach(Houses, i)
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[hEnterX], HouseInfo[hEnterY], HouseInfo[hEnterZ]))
{
if(HouseInfo[hOwned] == 1)
{
new HQuery2[200], HQuery3[200];
format(HQuery2, sizeof(HQuery2), \"SELECT `Rent User` FROM `house` WHERE `Rent User` = \'%s\'\", GetName(playerid));
mysql_query(HQuery2);
mysql_store_result();
if(mysql_num_rows() == 1) return SendClientMessage(playerid, COLOR_KRED, \"You have rented house already!\");
mysql_free_result();
format(HQuery3, sizeof(HQuery3), \"SELECT User FROM `house` WHERE `User` = \'%s\'\", GetName(playerid));
mysql_query(HQuery3);
mysql_store_result();
if(mysql_num_rows() == 1) return SendClientMessage(playerid, COLOR_KRED, \"You have house!\");
mysql_free_result();
if(GetPlayerMoney(playerid) < HouseInfo[hRentPrice]) return SendClientMessage(playerid, COLOR_KRED, \"You don\'t have enough money!\");
if(HouseInfo[hRented] == 1) return SendClientMessage(playerid, COLOR_KRED, \"House is already rented!\");
if(HouseInfo[hRentDisabled] == 1) return SendClientMessage(playerid, COLOR_KRED, \"Renting this house is disabled!\");
format(HouseInfo[hRentUser], 24, \"%s\", GetName(playerid));
HouseInfo[hRented] = 1;
GivePlayerMoney(playerid, -HouseInfo[hRentPrice]);
format(hstring, sizeof(hstring), \"Owner: %s\\nHouse ID: %d\\nRent User: %s\\nRent Price: %d\", HouseInfo[hOwner], i, HouseInfo[hRentUser], HouseInfo[hRentPrice]);
Update3DTextLabelText(HouseInfo[hLabel], 0x21DD00FF, hstring);
SendClientMessage(playerid, COLOR_YELLOW, \"Now you rent this house!\");
format(HQuery, sizeof(HQuery), \"UPDATE `house` SET `Rent User` = \'%s\', `Rented` = 1 WHERE `HouseID` = %d\", HouseInfo[hRentUser], i);
mysql_query(HQuery);
}
else SendClientMessage(playerid, COLOR_KRED, \"That house is not owned! You can buy it but not rent it!\");
}
}
return 1;
}
/*
• Command: /stoprent
• Processor: y_commands (YCMD)
• Usage: Stop renting room (house) (Player must be in range of his rented house to stop renting it!)
*/
YCMD:stoprent(playerid, params[], help)
{
#pragma unused help
#pragma unused params
foreach(Houses, i)
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[hEnterX], HouseInfo[hEnterY], HouseInfo[hEnterZ]))
{
if(HouseInfo[hOwned] == 1)
{
if(strcmp(HouseInfo[hRentUser], GetName(playerid), false)) return SendClientMessage(playerid, COLOR_KRED, \"You don\'t rent this room!\");
format(HouseInfo[hRentUser], 24, \"None\");
HouseInfo[hRented] = 0;
format(hstring, sizeof(hstring), \"Owner: %s\\nHouse ID: %d\\nRent User: %s\\nRent Price: %d\", HouseInfo[hOwner], i, HouseInfo[hRentUser], HouseInfo[hRentPrice]);
Update3DTextLabelText(HouseInfo[hLabel], 0x21DD00FF, hstring);
SendClientMessage(playerid, COLOR_YELLOW, \"You stop renting this house!\");
format(HQuery, sizeof(HQuery), \"UPDATE `house` SET `Rent User` = \'None\', `Rented` = 0 WHERE `HouseID` = %d\", i);
mysql_query(HQuery);
}
else SendClientMessage(playerid, COLOR_KRED, \"That house is not owned!\");
}
}
return 1;
}
/*
• Command: /housecontrol
• Processor: y_commands (YCMD)
• Usage: Controling your house: lock house, unlock house, set rent price, storing weapons in house, taking weapons from house, storing money in house, taking money from house & kicking rented user from house (Player must be in his house to control it!)
*/
YCMD:housecontrol(playerid, params[], help)
{
#pragma unused help
#pragma unused params
foreach(Houses, i)
{
if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[hExitX], HouseInfo[hExitY], HouseInfo[hExitZ]))
{
if(!strcmp(HouseInfo[hOwner], GetName(playerid), false) && PlayerEnteredHisHouse[playerid] == true)
{
ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, \" Control your house!\", \"Lock house\\nUnlock house\\nSet rent price\\nStore weapon\\nTake weapon\\nStore money\\nTake money\\nKick rent user\\nBuy alarm | $2000\\nSell alarm\", \"Ok\", \"Exit\");
}
else SendClientMessage(playerid, COLOR_KRED, \"You must enter your house!\");
}
}
return 1;
}
/*
• Command: /houseinfo
• Processor: y_commands (YCMD)
• Usage: Getting stats of your house, is locked, unlocked blabalba
*/
YCMD:housestats(playerid, params[], help)
{
#pragma unused help
#pragma unused params
foreach(Houses, i)
{
format(HQuery, sizeof(HQuery), \"SELECT HouseID FROM `house` WHERE `HouseID` = \'%d\'\", i);
mysql_query(HQuery);
mysql_store_result();
if(mysql_num_rows() == 1)
{
if(!strcmp(HouseInfo[hOwner], GetName(playerid), false))
{
new gunstring1[128], gunstring2[128], gunstring3[128];
if(HouseInfo[hWeaponID1] == 0) format(gunstring1, sizeof(gunstring1), \"{FFFFFF}Weapon: {F81414}Nothing\");
else format(gunstring1, sizeof(gunstring1), \"{FFFFFF}Weapon: {F81414}%s {FFFFFF}| Ammo: {F81414}%d\", GetWeapon(HouseInfo[hWeaponID1]), HouseInfo[hWeaponID1Ammo]);
if(HouseInfo[hWeaponID2] == 0) format(gunstring2, sizeof(gunstring1), \"{FFFFFF}Weapon: {F81414}Nothing\");
else format(gunstring2, sizeof(gunstring2), \"{FFFFFF}Weapon: {F81414}%s {FFFFFF}| Ammo: {F81414}%d\", GetWeapon(HouseInfo[hWeaponID2]), HouseInfo[hWeaponID2Ammo]);
if(HouseInfo[hWeaponID3] == 0) format(gunstring3, sizeof(gunstring1), \"{FFFFFF}Weapon: {F81414}Nothing\");
else format(gunstring3, sizeof(gunstring3), \"{FFFFFF}Weapon: {F81414}%s {FFFFFF}| Ammo: {F81414}%d\", GetWeapon(HouseInfo[hWeaponID3]), HouseInfo