25.04.2018, 12:34
Hi. On my server, I put an house filterscript.
Every command works, but when you press "BUY" at dialogresponse, it won't do anything.
Can you help?
Every command works, but when you press "BUY" at dialogresponse, it won't do anything.
Can you help?
PHP код:
if(dialogid == DIALOG_HOUSE)
{
if(!response) return 1;
new id = GetPVarInt(playerid, "PickupHouseID");
if(!IsPlayerInRangeOfPoint(playerid, 2.0, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ])) return SendClientMessage(playerid, 0xE74C3CFF, "You're not near any house.");
if(HouseData[id][Price] > pInfo[playerid][Money]) return SendClientMessage(playerid, 0xE74C3CFF, "You can't afford this house.");
pInfo[playerid][Money] -= HouseData[id][Price];
GetPlayerName(playerid, HouseData[id][Owner], MAX_PLAYER_NAME);
HouseData[id][LastEntered] = gettime();
HouseData[id][Save] = true;
UpdateHouseLabel(id);
Streamer_SetIntData(STREAMER_TYPE_PICKUP, HouseData[id][HousePickup], E_STREAMER_MODEL_ID, 19522);
Streamer_SetIntData(STREAMER_TYPE_MAP_ICON, HouseData[id][HouseIcon], E_STREAMER_TYPE, 32);
SendToHouse(playerid, id);
return 1;
}
if(dialogid == DIALOG_HOUSE+1)
{
if(!response) return 1;
new id = GetPVarInt(playerid, "PickupHouseID");
if(!IsPlayerInRangeOfPoint(playerid, 2.0, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ])) return SendClientMessage(playerid, 0xE74C3CFF, "You're not near any house.");
if(!(1 <= strlen(inputtext) <= MAX_HOUSE_PASSWORD)) return ShowPlayerDialog(playerid, DIALOG_HOUSE+1, DIALOG_STYLE_INPUT, "House Password", "This house is password protected.\n\nEnter house password:\n\n{E74C3C}The password you entered is either too short or too long.", "Try Again", "Close");
if(strcmp(HouseData[id][Password], inputtext)) return ShowPlayerDialog(playerid, DIALOG_HOUSE+1, DIALOG_STYLE_INPUT, "House Password", "This house is password protected.\n\nEnter house password:\n\n{E74C3C}Wrong password.", "Try Again", "Close");
SendToHouse(playerid, id);
return 1;
}
if(dialogid == DIALOG_HOUSE+2)
{
if(!response) return 1;
new id = InHouse[playerid], name[24];
if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(strcmp(HouseData[id][Owner], name)) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
if(listitem == 0) ShowPlayerDialog(playerid, DIALOG_HOUSE+3, DIALOG_STYLE_INPUT, "House Name", "Write a new name for this house:", "Change", "Back");
if(listitem == 1) ShowPlayerDialog(playerid, DIALOG_HOUSE+4, DIALOG_STYLE_INPUT, "House Password", "Write a new password for this house:", "Change", "Back");
if(listitem == 2) ShowPlayerDialog(playerid, DIALOG_HOUSE+5, DIALOG_STYLE_LIST, "House Lock", "Not Locked\nPassword Lock\nKeys\nOwner Only", "Change", "Back");
if(listitem == 3)
{
new string[144];
format(string, sizeof(string), "Take Money From Safe {2ECC71}($%s)\nPut Money To Safe {2ECC71}($%s)\nView Safe History\nClear Safe History", convertNumber(HouseData[id][SafeMoney]), convertNumber(GetPlayerMoney(playerid)));
ShowPlayerDialog(playerid, DIALOG_HOUSE+6, DIALOG_STYLE_LIST, "House Safe", string, "Choose", "Back");
}
if(listitem == 4) ShowPlayerDialog(playerid, DIALOG_HOUSE+11, DIALOG_STYLE_LIST, "Furnitures", "Buy Furniture\nEdit Furniture\nSell Furniture\nSell All Furnitures", "Choose", "Back");
if(listitem == 5) ShowPlayerDialog(playerid, DIALOG_HOUSE+9, DIALOG_STYLE_LIST, "Guns", "Put Gun\nTake Gun", "Choose", "Back");
if(listitem == 6)
{
ListPage[playerid] = 0;
ShowPlayerDialog(playerid, DIALOG_HOUSE+14, DIALOG_STYLE_LIST, "Visitors", "Look Visitor History\nClear Visitor History", "Choose", "Back");
}
if(listitem == 7)
{
ListPage[playerid] = 0;
ShowPlayerDialog(playerid, DIALOG_HOUSE+16, DIALOG_STYLE_LIST, "Keys", "View Key Owners\nChange Locks", "Choose", "Back");
}
if(listitem == 8)
{
new string[128];
format(string, sizeof(string), "House owner %s kicked everybody from the house.", HouseData[id][Owner]);
foreach(new i : Player)
{
if(i == playerid) continue;
if(InHouse[i] == id)
{
SetPVarInt(i, "HousePickupCooldown", tickcount()+8000);
SetPlayerVirtualWorld(i, 0);
SetPlayerInterior(i, 0);
SetPlayerPos(i, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]);
InHouse[i] = INVALID_HOUSE_ID;
SendClientMessage(i, -1, string);
}
}
SendClientMessage(playerid, -1, "You kicked everybody from your house.");
}
if(listitem == 9)
{
new money = floatround(HouseData[id][Price] * 0.85) + HouseData[id][SafeMoney];
pInfo[playerid][Money] += money;
ResetHouse(id);
}
return 1;
}
if(dialogid == DIALOG_HOUSE+3)
{
if(!response) return ShowHouseMenu(playerid);
new id = InHouse[playerid], name[24];
if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(strcmp(HouseData[id][Owner], name)) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
if(!(1 <= strlen(inputtext) <= MAX_HOUSE_NAME)) return ShowPlayerDialog(playerid, DIALOG_HOUSE+3, DIALOG_STYLE_INPUT, "House Name", "Write a new name for this house:\n\n{E74C3C}The name you entered is either too short or too long.", "Change", "Back");
format(HouseData[id][Name], MAX_HOUSE_NAME, "%s", inputtext);
HouseData[id][Save] = true;
UpdateHouseLabel(id);
ShowHouseMenu(playerid);
return 1;
}
if(dialogid == DIALOG_HOUSE+4)
{
if(!response) return ShowHouseMenu(playerid);
new id = InHouse[playerid], name[24];
if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(strcmp(HouseData[id][Owner], name)) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
if(!(1 <= strlen(inputtext) <= MAX_HOUSE_PASSWORD)) return ShowPlayerDialog(playerid, DIALOG_HOUSE+3, DIALOG_STYLE_INPUT, "House Name", "Write a new name for this house:\n\n{E74C3C}The name you entered is either too short or too long.", "Change", "Back");
format(HouseData[id][Password], MAX_HOUSE_PASSWORD, "%s", inputtext);
HouseData[id][Save] = true;
ShowHouseMenu(playerid);
return 1;
}
if(dialogid == DIALOG_HOUSE+5)
{
if(!response) return ShowHouseMenu(playerid);
new id = InHouse[playerid], name[24];
if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(strcmp(HouseData[id][Owner], name)) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
HouseData[id][LockMode] = listitem;
HouseData[id][Save] = true;
UpdateHouseLabel(id);
ShowHouseMenu(playerid);
return 1;
}
if(dialogid == DIALOG_HOUSE+6)
{
if(!response) return ShowHouseMenu(playerid);
new id = InHouse[playerid], name[24];
if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(strcmp(HouseData[id][Owner], name)) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
if(listitem == 0) ShowPlayerDialog(playerid, DIALOG_HOUSE+7, DIALOG_STYLE_INPUT, "Safe: Take Money", "Write the amount you want to take from safe:", "Take", "Back");
if(listitem == 1) ShowPlayerDialog(playerid, DIALOG_HOUSE+8, DIALOG_STYLE_INPUT, "Safe: Put Money", "Write the amount you want to put to safe:", "Put", "Back");
if(listitem == 2)
{
ListPage[playerid] = 0;
new query[200], Cache: safelog;
mysql_format(SQLHandle, query, sizeof(query), "SELECT Type, Amount, FROM_UNIXTIME(Date, '%%d/%%m/%%Y %%H:%%i') as TransactionDate FROM housesafelogs WHERE HouseID=%d ORDER BY Date DESC LIMIT 0, 15", id);
safelog = mysql_query(SQLHandle, query);
new rows = cache_num_rows();
if(rows) {
new list[1024], date[20];
format(list, sizeof(list), "Action\tDate\n");
for(new i; i < rows; ++i)
{
cache_get_field_content(i, "TransactionDate", date);
format(list, sizeof(list), "%s%s $%s\t{FFFFFF}%s\n", list, TransactionNames[ cache_get_field_content_int(i, "Type") ], convertNumber(cache_get_field_content_int(i, "Amount")), date);
}
ShowPlayerDialog(playerid, DIALOG_HOUSE+18, DIALOG_STYLE_TABLIST_HEADERS, "Safe History (Page 1)", list, "Next", "Previous");
}else{
SendClientMessage(playerid, 0xE74C3CFF, "Can't find any safe history.");
}
cache_delete(safelog);
}
if(listitem == 3)
{
new query[64];
mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housesafelogs WHERE HouseID=%d", id);
mysql_tquery(SQLHandle, query, "", "");
ShowHouseMenu(playerid);
}
return 1;
}
if(dialogid == DIALOG_HOUSE+7)
{
if(!response) return ShowHouseMenu(playerid);
new id = InHouse[playerid], name[24];
if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(strcmp(HouseData[id][Owner], name)) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
new amount = strval(inputtext);
if(!(1 <= amount <= 10000000)) return ShowPlayerDialog(playerid, DIALOG_HOUSE+7, DIALOG_STYLE_INPUT, "Safe: Take Money", "Write the amount you want to take from safe:\n\n{E74C3C}Invalid amount. You can take between $1 - $10,000,000 at a time.", "Take", "Back");
if(amount > HouseData[id][SafeMoney]) return ShowPlayerDialog(playerid, DIALOG_HOUSE+7, DIALOG_STYLE_INPUT, "Safe: Take Money", "Write the amount you want to take from safe:\n\n{E74C3C}You don't have that much money in your safe.", "Take", "Back");
new query[128];
mysql_format(SQLHandle, query, sizeof(query), "INSERT INTO housesafelogs SET HouseID=%d, Type=0, Amount=%d, Date=UNIX_TIMESTAMP()", id, amount);
mysql_tquery(SQLHandle, query, "", "");
pInfo[playerid][Money] += amount;
HouseData[id][SafeMoney] -= amount;
HouseData[id][Save] = true;
ShowHouseMenu(playerid);
return 1;
}
if(dialogid == DIALOG_HOUSE+8)
{
if(!response) return ShowHouseMenu(playerid);
new id = InHouse[playerid], name[24];
if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(strcmp(HouseData[id][Owner], name)) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
new amount = strval(inputtext);
if(!(1 <= amount <= 10000000)) return ShowPlayerDialog(playerid, DIALOG_HOUSE+8, DIALOG_STYLE_INPUT, "Safe: Put Money", "Write the amount you want to put to safe:\n\n{E74C3C}Invalid amount. You can put between $1 - $10,000,000 at a time.", "Put", "Back");
if(amount > GetPlayerMoney(playerid)) return ShowPlayerDialog(playerid, DIALOG_HOUSE+8, DIALOG_STYLE_INPUT, "Safe: Put Money", "Write the amount you want to put to safe:\n\n{E74C3C}You don't have that much money on you.", "Put", "Back");
new query[128];
mysql_format(SQLHandle, query, sizeof(query), "INSERT INTO housesafelogs SET HouseID=%d, Type=1, Amount=%d, Date=UNIX_TIMESTAMP()", id, amount);
mysql_tquery(SQLHandle, query, "", "");
pInfo[playerid][Money] += -amount;
HouseData[id][SafeMoney] += amount;
HouseData[id][Save] = true;
ShowHouseMenu(playerid);
return 1;
}
if(dialogid == DIALOG_HOUSE+9)
{
if(!response) return ShowHouseMenu(playerid);
new id = InHouse[playerid], name[24];
if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(strcmp(HouseData[id][Owner], name)) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
if(listitem == 0)
{
if(GetPlayerWeapon(playerid) == 0) return SendClientMessage(playerid, 0xE74C3CFF, "You can't put your fists in your house.");
new query[128], weapon = GetPlayerWeapon(playerid), ammo = GetPlayerAmmo(playerid);
RemovePlayerWeapon(playerid, weapon);
mysql_format(SQLHandle, query, sizeof(query), "INSERT INTO houseguns VALUES (%d, %d, %d) ON DUPLICATE KEY UPDATE Ammo=Ammo+%d", id, weapon, ammo, ammo);
mysql_tquery(SQLHandle, query, "", "");
ShowHouseMenu(playerid);
}
if(listitem == 1)
{
new query[80], Cache: weapons;
mysql_format(SQLHandle, query, sizeof(query), "SELECT WeaponID, Ammo FROM houseguns WHERE HouseID=%d ORDER BY WeaponID ASC", id);
weapons = mysql_query(SQLHandle, query);
new rows = cache_num_rows();
if(rows) {
new list[512], weapname[32];
format(list, sizeof(list), "#\tWeapon Name\tAmmo\n");
for(new i; i < rows; ++i)
{
GetWeaponName(cache_get_field_content_int(i, "WeaponID"), weapname, sizeof(weapname));
format(list, sizeof(list), "%s%d\t%s\t%s\n", list, i+1, weapname, convertNumber(cache_get_field_content_int(i, "Ammo")));
}
ShowPlayerDialog(playerid, DIALOG_HOUSE+10, DIALOG_STYLE_TABLIST_HEADERS, "House Guns", list, "Take", "Back");
}else{
SendClientMessage(playerid, 0xE74C3CFF, "You don't have any guns in your house.");
}
cache_delete(weapons);
}
return 1;
}
if(dialogid == DIALOG_HOUSE+10)
{
if(!response) return ShowHouseMenu(playerid);
new id = InHouse[playerid], name[24];
if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(strcmp(HouseData[id][Owner], name)) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
new query[96], Cache: weapon;
mysql_format(SQLHandle, query, sizeof(query), "SELECT WeaponID, Ammo FROM houseguns WHERE HouseID=%d ORDER BY WeaponID ASC LIMIT %d, 1", id, listitem);
weapon = mysql_query(SQLHandle, query);
new rows = cache_num_rows();
if(rows) {
new string[64], weapname[32], weaponid = cache_get_field_content_int(0, "WeaponID");
GetWeaponName(weaponid, weapname, sizeof(weapname));
GivePlayerWeapon(playerid, weaponid, cache_get_field_content_int(0, "Ammo"));
format(string, sizeof(string), "You've taken a %s from your house.", weapname);
SendClientMessage(playerid, 0xFFFFFFFF, string);
mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM houseguns WHERE HouseID=%d AND WeaponID=%d", id, weaponid);
mysql_tquery(SQLHandle, query, "", "");
}else{
SendClientMessage(playerid, 0xE74C3CFF, "Can't find that weapon.");
}
cache_delete(weapon);
return 1;
}
if(dialogid == DIALOG_HOUSE+11)
{
if(!response) return ShowHouseMenu(playerid);
new id = InHouse[playerid], name[24];
if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(strcmp(HouseData[id][Owner], name)) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
if(listitem == 0)
{
new list[512];
format(list, sizeof(list), "#\tFurniture Name\tPrice\n");
for(new i; i < sizeof(HouseFurnitures); ++i)
{
format(list, sizeof(list), "%s%d\t%s\t$%s\n", list, i+1, HouseFurnitures[i][Name], convertNumber(HouseFurnitures[i][Price]));
}
ShowPlayerDialog(playerid, DIALOG_HOUSE+12, DIALOG_STYLE_TABLIST_HEADERS, "Buy Furniture", list, "Buy", "Back");
}
if(listitem == 1)
{
SelectMode[playerid] = SELECT_MODE_EDIT;
SelectObject(playerid);
SendClientMessage(playerid, 0xFFFFFFFF, "Click on the furniture you want to edit.");
}
if(listitem == 2)
{
SelectMode[playerid] = SELECT_MODE_SELL;
SelectObject(playerid);
SendClientMessage(playerid, 0xFFFFFFFF, "Click on the furniture you want to sell.");
}
if(listitem == 3)
{
new money, sold, data[e_furniture], query[64];
for(new i; i < Streamer_GetUpperBound(STREAMER_TYPE_OBJECT); ++i)
{
if(!IsValidDynamicObject(i)) continue;
Streamer_GetArrayData(STREAMER_TYPE_OBJECT, i, E_STREAMER_EXTRA_ID, data);
if(data[SQLID] > 0 && data[HouseID] == id)
{
sold++;
money += HouseFurnitures[ data[ArrayID] ][Price];
DestroyDynamicObject(i);
}
}
new string[64];
format(string, sizeof(string), "Sold %d furnitures for $%s.", sold, convertNumber(money));
SendClientMessage(playerid, -1, string);
pInfo[playerid][Money] += money;
mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housefurnitures WHERE HouseID=%d", id);
mysql_tquery(SQLHandle, query, "", "");
}
return 1;
}
if(dialogid == DIALOG_HOUSE+12)
{
if(!response) return ShowHouseMenu(playerid);
new id = InHouse[playerid], name[24];
if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(strcmp(HouseData[id][Owner], name)) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
if(HouseFurnitures[listitem][Price] > pInfo[playerid][Money]) return SendClientMessage(playerid, 0xE74C3CFF, "You can't afford this furniture.");
pInfo[playerid][Money] += -HouseFurnitures[listitem][Price];
new Float: x, Float: y, Float: z;
GetPlayerPos(playerid, x, y, z);
GetXYInFrontOfPlayer(playerid, x, y, 3.0);
new objectid = CreateDynamicObject(HouseFurnitures[listitem][ModelID], x, y, z, 0.0, 0.0, 0.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid)), query[256];
mysql_format(SQLHandle, query, sizeof(query), "INSERT INTO housefurnitures SET HouseID=%d, FurnitureID=%d, FurnitureX=%f, FurnitureY=%f, FurnitureZ=%f, FurnitureVW=%d, FurnitureInt=%d", id, listitem, x, y, z, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
new Cache: add = mysql_query(SQLHandle, query), data[e_furniture];
data[SQLID] = cache_insert_id();
data[HouseID] = id;
data[ArrayID] = listitem;
data[furnitureX] = x;
data[furnitureY] = y;
data[furnitureZ] = z;
data[furnitureRX] = 0.0;
data[furnitureRY] = 0.0;
data[furnitureRZ] = 0.0;
cache_delete(add);
Streamer_SetArrayData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_EXTRA_ID, data);
EditDynamicObject(playerid, objectid);
return 1;
}
if(dialogid == DIALOG_HOUSE+13)
{
if(!response) return 1;
new id = InHouse[playerid], name[24];
if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(strcmp(HouseData[id][Owner], name)) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
new objectid = GetPVarInt(playerid, "SelectedFurniture"), query[64], data[e_furniture];
Streamer_GetArrayData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_EXTRA_ID, data);
pInfo[playerid][Money] += HouseFurnitures[ data[ArrayID] ][Price];
mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housefurnitures WHERE ID=%d", data[SQLID]);
mysql_tquery(SQLHandle, query, "", "");
DestroyDynamicObject(objectid);
DeletePVar(playerid, "SelectedFurniture");
return 1;
}
if(dialogid == DIALOG_HOUSE+14)
{
if(!response) return ShowHouseMenu(playerid);
new id = InHouse[playerid], name[24];
if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(strcmp(HouseData[id][Owner], name)) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
if(listitem == 0)
{
new query[200], Cache: visitors;
mysql_format(SQLHandle, query, sizeof(query), "SELECT Visitor, FROM_UNIXTIME(Date, '%%d/%%m/%%Y %%H:%%i') as VisitDate FROM housevisitors WHERE HouseID=%d ORDER BY Date DESC LIMIT 0, 15", id);
visitors = mysql_query(SQLHandle, query);
new rows = cache_num_rows();
if(rows) {
new list[1024], visitor_name[MAX_PLAYER_NAME], visit_date[20];
format(list, sizeof(list), "Visitor Name\tDate\n");
for(new i; i < rows; ++i)
{
cache_get_field_content(i, "Visitor", visitor_name);
cache_get_field_content(i, "VisitDate", visit_date);
format(list, sizeof(list), "%s%s\t%s\n", list, visitor_name, visit_date);
}
ShowPlayerDialog(playerid, DIALOG_HOUSE+15, DIALOG_STYLE_TABLIST_HEADERS, "House Visitors (Page 1)", list, "Next", "Previous");
}else{
SendClientMessage(playerid, 0xE74C3CFF, "You didn't had any visitors.");
}
cache_delete(visitors);
}
if(listitem == 1)
{
new query[64];
mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housevisitors WHERE HouseID=%d", id);
mysql_tquery(SQLHandle, query, "", "");
ShowHouseMenu(playerid);
}
return 1;
}
if(dialogid == DIALOG_HOUSE+15)
{
if(!response) {
ListPage[playerid]--;
if(ListPage[playerid] < 0)
{
ListPage[playerid] = 0;
ShowHouseMenu(playerid);
return 1;
}
}else{
ListPage[playerid]++;
}
new id = InHouse[playerid], name[24];
if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(strcmp(HouseData[id][Owner], name)) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
new query[200], Cache: visitors;
mysql_format(SQLHandle, query, sizeof(query), "SELECT Visitor, FROM_UNIXTIME(Date, '%%d/%%m/%%Y %%H:%%i') as VisitDate FROM housevisitors WHERE HouseID=%d ORDER BY Date DESC LIMIT %d, 15", id, ListPage[playerid]*15);
visitors = mysql_query(SQLHandle, query);
new rows = cache_num_rows();
if(rows) {
new list[1024], visitor_name[MAX_PLAYER_NAME], visit_date[20];
format(list, sizeof(list), "Visitor Name\tDate\n");
for(new i; i < rows; ++i)
{
cache_get_field_content(i, "Visitor", visitor_name);
cache_get_field_content(i, "VisitDate", visit_date);
format(list, sizeof(list), "%s%s\t%s\n", list, visitor_name, visit_date);
}
new title[32];
format(title, sizeof(title), "House Visitors (Page %d)", ListPage[playerid]+1);
ShowPlayerDialog(playerid, DIALOG_HOUSE+15, DIALOG_STYLE_TABLIST_HEADERS, title, list, "Next", "Previous");
}else{
SendClientMessage(playerid, 0xE74C3CFF, "Can't find any more visitors.");
ListPage[playerid] = 0;
ShowHouseMenu(playerid);
}
cache_delete(visitors);
return 1;
}
if(dialogid == DIALOG_HOUSE+16)
{
if(!response) return ShowHouseMenu(playerid);
new id = InHouse[playerid], name[24];
if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(strcmp(HouseData[id][Owner], name)) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
if(listitem == 0)
{
new query[200], Cache: keyowners;
mysql_format(SQLHandle, query, sizeof(query), "SELECT Player, FROM_UNIXTIME(Date, '%%d/%%m/%%Y %%H:%%i') as KeyDate FROM housekeys WHERE HouseID=%d ORDER BY Date DESC LIMIT %d, 15", id, ListPage[playerid]*15);
keyowners = mysql_query(SQLHandle, query);
new rows = cache_num_rows();
if(rows) {
new list[1024], key_name[MAX_PLAYER_NAME], key_date[20];
format(list, sizeof(list), "Key Owner\tKey Given On\n");
for(new i; i < rows; ++i)
{
cache_get_field_content(i, "Player", key_name);
cache_get_field_content(i, "KeyDate", key_date);
format(list, sizeof(list), "%s%s\t%s\n", list, key_name, key_date);
}
ShowPlayerDialog(playerid, DIALOG_HOUSE+17, DIALOG_STYLE_TABLIST_HEADERS, "Key Owners (Page 1)", list, "Next", "Previous");
}else{
SendClientMessage(playerid, 0xE74C3CFF, "Can't find any key owners.");
}
cache_delete(keyowners);
}
if(listitem == 1)
{
foreach(new i : Player)
{
if(Iter_Contains(HouseKeys[i], id)) Iter_Remove(HouseKeys[i], id);
}
new query[64];
mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housekeys WHERE HouseID=%d", id);
mysql_tquery(SQLHandle, query, "", "");
ShowHouseMenu(playerid);
}
return 1;
}
if(dialogid == DIALOG_HOUSE+17)
{
if(!response) {
ListPage[playerid]--;
if(ListPage[playerid] < 0)
{
ListPage[playerid] = 0;
ShowHouseMenu(playerid);
return 1;
}
}else{
ListPage[playerid]++;
}
new id = InHouse[playerid], name[24];
if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(strcmp(HouseData[id][Owner], name)) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
new query[200], Cache: keyowners;
mysql_format(SQLHandle, query, sizeof(query), "SELECT Player, FROM_UNIXTIME(Date, '%%d/%%m/%%Y %%H:%%i') as KeyDate FROM housekeys WHERE HouseID=%d ORDER BY Date DESC LIMIT %d, 15", id, ListPage[playerid]*15);
keyowners = mysql_query(SQLHandle, query);
new rows = cache_num_rows();
if(rows) {
new list[1024], key_name[MAX_PLAYER_NAME], key_date[20];
format(list, sizeof(list), "Key Owner\tKey Given On\n");
for(new i; i < rows; ++i)
{
cache_get_field_content(i, "Player", key_name);
cache_get_field_content(i, "KeyDate", key_date);
format(list, sizeof(list), "%s%s\t%s\n", list, key_name, key_date);
}
new title[32];
format(title, sizeof(title), "Key Owners (Page %d)", ListPage[playerid]+1);
ShowPlayerDialog(playerid, DIALOG_HOUSE+17, DIALOG_STYLE_TABLIST_HEADERS, title, list, "Next", "Previous");
}else{
ListPage[playerid] = 0;
ShowHouseMenu(playerid);
SendClientMessage(playerid, 0xE74C3CFF, "Can't find any more key owners.");
}
cache_delete(keyowners);
return 1;
}
if(dialogid == DIALOG_HOUSE+18)
{
if(!response) {
ListPage[playerid]--;
if(ListPage[playerid] < 0)
{
ListPage[playerid] = 0;
ShowHouseMenu(playerid);
return 1;
}
}else{
ListPage[playerid]++;
}
new id = InHouse[playerid], name[24];
if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(strcmp(HouseData[id][Owner], name)) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
new query[200], Cache: safelog;
mysql_format(SQLHandle, query, sizeof(query), "SELECT Type, Amount, FROM_UNIXTIME(Date, '%%d/%%m/%%Y %%H:%%i') as TransactionDate FROM housesafelogs WHERE HouseID=%d ORDER BY Date DESC LIMIT %d, 15", id, ListPage[playerid]*15);
safelog = mysql_query(SQLHandle, query);
new rows = cache_num_rows();
if(rows) {
new list[1024], date[20];
format(list, sizeof(list), "Action\tDate\n");
for(new i; i < rows; ++i)
{
cache_get_field_content(i, "TransactionDate", date);
format(list, sizeof(list), "%s%s $%s\t{FFFFFF}%s\n", list, TransactionNames[ cache_get_field_content_int(i, "Type") ], convertNumber(cache_get_field_content_int(i, "Amount")), date);
}
new title[32];
format(title, sizeof(title), "Safe History (Page %d)", ListPage[playerid]+1);
ShowPlayerDialog(playerid, DIALOG_HOUSE+18, DIALOG_STYLE_TABLIST_HEADERS, title, list, "Next", "Previous");
}else{
SendClientMessage(playerid, 0xE74C3CFF, "Can't find any more safe history.");
}
cache_delete(safelog);
return 1;
}
if(dialogid == DIALOG_HOUSE+19)
{
if(!response) {
ListPage[playerid]--;
if(ListPage[playerid] < 0)
{
ListPage[playerid] = 0;
return 1;
}
}else{
ListPage[playerid]++;
}
new query[200], name[MAX_PLAYER_NAME], Cache: mykeys;
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
mysql_format(SQLHandle, query, sizeof(query), "SELECT HouseID, FROM_UNIXTIME(Date, '%%d/%%m/%%Y %%H:%%i') as KeyDate FROM housekeys WHERE Player='%e' ORDER BY Date DESC LIMIT %d, 15", name, ListPage[playerid]*15);
mykeys = mysql_query(SQLHandle, query);
new rows = cache_num_rows();
if(rows) {
new list[1024], id, key_date[20];
format(list, sizeof(list), "House Info\tKey Given On\n");
for(new i; i < rows; ++i)
{
id = cache_get_field_content_int(i, "HouseID");
cache_get_field_content(i, "KeyDate", key_date);
format(list, sizeof(list), "%s%s's %s\t%s\n", list, HouseData[id][Owner], HouseData[id][Name], key_date);
}
new title[32];
format(title, sizeof(title), "My Keys (Page %d)", ListPage[playerid]+1);
ShowPlayerDialog(playerid, DIALOG_HOUSE+19, DIALOG_STYLE_TABLIST_HEADERS, title, list, "Next", "Previous");
}else{
ListPage[playerid] = 0;
SendClientMessage(playerid, 0xE74C3CFF, "Can't find any more keys.");
}
cache_delete(mykeys);
return 1;
}