20.08.2010, 09:19
Hello i fixed stefans elite house system https://sampforum.blast.hk/showthread.php?tid=98767
and realized that the script using /enter /exit commands (As gl_Properties does. and i need to save my gl_properties file cuz dinner places and all is included in the file. but i cant either have 2 files wich does /enter /exit cuz then the command bugs so do you guys now how to do? maybe it works to delite /enter /exit from properties file or from elite house system? iam not a good scripter so could you guys take a look on it please? here is the scripts
"House System"
Gl_Properties file.
very nice of you guys if you could take a look on it
thankz for now. :P
and realized that the script using /enter /exit commands (As gl_Properties does. and i need to save my gl_properties file cuz dinner places and all is included in the file. but i cant either have 2 files wich does /enter /exit cuz then the command bugs so do you guys now how to do? maybe it works to delite /enter /exit from properties file or from elite house system? iam not a good scripter so could you guys take a look on it please? here is the scripts
"House System"
Код:
/*
-------------------------------------------
| _____ _ __ |
| / ____| | / _| |
| | (___ | |_ ___| |_ __ _ _ __ |
| \___ \| __/ _ \ _/ _` | '_ \ |
| ____) | || __/ || (_| | | | | |
| |_____/ \__\___|_| \__,_|_| |_| |
| |
| ** House System v1.0 ** |
| |
-------------------------------------------
.:: Do not remove Credits ::.
*/
#include <a_samp>
#include <Dini>
#include <dudb>
#include <utils>
new FALSE = false;
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define SendFormattedMessage(%0,%1,%2) do{new _str[128]; format(_str,128,%2); SendClientMessage(%0,%1,_str);}while(FALSE)
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_LIME 0x80FF00AA
#define MAX_HOUSES 100 // Max houses allowed to be created
#define PTP_RADIUS 2.0 // Radius of PlayerToPoint Function
forward SavePlayerHouse(houseid);
forward ReadPlayerHouseData(playerid);
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
new Timer[1];
enum hInfo
{
hName[24],
hSellable,
hSell,
hRent,
hLevel,
hPickup,
Float:hExitX,
Float:hExitY,
Float:hExitZ,
hVirtualWorld,
hLocked
};
new HouseInfo[MAX_HOUSES][hInfo];
new Float:HousesCoords[13][3] = {
{222.9534, 1287.7649, 1082.1406}, // Sml - 1 bedroom
{261.0827, 1284.6899, 1080.2578}, // Sml - 1 bedroom
{260.6734, 1237.7909, 1084.2578}, // Sml - 1 bedroom
{376.7426, 1417.3226, 1081.3281}, // Sml - 1 bedroom
{295.2874, 1473.2769, 1080.2578}, // Med - 2 bedroom
{327.9431, 1478.3801, 1084.4375}, // Med - 2 bedroom
{2270.1050, -1210.3917, 1047.5625}, // Med - 2 bedroom
{447.1211, 1397.8444, 1084.3047}, // Med - 2 bedroom
{2196.0063, -1204.6326, 1049.0234}, // Lrg - 3 bedroom
{235.3416, 1187.2882, 1080.2578}, // Lrg - 3 bedroom
{490.9987, 1399.4164, 1080.2578}, // Lrg - 3 bedroom
{227.1212, 1114.1840, 1080.9972}, // Lrg - 4 bedroom
{225.6624, 1022.5345, 1084.0145} // Xlrg - 4 bedrooms
};
new HousesLevels[13][2] = {
{1, 2000}, // Sml - 1 bedroom
{4, 4500}, // Sml - 1 bedroom
{9, 7000}, // Sml - 1 bedroom
{15, 10000}, // Sml - 1 bedroom
{15, 17000}, // Med - 2 bedroom
{15, 23000}, // Med - 2 bedroom
{10, 34000}, // Med - 2 bedroom
{2, 62000}, // Med - 2 bedroom
{6, 102000}, // Lrg - 3 bedroom
{3, 156000}, // Lrg - 3 bedroom
{2, 188000}, // Lrg - 3 bedroom
{5, 235000}, // Lrg - 4 bedroom
{7, 295000} // Xlrg - 4 bedrooms
};
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print("Stefan's House System");
print("--------------------------------------\n");
for(new i = 0; i <= MAX_PLAYERS; i++)
{
Timer[0] = SetTimerEx("ReadPlayerHouseData", 1000, true, "%i", i);
}
for(new h = 0; h <= MAX_HOUSES; h++) // Player Homes
{
LoadPlayerHouse(h);
}
return true;
}
public OnFilterScriptExit()
{
KillTimer(Timer[0]);
}
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(househelp,9,cmdtext);
dcmd(houseinfo,9,cmdtext);
dcmd(enter,5,cmdtext);
dcmd(exit,4,cmdtext);
/*dcmd(evict,5,cmdtext);
dcmd(renthouse,9,cmdtext);
dcmd(unrenthouse,11,cmdtext);
dcmd(tenants,7,cmdtext);*/
dcmd(house,5,cmdtext);
dcmd(lockhouse,9,cmdtext);
dcmd(unlockhouse,11,cmdtext);
dcmd(rentprice,9,cmdtext);
dcmd(buyhouse,8,cmdtext);
dcmd(sellhouse,9,cmdtext);
dcmd(unsellhouse,11,cmdtext);
dcmd(createhouse,11,cmdtext);
dcmd(destroyhouse,12,cmdtext);
return false;
}
///////////////////////////////////////
// Buisness + Homes Functions
//////////////////////////////////////
stock CreatePlayerHouse(playerid, sellprice, HouseLvl)
{
if((ReturnNextUnusedHouseID()-1) >= MAX_HOUSES) return SendClientMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: Maximum amount of houses on the server have been created.");
new house[64], Float:X, Float:Y, Float:Z; GetPlayerPos(playerid, X, Y, Z);
new NextHouseID = ReturnNextUnusedHouseID();
new World = ReturnNextUnusedVirtualWorld();
format(house, sizeof(house), "/Houses/%d.dini.save", NextHouseID);
if(!dini_Exists(house)){
dini_Create(house);
dini_Set(house, "Name", "None");
dini_IntSet(house, "For_Sell", 1);
dini_IntSet(house, "Sell_Price", sellprice);
dini_IntSet(house, "Rent_Price", 1000);
dini_IntSet(house, "House_Level", HouseLvl);
dini_FloatSet(house,"Exit_Coord:X", X);
dini_FloatSet(house,"Exit_Coord:Y", Y);
dini_FloatSet(house,"Exit_Coord:Z", Z);
dini_IntSet(house, "VirtualWorld", World);
dini_IntSet(house, "Status", 0);
LoadPlayerHouse(NextHouseID);
SendClientMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: House has been Successfully created.");
}
return true;
}
stock LoadPlayerHouse(houseid)
{
new house[64]; format(house, sizeof(house), "/Houses/%d.dini.save", houseid);
if(dini_Exists(house)){
format(HouseInfo[houseid][hName], MAX_PLAYER_NAME, "%s", dini_Get(house, "Name"));
HouseInfo[houseid][hSellable] = dini_Int(house, "For_Sell");
HouseInfo[houseid][hSell] = dini_Int(house, "Sell_Price");
HouseInfo[houseid][hRent] = dini_Int(house, "Rent_Price");
HouseInfo[houseid][hLevel] = dini_Int(house, "House_Level");
HouseInfo[houseid][hExitX] = dini_Float(house, "Exit_Coord:X");
HouseInfo[houseid][hExitY] = dini_Float(house, "Exit_Coord:Y");
HouseInfo[houseid][hExitZ] = dini_Float(house, "Exit_Coord:Z");
HouseInfo[houseid][hVirtualWorld] = dini_Int(house, "VirtualWorld");
HouseInfo[houseid][hLocked] = dini_Int(house, "Status");
if(HouseInfo[houseid][hSellable] == 1){
HouseInfo[houseid][hPickup] = CreatePickup(1273, 23, HouseInfo[houseid][hExitX], HouseInfo[houseid][hExitY], HouseInfo[houseid][hExitZ]); // not bought
} else {
HouseInfo[houseid][hPickup] = CreatePickup(1272,23, HouseInfo[houseid][hExitX], HouseInfo[houseid][hExitY], HouseInfo[houseid][hExitZ]); // bought
}
}
return true;
}
public SavePlayerHouse(houseid)
{
new house[64]; format(house, sizeof(house), "/Houses/%d.dini.save", houseid);
if(dini_Exists(house)){
dini_Set(house, "Name", HouseInfo[houseid][hName]);
dini_IntSet(house, "For_Sell", HouseInfo[houseid][hSellable]);
dini_IntSet(house, "Sell_Price", HouseInfo[houseid][hSell]);
dini_IntSet(house, "Rent_Price", HouseInfo[houseid][hRent]);
dini_IntSet(house, "House_Level", HouseInfo[houseid][hLevel]);
dini_FloatSet(house, "Exit_Coord:X", HouseInfo[houseid][hExitX]);
dini_FloatSet(house, "Exit_Coord:Y", HouseInfo[houseid][hExitY]);
dini_FloatSet(house, "Exit_Coord:Z", HouseInfo[houseid][hExitZ]);
dini_IntSet(house, "VirtualWorld", HouseInfo[houseid][hVirtualWorld]);
dini_IntSet(house, "Status", HouseInfo[houseid][hLocked]);
}
return true;
}
stock ReturnNextUnusedHouseID()
{
new house[64];
for(new h = 0; h <= MAX_HOUSES; h++){
format(house, sizeof(house), "/Houses/%d.dini.save", h);
if(!dini_Exists(house)) return h; }
return true;
}
stock ReturnNextUnusedVirtualWorld()
{
new house[64]; // Please do not make more then 255 houses because that is the Maximum Virtual Worlds. Or use as many as you want in 0.3
format(house, sizeof(house), "/Houses/%d.dini.save", ReturnNextUnusedHouseID()-1);
return dini_Int(house, "VirtualWorld")+1;
}
public ReadPlayerHouseData(playerid)
{
new string[256], house[64];
for(new h = 0; h <= MAX_HOUSES; h++){
format(house, sizeof(house), "/Houses/%d.dini.save", h);
if(dini_Exists(house)){
if(HouseInfo[h][hSellable] == 1){
if(PlayerToPoint(PTP_RADIUS, playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])) {
format(string, sizeof(string), "~g~] House for Sale ]~n~~w~Owner:~y~ %s~n~~w~Level:~r~ %d~n~~w~Sell Price:~r~ %d~n~~w~Rent Cost:~r~ %d", HouseInfo[h][hName], HouseInfo[h][hLevel], HouseInfo[h][hSell], HouseInfo[h][hRent]);
GameTextForPlayer(playerid,string, 1500, 3);
}
} else if(HouseInfo[h][hSellable] == 0){
if(PlayerToPoint(PTP_RADIUS, playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])) {
format(string, sizeof(string), "~w~Owner:~y~ %s~n~~w~Level:~r~ %d~n~~w~Rent Cost:~r~ %d", HouseInfo[h][hName], HouseInfo[h][hLevel], HouseInfo[h][hRent]);
GameTextForPlayer(playerid,string, 1500, 3);
} } } }
}
stock DestroyPlayerHouse(playerid, houseid)
{
new house[64];
format(house, sizeof(house), "/Houses/%d.dini.save", houseid);
if(dini_Exists(house)){
dini_Remove(house);
DestroyPickup(HouseInfo[houseid][hPickup]);
SendClientMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: The given house has been destroyed.");
} else return SendClientMessage(playerid, COLOR_WHITE, ".:: [ERROR]: The given house id does not exsist so it cannot be destroyed.");
return false;
}
///////////////////////////
// Dcmd Commands
//////////////////////////
dcmd_househelp(playerid,params[]) {
#pragma unused params
if(IsPlayerConnected(playerid)){
SendClientMessage(playerid, COLOR_WHITE,"[HOUSE OWNER]: /(un)sellhouse, /(un)lockhouse, /rentprice, /tenants, /evict, /house (upgrade/downgrade)");
SendClientMessage(playerid, COLOR_WHITE,"[HOUSE PLAYERS]: /houseinfo, /buyhouse, /(un)renthouse");
}
return true;
}
dcmd_houseinfo(playerid,params[]) {
#pragma unused params
if(IsPlayerConnected(playerid)){
for(new h = 0; h <= MAX_HOUSES; h++){
if(PlayerToPoint(PTP_RADIUS, playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])){
new IsLocked[24];
if(HouseInfo[h][hLocked] == 1) { IsLocked = "True"; } else { IsLocked = "False"; }
SendClientMessage(playerid, COLOR_LIME,"HOUSE STATS ----------------------------------------------------------");
SendFormattedMessage(playerid, COLOR_WHITE, "Owner: %s - Level[%d] - RentCost[$%d] - SellPrice[$%d]", HouseInfo[h][hName], HouseInfo[h][hLevel], HouseInfo[h][hRent], HouseInfo[h][hSell]);
SendFormattedMessage(playerid, COLOR_WHITE, "IsLocked[%s] - HouseID[%d] - ExitCoords[X:%.4f, Y:%.4f, Z:%.4f]", IsLocked, h, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ]);
SendClientMessage(playerid, COLOR_LIME,"----------------------------------------------------------");
} } }
return true;
}
dcmd_enter(playerid,params[]) {
#pragma unused params
if(IsPlayerConnected(playerid)){
for(new h = 0; h <= MAX_HOUSES; h++){
if(PlayerToPoint(PTP_RADIUS, playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])){
new Level = HouseInfo[h][hLevel];
if(HouseInfo[h][hLocked] == 1 && strcmp(HouseInfo[h][hName],GetName(playerid), false ) != 0) return SendClientMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: This house has been locked by the owner.");
SetPlayerPos(playerid, HousesCoords[Level][0], HousesCoords[Level][1], HousesCoords[Level][2]);
SetPlayerInterior(playerid, HousesLevels[Level][0]); SetPlayerVirtualWorld(playerid, HouseInfo[h][hVirtualWorld]);
} } }
return true;
}
dcmd_exit(playerid,params[]) {
#pragma unused params
if(IsPlayerConnected(playerid)){
for(new h = 0; h <= MAX_HOUSES; h++){
if(PlayerToPoint(PTP_RADIUS, playerid, HousesCoords[HouseInfo[h][hLevel]][0], HousesCoords[HouseInfo[h][hLevel]][1], HousesCoords[HouseInfo[h][hLevel]][2])){
SetPlayerPos(playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ]);
SetPlayerInterior(playerid, 0); SetPlayerVirtualWorld(playerid, 0);
} } }
}
/*dcmd_evict(playerid,params[]) { // This needs to be intergrated with your players .ini account
#pragma unused params
if(IsPlayerConnected(playerid)){
new giveplayerid;
if(sscanf(params, "i", giveplayerid)) return SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /evict [id]");
if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_WHITE, "The given player does not exist");
for(new h = 0; h <= MAX_HOUSES; h++){
if(PlayerToPoint(PTP_RADIUS, playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])){
if(strcmp(HouseInfo[h][hName],GetName(playerid), false ) == 0){
if(PlayerInfo[giveplayerid][pHouse] != h) return SendClientMessage(playerid, COLOR_WHITE, ".:: [ERROR]: This player is not renting your house.");
PlayerInfo[giveplayerid][pHouse] = -1; PlayerUpdate(giveplayerid);
SendFormattedMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: You have evicted %s[%d] from your house.", GetName(giveplayerid), giveplayerid);
} else return SendClientMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: You are not the owner of this house.");
} } }
return true;
}
dcmd_tenants(playerid,params[]) { // This needs to be intergrated with your players .ini account
#pragma unused params
if(IsPlayerConnected(playerid)){
for(new i = 0; i <= MAX_PLAYERS; i++){
for(new h = 0; h <= MAX_HOUSES; h++){
if(PlayerToPoint(PTP_RADIUS, playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])){
if(PlayerInfo[i][pHouse] == h){
if(strcmp(HouseInfo[h][hName],GetName(playerid), false ) == 0){
PlayerInfo[giveplayerid][pHouse] = -1;
SendClientMessage(playerid, COLOR_LIME, "_---- Tenants ----");
SendFormattedMessage(playerid, COLOR_WHITE, "%s[%d]", GetName(i), i);
} else return SendClientMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: You are not the owner of this house.");
} } } } }
return true;
}
dcmd_renthouse(playerid,params[]) { // This needs to be intergrated with your players .ini account
#pragma unused params
if(IsPlayerConnected(playerid)){
for(new h = 0; h <= MAX_HOUSES; h++){
if(PlayerToPoint(PTP_RADIUS, playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])){
if(HouseInfo[h][hName] == "Name") return SendClientMessage(playerid, COLOR_WHITE, ".:: [ERROR]: No one has bought this house so you cannot rent from here.");
if(PlayerInfo[playerid][pHouse] != -1) return SendClientMessage(playerid, COLOR_WHITE, ".:: [ERROR]: You are allready renting a house. Use /unrenthouse to stop renting there.");
PlayerInfo[playerid][pHouse] = h; PlayerUpdate(giveplayerid);
SendFormattedMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: You are now renting from %s.", HouseInfo[h][hName]);
} } }
return true;
}
dcmd_unrenthouse(playerid,params[]) { // This needs to be intergrated with your players .ini account
#pragma unused params
if(IsPlayerConnected(playerid)){
if(PlayerInfo[playerid][pHouse] == -1) return SendClientMessage(playerid, COLOR_WHITE, ".:: [ERROR]: You are not renting a house.");
PlayerInfo[playerid][pHouse] = -1; PlayerUpdate(giveplayerid);
SendFormattedMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: You are not renting from %s anymore.", HouseInfo[h][hName]);
}
return true;
}
*/
dcmd_buyhouse(playerid,params[]) {
#pragma unused params
if(IsPlayerConnected(playerid)){
for(new h = 0; h <= MAX_HOUSES; h++){
if(PlayerToPoint(PTP_RADIUS, playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])){
if(strcmp(HouseInfo[h][hName],GetName(playerid), false ) != 0){
if(HouseInfo[h][hSellable] == 1){
if(GetPlayerMoney(playerid) < HouseInfo[h][hSell]) return SendClientMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: You do not have anough money to buy this house.");
DestroyPickup(HouseInfo[h][hPickup]);
HouseInfo[h][hPickup] = CreatePickup(1272,23, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ]); // bought
HouseInfo[h][hSellable] = 0; GivePlayerMoney(playerid, -HouseInfo[h][hSell]);
format(HouseInfo[h][hName], 24, "%s", GetName(playerid)); SavePlayerHouse(h);
} else return SendClientMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: This house is not for sale.");
} else return SendClientMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: You are cannot buy the house you are selling.");
} } }
return true;
}
dcmd_rentprice(playerid,params[]) {
#pragma unused params
if(IsPlayerConnected(playerid)){
new Price;
if(sscanf(params, "i", Price)) return SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /rentprice [rentprice]");
if(Price < 0 || Price > 10000) return SendClientMessage(playerid, COLOR_WHITE, "You cannot set the rent price below 0 or above 10k");
for(new h = 0; h <= MAX_HOUSES; h++){
if(PlayerToPoint(PTP_RADIUS, playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])){
if(strcmp(HouseInfo[h][hName],GetName(playerid), false ) == 0){
HouseInfo[h][hRent] = Price; SavePlayerHouse(h);
} else return SendClientMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: You are not the owner of this house.");
} } }
return true;
}
dcmd_house(playerid,params[]) {
#pragma unused params
if(IsPlayerConnected(playerid)){
new tmp[64];
if(sscanf(params, "s", tmp)) return SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /house (upgrade/downgrade)");
SendFormattedMessage(playerid, COLOR_WHITE, "Houses: 0[%d], 1[%d], 2[%d], 3[%d], 4[%d], 5[%d], 6[%d]", HousesLevels[0][1], HousesLevels[1][1], HousesLevels[2][1], HousesLevels[3][1], HousesLevels[4][1], HousesLevels[5][1], HousesLevels[6][1]);
SendFormattedMessage(playerid, COLOR_WHITE, "7[%d], 8[%d], 9[%d], 10[%d], 11[%d], 12[%d]", HousesLevels[7][1], HousesLevels[8][1], HousesLevels[9][1], HousesLevels[10][1], HousesLevels[11][1], HousesLevels[12][1]);
if(strlen(tmp) == strlen("upgrade")){
for(new h = 0; h <= MAX_HOUSES; h++){
if(PlayerToPoint(PTP_RADIUS, playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])){
if(strcmp(HouseInfo[h][hName],GetName(playerid), false ) == 0){
if(HouseInfo[h][hLevel]+1 > 12) return SendClientMessage(playerid, COLOR_WHITE, "You cannot set your house lvl above 12");
new Level = HousesLevels[HouseInfo[h][hLevel]+1][1];
SendFormattedMessage(playerid, COLOR_WHITE, "You have added improvments to your house that costs $%d", Level);
HouseInfo[h][hLevel] = (HouseInfo[h][hLevel]+1); GivePlayerMoney(playerid, -Level);
SavePlayerHouse(h);
} else return SendClientMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: You are not the owner of this house."); } }
}
if(strlen(tmp) == strlen("downgrade")){
for(new h = 0; h <= MAX_HOUSES; h++){
if(PlayerToPoint(PTP_RADIUS, playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])){
if(strcmp(HouseInfo[h][hName],GetName(playerid), false ) == 0){
if(HouseInfo[h][hLevel]-1 < 0) return SendClientMessage(playerid, COLOR_WHITE, "You cannot set your house lvl below 0");
new Level = HousesLevels[HouseInfo[h][hLevel]-1][1];
SendFormattedMessage(playerid, COLOR_WHITE, "You have removed improvments done to your house and have been refunded $%d", Level);
HouseInfo[h][hLevel] = (HouseInfo[h][hLevel]-1); GivePlayerMoney(playerid, Level);
SavePlayerHouse(h);
} else return SendClientMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: You are not the owner of this house."); } }
}
}
return true;
}
dcmd_lockhouse(playerid,params[]) {
#pragma unused params
if(IsPlayerConnected(playerid)){
for(new h = 0; h <= MAX_HOUSES; h++){
if(PlayerToPoint(PTP_RADIUS, playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])){
if(strcmp(HouseInfo[h][hName],GetName(playerid), false ) == 0){
if(HouseInfo[h][hLocked] == 1) return SendClientMessage(playerid, COLOR_WHITE, ".:: [ERROR]: This house is allready locked.");
HouseInfo[h][hLocked] = 1; SavePlayerHouse(h);
SendClientMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: You house has been locked.");
} else return SendClientMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: You are not the owner of this house.");
} } }
return true;
}
dcmd_unlockhouse(playerid,params[]) {
#pragma unused params
if(IsPlayerConnected(playerid)){
for(new h = 0; h <= MAX_HOUSES; h++){
if(PlayerToPoint(PTP_RADIUS, playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])){
if(strcmp(HouseInfo[h][hName],GetName(playerid), false ) == 0){
if(HouseInfo[h][hLocked] == 0) return SendClientMessage(playerid, COLOR_WHITE, ".:: [ERROR]: This house is allready unlocked.");
HouseInfo[h][hLocked] = 0; SavePlayerHouse(h);
SendClientMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: You house has been unlocked.");
} else return SendClientMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: You are not the owner of this house.");
} } }
return true;
}
dcmd_sellhouse(playerid,params[]) {
#pragma unused params
if(IsPlayerConnected(playerid)){
new Sell;
if(sscanf(params, "i", Sell)) return SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /sellhouse [sellprice]");
if(Sell < 0 || Sell > 5000000) return SendClientMessage(playerid, COLOR_WHITE, "You cannot set the sell price below 0 or above 5 Mill");
for(new h = 0; h <= MAX_HOUSES; h++){
if(PlayerToPoint(PTP_RADIUS, playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])){
if(strcmp(HouseInfo[h][hName],GetName(playerid), false ) == 0){
DestroyPickup(HouseInfo[h][hPickup]);
HouseInfo[h][hPickup] = CreatePickup(1273, 23, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ]); // not bought
HouseInfo[h][hSellable] = 1; HouseInfo[h][hSell] = Sell; SavePlayerHouse(h);
} else return SendClientMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: You are not the owner of this house.");
} } }
return true;
}
dcmd_unsellhouse(playerid,params[]) {
#pragma unused params
if(IsPlayerConnected(playerid)){
for(new h = 0; h <= MAX_HOUSES; h++){
if(PlayerToPoint(PTP_RADIUS, playerid, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])){
if(strcmp(HouseInfo[h][hName],GetName(playerid), false ) == 0){
DestroyPickup(HouseInfo[h][hPickup]);
HouseInfo[h][hPickup] = CreatePickup(1272,23, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ]); // bought
HouseInfo[h][hSellable] = 0; SavePlayerHouse(h);
} else return SendClientMessage(playerid, COLOR_WHITE, ".:: [HOUSE]: You are not the owner of this house.");
} } }
return true;
}
dcmd_createhouse(playerid,params[]) {
#pragma unused params
if(IsPlayerConnected(playerid)){
//if(PlayerInfo[playerid][pAdmin] < 10) return SendClientMessage(playerid,COLOR_WHITE,"SERVER: Unknown command.");
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_WHITE, "Only admins allowed to use this command");
new Sell, lvl;
if(sscanf(params, "ii", Sell, lvl)) return SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /createhouse [sellprice] [HouseLvl]");
if(Sell < 0 || Sell > 5000000) return SendClientMessage(playerid, COLOR_WHITE, "You cannot set the sell price below 0 or above 5 Mill");
if(lvl < 0 || lvl > 12) return SendClientMessage(playerid, COLOR_WHITE, "You cannot create a house lvl that is below 0 or above 12");
CreatePlayerHouse(playerid, Sell, lvl); }
return true;
}
dcmd_destroyhouse(playerid,params[]) {
#pragma unused params
if(IsPlayerConnected(playerid)){
//if(PlayerInfo[playerid][pAdmin] < 10) return SendClientMessage(playerid,COLOR_WHITE,"SERVER: Unknown command.");
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_WHITE, "Only admins allowed to use this command");
new houseid;
if(sscanf(params, "i", houseid)) return SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /destroyhouse [houseid]");
DestroyPlayerHouse(playerid, houseid);}
return true;
}
///////////////////////////
// Standard Functions
//////////////////////////
stock GetName(playerid)
{
new pname[MAX_PLAYER_NAME]; pname="Invalid PlayerID";
if(IsPlayerConnected(playerid)) {
GetPlayerName(playerid, pname, sizeof (pname));
}
return pname;
}
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x); tempposy = (oldposy -y); tempposz = (oldposz -z);
if(((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{ return true; }
return false;
}
Код:
//-------------------------------------------------------
//
// GRAND LARCENY Property creation and management script
//
// by damospiderman 2008
//
//-------------------------------------------------------
#include <a_samp>
#include "../include/gl_common.inc"
#define FILTERSCRIPT
//#define USE_SQLITE
#define PROP_VW (10000)
#define MAX_INTERIORS (146)
#define MAX_PROPERTIES (1000)
#define PROPERTY_FOLDER "properties" // Location of properties file
#define PROPERTY_UNIQID_FILE "properties/uniqId.txt" // Location of Uniq Interior Info
#define DB_PROPERTIES "properties/dbProperties.db" // Location of the properties Database
#define MAX_TYPES (5)
#define TYPE_EMPTY (0)
#define TYPE_HOUSE (1)
#define TYPE_BUSINESS (2)
#define TYPE_BANK (3)
#define TYPE_COP (4)
enum // Property Type Enum
E_P_TYPES {
tIcon,
tName[32]
}
enum // Uniq Interiors Enum
E_INTERIORS {
inIntID,
Float:inExitX,
Float:inExitY,
Float:inExitZ,
Float:inExitA,
inName[64]
};
enum // Properties Enum
E_PROPERTIES {
eInterior,
eType,
Float:eEntX,
Float:eEntY,
Float:eEntZ,
Float:eEntA,
eUniqIntId,
eOwner,
ePrice,
ePname[64]
};
// [ uniq property id ]
new unid;
// [ Array of all the property interior info ]
new interiorInfo[MAX_INTERIORS][E_INTERIORS];
// [ Pickup array with property id assigned via array slot ( pickupid ) ]
new propPickups[MAX_PROPERTIES] = {-1};
// [ Handles for 3D text displayed at property entrances ]
new Text3D:propTextInfo[MAX_PROPERTIES];
// [ Mass array of all the properties and info about them ]
new properties[MAX_PROPERTIES][E_PROPERTIES];
// [ The last pickup the player went through so they can do /enter command ]
new lastPickup[MAX_PLAYERS] = {-1};
// [ Current property Unique Interior the player is in.. defaults to -1 when not in any property ]
new currentInt[MAX_PLAYERS] = {-1};
// [ Player Position array to store the last place the player was before /view command so they can be teleported back ]
new Float:plPos[MAX_PLAYERS][3];
// [ Players actual interior id used for /view /return command ]
new plInt[MAX_PLAYERS];
// [ Array of property type iconid's and strings for property type ]
new propIcons[MAX_TYPES][E_P_TYPES] = {
{ 0, "" }, // TYPE_EMPTY ( not used )
{ 1273, "House" }, // TYPE_HOUSE green house icon
{ 1272, "Business" }, // TYPE_BUSINESS blue house icon
{ 1274, "Bank" }, // TYPE_BANK dollar sign icon
{ 1247, "Police Station" } // TYPE_COP Bribe Star 1247
};
new propFile[MAX_TYPES][64] = {
{ "blank" },
{ "properties/houses.txt" },
{ "properties/businesses.txt" },
{ "properties/banks.txt" },
{ "properties/police.txt" }
};
// Keep track of what properties we've sent an /enter notification for
new gLastPropertyEnterNotification[MAX_PLAYERS];
/********************************
* Interior Info Functions *
********************************/
stock Float:GetInteriorExit( id, &Float:x, &Float:y, &Float:z ){
if( id > MAX_INTERIORS ) return 0.0;
else {
x = interiorInfo[id][inExitX];
y = interiorInfo[id][inExitY];
z = interiorInfo[id][inExitZ];
return interiorInfo[id][inExitA];
}
}
// Gets interior exit info from uniq Interior Id. Returns InteriorId or -1 if interior doesn't exist
stock GetInteriorExitInfo( uniqIntId, &Float:exitX, &Float:exitY, &Float:exitZ, &Float:exitA ){
if( uniqIntId < MAX_INTERIORS ){
exitX = interiorInfo[uniqIntId][inExitX];
exitY = interiorInfo[uniqIntId][inExitY];
exitZ = interiorInfo[uniqIntId][inExitZ];
exitA = interiorInfo[uniqIntId][inExitA];
return interiorInfo[uniqIntId][inIntID];
}
return -1;
}
stock GetInteriorIntID( id ){ // Gets the interior id of a uniq Interior Id :S
if( id > MAX_INTERIORS ) return -1;
else return interiorInfo[id][inIntID];
}
stock GetInteriorName( id )
{
new tmp[64];
if( id > MAX_PROPERTIES ) return tmp;
else {
format( tmp, 64, "%s", interiorInfo[id][inName] );
return tmp;
}
}
/********************************************************
********************************************************/
/********************************
* Property Functions *
********************************/
stock Float:GetPropertyEntrance( id, &Float:x, &Float:y, &Float:z ){
if( id > MAX_PROPERTIES ) return 0.0;
x = properties[id][eEntX];
y = properties[id][eEntY];
z = properties[id][eEntZ];
return properties[id][eEntA];
}
stock Float:GetPropertyExit( id, &Float:x, &Float:y, &Float:z ){
if( id > MAX_PROPERTIES ) return 0.0;
return GetInteriorExit( properties[id][eUniqIntId], x, y, z );
}
stock GetPropertyInteriorFileId( id ){
if( id > MAX_PROPERTIES ) return 0;
else return properties[id][eUniqIntId];
}
stock GetPropertyInteriorId( id ){
if( id > MAX_PROPERTIES ) return 0;
else return GetInteriorIntID( properties[id][eUniqIntId] );
}
stock GetPropertyType( id ){
if( id > MAX_PROPERTIES ) return 0;
else return properties[id][eType];
}
stock GetPropertyOwner( id ){
if( id > MAX_PROPERTIES ) return -1;
else return properties[id][eOwner];
}
stock GetPropertyPrice( id ){
if( id > MAX_PROPERTIES ) return -1;
else return properties[id][ePrice];
}
stock GetPropertyName( id ){
new tmp[64];
if( id > MAX_PROPERTIES ) return tmp;
else {
format( tmp, 64, "%s", properties[id][ePname] );
return tmp;
}
}
/********************************************************
********************************************************/
/********************************
* Database Functions *
********************************/
stock Float:dbGetPropertyEntrance( database[], uniqId, &Float:x, &Float:y, &Float:z ){
new
DB:prop,
DBResult:query_result,
query[128],
num;
prop = db_open( database );
format( query, 128,"SELECT entX, entY, enZ, entA FROM properties WHERE id = %d LIMIT 1", uniqId );
query_result = db_query( prop, query );
num = db_num_rows(query_result);
if(!num) return -1.0;
else {
db_get_field_assoc( query_result, "entX", query, 128 );
x = floatstr( query );
db_get_field_assoc( query_result, "entY", query, 128 );
y = floatstr( query );
db_get_field_assoc( query_result, "entZ", query, 128 );
z = floatstr( query );
db_get_field_assoc( query_result, "entA", query, 128 );
return floatstr( query );
}
}
stock dbSetPropertyOwner( database[], uniqId, ownerId ){
}
stock dbSetPropertyPrice( database[], uniqId, price ){
}
stock dbDeleteProperty( database[], uniqId ){
}
stock dbCreateProperty( database[], uniqId, Float:entX, Float:entY, Float:entZ, Float:entA ){ // remember to add rest of params
}
stock dbLoadProperties( database[] )
{
new
DB:prop,
DBResult:query_result,
query[128],
num,
i;
prop = db_open( database );
format( query, 128,"SELECT * FROM properties", uniqId );
query_result = db_query( prop, query );
num = db_num_rows(query_result);
if(!num) return 0;
else {
while( i < num ){
db_get_field_assoc( query_result, "entX", query, 128 );
x = floatstr( query );
db_get_field_assoc( query_result, "entX", query, 128 );
x = floatstr( query );
db_get_field_assoc( query_result, "entY", query, 128 );
y = floatstr( query );
db_get_field_assoc( query_result, "entZ", query, 128 );
z = floatstr( query );
db_get_field_assoc( query_result, "entA", query, 128 );
i++;
}
}
}
/********************************************************
********************************************************/
/*********************************
* Property System Functions *
*********************************/
ReadInteriorInfo( fileName[] )
{
new
File:file_ptr,
buf[256],
tmp[64],
idx,
uniqId;
file_ptr = fopen( fileName, io_read );
if( file_ptr ){
while( fread( file_ptr, buf, 256 ) > 0){
idx = 0;
idx = token_by_delim( buf, tmp, ' ', idx );
if(idx == (-1)) continue;
uniqId = strval( tmp );
if( uniqId >= MAX_INTERIORS ) return 0;
idx = token_by_delim( buf, tmp, ' ', idx+1 );
if(idx == (-1)) continue;
interiorInfo[uniqId][inIntID] = strval( tmp );
idx = token_by_delim( buf, tmp, ' ', idx+1 );
if(idx == (-1)) continue;
interiorInfo[uniqId][inExitX] = floatstr( tmp );
idx = token_by_delim( buf, tmp, ' ', idx+1 );
if(idx == (-1)) continue;
interiorInfo[uniqId][inExitY] = floatstr( tmp );
idx = token_by_delim( buf, tmp, ' ', idx+1);
if(idx == (-1)) continue;
interiorInfo[uniqId][inExitZ] = floatstr( tmp );
idx = token_by_delim( buf, tmp, ' ', idx+1 );
if(idx == (-1)) continue;
interiorInfo[uniqId][inExitA] = floatstr( tmp );
idx = token_by_delim( buf, interiorInfo[uniqId][inName], ';', idx+1 );
if(idx == (-1)) continue;
/*
printf( "ReadInteriorInfo(%d, %d, %f, %f, %f, %f ( %s ))",
uniqId,
interiorInfo[uniqId][inIntID],
interiorInfo[uniqId][inExitX],
interiorInfo[uniqId][inExitY],
interiorInfo[uniqId][inExitZ],
interiorInfo[uniqId][inExitA],
interiorInfo[uniqId][inName] );*/
}
//printf( "Interiors File read successfully" );
fclose( file_ptr );
return 1;
}
printf( "Could Not Read Interiors file ( %s )", fileName );
return 0;
}
ReadPropertyFile( fileName[] )
{
new File:file_ptr,
tmp[128],
buf[256],
idx,
Float:enX,
Float:enY,
Float:enZ,
Float:enA,
uniqIntId,
p_type,
pIcon;
printf("Reading File: %s",fileName);
file_ptr = fopen( fileName, io_read );
if(!file_ptr )return 0;
while( fread( file_ptr, buf, 256 ) > 0){
idx = 0;
idx = token_by_delim( buf, tmp, ',', idx );
if(idx == (-1)) continue;
pIcon = strval( tmp );
idx = token_by_delim( buf, tmp, ',', idx+1 );
if(idx == (-1)) continue;
enX = floatstr( tmp );
idx = token_by_delim( buf, tmp, ',', idx+1 );
if(idx == (-1)) continue;
enY = floatstr( tmp );
idx = token_by_delim( buf, tmp, ',', idx+1 );
if(idx == (-1)) continue;
enZ = floatstr( tmp );
idx = token_by_delim( buf, tmp, ',', idx+1 );
if(idx == (-1)) continue;
enA = floatstr( tmp );
idx = token_by_delim( buf, tmp, ',', idx+1 );
if(idx == (-1)) continue;
uniqIntId = strval( tmp );
idx = token_by_delim( buf, tmp, ';', idx+1 );
if(idx == (-1)) continue;
p_type = strval( tmp );
CreateProperty( uniqIntId, pIcon, enX, enY, enZ, enA, p_type );
}
fclose( file_ptr );
return 1;
}
PutPlayerInProperty( playerid, propId, propVW = 0 )
{
new Float:x, Float:y, Float:z, Float:a;
new intFileId;
a = GetPropertyExit( propId, x, y, z );
SetPlayerPos( playerid, x, y, z );
SetPlayerFacingAngle( playerid, a );
SetPlayerInterior( playerid, GetPropertyInteriorId( propId ));
SetPlayerVirtualWorld( playerid, (propVW==0)? propId+PROP_VW:propVW );
intFileId = GetPropertyInteriorFileId(propId);
currentInt[playerid] = propId;
//new dbgstring[128];
//format(dbgstring,sizeof(dbgstring),"PutPlayerInProperty(%d): FileInt=%d",propId,intFileId);
//SendClientMessage(playerid,0xFFFFFFFF,dbgstring);
// the following will make the client shop scripts run if we tell it
// the name of the shop.
if(intFileId == 22) {
SetPlayerShopName(playerid,"FDPIZA");
}
else if(intFileId == 47) {
SetPlayerShopName(playerid,"FDBURG");
}
else if(intFileId == 130) {
SetPlayerShopName(playerid,"FDCHICK");
}
else if(intFileId == 32) {
SetPlayerShopName(playerid,"AMMUN1");
}
else if(intFileId == 96) {
SetPlayerShopName(playerid,"AMMUN2");
}
else if(intFileId == 122) {
SetPlayerShopName(playerid,"AMMUN3");
}
else if(intFileId == 123) {
SetPlayerShopName(playerid,"AMMUN5");
}
}
// Adds new property to property file
AddProperty( uniqIntId, Float:entX, Float:entY, Float:entZ, Float:entA, p_type, comment[]="" )
{
new
Float:exitX,
Float:exitY,
Float:exitZ,
Float:exitA,
interiorId,
File:file_ptr,
tmp[128];
interiorId = GetInteriorExitInfo( uniqIntId, exitX, exitY, exitZ, exitA );
if( interiorId != -1 ){
file_ptr = fopen( propFile[p_type], io_append );
if(file_ptr){
format( tmp, 128, "%d, %f, %f, %f, %f, %d, %d ; //%s\r\n", propIcons[p_type][tIcon],entX, entY, entZ, entA, uniqIntId, p_type, comment );
fwrite( file_ptr, tmp );
fclose( file_ptr );
printf( "PropDB - %s", tmp );
return CreateProperty( uniqIntId, propIcons[p_type][tIcon], entX, entY, entZ, entA, p_type );
}
}
return -1;
}
CreateProperty( uniqIntId, iconId, Float:entX, Float:entY, Float:entZ, Float:entA, p_type, name[64]="", owner=-1, price=0 )
{
if( (unid+1) < MAX_PROPERTIES ){
new Id = CreatePickup( iconId ,23, entX, entY, entZ, 0 );
//printf( "CreateProperty(%d, %d, %f, %f, %f, %f, %d)", uniqIntId, iconId, entX, entY, entZ, entA, p_type );
propPickups[Id] = unid;
properties[unid][eEntX] = entX;
properties[unid][eEntY] = entY;
properties[unid][eEntZ] = entZ;
properties[unid][eEntA] = entA;
properties[unid][eUniqIntId] = uniqIntId;
properties[unid][eOwner] = owner;
properties[unid][ePrice] = price;
properties[unid][eType] = p_type;
format( properties[unid][ePname], 64, "%s", name );
new text_info[256];
propTextInfo[unid] = Text3D:INVALID_3DTEXT_ID;
if(p_type == TYPE_HOUSE) {
format(text_info,256,"[House]");
propTextInfo[unid] = Create3DTextLabel(text_info,0x88EE88FF,entX,entY,entZ+0.75,20.0,0,1);
}
else if(p_type == TYPE_BUSINESS) {
format(text_info,256,"[Business]");
propTextInfo[unid] = Create3DTextLabel(text_info,0xAAAAFFFF,entX,entY,entZ+0.75,20.0,0,1);
}
else if(p_type == TYPE_BANK) {
format(text_info,256,"[Bank]");
propTextInfo[unid] = Create3DTextLabel(text_info,0xEEEE88FF,entX,entY,entZ+0.75,20.0,0,1);
}
else if(p_type == TYPE_COP) {
format(text_info,256,"[Police Station]");
propTextInfo[unid] = Create3DTextLabel(text_info,0xEEEE88FF,entX,entY,entZ+0.75,20.0,0,1);
}
return unid++;
}
else print( "Property Limit Reached" );
return -1;
}
PropertyCommand( playerid, cmd[],cmdtext[],idx, p_type )
{
new
Float:x,
Float:y,
Float:z,
Float:a,
tmp[256],
string[128],
uniqId,
id;
if( GetPlayerInterior(playerid) != 0 || GetPlayerVirtualWorld(playerid)!= 0 ){
SendClientMessage(playerid, 0x550000FF, "You can only create properties in Interior 0 and VW 0" );
return 1;
}
GetPlayerPos( playerid, x, y, z );
GetPlayerFacingAngle( playerid, a );
tmp = strtok( cmdtext, idx );
if(!strlen(tmp)){
format( string, 128, "Usage: %s [uniqInteriorId] [optional-comment]", cmd );
SendClientMessage( playerid, 0xFF00CC, string );
return 1;
}
if(!isNumeric(tmp)){
SendClientMessage(playerid, 0x550000, "Uniq Interior Id must be a number" );
return 1;
}
uniqId = strval( tmp );
if( uniqId > MAX_INTERIORS || uniqId < 0 ){
SendClientMessage( playerid, 0xFFFFCC, "Invalid Uniq Interior Id" );
return 1;
}
idx = token_by_delim( cmdtext, tmp, '\0', idx );
if(idx){
id = AddProperty( uniqId, x, y, z, a, p_type, tmp );
}
else {
id = AddProperty( uniqId, x, y, z, a, p_type );
}
if( id != -1 ){
format( tmp, 256, "Property Type ( %d ) Added Successfully: UniqId: %d Interior: %d IntName: %s",p_type, id, interiorInfo[uniqId][inIntID], interiorInfo[uniqId][inName] );
SendClientMessage( playerid, 0xCC7700, tmp );
}else{
SendClientMessage( playerid, 0x00FF55, "Error: Something went wrong/Property Limit Reached" );
}
return 1;
}
LoadProperties()
{
if( properties[0][eType] != TYPE_EMPTY ){
UnloadProperties();
}
unid = 0;
for( new i = 0; i < MAX_PROPERTIES; i++ ){
properties[i][eType] = TYPE_EMPTY;
}
ReadInteriorInfo( "properties/interiors.txt" );
for( new i = 0; i < MAX_TYPES; i++ ){
ReadPropertyFile( propFile[i] );
}
return 1;
}
UnloadProperties()
{
new
p;
for( new i = 0; i < MAX_PROPERTIES; i++ ){
if( propPickups[i] != -1 ){
DestroyPickup( i );
p = propPickups[i];
propPickups[i] = -1;
properties[p][eInterior] = -1;
properties[p][eType] = TYPE_EMPTY;
properties[p][eOwner] = -1;
properties[p][ePrice] = 0;
properties[p][ePname][0] = '\0';
}
}
}
/********************************************************
********************************************************/
/************************************
* Callbacks *
************************************/
public OnFilterScriptInit()
{
print("\n-----------------------------------");
print("Grand Larceny Property Filterscript ");
print("-----------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
UnloadProperties();
return 1;
}
public OnGameModeInit()
{
LoadProperties();
return 1;
}
public OnGameModeExit()
{
UnloadProperties();
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
if( newinteriorid == 0 ){
currentInt[playerid] = -1;
SetPlayerVirtualWorld( playerid, 0 );
}
return 1;
}
public OnPlayerSpawn( playerid )
{
gLastPropertyEnterNotification[playerid] = -1;
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
//printf( "DEBUG: Player %d pickedup Pickup %d Prop Id %d", playerid, pickupid );
lastPickup[playerid] = pickupid;
new id = propPickups[pickupid];
new pmsg[256];
if( properties[id][eType] > 0 ){
if(gLastPropertyEnterNotification[playerid] != id){
gLastPropertyEnterNotification[playerid] = id;
switch( properties[id][eType] ){
case TYPE_HOUSE:{
format(pmsg,256,"* House: type /enter to enter");
SendClientMessage( playerid, 0xFF55BBFF, pmsg );
return 1;
}
case TYPE_BUSINESS:{
format(pmsg,256,"* Business: type /enter to enter");
SendClientMessage( playerid, 0xFF55BBFF, pmsg );
return 1;
}
case TYPE_BANK:{
format(pmsg,256,"* Bank: type /enter to enter");
SendClientMessage( playerid, 0xFF55BBFF, pmsg );
return 1;
}
case TYPE_COP:{
format(pmsg,256,"* Police Station: type /enter to enter");
SendClientMessage( playerid, 0xFF55BBFF, pmsg );
return 1;
}
}
}
}
else SendClientMessage( playerid, 0xFF9900FF, "This property doesn't exist :S" );
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new idx;
new cmd[256];
cmd = strtok(cmdtext, idx);
// Public commands.
if(strcmp("/enter", cmd, true) == 0) // enter property
{
if( lastPickup[playerid] != -1 || properties[lastPickup[playerid]][eType] > 0 ){
new
id = propPickups[lastPickup[playerid]],
Float:x,
Float:y,
Float:z;
GetPropertyEntrance( id, x, y, z );
if( IsPlayerInRangeOfPoint( playerid, 3.0, x, y, z )){
PutPlayerInProperty( playerid, id );
SendClientMessage( playerid, 0x55AADDFF, "* You have entered a property.. type /exit to leave" );
return 1;
}
}
return 1;
}
else if(strcmp("/exit", cmd, true) == 0) // exit property
{
if( currentInt[playerid] > -1 && GetPlayerInterior(playerid) == GetPropertyInteriorId( currentInt[playerid] )){
new id = currentInt[playerid];
new Float:x;
new Float:y;
new Float:z;
new Float:a;
// make sure they're near the exit before allowing them to exit.
GetPropertyExit( id, x, y, z );
if(!IsPlayerInRangeOfPoint(playerid,4.5,x,y,z)) {
SendClientMessage(playerid,0xDDAA55FF,"* You must be near the property exit to /exit");
return 1;
}
a = GetPropertyEntrance( id, x, y, z );
SetPlayerPos( playerid, x, y, z );
SetPlayerFacingAngle( playerid, a );
SetPlayerInterior( playerid, 0 );
SetPlayerVirtualWorld( playerid, 0 );
}
currentInt[playerid] = -1;
return 1;
}
// The rest of the commands here are for
// property creation which is admin only.
if(!IsPlayerAdmin(playerid)) return 0;
if(strcmp("/chouse", cmd, true) == 0) // creates a house type property
{
PropertyCommand( playerid, cmd, cmdtext,idx, TYPE_HOUSE );
return 1;
}
else if(strcmp("/cbus", cmd, true) == 0) // creates a business type property
{
PropertyCommand( playerid, cmd, cmdtext,idx, TYPE_BUSINESS );
return 1;
}
else if(strcmp("/ccop", cmd, true) == 0) // creates a police station property
{
PropertyCommand( playerid, cmd, cmdtext,idx, TYPE_COP );
return 1;
}
else if(strcmp("/cbank", cmd, true) == 0) // creates a bank type property
{
PropertyCommand( playerid, cmd, cmdtext,idx, TYPE_BANK );
return 1;
}
else if(strcmp("/view", cmd, true) == 0) //Basically lets you view an interior from the interiors.txt file by id
{
new
tmp[256],
string[128],
uniqId,
Float:x,
Float:y,
Float:z,
Float:a;
tmp = strtok( cmdtext, idx );
if(!strlen(tmp)){
format( string, 128, "Usage: %s [uniqInteriorId]", cmd );
SendClientMessage( playerid, 0xFF00CC, string );
return 1;
}
if(!isNumeric(tmp)){
SendClientMessage(playerid, 0x550000, "Uniq Interior Id must be a number" );
return 1;
}
uniqId = strval( tmp );
if( uniqId > MAX_INTERIORS || uniqId < 0 ){
SendClientMessage( playerid, 0xFFFFCC, "Invalid Uniq Interior Id" );
return 1;
}
if( GetPlayerInterior( playerid ) == 0 ){
GetPlayerPos( playerid, plPos[playerid][0], plPos[playerid][1], plPos[playerid][2] );
plInt[playerid] = GetPlayerInterior( playerid );
}
a = GetInteriorExit( uniqId, x, y, z );
SetPlayerInterior( playerid, GetInteriorIntID( uniqId ) );
SetPlayerPos( playerid, x, y, z );
SetPlayerFacingAngle( playerid, a );
format( string, 128, "UniqId: %d InteriorId: %d Name: %s | Use /return to go to last position", uniqId,GetInteriorIntID( uniqId ), GetInteriorName( uniqId ));
SendClientMessage( playerid, 0x556600FF, string );
return 1;
}
else if( strcmp( "/return", cmd, true ) == 0 ) // return from /view command to last position
{
SetPlayerPos( playerid, plPos[playerid][0], plPos[playerid][1], plPos[playerid][2] );
SetPlayerInterior( playerid, plInt[playerid] );
return 1;
}
return 0;
}
/***********************************************************************
***********************************************************************/
very nice of you guys if you could take a look on it
thankz for now. :P

