Dialog:ManageHouseInt(playerid, response, listitem, inputtext[])
{
if(response) {
new id = GetPVarInt(playerid, "BUYHOUSEID");
switch(listitem)
{
case 0:
{
SetPlayerPosEx(playerid, HouseData[id][housePos][0], HouseData[id][housePos][1], HouseData[id][housePos][2]);
SetPlayerFacingAngle(playerid, HouseData[id][housePos][3] - 180.0);
SetPlayerInterior(playerid, HouseData[id][houseExterior]);
SetPlayerVirtualWorld(playerid, HouseData[id][houseExteriorVW]);
SetCameraBehindPlayer(playerid);
PlayerInfo[playerid][pHouse] = -1;
}
case 1:
{
new canlock;
if (!IsPlayerInAnyVehicle(playerid) && (id = (House_Inside(playerid) == -1) ? (House_Nearest(playerid)) : (House_Inside(playerid))) != -1 && House_IsOwner(playerid, id))
{
if (!HouseData[id][houseLocked])
{
HouseData[id][houseLocked] = true;
House_Refresh(id);
House_Save(id);
//ShowPlayerFooter(playerid, "You have ~r~locked~w~ your house!");
PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
SendClientMessage(playerid, -1, "คุณได้ล็อคบ้านแล้ว");
canlock = 1;
}
else
{
HouseData[id][houseLocked] = false;
House_Refresh(id);
House_Save(id);
//ShowPlayerFooter(playerid, "You have ~g~unlocked~w~ your house!");
PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
SendClientMessage(playerid, -1, "คุณได้ปลดล็อคบ้านแล้ว");
canlock = 1;
}
}
if (!canlock) SendClientMessage(playerid, -1, "คุณไม่ได้อยู่ในขอบเขตของอะไรก็ตามที่ล็อคได้");
}
}
}
return 1;
}
Dialog:ManageHouseIntNot(playerid, response, listitem, inputtext[])
{
if(response) {
new id = GetPVarInt(playerid, "BUYHOUSEID");
switch(listitem)
{
case 0:
{
SetPlayerPosEx(playerid, HouseData[id][housePos][0], HouseData[id][housePos][1], HouseData[id][housePos][2]);
SetPlayerFacingAngle(playerid, HouseData[id][housePos][3] - 180.0);
SetPlayerInterior(playerid, HouseData[id][houseExterior]);
SetPlayerVirtualWorld(playerid, HouseData[id][houseExteriorVW]);
SetCameraBehindPlayer(playerid);
PlayerInfo[playerid][pHouse] = -1;
}
}
}
return 1;
}
Dialog:BuyLevelHouse(playerid, response, listitem, inputtext[])
{
if(!response)
return 1;
new id = GetPVarInt(playerid, "FurnitureHouse");
if(response)
{
if(listitem == 0)
{
if(ScriptMoney[playerid] < 250000)
return SendClientMessage(playerid, COLOR_RED, "คุณมีเงินไม่พอ");
if(HouseData[id][houseLevel] == 2)
return SendClientMessage(playerid, COLOR_RED, "บ้านของคุณมีเลเวล 2 อยู่แล้ว");
if(HouseData[id][houseLevel] > 2)
return SendClientMessage(playerid, COLOR_RED, "บ้านคุณมีเลเวลมากกว่า 2 แล้ว");
if(HouseData[id][houseLevel] == 1)
{
SafeGivePlayerMoney(playerid, -250000);
PlayerInfo[playerid][pCash] -= 250000;
HouseData[id][houseLevel] = 2;
House_Save(id);
SendClientMessage(playerid, COLOR_GREEN, "คุณได้อัพเลเวลบ้านเป็น 2 แล้ว");
}
}
if(listitem == 1)
{
if(ScriptMoney[playerid] < 500000)
return SendClientMessage(playerid, COLOR_RED, "คุณมีเงินไม่พอ");
if(HouseData[id][houseLevel] == 3)
return SendClientMessage(playerid, COLOR_RED, "บ้านของคุณมีเลเวล 3 อยู่แล้ว");
if(HouseData[id][houseLevel] > 3)
return SendClientMessage(playerid, COLOR_RED, "บ้านคุณมีเลเวลมากกว่า 3 แล้ว");
if(HouseData[id][houseLevel] == 2)
{
SafeGivePlayerMoney(playerid, -500000);
PlayerInfo[playerid][pCash] -= 500000;
HouseData[id][houseLevel] = 3;
House_Save(id);
SendClientMessage(playerid, COLOR_GREEN, "คุณได้อัพเลเวลบ้านเป็น 3 แล้ว");
}
else
return SendClientMessage(playerid, COLOR_RED, "คุณจำเป็นต้องอัพบ้านเป็นเวล 2 ก่อน");
}
if(listitem == 2)
{
if(ScriptMoney[playerid] < 750000)
return SendClientMessage(playerid, COLOR_RED, "คุณมีเงินไม่พอ");
if(HouseData[id][houseLevel] == 4)
return SendClientMessage(playerid, COLOR_RED, "บ้านของคุณมีเลเวล 4 อยู่แล้ว");
if(HouseData[id][houseLevel] > 4)
return SendClientMessage(playerid, COLOR_RED, "บ้านคุณมีเลเวลมากกว่า 4 แล้ว");
if(HouseData[id][houseLevel] == 3)
{
SafeGivePlayerMoney(playerid, -750000);
PlayerInfo[playerid][pCash] -= 750000;
HouseData[id][houseLevel] = 4;
House_Save(id);
SendClientMessage(playerid, COLOR_GREEN, "คุณได้อัพเลเวลบ้านเป็น 4 แล้ว");
}
else
return SendClientMessage(playerid, COLOR_RED, "คุณจำเป็นต้องอัพบ้านเป็นเวล 3 ก่อน");
}
if(listitem == 3)
{
if(ScriptMoney[playerid] < 1000000)
return SendClientMessage(playerid, COLOR_RED, "คุณมีเงินไม่พอ");
if(HouseData[id][houseLevel] == 5)
return SendClientMessage(playerid, COLOR_RED, "บ้านของคุณมีเลเวล 5 อยู่แล้ว");
if(HouseData[id][houseLevel] > 5)
return SendClientMessage(playerid, COLOR_RED, "บ้านคุณมีเลเวลมากกว่า 5 แล้ว");
if(HouseData[id][houseLevel] == 4)
{
SafeGivePlayerMoney(playerid, -1000000);
PlayerInfo[playerid][pCash] -= 1000000;
HouseData[id][houseLevel] = 5;
House_Save(id);
SendClientMessage(playerid, COLOR_GREEN, "คุณได้อัพเลเวลบ้านเป็น 5 แล้ว");
}
else
return SendClientMessage(playerid, COLOR_RED, "คุณจำเป็นต้องอัพบ้านเป็นเวล 4 ก่อน");
}
}
return 1;
}
Dialog:ManageFurniture(playerid, response, listitem, inputtext[])
{
if(response) {
new id = GetPVarInt(playerid, "FurnitureHouse");
switch(listitem)
{
case 0:
{
if ((id = House_Inside(playerid)) != -1 && House_IsOwner(playerid, id)) {
House_OpenStorage(playerid, id);
}
else SendClientMessage(playerid, -1,"คุณไม่ได้อยู่ในขอบเขตภายในบ้านของคุณ");
}
case 1:
{
Dialog_Show(playerid, BuyLevelHouse, DIALOG_STYLE_LIST, "อัพลเวลบ้าน", "เวล 2 [250k]\nเวล 3 [500k]\nเวล 4 [750k]\nเวล 5 [1M]", "อัพเลเวล","ยกเลิก");
}
/*case 1:
{
Dialog_Show(playerid, ChangeSpawnHouse, DIALOG_STYLE_LIST, "เปลี่ยนจุดเกิด", "เกิดบ้าน\nเกิดเริ่มต้น", "ตกลง", "ยกเลิก");
}*/
}
}
return 1;
}
Dialog:ChangeSpawnHouse(playerid, response, listitem, inputtext[])
{
if(response) {
new id = GetPVarInt(playerid, "BUYHOUSEID");
switch(listitem)
{
case 0:
{
PlayerInfo[playerid][pHouseSpawn] = 1;
PlayerInfo[playerid][pFixHouseID] = id;
OnAccountUpdate(playerid);
SendClientMessage(playerid, -1, "คุณได้เปลี่ยนจุดเกิดมาเกิดที่ 'บ้าน' เรียบร้อยแล้ว!");
}
case 1:
{
PlayerInfo[playerid][pHouseSpawn] = 0;
PlayerInfo[playerid][pFixHouseID] = -1;
OnAccountUpdate(playerid);
SendClientMessage(playerid, -1, "คุณได้เปลี่ยนจุดเกิดมาเกิดที่ 'จุดเริ่มต้น' เรียบร้อยแล้ว!");
}
}
}
return 1;
}
stock House_OpenStorage(playerid, houseid)
{
if (houseid == -1 || !HouseData[houseid][houseExists])
return 0;
new
string[128];
if (House_IsOwner(playerid, houseid))
{
format(string, sizeof(string), "เงินในคลัง (%s)\nเงินแดงในคลัง (%s)\nเหล็ก [%d]", FormatNumber(HouseData[houseid][houseMoney]), FormatNumber(HouseData[houseid][houseRedMoney]), HouseData[houseid][houseIron]);
Dialog_Show(playerid, HouseStorage, DIALOG_STYLE_LIST, "ช่องเก็บของภายในบ้าน", string, "เลือก", "ยกเลิก");
}
return 1;
}
Dialog:HouseStorage(playerid, response, listitem, inputtext[])
{
new
houseid = -1;
if ((houseid = House_Inside(playerid)) != -1 && House_IsOwner(playerid, houseid))
{
if (response)
{
if (listitem == 0) {
Dialog_Show(playerid, HouseMoney, DIALOG_STYLE_LIST, "เงินในคลัง", "ถอนเงินจากตู้เซฟ\nฝากเงินใส่ตู้เซฟ", "เลือก", "ย้อนกลับ");
}
if (listitem == 1) {
Dialog_Show(playerid, HouseRedMoney, DIALOG_STYLE_LIST, "เงินแดงในคลัง", "ถอนเงินแดงจากตู้เซฟ\nฝากเงินแดงใส่ตู้เซฟ", "เลือก", "ย้อนกลับ");
}
if (listitem == 2) {
Dialog_Show(playerid, HouseIron, DIALOG_STYLE_LIST, "เหล็กในคลัง", "ถอนเหล็กจากคลัง\nฝากเหล็กเข้าคลัง", "เลือก", "ย้อนกลับ");
}
}
}
return 1;
}
Dialog:HouseMoney(playerid, response, listitem, inputtext[])
{
new
houseid = -1;
if ((houseid = House_Inside(playerid)) != -1 && House_IsOwner(playerid, houseid))
{
if (response)
{
switch (listitem)
{
case 0: {
Dialog_Show(playerid, HouseWithdrawCash, DIALOG_STYLE_INPUT, "การถอนเงินจากคลัง", "ยอดเงินคงเหลือในตู้: %s\n\nโปรดป้อนจำนวนเงินที่คุณต้องการถอนจากตู้เซฟ:", "ถอน", "ย้อนกลับ", FormatNumber(HouseData[houseid][houseMoney]));
}
case 1: {
Dialog_Show(playerid, HouseDepositCash, DIALOG_STYLE_INPUT, "การฝากเงินเข้าคลัง", "ยอดเงินคงเหลือในตู้: %s\n\nโปรดป้อนจำนวนเงินที่คุณต้องการฝากเข้าตู้เซฟ:", "ฝาก", "ย้อนกลับ", FormatNumber(HouseData[houseid][houseMoney]));
}
}
}
else House_OpenStorage(playerid, houseid);
}
return 1;
}
Dialog:HouseRedMoney(playerid, response, listitem, inputtext[])
{
new
houseid = -1;
if ((houseid = House_Inside(playerid)) != -1 && House_IsOwner(playerid, houseid))
{
if (response)
{
switch (listitem)
{
case 0: {
Dialog_Show(playerid, HouseRedWithdrawCash, DIALOG_STYLE_INPUT, "การถอนเงินแดงจากคลัง", "ยอดเงินแดงคงเหลือในตู้: %s\n\nโปรดป้อนจำนวนเงินแดงที่คุณต้องการถอนจากตู้เซฟ:", "ถอน", "ย้อนกลับ", FormatNumber(HouseData[houseid][houseRedMoney]));
}
case 1: {
Dialog_Show(playerid, HouseRedDepositCash, DIALOG_STYLE_INPUT, "การฝากเงินแดงเข้าคลัง", "ยอดเงินแดงคงเหลือในตู้: %s\n\nโปรดป้อนจำนวนเงินแดงที่คุณต้องการฝากเข้าตู้เซฟ:", "ฝาก", "ย้อนกลับ", FormatNumber(HouseData[houseid][houseRedMoney]));
}
}
}
else House_OpenStorage(playerid, houseid);
}
return 1;
}
Dialog:HouseIron(playerid, response, listitem, inputtext[])
{
new
houseid = -1;
if ((houseid = House_Inside(playerid)) != -1 && House_IsOwner(playerid, houseid))
{
if (response)
{
switch (listitem)
{
case 0: {
Dialog_Show(playerid, HouseIronWithdraw, DIALOG_STYLE_INPUT, "ถอนเหล็กออกจากคลัง", "เหล็กในคลัง: %d\n\nโปรดป้อนจำนวนเหล็กที่คุณต้องการถอนจากตู้เซฟ:", "ถอน", "ย้อนกลับ", HouseData[houseid][houseIron]);
}
case 1: {
Dialog_Show(playerid, HouseIronDeposit, DIALOG_STYLE_INPUT, "ฝากเหล็กเข้าคลัง", "เหล็กในคลัง: %d\n\nโปรดป้อนจำนวนเหล็กที่คุณต้องการฝากเข้าตู้เซฟ:", "ฝาก", "ย้อนกลับ", HouseData[houseid][houseIron]);
}
}
}
else House_OpenStorage(playerid, houseid);
}
return 1;
}
Dialog:HouseIronDeposit(playerid, response, listitem, inputtext[])
{
new
houseid = -1;
new string[128];
if ((houseid = House_Inside(playerid)) != -1 && House_IsOwner(playerid, houseid))
{
if (response)
{
new amount = strval(inputtext);
if (isnull(inputtext))
return Dialog_Show(playerid, HouseIronDeposit, DIALOG_STYLE_INPUT, "ฝากเหล็กเข้าคลัง", "เหล็กในคลัง: %d\n\nโปรดป้อนจำนวนเหล็กที่คุณต้องการฝากใส่ตู้เซฟ:", "ฝาก", "ย้อนกลับ", HouseData[houseid][houseIron]);
if (amount < 1 || amount > PlayerInfo[playerid][pIron])
return Dialog_Show(playerid, HouseIronDeposit, DIALOG_STYLE_INPUT, "ฝากเหล็กเข้าคลัง", "ข้อผิดพลาด: คุณมีเหล็กไม่พอ\n\nเหล็กในคลัง: %d\n\nโปรดป้อนจำนวนเหล็กที่คุณต้องการฝากเข้าตู้เซฟ:", "ฝาก", "ย้อนกลับ", HouseData[houseid][houseIron]);
//houselevel
if(HouseData[houseid][houseLevel] == 1)
{
if(amount > 100)
return SendClientMessage(playerid, COLOR_RED, "[!] บ้านเลเวล 1 สามารถฝากเหล็กด้แค่ 100 เท่านั้น");
}
if(HouseData[houseid][houseLevel] == 2)
{
if(amount > 200)
return SendClientMessage(playerid, COLOR_RED, "[!] บ้านเลเวล 2 สามารถฝากเหล็กด้แค่ 200 เท่านั้น");
}
if(HouseData[houseid][houseLevel] == 3)
{
if(amount > 300)
return SendClientMessage(playerid, COLOR_RED, "[!] บ้านเลเวล 3 สามารถฝากเหล็กด้แค่ 300 เท่านั้น");
}
if(HouseData[houseid][houseLevel] == 4)
{
if(amount > 400)
return SendClientMessage(playerid, COLOR_RED, "[!] บ้านเลเวล 4 สามารถฝากเหล็กด้แค่ 400 เท่านั้น");
}
if(HouseData[houseid][houseLevel] == 5)
{
if(amount > 500)
return SendClientMessage(playerid, COLOR_RED, "[!] บ้านเลเวล 5 สามารถฝากเหล็กด้แค่ 500 เท่านั้น");
}
HouseData[houseid][houseIron] += amount;
PlayerInfo[playerid][pIron] -= amount;
House_Save(houseid);
House_OpenStorage(playerid, houseid);
format(string, sizeof(string) , "** คุณได้ฝากเหล็ก %s ใส่ตู้เก็บของในบ้าน", FormatNumber(amount));
SendClientMessage(playerid, -1, string);
OnAccountUpdate(playerid);
//SendClientMessage(playerid, -1, "** คุณได้ฝากเงิน %s ใส่ตู้เก็บของในบ้าน", FormatNumber(amount));
}
else Dialog_Show(playerid, HouseIron, DIALOG_STYLE_LIST, "เหล็กในคลัง", "ถอนเหล็กจากคลัง\nฝากเหล็กเข้าคลัง", "เลือก", "ย้อนกลับ");
}
return 1;
}
Dialog:HouseIronWithdraw(playerid, response, listitem, inputtext[])
{
new
houseid = -1;
if ((houseid = House_Inside(playerid)) != -1 && House_IsOwner(playerid, houseid))
{
if (response)
{
new amount = strval(inputtext);
new string[128];
if (isnull(inputtext))
return Dialog_Show(playerid, HouseIronWithdraw, DIALOG_STYLE_INPUT, "ถอนเหล็กออกจากคลัง", "เหล็กในคลัง: %d\n\nโปรดป้อนจำนวนเหล็กที่คุณต้องการถอนจากตู้เซฟ:", "ถอน", "ย้อนกลับ", HouseData[houseid][houseIron]);
if (amount < 1 || amount > HouseData[houseid][houseIron])
return Dialog_Show(playerid, HouseIronWithdraw, DIALOG_STYLE_INPUT, "ถอนเหล็กออกจากคลัง", "ข้อผิดพลาด: ในบ้านคุณมีเหล็กไม่พอ\n\nเหล็กในคลัง: %d\n\nโปรดป้อนจำนวนเหล็กที่คุณต้องการถอนจากตู้เซฟ:", "ถอน", "ย้อนกลับ", HouseData[houseid][houseIron]);
HouseData[houseid][houseIron] -= amount;
PlayerInfo[playerid][pIron] += amount;
House_Save(houseid);
House_OpenStorage(playerid, houseid);
format(string, sizeof(string) , "** คุณได้ถอนเหล็ก %s จากตู้เซฟในบ้าน", FormatNumber(amount));
SendClientMessage(playerid, -1, string);
OnAccountUpdate(playerid);
}
else Dialog_Show(playerid, HouseIron, DIALOG_STYLE_LIST, "เหล็กในคลัง", "ถอนเหล็กจากคลัง\nฝากเหล็กเข้าคลัง", "เลือก", "ย้อนกลับ");
}
return 1;
}
Dialog:HouseWithdrawCash(playerid, response, listitem, inputtext[])
{
new
houseid = -1;
if ((houseid = House_Inside(playerid)) != -1 && House_IsOwner(playerid, houseid))
{
if (response)
{
new amount = strval(inputtext);
new string[128];
if (isnull(inputtext))
return Dialog_Show(playerid, HouseWithdrawCash, DIALOG_STYLE_INPUT, "การถอนเงินจากคลัง", "ยอดเงินคงเหลือในตู้เซฟ: %d\n\nโปรดป้อนจำนวนเงินที่คุณต้องการถอนจากตู้เซฟ:", "ถอน", "ย้อนกลับ", FormatNumber(HouseData[houseid][houseMoney]));
if (amount < 1 || amount > HouseData[houseid][houseMoney])
return Dialog_Show(playerid, HouseWithdrawCash, DIALOG_STYLE_INPUT, "การถอนเงินจากคลัง", "ข้อผิดพลาด: คุณมีเงินไม่พอ\n\nยอดเงินคงเหลือในตู้เซฟ: %d\n\nโปรดป้อนจำนวนเงินที่คุณต้องการถอนจากตู้เซฟ:", "ถอน", "ย้อนกลับ", FormatNumber(HouseData[houseid][houseMoney]));
HouseData[houseid][houseMoney] -= amount;
SafeGivePlayerMoney(playerid, amount);
PlayerInfo[playerid][pCash] += amount;
House_Save(houseid);
House_OpenStorage(playerid, houseid);
format(string, sizeof(string) , "** คุณได้ถอนเงิน %s จากตู้เซฟในบ้าน", FormatNumber(amount));
SendClientMessage(playerid, -1, string);
OnAccountUpdate(playerid);
}
else Dialog_Show(playerid, HouseMoney, DIALOG_STYLE_LIST, "เงินในคลัง", "ถอนเงินจากตู้เซฟ\nฝากเงินใส่ตู้เซฟ", "เลือก", "ย้อนกลับ");
}
return 1;
}
Dialog:HouseRedWithdrawCash(playerid, response, listitem, inputtext[])
{
new
houseid = -1;
new string[128];
if ((houseid = House_Inside(playerid)) != -1 && House_IsOwner(playerid, houseid))
{
if (response)
{
new amount = strval(inputtext);
if (isnull(inputtext))
return Dialog_Show(playerid, HouseReWithdrawCash, DIALOG_STYLE_INPUT, "การถอนเงินแดงจากคลัง", "ยอดเงินแดงคงเหลือในตู้เซฟ: %s\n\nโปรดป้อนจำนวนเงินแดงที่คุณต้องการถอนจากตู้เซฟ:", "ถอน", "ย้อนกลับ", FormatNumber(HouseData[houseid][houseRedMoney]));
if (amount < 1 || amount > HouseData[houseid][houseRedMoney])
return Dialog_Show(playerid, HouseRedWithdrawCash, DIALOG_STYLE_INPUT, "การถอนเงินแดงจากคลัง", "ข้อผิดพลาด: คุณมีเงินแดงไม่พอ\n\nยอดเงินแดงคงเหลือในตู้เซฟ: %s\n\nโปรดป้อนจำนวนเงินแดงที่คุณต้องการถอนจากตู้เซฟ:", "ถอน", "ย้อนกลับ", FormatNumber(HouseData[houseid][houseRedMoney]));
HouseData[houseid][houseRedMoney] -= amount;
PlayerInfo[playerid][pRMoney] += amount;
House_Save(houseid);
House_OpenStorage(playerid, houseid);
format(string, sizeof(string) , "** คุณได้ถอนเงินแดง %s จากตู้เซฟในบ้าน", FormatNumber(amount));
SendClientMessage(playerid, -1, string);
//SendClientMessage(playerid, -1, "** คุณได้ถอนเงินแดง %s จากตู้เซฟในบ้าน", FormatNumber(amount));
OnAccountUpdate(playerid);
}
else Dialog_Show(playerid, HouseRedMoney, DIALOG_STYLE_LIST, "เงินแดงในคลัง", "ถอนเงินแดงจากตู้เซฟ\nฝากเงินแดงใส่ตู้เซฟ", "เลือก", "ย้อนกลับ");
}
return 1;
}
Dialog:HouseDepositCash(playerid, response, listitem, inputtext[])
{
new
houseid = -1;
new string[128];
if ((houseid = House_Inside(playerid)) != -1 && House_IsOwner(playerid, houseid))
{
if (response)
{
new amount = strval(inputtext);
if (isnull(inputtext))
return Dialog_Show(playerid, HouseDepositCash, DIALOG_STYLE_INPUT, "การฝากเงินเข้าคลัง", "ยอดเงินคงเหลือในตู้: %s\n\nโปรดป้อนจำนวนเงินที่คุณต้องการฝากใส่ตู้เซฟ:", "ฝาก", "ย้อนกลับ", FormatNumber(HouseData[houseid][houseMoney]));
if (amount < 1 || amount > ScriptMoney[playerid])
return Dialog_Show(playerid, HouseDepositCash, DIALOG_STYLE_INPUT, "การฝากเงินเข้าคลัง", "ข้อผิดพลาด: คุณมีเงินไม่พอ\n\nยอดเงินคงเหลือในตู้เซฟ: %s\n\nโปรดป้อนจำนวนเงินที่คุณต้องการฝากเข้าตู้เซฟ:", "ฝาก", "ย้อนกลับ", FormatNumber(HouseData[houseid][houseMoney]));
//houselevel
if(HouseData[houseid][houseLevel] == 1)
{
if(amount > 1000000)
return SendClientMessage(playerid, COLOR_RED, "[!] บ้านเลเวล 1 สามารถฝากเงินเขียวได้แค่ 1M เท่านั้น");
}
if(HouseData[houseid][houseLevel] == 2)
{
if(amount > 2000000)
return SendClientMessage(playerid, COLOR_RED, "[!] บ้านเลเวล 2 สามารถฝากเงินเขียวได้แค่ 2M เท่านั้น");
}
if(HouseData[houseid][houseLevel] == 3)
{
if(amount > 3000000)
return SendClientMessage(playerid, COLOR_RED, "[!] บ้านเลเวล 3 สามารถฝากเงินเขียวได้แค่ 3M เท่านั้น");
}
if(HouseData[houseid][houseLevel] == 4)
{
if(amount > 4000000)
return SendClientMessage(playerid, COLOR_RED, "[!] บ้านเลเวล 4 สามารถฝากเงินเขียวได้แค่ 4M เท่านั้น");
}
if(HouseData[houseid][houseLevel] == 5)
{
if(amount > 5000000)
return SendClientMessage(playerid, COLOR_RED, "[!] บ้านเลเวล 5 สามารถฝากเงินเขียวได้แค่ 5M เท่านั้น");
}
HouseData[houseid][houseMoney] += amount;
SafeGivePlayerMoney(playerid, -amount);
PlayerInfo[playerid][pCash] -= amount;
House_Save(houseid);
House_OpenStorage(playerid, houseid);
format(string, sizeof(string) , "** คุณได้ฝากเงิน %s ใส่ตู้เก็บของในบ้าน", FormatNumber(amount));
SendClientMessage(playerid, -1, string);
OnAccountUpdate(playerid);
//SendClientMessage(playerid, -1, "** คุณได้ฝากเงิน %s ใส่ตู้เก็บของในบ้าน", FormatNumber(amount));
}
else Dialog_Show(playerid, HouseMoney, DIALOG_STYLE_LIST, "เงินในคลัง", "ถอนเงินแดงจากตู้เซฟ\nฝากเงินแดงใส่ตู้เซฟ", "เลือก", "ย้อนกลับ");
}
return 1;
}
Dialog:HouseRedDepositCash(playerid, response, listitem, inputtext[])
{
new
houseid = -1;
new string[128];
if ((houseid = House_Inside(playerid)) != -1 && House_IsOwner(playerid, houseid))
{
if (response)
{
new amount = strval(inputtext);
if (isnull(inputtext))
return Dialog_Show(playerid, HouseRedDepositCash, DIALOG_STYLE_INPUT, "การฝากเงินแดงเข้าคลัง", "ยอดเงินแดงคงเหลือในตู้: %s\n\nโปรดป้อนจำนวนเงินแดงที่คุณต้องการฝากใส่ตู้เซฟ:", "ฝาก", "ย้อนกลับ", FormatNumber(HouseData[houseid][houseRedMoney]));
if (amount < 1 || amount > PlayerInfo[playerid][pRMoney])
return Dialog_Show(playerid, HouseRedDepositCash, DIALOG_STYLE_INPUT, "การฝากเงินแดงเข้าคลัง", "ข้อผิดพลาด: คุณมีเงินแดงไม่พอ\n\nยอดเงินแดงคงเหลือในตู้เซฟ: %s\n\nโปรดป้อนจำนวนเงินแดงที่คุณต้องการฝากเข้าตู้เซฟ:", "ฝาก", "ย้อนกลับ", FormatNumber(HouseData[houseid][houseRedMoney]));
//houselevel
if(HouseData[houseid][houseLevel] == 1)
{
if(amount > 1000000)
return SendClientMessage(playerid, COLOR_RED, "[!] บ้านเลเวล 1 สามารถฝากเงินแดงได้แค่ 1M เท่านั้น");
}
if(HouseData[houseid][houseLevel] == 2)
{
if(amount > 2000000)
return SendClientMessage(playerid, COLOR_RED, "[!] บ้านเลเวล 2 สามารถฝากเงินแดงได้แค่ 2M เท่านั้น");
}
if(HouseData[houseid][houseLevel] == 3)
{
if(amount > 3000000)
return SendClientMessage(playerid, COLOR_RED, "[!] บ้านเลเวล 3 สามารถฝากเงินแดงได้แค่ 3M เท่านั้น");
}
if(HouseData[houseid][houseLevel] == 4)
{
if(amount > 4000000)
return SendClientMessage(playerid, COLOR_RED, "[!] บ้านเลเวล 4 สามารถฝากเงินแดงได้แค่ 4M เท่านั้น");
}
if(HouseData[houseid][houseLevel] == 5)
{
if(amount > 5000000)
return SendClientMessage(playerid, COLOR_RED, "[!] บ้านเลเวล 5 สามารถฝากเงินแดงได้แค่ 5M เท่านั้น");
}
HouseData[houseid][houseRedMoney] += amount;
PlayerInfo[playerid][pRMoney] -= amount;
House_Save(houseid);
House_OpenStorage(playerid, houseid);
format(string, sizeof(string) , "** คุณได้ฝากเงินแดง %s ใส่ตู้เก็บของในบ้าน", FormatNumber(amount));
SendClientMessage(playerid, -1, string);
// SendClientMessage(playerid, -1, "** คุณได้ฝากเงินแดง %s ใส่ตู้เก็บของในบ้าน", FormatNumber(amount));
OnAccountUpdate(playerid);
}
else Dialog_Show(playerid, HouseRedMoney, DIALOG_STYLE_LIST, "เงินแดงในคลัง", "ถอนเงินจากตู้เซฟ\nฝากเงินใส่ตู้เซฟ", "เลือก", "ย้อนกลับ");
}
return 1;
}
Dialog:BuyHouse(playerid, response, listitem, inputtext[])
{
if(response) {
new id = GetPVarInt(playerid, "BUYHOUSEID");
new string[128];
if(ScriptMoney[playerid] < HouseData[id][housePrice])
{
SendClientMessage(playerid, COLOR_GREY, " คุณมีเงินไม่พอ !");
return 1;
}
PlayerInfo[playerid][pFixHouseID] = id;
DestroyDynamicMapIcon(HouseData[id][houseMapIcon]);
HouseData[id][houseMapIcon] = CreateDynamicMapIcon(HouseData[id][housePos][0], HouseData[id][housePos][1], HouseData[id][housePos][2], 32, 0);
format(string, sizeof(string), "ระบบบ้าน : คุณได้ซื้อบ้าน %s เรียบร้อยแล้ว", HouseData[id][houseAddress]);
SendClientMessage(playerid, COLOR_GRAD1, string);
format(string, sizeof(string), "ระบบบ้าน : การซื้อขาย สำเร็จ");
SendClientMessage(playerid, COLOR_GRAD1, string);
format(string, sizeof(string), "ระบบบ้าน : ใช้คำสั่งเพื่อจัดการบ้านของคุณ /myhouse");
SendClientMessage(playerid, COLOR_GRAD1, string);
/*SendClientMessage(playerid, COLOR_WHITE, " ระบบบ้าน :คุณได้ซื้อบ้าน"EMBED_GREEN" %s เรียบร้อยแล้ว", HouseData[id][houseAddress]);
SendClientMessage(playerid, COLOR_WHITE, " ระบบบ้าน :การซื้อขาย"EMBED_GREEN" สำเร็จ");
SendClientMessage(playerid, COLOR_WHITE, " ระบบบ้าน :ใช้คำสั่งเพื่อจัดการบ้านของคุณ"EMBED_GREEN" /จัดการของ");
*/
SafeGivePlayerMoney(playerid, -HouseData[id][housePrice]);
HouseData[id][houseOwner] = GetPlayerSQLID(playerid);
House_Refresh(id);
House_Save(id);
}
return 1;
}
Dialog:ManageHouse(playerid, response, listitem, inputtext[])
{
if(response) {
new id = GetPVarInt(playerid, "BUYHOUSEID");
new string[128];
switch(listitem)
{
case 0:
{
if (HouseData[id][houseLocked])
return SendClientMessage(playerid, -1, "คุณไม่สามารถเข้าบ้านที่ล็อคได้");
SetPlayerPosEx(playerid, HouseData[id][houseInt][0], HouseData[id][houseInt][1], HouseData[id][houseInt][2]);
SetPlayerFacingAngle(playerid, HouseData[id][houseInt][3]);
SetPlayerInterior(playerid, HouseData[id][houseInterior]);
SetPlayerVirtualWorld(playerid, HouseData[id][houseID] + 5000);
SetCameraBehindPlayer(playerid);
PlayerInfo[playerid][pHouse] = HouseData[id][houseID];
}
case 1:
{
new canlock;
if (!IsPlayerInAnyVehicle(playerid) && (id = (House_Inside(playerid) == -1) ? (House_Nearest(playerid)) : (House_Inside(playerid))) != -1 && House_IsOwner(playerid, id))
{
if (!HouseData[id][houseLocked])
{
HouseData[id][houseLocked] = true;
House_Refresh(id);
House_Save(id);
//ShowPlayerFooter(playerid, "You have ~r~locked~w~ your house!");
PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
SendClientMessage(playerid, -1, "คุณได้ล็อคบ้านแล้ว");
canlock = 1;
}
else
{
HouseData[id][houseLocked] = false;
House_Refresh(id);
House_Save(id);
//ShowPlayerFooter(playerid, "You have ~g~unlocked~w~ your house!");
PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
SendClientMessage(playerid, -1, "คุณได้ปลดล็อคบ้านแล้ว");
canlock = 1;
}
}
if (!canlock) SendClientMessage(playerid, -1, "คุณไม่ได้อยู่ในขอบเขตของอะไรก็ตามที่ล็อคได้");
}
case 2:
{
new money = (HouseData[id][housePrice] / 2);
HouseData[id][houseOwner] = 0;
SafeGivePlayerMoney(playerid, money);
OnAccountUpdate(playerid);
PlayerInfo[playerid][pFixHouseID] = -1;
House_Refresh(id);
House_Save(id);
DestroyDynamicMapIcon(HouseData[id][houseMapIcon]);
HouseData[id][houseMapIcon] = CreateDynamicMapIcon(HouseData[id][housePos][0], HouseData[id][housePos][1], HouseData[id][housePos][2], 31, 0);
format(string, sizeof(string), "คุณได้ขายบ้านของคุณ: %s ได้เงินจำนวน %s", HouseData[id][houseAddress], FormatNumber(money));
SendClientMessage(playerid, -1, string);
}
}
}
return 1;
}
Dialog:ManageHouseNot(playerid, response, listitem, inputtext[])
{
if(response) {
new id = GetPVarInt(playerid, "BUYHOUSEID");
switch(listitem)
{
case 0:
{
if (HouseData[id][houseLocked])
return SendClientMessage(playerid, -1, "คุณไม่สามารถเข้าบ้านที่ล็อคได้");
SetPlayerPosEx(playerid, HouseData[id][houseInt][0], HouseData[id][houseInt][1], HouseData[id][houseInt][2]);
SetPlayerFacingAngle(playerid, HouseData[id][houseInt][3]);
SetPlayerInterior(playerid, HouseData[id][houseInterior]);
SetPlayerVirtualWorld(playerid, HouseData[id][houseID] + 5000);
SetCameraBehindPlayer(playerid);
PlayerInfo[playerid][pHouse] = HouseData[id][houseID];
}
}
}
return 1;
}
Dialog:Edithouse(playerid, response, listitem, inputtext[])
{
if(response)
{
new caption[128];
new id = GetPVarInt(playerid, "IDHOUSE");
new string[128];
switch(listitem)
{
case 0: // ตำแหน่ง
{
GetPlayerPos(playerid, HouseData[id][housePos][0], HouseData[id][housePos][1], HouseData[id][housePos][2]);
GetPlayerFacingAngle(playerid, HouseData[id][housePos][3]);
HouseData[id][houseExterior] = GetPlayerInterior(playerid);
HouseData[id][houseExteriorVW] = GetPlayerVirtualWorld(playerid);
House_Refresh(id);
House_Save(id);
format(string, sizeof(string), "คุณได้ปรับตำแหน่งของบ้านไอดี: %d", id);
SendClientMessage(playerid, -1, string);
}
case 1: //ภายใน
{
GetPlayerPos(playerid, HouseData[id][houseInt][0], HouseData[id][houseInt][1], HouseData[id][houseInt][2]);
GetPlayerFacingAngle(playerid, HouseData[id][houseInt][3]);
HouseData[id][houseInterior] = GetPlayerInterior(playerid);
foreach (new i : Player)
{
if (PlayerInfo[pHouse] == HouseData[id][houseID])
{
SetPlayerPosEx(i, HouseData[id][houseInt][0], HouseData[id][houseInt][1], HouseData[id][houseInt][2]);
SetPlayerFacingAngle(i, HouseData[id][houseInt][3]);
SetPlayerInterior(i, HouseData[id][houseInterior]);
SetCameraBehindPlayer(i);
}
}
House_Save(id);
format(string, sizeof(string), "คุณได้ปรับตำแหน่งจุดเกิดภายในของบ้านไอดี: %d", id);
SendClientMessage(playerid, -1, string);
}
case 2: //ราคา
{
format(caption, sizeof(caption), "แก้ไข -> ราคาปัจจุบัน: %s", FormatNumber(HouseData[id][housePrice]));
Dialog_Show(playerid, HousePrice, DIALOG_STYLE_INPUT, caption, "การเปลี่ยนราคาบ้าน\nใส่ราคาใหม่เพื่อเปลี่ยน:", "เปลี่ยน", "กลับ");
}
case 3://ชื่อบ้าน
{
format(caption, sizeof(caption), "แก้ไข -> ชื่อบ้านปัจจุบัน: %s", HouseData[id][houseAddress]);
Dialog_Show(playerid, HouseName, DIALOG_STYLE_INPUT, caption, "การเปลี่ยนชื่อบ้านตัวอักษรต้องมากกว่า 0 และไม่เกิน 60\nใส่ชื่อบ้านใหม่ที่ต้องการจะเปลี่ยน:", "เปลี่ยน", "กลับ");
}
case 4://บ้านสำเร็จรูป
{
format(caption, sizeof(caption), "แก้ไข -> ภายในบ้านสำเร็จรูป");
Dialog_Show(playerid, HouseType, DIALOG_STYLE_INPUT, caption, "การเปลี่ยนภายในสำเร็จรูป\nเลือกตัวเลข 1-20 เพื่อเปลี่ยนภายในสำเร็จรูป:", "เปลี่ยน", "กลับ");
}
case 5://เจ้าของ
{
if(HouseData[id][houseOwner] == 0)
{
format(caption, sizeof(caption), "แก้ไข -> เจ้าของปัจจุบัน: ไม่มีเจ้าของ");
Dialog_Show(playerid, HouseOwner, DIALOG_STYLE_INPUT, caption, "กรอก SQLID ผู้เล่น ที่ต้องการจะให้เป็นเจ้าของ:", "เปลี่ยน", "กลับ");
}
else
{
format(caption, sizeof(caption), "แก้ไข -> เจ้าของปัจจุบัน: %s", GetIDFromName(HouseData[id][houseOwner]));
Dialog_Show(playerid, HouseOwner, DIALOG_STYLE_INPUT, caption, "กรอก SQLID ผู้เล่น ที่ต้องการจะให้เป็นเจ้าของ:", "เปลี่ยน", "กลับ");
}
}
case 6://เลเวลบ้าน
{
format(caption, sizeof(caption), "แก้ไข -> เลเวลบ้าน");
Dialog_Show(playerid, HouseLevel, DIALOG_STYLE_INPUT, caption, "กรอกเลเวลบ้านที่ต้องการ เฉพาะ 1-5 เท่านั้น:", "เปลี่ยน", "กลับ");
}
}
}
return 1;
}
Dialog:HouseLevel(playerid, response, listitem, inputtext[])
{
if(response) {
new caption[128];
new id = GetPVarInt(playerid, "IDHOUSE");
new string[128];
new price = strval(inputtext);
if (price < 1 || price > 5)
{
format(caption, sizeof(caption), "แก้ไข -> เลเวลบ้าน");
Dialog_Show(playerid, HouseLevel, DIALOG_STYLE_INPUT, caption, "กรอกเลเวลบ้านที่ต้องการ เฉพาะ 1-5 เท่านั้น:", "เปลี่ยน", "กลับ");
return 1;
}
format(string, sizeof(string), "บ้านชื่อ %s ถูกเปลี่ยนเลเวลเป็น %d", HouseData[id][houseAddress], price);
SendClientMessage(playerid, COLOR_GRAD1, string);
HouseData[id][houseLevel] = price;
House_Refresh(id);
House_Save(id);
}
return Dialog_Show(playerid, Edithouse, DIALOG_STYLE_LIST, "จัดการบ้าน", "แก้ไขตำแหน่ง\nแก้ไขภายใน\nแก้ไขราคา\nแก้ไขชื่อบ้าน\nแก้ไขภายในสำเร็จรูป\nแก้ไขเจ้าของ\nแก้ไขเลเวล", "แก้ไข", "กลับ");
}
Dialog:HousePrice(playerid, response, listitem, inputtext[])
{
if(response) {
new caption[128];
new id = GetPVarInt(playerid, "IDHOUSE");
new string[128];
new price = strval(inputtext);
if(isnull(inputtext)) {
format(caption, sizeof(caption), "แก้ไข -> ราคา: %s", FormatNumber(HouseData[id][housePrice]));
return 1;
}
format(string, sizeof(string), "บ้านชื่อ %s ถูกเปลี่ยนราคาเป็น %s", HouseData[id][houseAddress], FormatNumber(price));
SendClientMessage(playerid, COLOR_GRAD1, string);
HouseData[id][housePrice] = price;
House_Refresh(id);
House_Save(id);
}
return Dialog_Show(playerid, Edithouse, DIALOG_STYLE_LIST, "จัดการบ้าน", "แก้ไขตำแหน่ง\nแก้ไขภายใน\nแก้ไขราคา\nแก้ไขชื่อบ้าน\nแก้ไขภายในสำเร็จรูป\nแก้ไขเจ้าของ\nแก้ไขเลเวล", "แก้ไข", "กลับ");
}
Dialog:HouseName(playerid, response, listitem, inputtext[])
{
if(response) {
new caption[128];
new id = GetPVarInt(playerid, "IDHOUSE");
new string[128];
if(isnull(inputtext) || strlen(inputtext) >= 60) {
format(caption, sizeof(caption), "แก้ไข -> ชื่อ: %s", HouseData[id][houseAddress]);
Dialog_Show(playerid, HouseName, DIALOG_STYLE_INPUT, caption, "พบข้อผิดพลาด:\nคุณยังไม่ได้กรอกตัวอักษรหรือกรอกเกิน 60 ตัวอักษร", "เปลี่ยน", "กลับ");
return 1;
}
format(string, sizeof(string), " บ้านชื่อ %s ถูกเปลี่ยนชื่อเป็น %s", HouseData[id][houseAddress], inputtext);
SendClientMessage(playerid, COLOR_GRAD1, string);
// SendClientMessage(playerid, COLOR_GRAD1, " บ้านชื่อ %s ถูกเปลี่ยนชื่อเป็น %s", HouseData[id][houseAddress], inputtext);
format(HouseData[id][houseAddress], 60, inputtext);
House_Refresh(id);
House_Save(id);
}
return Dialog_Show(playerid, Edithouse, DIALOG_STYLE_LIST, "จัดการบ้าน", "แก้ไขตำแหน่ง\nแก้ไขภายใน\nแก้ไขราคา\nแก้ไขชื่อบ้าน\nแก้ไขภายในสำเร็จรูป\nแก้ไขเจ้าของ\nแก้ไขเลเวล", "แก้ไข", "กลับ");
}
Dialog:HouseType(playerid, response, listitem, inputtext[])
{
if(response) {
new caption[128];
new id = GetPVarInt(playerid, "IDHOUSE");
new string[128];
new type = strval(inputtext);
if(isnull(inputtext) || strval(inputtext) > sizeof(arrHouseInteriors)) {
format(caption, sizeof(caption), "แก้ไข -> ภายในบ้านสำเร็จรูป: %s", HouseData[id][houseAddress]);
Dialog_Show(playerid, HouseType, DIALOG_STYLE_INPUT, caption, "พบข้อผิดพลาด:\nคุณต้องกรอกระหว่าง 1-%d เท่านั้น", "เปลี่ยน", "กลับ",sizeof(arrHouseInteriors));
return 1;
}
format(string, sizeof(string), " บ้านชื่อ %s ถูกเปลี่ยนภายในสำเร็จรูปเป็น %s", HouseData[id][houseAddress], FormatNumber(type));
SendClientMessage(playerid, COLOR_GRAD1, string);
//SendClientMessage(playerid, COLOR_GRAD1, " บ้านชื่อ %s ถูกเปลี่ยนภายในสำเร็จรูปเป็น %s", HouseData[id][houseAddress], FormatNumber(type));
type--;
HouseData[id][houseInt][0] = arrHouseInteriors[type][eHouseX];
HouseData[id][houseInt][1] = arrHouseInteriors[type][eHouseY];
HouseData[id][houseInt][2] = arrHouseInteriors[type][eHouseZ];
HouseData[id][houseInt][3] = arrHouseInteriors[type][eHouseAngle];
HouseData[id][houseInterior] = arrHouseInteriors[type][eHouseInterior];
foreach (new i : Player)
{
if (PlayerInfo[pHouse] == HouseData[id][houseID])
{
SetPlayerPosEx(i, HouseData[id][houseInt][0], HouseData[id][houseInt][1], HouseData[id][houseInt][2]);
SetPlayerFacingAngle(i, HouseData[id][houseInt][3]);
SetPlayerInterior(i, HouseData[id][houseInterior]);
SetCameraBehindPlayer(i);
}
}
House_Save(id);
format(string, sizeof(string), "คุณได้ปรับภายในสำเร็จรูปของบ้านไอดี: %d เป็น %d", id, type+1);
SendClientMessage(playerid, -1, string);
}
return Dialog_Show(playerid, Edithouse, DIALOG_STYLE_LIST, "จัดการบ้าน", "แก้ไขตำแหน่ง\nแก้ไขภายใน\nแก้ไขราคา\nแก้ไขชื่อบ้าน\nแก้ไขภายในสำเร็จรูป\nแก้ไขเจ้าของ\nแก้ไขเลเวล", "แก้ไข", "กลับ");
}
stock SetPlayerPosEx(playerid,Float:X,Float:Y,Float:Z)
{
PlayerEnterTime[playerid] = INVALID_VEHICLE_ID;
SetPlayerPos(playerid,X,Y,Z);
}
Dialog:HouseOwner(playerid, response, listitem, inputtext[])
{
if(response) {
new caption[128];
new id = GetPVarInt(playerid, "IDHOUSE");
new string[128];
new sqlid = strval(inputtext);
if(isnull(inputtext)) {
if(HouseData[id][houseOwner] == 0)
{
format(caption, sizeof(caption), "แก้ไข -> เจ้าของ: ไม่มีเจ้าของ");
Dialog_Show(playerid, HouseOwner, DIALOG_STYLE_INPUT, caption, "พบข้อผิดพลาด:\nคุณจำเป็นต้องกรอก SQLID", "เปลี่ยน", "กลับ");
}
else
{
format(caption, sizeof(caption), "แก้ไข -> เจ้าของ: %s", GetIDFromName(HouseData[id][houseOwner]));
Dialog_Show(playerid, BizName, DIALOG_STYLE_INPUT, caption, "พบข้อผิดพลาด:\nคุณจำเป็นต้องกรอก SQLID", "เปลี่ยน", "กลับ");
}
return 1;
}
if(sqlid == 0)
{
format(string, sizeof(string), " บ้านชื่อ %s ถูกเปลี่ยนเจ้าของเป็น ไม่มีเจ้าของ", HouseData[id][houseOwner]);
SendClientMessage(playerid, -1, string);
//SendClientMessage(playerid, COLOR_GRAD1, " บ้านชื่อ %s ถูกเปลี่ยนเจ้าของเป็น ไม่มีเจ้าของ", HouseData[id][houseOwner]);
}
else
{
format(string, sizeof(string), " บ้านชื่อ %s ถูกเปลี่ยนเจ้าของเป็น %s", HouseData[id][houseAddress], GetIDFromName(sqlid));
SendClientMessage(playerid, -1, string);
//SendClientMessage(playerid, COLOR_GRAD1, " บ้านชื่อ %s ถูกเปลี่ยนเจ้าของเป็น %s", HouseData[id][houseAddress], GetIDFromName(sqlid));
}
HouseData[id][houseOwner] = sqlid;
House_Refresh(id);
House_Save(id);
}
return Dialog_Show(playerid, Edithouse, DIALOG_STYLE_LIST, "จัดการบ้าน", "แก้ไขตำแหน่ง\nแก้ไขภายใน\nแก้ไขราคา\nแก้ไขชื่อบ้าน\nแก้ไขภายในสำเร็จรูป\nแก้ไขเจ้าของ\nแก้ไขเลเวล", "แก้ไข", "กลับ");
}
//PartySystem
Dialog:DialogParty(playerid, response, listitem, inputtext[])
{
if(response) {
switch(listitem) {
case 0: {
ShowPartyList(playerid);
}
case 1: {
Party_Leave(playerid, PlayerParty[playerid]);
SendClientMessageEx(playerid, COLOR_LIGHTRED, "[Party]: คุณได้ออกจากปาร์ตี้แล้ว");
RemoveMarkers(playerid);
// ShowPartyMenu(playerid);
}
default: {
PlayerParty[playerid]=playerid;
SendClientMessageEx(playerid, COLOR_LIGHTRED, "[Party]: ปาร์ตี้ของคุณถูกสร้างเรียบร้อยแล้ว");
ShowPartyMenu(playerid);
}
}
}
return 1;
}
Dialog:DialogPartyList(playerid, response, listitem, inputtext[])
{
if (response && PlayerParty[playerid] == playerid) {
if (listitem == 0) {
return Dialog_Show(playerid, DialogPartyAdd, DIALOG_STYLE_INPUT, "เพิ่มสมาชิก", "กรอกไอดีผู้เล่นที่ต้องการเชิญ", "เชิญ", "ปิด");
}
new editid = GetPVarInt(playerid, sprintf("PartyEdit_%d", listitem));
if (IsPlayerConnected(editid)) {
Party_Leave(editid, PlayerParty[editid], 4);
/*SetPVarInt(playerid, "PartyEditID", editid);
return Dialog_Show(playerid, DialogPartyEdit, DIALOG_STYLE_LIST, sprintf("สมาชิกในปาร์ตี้ %s", ReturnRealName(editid)), "เตะออกจากปาร์ตี้", "เลือก", "กลับ");*/
}
return ShowPartyList(playerid);
}
return ShowPartyMenu(playerid);
}
Dialog:DialogPartyEdit(playerid, response, listitem, inputtext[])
{
if (response && PlayerParty[playerid] == playerid) {
new targetid = GetPVarInt(playerid, "PartyEditID");
if (PlayerParty[playerid] == PlayerParty[targetid]) {
switch(listitem) {
case 0: {
if (playerid != targetid) {
Party_Leave(targetid, PlayerParty[targetid], 4);
}
else {
SendClientMessage(playerid, COLOR_LIGHTRED, "คุณไม่สามารถเตะตัวเองออกจากปาร์ตี้ได้");
}
}
}
}
}
return ShowPartyList(playerid);
}
Dialog:DialogPartyAdd(playerid, response, listitem, inputtext[])
{
if (response) {
new targetid = strval(inputtext);
if (IsPlayerConnected(targetid)) {
if (PlayerParty[targetid] == NO_PARTY) {
SetPVarInt(targetid, "PartyInvite", playerid);
SendClientMessageEx(playerid, COLOR_LIGHTRED, "[Party]: คุณได้เชิญ %s ให้เข้าร่วมปาร์ตี้ของคุณ", ReturnRealName(targetid));
Dialog_Show(targetid, DialogPartyJoin, DIALOG_STYLE_MSGBOX, "เข้าร่วมปาร์ตี้", "%s ได้เชิญคุณให้เข้าร่วมปาร์ตี้ของเขา", "เข้าร่วม", "ปฏิเสธ", ReturnRealName(playerid));
}
else SendClientMessage(playerid, COLOR_GRAD1, " ผู้เล่นนั้นมีปาร์ตี้อยู่แล้ว!");
}
else {
SendClientMessage(playerid, COLOR_GRAD1, " ผู้เล่นนั้นยังไม่ได้เชื่อมต่อกับเซิร์ฟเวอร์!");
}
}
return ShowPartyList(playerid);
}
Dialog:DialogPartyJoin(playerid, response, listitem, inputtext[])
{
if (response) {
new targetid = GetPVarInt(playerid, "PartyInvite");
if (IsPlayerConnected(targetid) && PlayerParty[targetid] == targetid) {
PlayerParty[playerid] = PlayerParty[targetid];
foreach (new i : Player) {
if (PlayerParty == PlayerParty[playerid]) {
SendClientMessageEx(i, COLOR_LIGHTRED, "[Party]: %s เข้าร่วมปาร์ตี้", ReturnRealName(playerid));
ShowMarkers(playerid, i);
ShowMarkers(i, playerid);
}
}
// ResyncSkin(playerid);
}
else {
SendClientMessage(playerid, COLOR_GRAD1, " ผู้เล่นนั้นไม่ได้อยู่ในปาร์ตี้แล้ว!");
}
}
DeletePVar(playerid, "PartyInvite");
return 1;
}
ShowPartyMenu(playerid) {
if (PlayerParty[playerid]==NO_PARTY) return Dialog_Show(playerid, DialogParty, DIALOG_STYLE_MSGBOX, "ระบบปาร์ตี้", "คุณต้องการสร้างปาร์ตี้ใช่ไหม?", "ใช่", "ไม่");
else return Dialog_Show(playerid, DialogParty, DIALOG_STYLE_LIST, "ระบบปาร์ตี้", "สมาชิก\nออกจากปาร์ตี้", "เลือก", "ปิด");
}
ShowPartyList(playerid) {
new str[1024], count;
if (PlayerParty[playerid] == playerid) {
strcat(str, "เพิ่มสมาชิก");
count ++;
}
if (PlayerParty[playerid] != NO_PARTY) {
foreach (new i : Player)
{
if (PlayerParty == PlayerParty[playerid] && playerid != i) {
strcat(str, sprintf("\n%d) %s", i, ReturnPlayerName(i)));
SetPVarInt(playerid, sprintf("PartyEdit_%d", count), i);
count ++;
}
}
}
return Dialog_Show(playerid, DialogPartyList, DIALOG_STYLE_LIST, "สมาชิกในปาร์ตี้", str, "เลือก", "ปิด");
}
Party_Count(party) {
new count = 0;
foreach (new i : Player) {
if (PlayerParty == party) {
count++;
}
}
return count;
}
Party_Leave(playerid, party, reason = 3) {
if (party != NO_PARTY) {
PlayerParty[playerid]=NO_PARTY;
RemoveMarkers(playerid);
// ResyncSkin(playerid);
static const szDisconnectReason[5][] = {"หลุดออกจากเกมส์","ออกจากเกมส์","ถูกเตะออกจากเกมส์","ออกจากปาร์ตี้","ถูกเตะออกจากปาร์ตี้"};
new count = Party_Count(party);
if (count > 1) {
if (playerid == party) { // เป็นผู้นำ
// หาผู้นำคนใหม่
new leader = INVALID_PLAYER_ID;
foreach (new i : Player) {
if (PlayerParty == party) {
leader = i;
break;
}
}
if (leader != INVALID_PLAYER_ID) {
// แก้ไขปาร์ตี้สมาชิกคนอื่น ๆ
foreach (new i : Player) {
if (PlayerParty == party) {
PlayerParty = leader;
SendClientMessageEx(i, COLOR_ORANGE, "[Party]: %s คือผู้นำคนใหม่ (%s %s)", ReturnRealName(leader), ReturnRealName(playerid), szDisconnectReason[reason]);
new r, g, b, a;
HexToRGBA(GetPlayerColor(playerid), r, g, b, a);
SetPlayerMarkerForPlayer(i, playerid, RGBAToHex(r, g, b, 0x00));
}
}
//UpdatePartyMarker(leader);
}
}
else {
foreach (new i : Player) {
if (PlayerParty == party) {
SendClientMessageEx(i, COLOR_ORANGE, "[Party]: %s ออกจากปาร์ตี้ (%s)", ReturnRealName(playerid), szDisconnectReason[reason]);
new r, g, b, a;
HexToRGBA(GetPlayerColor(playerid), r, g, b, a);
SetPlayerMarkerForPlayer(i, playerid, RGBAToHex(r, g, b, 0x00));
}
}
//UpdatePartyMarker(party);
}
}
else {
foreach (new i : Player) {
if (PlayerParty == party) {
SendClientMessageEx(i, COLOR_ORANGE, "[Party]: %s ออกจากปาร์ตี้ (%s)", ReturnRealName(playerid), szDisconnectReason[reason]);
SendClientMessage(i, COLOR_ORANGE, "[Party]: ปาร์ตี้ในปัจจุบันของคุณถูกยุบ");
PlayerParty = NO_PARTY;
}
}
}
}
return 1;
}
forward PartyUpdateTimer(playerid);
public PartyUpdateTimer(playerid)
{
localplayerid[playerid] = GetPlayerVirtualWorld(playerid);
if(PlayerParty[playerid] != NO_PARTY) {
foreach (new i : Player)
{
if (i != playerid && PlayerParty[playerid] == PlayerParty && localplayerid[playerid] == SetPlayerVirtualWorld(i, localplayerid[playerid])) {
ShowMarkers(playerid, i);
}
}
}
else { RemoveMarkers(playerid); RemoveOtherMarkers(playerid); }
return 1;
}
ShowMarkers(playerid, memberid)
{
new r, g, b, a;
if(PlayerParty[playerid] != NO_PARTY) {
HexToRGBA(GetPlayerColor(memberid), r, g, b, a);
SetPlayerMarkerForPlayer(playerid, memberid, RGBAToHex(r, g, b, 0xFF));
}
}
RemoveMarkers(playerid)
{
new r, g, b, a;
foreach (new i : Player)
{
if (playerid != i && IsPlayerConnected(i)) {
HexToRGBA(GetPlayerColor(i), r, g, b, a);
SetPlayerMarkerForPlayer(playerid, i, RGBAToHex(r, g, b, 0x00));
}
}
}
RemoveOtherMarkers(playerid)
{
new r, g, b, a;
foreach (new i : Player)
{
if (playerid != i && IsPlayerConnected(i)) {
HexToRGBA(GetPlayerColor(playerid), r, g, b, a);
SetPlayerMarkerForPlayer(i, playerid, RGBAToHex(r, g, b, 0x00));
}
}
}
/*stock RGBAToHex(r, g, b, a) //
{
return (r<<24 | g<<16 | b<<8 | a);
}*/
stock HexToRGBA(colour, &r, &g, &b, &a) //By Betamaster
{
r = (colour >> 24) & 0xFF;
g = (colour >> 16) & 0xFF;
b = (colour >> 8) & 0xFF;
a = colour & 0xFF;
}
//--------------------///
Dialog:OloMain(playerid, response, listitem, inputtext[])
{
if(response) {
switch(listitem) {
case 0: {
Dialog_Show(playerid,OloMain_Define,DIALOG_STYLE_INPUT,"ระบบฉายาส่วนตัว","{FFFFFF}ฉายาส่วนตัวของคุณคือ : (%s{FFFFFF})\n\n{FFFFFF}คุณสามารถเปลี่ยนฉายาส่วนตัวของคุณด้วยการกำหนดฉายาใหม่ด้านล่าง :","ตกลง","กลับ", PlayerInfo[playerid][pOloName]);
}
case 1: {
PlayerInfo[playerid][pActiveTag] = 1;
SendClientMessage(playerid, COLOR_YELLOW, "คุณได้เปิดการใช้งาน Tag ส่วนตัว");
}
case 2: {
PlayerInfo[playerid][pActiveTag] = 0;
SendClientMessage(playerid, COLOR_LIGHTRED, "คุณได้ปิดการใช้งาน Tag ส่วนตัว");
}
}
}
return 1;
}
Dialog:OloMain_Define(playerid, response, listitem, inputtext[])
{
if (!response)
return 0;
new query[128],
string[512];
mysql_format(dbCon, query, sizeof query, "UPDATE `players` SET `OloName` = '%e' WHERE `ID` = %d", inputtext, PlayerInfo[playerid][pSQLID]);
mysql_tquery(dbCon, query);
format(PlayerInfo[playerid][pOloName], 255, inputtext);
OnAccountUpdate(playerid);
format(string, sizeof string, "{FFFFFF}คุณได้ทำการเปลี่ยนฉายาส่วนตัวของคุณเป็น : ({FF0000}%s{FFFFFF})", inputtext);
Dialog_Show(playerid,ShowOnly,DIALOG_STYLE_MSGBOX, "ระบบฉายาส่วนตัว",string,"ตกลง","");
return 1;
}