Guest User

ZeroHouse system

a guest
Jan 31st, 2015
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 43.25 KB | None | 0 0
  1. #include <a_samp>
  2. #include <TdMenu2>
  3. #include <foreach>
  4. #include <YSI\y_ini>
  5. #include <streamer>
  6. #include <ZCMD>
  7. #include "../include/gl_common.inc"
  8.  
  9. #define HDIALOGID   2000
  10. #define HMENUID     1
  11.  
  12. #define hPath  "ZeroHouses/Houses/%d.ini"
  13. #define iPath  "ZeroHouses/Interiors/%d.ini"
  14. #define uPath  "ZeroHouses/Users/%s.ini"
  15.  
  16. #define hText "{298ACF}House Name:{FFFFFF}%s\n{298ACF}House Owner:{FFFFFF}%s\n{298ACF}House Price:{FFFFFF}$%d\n{298ACF}House For Sale:{FFFFFF}%s\n{298ACF}House Privacy:{FFFFFF}%s"
  17.  
  18. #define INVALID_HOUSE_NAME "House For Sale!"
  19.  
  20. #define MAX_HOUSES          100
  21. #define MAX_INTERIORS       10
  22. #define MAX_DIST            10
  23. #define MAX_HOUSE_OWNED     2
  24. #define MIN_HOUSE_PRICE     500000
  25. #define MAX_HOUSE_PRICE     50000000
  26. #define SPAWN_IN_HOUSE      true
  27.  
  28. #define Loop(%0,%1,%2) for(new %0 = %2; %0 < %1; %0++)
  29. #define IsPlayerInHouse(%1,%2) if(!strcmp(HouseInfo[%2][hOwner], pName(%1), true)) if(IsPlayerInHouse[%1][%2] == 1)
  30. #define IsOwner(%1,%2) if(!strcmp(HouseInfo[%2][hOwner], pName(%1), true))
  31.  
  32. enum hInfo
  33. {
  34. hName[256],
  35. hOwner[256],
  36. hPrice,
  37. vModel,
  38. hInt,
  39. hStorage,
  40. hForSale,
  41. hSalePrice,
  42. hPrivacy,
  43. hPassword,
  44. Float:hCpX,
  45. Float:hCpY,
  46. Float:hCpZ,
  47. Float:hSpawnOutX,
  48. Float:hSpawnOutY,
  49. Float:hSpawnOutZ,
  50. Float:hSpawnOutA,
  51. Float:hVehX,
  52. Float:hVehY,
  53. Float:hVehZ,
  54. Float:hVehA,
  55. Text3D:Text
  56. }
  57.  
  58. enum iData
  59. {
  60. iIntid,
  61. Float:iCpX,
  62. Float:iCpY,
  63. Float:iCpZ,
  64. Float:iSpawnX,
  65. Float:iSpawnY,
  66. Float:iSpawnZ,
  67. Float:iSpawnA
  68. }
  69.  
  70. new Interior[MAX_INTERIORS][iData],
  71. HouseInfo[MAX_HOUSES][hInfo],
  72. HouseCar[MAX_HOUSES],HouseIcon[MAX_HOUSES],
  73. hCpOut[MAX_HOUSES],hCpIn[MAX_HOUSES],
  74. CH = 0,CI = 0,FirstSpawn[MAX_PLAYERS],
  75. IsPlayerInHouse[MAX_PLAYERS][MAX_HOUSES],
  76. Iterator:Houses<MAX_HOUSES>;
  77.  
  78. public OnFilterScriptInit()
  79. {
  80.     print("\n-----------------Loading-----------------\n");
  81.     print("House System V1.0 by (Emrah Malkic)Zero_Cool\n");
  82.    
  83.     LoadInteriors();
  84.     LoadHouses();
  85.    
  86.     CreateTdMenu(HMENUID,"~g~House Menu",6);
  87.     AddTdMenuItem(HMENUID,1,"Set House Name");
  88.     AddTdMenuItem(HMENUID,2,"House Selling");
  89.     AddTdMenuItem(HMENUID,3,"House Storage");
  90.     AddTdMenuItem(HMENUID,4,"House Password");
  91.     AddTdMenuItem(HMENUID,5,"Toggle House Privacy");
  92.     //AddTdMenuItem(HMENUID,6,"House Security");
  93.    
  94.     CreateTdMenuInPut(HMENUID+1,"~g~Set House Name");
  95.     AddTdMenuInfoRowText(HMENUID+1,2,"Set New House Name:");
  96.    
  97.     CreateTdMenu(HMENUID+2,"~g~House Selling",3);
  98.     AddTdMenuItem(HMENUID+2,1,"Set House For Sale");
  99.     AddTdMenuItem(HMENUID+2,2,"Cancel Active House Sale");
  100.     AddTdMenuItem(HMENUID+2,3,"Sell House");
  101.    
  102.     CreateTdMenu(HMENUID+3,"~g~House Storage",3);
  103.     AddTdMenuItem(HMENUID+3,1,"Withdraw Money");
  104.     AddTdMenuItem(HMENUID+3,2,"Deposit Money");
  105.     AddTdMenuItem(HMENUID+3,3,"Check Balance");
  106.    
  107.     CreateTdMenuInPut(HMENUID+4,"~g~Withdraw Money");
  108.     AddTdMenuInfoRowText(HMENUID+4,2,"Type in the amount you want to withdraw below:");
  109.    
  110.     CreateTdMenuInPut(HMENUID+5,"~g~Deposit Money");
  111.     AddTdMenuInfoRowText(HMENUID+5,2,"Type in the amount you want to deposit below:");
  112.    
  113.     CreateTdMenuInPut(HMENUID+6,"~g~Balance");
  114.    
  115.    
  116.     CreateTdMenu(HMENUID+7,"~g~House Password",2);
  117.     AddTdMenuItem(HMENUID+7,1,"Set House Password");
  118.     AddTdMenuItem(HMENUID+7,2,"Remove House Password");
  119.    
  120.     CreateTdMenuInPut(HMENUID+8,"~g~Set House Password");
  121.     AddTdMenuInfoRowText(HMENUID+8,2,"Type In The New House Password Below:");
  122.    
  123.     CreateTdMenu(HMENUID+9,"~g~House Privacy",2);
  124.     AddTdMenuItem(HMENUID+9,1,"Open House For Visitors");
  125.     AddTdMenuItem(HMENUID+9,2,"Close House For Visitors");
  126.    
  127.     CreateTdMenuInPut(HMENUID+10,"~g~Set House For Sale");
  128.     AddTdMenuInfoRowText(HMENUID+10,1,"Type in how much you want to");
  129.     AddTdMenuInfoRowText(HMENUID+10,2,"sell your house for below:");
  130.    
  131.     CreateTdMenu(HMENUID+11,"~g~House Menu",1);
  132.     AddTdMenuItem(HMENUID+11,1,"Enter House Using Password");
  133.    
  134.     CreateTdMenu(HMENUID+12,"~g~House Menu",2);
  135.     AddTdMenuItem(HMENUID+12,1,"Enter House");
  136.     AddTdMenuItem(HMENUID+12,2,"Enter House Using Password");
  137.    
  138.     CreateTdMenu(HMENUID+13,"~g~House Menu",2);
  139.     AddTdMenuItem(HMENUID+13,1,"Buy House");
  140.     AddTdMenuItem(HMENUID+13,2,"Enter House Using Password");
  141.    
  142.     CreateTdMenu(HMENUID+14,"~g~House Menu",3);
  143.     AddTdMenuItem(HMENUID+14,1,"Buy House");
  144.     AddTdMenuItem(HMENUID+14,2,"Enter House Using Password");
  145.     AddTdMenuItem(HMENUID+14,3,"Enter House");
  146.    
  147.     CreateTdMenu(HMENUID+15,"~g~House Menu",1);
  148.     AddTdMenuItem(HMENUID+15,1,"Buy House");
  149.    
  150.     CreateTdMenu(HMENUID+16,"~g~House Menu",2);
  151.     AddTdMenuItem(HMENUID+16,1,"Buy House");
  152.     AddTdMenuItem(HMENUID+16,2,"Enter House");
  153.    
  154.     CreateTdMenu(HMENUID+17,"~g~House Menu",1);
  155.     AddTdMenuItem(HMENUID+17,1,"Enter House");
  156.    
  157.     CreateTdMenuInPut(HMENUID+18,"~g~House Menu");
  158.     AddTdMenuInfoRowText(HMENUID+18,1,"Enter The Password For");
  159.     AddTdMenuInfoRowText(HMENUID+18,2,"The House Below If You Wish To Enter:");
  160.     print("-----------------Loaded-----------------\n");
  161.     return 1;
  162. }
  163. //
  164. public OnPlayerConnect(playerid)
  165. {
  166.     FirstSpawn[playerid] = 1;
  167.     return 1;
  168. }
  169.  
  170. public OnPlayerDisconnect(playerid, reason)
  171. {
  172.     FirstSpawn[playerid] = 1;
  173.     return 1;
  174. }
  175.  
  176. public OnPlayerSpawn(playerid)
  177. {
  178.     LoadUserFile(playerid);
  179.     #if SPAWN_IN_HOUSE == true
  180.         if(FirstSpawn[playerid] == 1)
  181.         {
  182.             SetTimerEx("SpawnPlayerInHouse",100,0,"d",playerid);
  183.             FirstSpawn[playerid] = 0;
  184.         }
  185.     #endif
  186.     return 1;
  187. }
  188. new Index;
  189. CMD:chouse(playerid, params[])
  190. {
  191.     new tmp[256];
  192.     tmp = strtok(params,Index);
  193.     new tmp2[256];
  194.     tmp2 = strtok(params,Index);
  195.     if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid,-1,"Use: /chouse [price] [intid]");
  196.     new id = strval(tmp2);
  197.     new Price = strval(tmp);
  198.     if(Price <= 0)
  199.     return SendClientMessage(playerid,-1,"Invalid house price. The house price must be between $"#MIN_HOUSE_PRICE" and $"#MAX_HOUSE_PRICE"");
  200.     CreateHouse(playerid,GetFreeHouseID(),Price,id);
  201.     SendClientMessage(playerid,-1,"House Created");
  202.     return 1;
  203. }
  204. CMD:addcar(playerid, params[])
  205. {
  206.     new tmp[256];
  207.     tmp = strtok(params,Index);
  208.     new hid = strval(tmp);
  209.     if(IsPlayerInAnyVehicle(playerid))
  210.     {
  211.         new Float:X,Float:Y,Float:Z,Float:Angle;
  212.         GetVehiclePos(GetPlayerVehicleID(playerid), X, Y, Z);
  213.         GetVehicleZAngle(GetPlayerVehicleID(playerid), Angle);
  214.         new model = GetVehicleModel(GetPlayerVehicleID(playerid));
  215.         dini_IntSet(HouseFile(hid),"vModel",model);
  216.         dini_FloatSet(HouseFile(hid),"vX",X);
  217.         dini_FloatSet(HouseFile(hid),"vY",Y);
  218.         dini_FloatSet(HouseFile(hid),"vZ",Z);
  219.         dini_FloatSet(HouseFile(hid),"vAng",Angle);
  220.         }
  221.         else return SendClientMessage(playerid,-1,"You need to be in a vehicle to add a house car");
  222.     return 1;
  223. }
  224. CMD:removehouse(playerid, params[])
  225. {
  226.     new tmp[256];
  227.     tmp = strtok(params,Index);
  228.     new hid = strval(tmp);
  229.     if(dini_Exists(HouseFile(hid)))
  230.     {
  231.         foreach(Player, i)
  232.         {
  233.             if(IsPlayerInHouse[i][hid] == 1)
  234.             {
  235.                 ExitPlayerFromHouse(i,hid);
  236.             }
  237.         }
  238.         Delete3DTextLabel(HouseInfo[hid][Text]);
  239.         DestroyDynamicCP(hCpOut[hid]);
  240.         IsValidDynamicCP(hCpIn[hid]);
  241.         dini_Remove(HouseFile(hid));
  242.     }
  243.     return 1;
  244. }
  245. CMD:houseinfo(playerid, params[])
  246. {
  247.     foreach(Houses, hid)
  248.     {
  249.         if(IsPlayerInRangeOfPoint(playerid,6.0,HouseInfo[hid][hCpX],HouseInfo[hid][hCpY],HouseInfo[hid][hCpZ]))
  250.         {
  251.             if(HouseInfo[hid][hForSale] || !strcmp(HouseInfo[hid][hOwner], pName(playerid), true))
  252.             {
  253.                 new string[256];
  254.                 new hCar;
  255.                 if(!HouseInfo[hid][vModel]) hCar = 0;
  256.                 else hCar = 1;
  257.                 format(string,sizeof(string),
  258.                 "{298ACF}House Name:{FFFFFF} %s\n{298ACF}House Owner:{FFFFFF} %s\n{298ACF}House Price:{FFFFFF} $%d\n{298ACF}House For Sale:{FFFFFF} %s\n{298ACF}House Privacy:{FFFFFF} %s\n{298ACF}House Car:{FFFFFF} %s",
  259.                 HouseInfo[hid][hName],
  260.                 HouseInfo[hid][hOwner],
  261.                 HouseInfo[hid][hPrice],
  262.                 YesOrNo(HouseInfo[hid][hForSale]),
  263.                 OpenOrClose(HouseInfo[hid][hPrivacy]),
  264.                 YesOrNo(hCar));
  265.                 ShowPlayerDialog(playerid,100,DIALOG_STYLE_MSGBOX,"{298ACF}House Info",string,"OK","");
  266.             }
  267.             else SendClientMessage(playerid,-1,"This house is not for sale.");
  268.         }
  269.     }
  270.     return 1;
  271. }
  272. forward SpawnPlayerInHouse(playerid);
  273. public SpawnPlayerInHouse(playerid)
  274. {
  275.     foreach(Houses, hid)
  276.     {
  277.         IsOwner(playerid,hid)
  278.         {
  279.             SetPVarInt(playerid,"pHouseID",hid);
  280.             IsPlayerInHouse[playerid][hid] = 1;
  281.             hCpIn[hid] = CreateDynamicCP(Interior[HouseInfo[hid][hInt]][iCpX],Interior[HouseInfo[hid][hInt]][iCpY],Interior[HouseInfo[hid][hInt]][iCpZ],1.5,-1,-1,-1,10);
  282.             SetPlayerInInterior(playerid,HouseInfo[hid][hInt]);
  283.         }
  284.     }
  285. }
  286.  
  287. stock GetPlayerID(const Name[])
  288. {
  289.     for(new i; i<MAX_PLAYERS; i++)
  290.     {
  291.         if(IsPlayerConnected(i))
  292.         {
  293.             new p_Name[MAX_PLAYER_NAME];
  294.             GetPlayerName(i, p_Name, sizeof(p_Name));
  295.             if(strcmp(Name, p_Name, true)==0)
  296.             {
  297.                 return i;
  298.             }
  299.         }
  300.     }
  301.     return -1;
  302. }
  303. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  304. {
  305.     if(newkeys == KEY_SUBMISSION)
  306.     {
  307.         foreach(Houses, hid)
  308.         {
  309.             IsPlayerInHouse(playerid,hid)
  310.             {
  311.                 ShowTdMenu(playerid,HMENUID);
  312.             }
  313.         }
  314.     }
  315.     return 1;
  316. }
  317. public OnPlayerEnterDynamicCP(playerid, checkpointid)
  318. {
  319.     if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
  320.     {
  321.         foreach(Houses, hid)
  322.         {
  323.             if(checkpointid == hCpOut[hid])
  324.             {
  325.                 SetPVarInt(playerid,"pHouseID",hid);
  326.                 IsOwner(playerid,hid)
  327.                 {
  328.                     IsPlayerInHouse[playerid][hid] = 1;
  329.                     hCpIn[hid] = CreateDynamicCP(Interior[HouseInfo[hid][hInt]][iCpX],Interior[HouseInfo[hid][hInt]][iCpY],Interior[HouseInfo[hid][hInt]][iCpZ],1.5,-1,-1,-1,10);
  330.                     SetPlayerInInterior(playerid,HouseInfo[hid][hInt]);
  331.                 }
  332.                 else
  333.                 {
  334.                     if(HouseInfo[hid][hPassword] != udb_hash("INVALID_PASSWORD") && HouseInfo[hid][hForSale] == 0)
  335.                     {
  336.                         switch(HouseInfo[hid][hPrivacy])
  337.                         {
  338.                             case 0:{ShowTdMenu(playerid,HMENUID+11);}//ShowDialog(playerid,HDIALOGID+10,0,"House Menu","Enter House Using Password");
  339.                             case 1:{ShowTdMenu(playerid,HMENUID+12);}//ShowDialog(playerid,HDIALOGID+10,0,"House Menu","Enter House\nEnter House Using Password");}
  340.                         }
  341.                         return 1;
  342.                     }
  343.                     if(HouseInfo[hid][hPassword] == udb_hash("INVALID_PASSWORD") && HouseInfo[hid][hForSale] == 0)
  344.                     {
  345.                         switch(HouseInfo[hid][hPrivacy])
  346.                         {
  347.                             case 0:{}
  348.                             case 1:{ShowTdMenu(playerid,HMENUID+17);}//ShowDialog(playerid,HDIALOGID+10,0,"House Menu","Enter House");}
  349.                         }
  350.                         return 1;
  351.                     }
  352.                     if(HouseInfo[hid][hForSale] == 1)
  353.                     {
  354.                         if(HouseInfo[hid][hPassword] != udb_hash("INVALID_PASSWORD"))
  355.                         {
  356.                             switch(HouseInfo[hid][hPrivacy])
  357.                             {
  358.                                 case 0:{ShowTdMenu(playerid,HMENUID+13);}//ShowDialog(playerid,HDIALOGID+13,0,"House Menu","Buy House\nEnter House Using Password");}
  359.                                 case 1:{ShowTdMenu(playerid,HMENUID+14);}//ShowDialog(playerid,HDIALOGID+13,0,"House Menu","Buy House\nEnter House Using Password\nEnter House");}
  360.                             }
  361.                             return 1;
  362.                         }
  363.                         if(HouseInfo[hid][hPassword] == udb_hash("INVALID_PASSWORD"))
  364.                         {
  365.                             switch(HouseInfo[hid][hPrivacy])
  366.                             {
  367.                                 case 0:{ShowTdMenu(playerid,HMENUID+15);}//ShowDialog(playerid,HDIALOGID+14,0,"House Menu","Buy House");}
  368.                                 case 1:{ShowTdMenu(playerid,HMENUID+16);}//ShowDialog(playerid,HDIALOGID+14,0,"House Menu","Buy House\nEnter House");}
  369.                             }
  370.                         }
  371.                     }
  372.                 }
  373.             }
  374.            
  375.             if(checkpointid == hCpIn[GetPVarInt(playerid,"pHouseID")])
  376.             {
  377.                 ExitPlayerFromHouse(playerid,GetPVarInt(playerid,"pHouseID"));
  378.             }
  379.         }
  380.     }
  381.     return 1;
  382. }
  383.  
  384. public OnPlayerLeaveDynamicCP(playerid, checkpointid)
  385. {
  386.     if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
  387.     {
  388.         foreach(Houses, h)
  389.         {
  390.             if(checkpointid == hCpOut[h])
  391.             {
  392.                 HideCurrentTdMenu(playerid);
  393.             }
  394.         }
  395.     }
  396.     return 1;
  397. }
  398.  
  399. public OnPlayerTdMenuUsed(playerid,menuid,row)
  400. {
  401.     new hid = GetPVarInt(playerid,"pHouseID");
  402.     if(menuid == HMENUID+16)
  403.     {
  404.         if(row == 1)
  405.         {
  406.             if(IsPlayerInDynamicCP(playerid,hCpOut[hid]))
  407.             {
  408.                 if(HouseInfo[hid][hForSale] == 1  && HouseInfo[hid][hSalePrice] == 0)
  409.                 {
  410.                     new str[256]; format(str,sizeof(str),"You already own %d house%s.",MAX_HOUSE_OWNED,AddS(MAX_HOUSE_OWNED));
  411.                     if(GetOwnedHouses(playerid) > MAX_HOUSE_OWNED) return SendClientMessage(playerid,-1,str);
  412.                     if(GetPlayerMoney(playerid) < HouseInfo[hid][hPrice]) return SendClientMessage(playerid,-1,"You can not afford to buy this house.");
  413.                     format(HouseInfo[hid][hName], sizeof(str), "%s's House", pName(playerid));
  414.                     dini_Set(HouseFile(hid),"HouseName",HouseInfo[hid][hName]);
  415.                     format(HouseInfo[hid][hOwner], MAX_PLAYER_NAME, "%s", pName(playerid));
  416.                     dini_Set(HouseFile(hid),"Owner",HouseInfo[hid][hOwner]);
  417.                     dini_IntSet(HouseFile(hid),"HouseForSale",0);
  418.                     HouseInfo[hid][hForSale] = 0;
  419.                     GivePlayerMoney(playerid, -HouseInfo[hid][hPrice]);
  420.                     format(str,sizeof(str),hText,HouseInfo[hid][hName],HouseInfo[hid][hOwner],HouseInfo[hid][hPrice],YesOrNo(HouseInfo[hid][hForSale]),OpenOrClose(HouseInfo[hid][hPrivacy]));
  421.                     Update3DTextLabelText(HouseInfo[hid][Text],-1,str);
  422.                     DestroyDynamicMapIcon(HouseIcon[hid]);
  423.                     HideCurrentTdMenu(playerid);
  424.                     HouseIcon[hid] = CreateDynamicMapIcon(HouseInfo[hid][hCpX],HouseInfo[hid][hCpY],HouseInfo[hid][hCpZ],32,-1);
  425.                 }
  426.                 else if(HouseInfo[hid][hForSale] == 1  && HouseInfo[hid][hSalePrice] > 0)
  427.                 {
  428.                     new str[256]; format(str,sizeof(str),"You already own %d house%s.",MAX_HOUSE_OWNED,AddS(MAX_HOUSE_OWNED));
  429.                     if(GetOwnedHouses(playerid) > MAX_HOUSE_OWNED) return SendClientMessage(playerid,-1,str);
  430.                     if(GetPlayerMoney(playerid) < HouseInfo[hid][hSalePrice]) return SendClientMessage(playerid,-1,"You can not afford to buy this house.");
  431.                     new ID = GetPlayerID(HouseInfo[hid][hOwner]);
  432.                     if(IsPlayerConnected(ID))
  433.                     {
  434.                         GivePlayerMoney(ID, HouseInfo[hid][hSalePrice]);
  435.                     }
  436.                     else
  437.                     {
  438.                         new file[128];
  439.                         format(file, sizeof(file), uPath, HouseInfo[hid][hOwner]);
  440.                         if(!dini_Exists(file))
  441.                         {
  442.                             dini_Create(file);
  443.                         }
  444.                         dini_Set(file,"HouseName",HouseInfo[hid][hName]);
  445.                         dini_Set(file,"Buyer",pName(playerid));
  446.                         dini_IntSet(file,"MoneyToPlayer",HouseInfo[hid][hSalePrice]);
  447.                         dini_IntSet(file,"MoneyToHouse",HouseInfo[hid][hStorage]);
  448.                     }
  449.                     format(HouseInfo[hid][hName], sizeof(str), "%s's House", pName(playerid));
  450.                     dini_Set(HouseFile(hid),"HouseName",HouseInfo[hid][hName]);
  451.                     format(HouseInfo[hid][hOwner], MAX_PLAYER_NAME, "%s", pName(playerid));
  452.                     dini_Set(HouseFile(hid),"Owner",HouseInfo[hid][hOwner]);
  453.                     dini_IntSet(HouseFile(hid),"HouseForSale",0);
  454.                     HouseInfo[hid][hStorage] = 0;
  455.                     dini_IntSet(HouseFile(hid),"HouseStorage",0);
  456.                     HouseInfo[hid][hPassword] = udb_hash("INVALID_PASSWORD");
  457.                     dini_IntSet(HouseFile(hid),"HousePassword",HouseInfo[hid][hPassword]);
  458.                     HouseInfo[hid][hForSale] = 0;
  459.                     GivePlayerMoney(playerid, -HouseInfo[hid][hSalePrice]);
  460.                     format(str,sizeof(str),hText,HouseInfo[hid][hName],HouseInfo[hid][hOwner],HouseInfo[hid][hPrice],YesOrNo(HouseInfo[hid][hForSale]),OpenOrClose(HouseInfo[hid][hPrivacy]));
  461.                     Update3DTextLabelText(HouseInfo[hid][Text],-1,str);
  462.                     DestroyDynamicMapIcon(HouseIcon[hid]);
  463.                     HideCurrentTdMenu(playerid);
  464.                     HouseIcon[hid] = CreateDynamicMapIcon(HouseInfo[hid][hCpX],HouseInfo[hid][hCpY],HouseInfo[hid][hCpZ],32,-1);
  465.                 }
  466.             }
  467.         }
  468.         if(row == 2)
  469.         {
  470.             IsPlayerInHouse[playerid][hid] = 1;
  471.             hCpIn[hid] = CreateDynamicCP(Interior[HouseInfo[hid][hInt]][iCpX],Interior[HouseInfo[hid][hInt]][iCpY],Interior[HouseInfo[hid][hInt]][iCpZ],1.5,-1,-1,-1,10);
  472.             SetPlayerInInterior(playerid,HouseInfo[hid][hInt]);
  473.             HideTdMenu(playerid,HMENUID+16);
  474.         }
  475.     }
  476.     if(menuid == HMENUID+15)
  477.     {
  478.         if(row == 1)
  479.         {
  480.             if(IsPlayerInDynamicCP(playerid,hCpOut[hid]))
  481.             {
  482.                 if(HouseInfo[hid][hForSale] == 1  && HouseInfo[hid][hSalePrice] == 0)
  483.                 {
  484.                     new str[256]; format(str,sizeof(str),"You already own %d house%s.",MAX_HOUSE_OWNED,AddS(MAX_HOUSE_OWNED));
  485.                     if(GetOwnedHouses(playerid) > MAX_HOUSE_OWNED) return SendClientMessage(playerid,-1,str);
  486.                     if(GetPlayerMoney(playerid) < HouseInfo[hid][hPrice]) return SendClientMessage(playerid,-1,"You can not afford to buy this house.");
  487.                     format(HouseInfo[hid][hName], sizeof(str), "%s's House", pName(playerid));
  488.                     dini_Set(HouseFile(hid),"HouseName",HouseInfo[hid][hName]);
  489.                     format(HouseInfo[hid][hOwner], MAX_PLAYER_NAME, "%s", pName(playerid));
  490.                     dini_Set(HouseFile(hid),"Owner",HouseInfo[hid][hOwner]);
  491.                     dini_IntSet(HouseFile(hid),"HouseForSale",0);
  492.                     HouseInfo[hid][hForSale] = 0;
  493.                     GivePlayerMoney(playerid, -HouseInfo[hid][hPrice]);
  494.                     format(str,sizeof(str),hText,HouseInfo[hid][hName],HouseInfo[hid][hOwner],HouseInfo[hid][hPrice],YesOrNo(HouseInfo[hid][hForSale]),OpenOrClose(HouseInfo[hid][hPrivacy]));
  495.                     Update3DTextLabelText(HouseInfo[hid][Text],-1,str);
  496.                     DestroyDynamicMapIcon(HouseIcon[hid]);
  497.                     HideCurrentTdMenu(playerid);
  498.                     HouseIcon[hid] = CreateDynamicMapIcon(HouseInfo[hid][hCpX],HouseInfo[hid][hCpY],HouseInfo[hid][hCpZ],32,-1);
  499.                 }
  500.                 else if(HouseInfo[hid][hForSale] == 1  && HouseInfo[hid][hSalePrice] > 0)
  501.                 {
  502.                     new str[256]; format(str,sizeof(str),"You already own %d house%s.",MAX_HOUSE_OWNED,AddS(MAX_HOUSE_OWNED));
  503.                     if(GetOwnedHouses(playerid) > MAX_HOUSE_OWNED) return SendClientMessage(playerid,-1,str);
  504.                     if(GetPlayerMoney(playerid) < HouseInfo[hid][hSalePrice]) return SendClientMessage(playerid,-1,"You can not afford to buy this house.");
  505.                     new ID = GetPlayerID(HouseInfo[hid][hOwner]);
  506.                     if(IsPlayerConnected(ID))
  507.                     {
  508.                         GivePlayerMoney(ID, HouseInfo[hid][hSalePrice]);
  509.                     }
  510.                     else
  511.                     {
  512.                         new file[128];
  513.                         format(file, sizeof(file), uPath, HouseInfo[hid][hOwner]);
  514.                         if(!dini_Exists(file))
  515.                         {
  516.                             dini_Create(file);
  517.                         }
  518.                         dini_Set(file,"HouseName",HouseInfo[hid][hName]);
  519.                         dini_Set(file,"Buyer",pName(playerid));
  520.                         dini_IntSet(file,"MoneyToPlayer",HouseInfo[hid][hSalePrice]);
  521.                         dini_IntSet(file,"MoneyToHouse",HouseInfo[hid][hStorage]);
  522.                     }
  523.                     format(HouseInfo[hid][hName], sizeof(str), "%s's House", pName(playerid));
  524.                     dini_Set(HouseFile(hid),"HouseName",HouseInfo[hid][hName]);
  525.                     format(HouseInfo[hid][hOwner], MAX_PLAYER_NAME, "%s", pName(playerid));
  526.                     dini_Set(HouseFile(hid),"Owner",HouseInfo[hid][hOwner]);
  527.                     dini_IntSet(HouseFile(hid),"HouseForSale",0);
  528.                     HouseInfo[hid][hStorage] = 0;
  529.                     dini_IntSet(HouseFile(hid),"HouseStorage",0);
  530.                     HouseInfo[hid][hPassword] = udb_hash("INVALID_PASSWORD");
  531.                     dini_IntSet(HouseFile(hid),"HousePassword",HouseInfo[hid][hPassword]);
  532.                     HouseInfo[hid][hForSale] = 0;
  533.                     GivePlayerMoney(playerid, -HouseInfo[hid][hSalePrice]);
  534.                     format(str,sizeof(str),hText,HouseInfo[hid][hName],HouseInfo[hid][hOwner],HouseInfo[hid][hPrice],YesOrNo(HouseInfo[hid][hForSale]),OpenOrClose(HouseInfo[hid][hPrivacy]));
  535.                     Update3DTextLabelText(HouseInfo[hid][Text],-1,str);
  536.                     DestroyDynamicMapIcon(HouseIcon[hid]);
  537.                     HideCurrentTdMenu(playerid);
  538.                     HouseIcon[hid] = CreateDynamicMapIcon(HouseInfo[hid][hCpX],HouseInfo[hid][hCpY],HouseInfo[hid][hCpZ],32,-1);
  539.                 }
  540.             }
  541.         }
  542.     }
  543.     if(menuid == HMENUID+14)
  544.     {
  545.         if(row == 1)
  546.         {
  547.             if(IsPlayerInDynamicCP(playerid,hCpOut[hid]))
  548.             {
  549.                 if(HouseInfo[hid][hForSale] == 1  && HouseInfo[hid][hSalePrice] == 0)
  550.                 {
  551.                     new str[256]; format(str,sizeof(str),"You already own %d house%s.",MAX_HOUSE_OWNED,AddS(MAX_HOUSE_OWNED));
  552.                     if(GetOwnedHouses(playerid) > MAX_HOUSE_OWNED) return SendClientMessage(playerid,-1,str);
  553.                     if(GetPlayerMoney(playerid) < HouseInfo[hid][hPrice]) return SendClientMessage(playerid,-1,"You can not afford to buy this house.");
  554.                     format(HouseInfo[hid][hName], sizeof(str), "%s's House", pName(playerid));
  555.                     dini_Set(HouseFile(hid),"HouseName",HouseInfo[hid][hName]);
  556.                     format(HouseInfo[hid][hOwner], MAX_PLAYER_NAME, "%s", pName(playerid));
  557.                     dini_Set(HouseFile(hid),"Owner",HouseInfo[hid][hOwner]);
  558.                     dini_IntSet(HouseFile(hid),"HouseForSale",0);
  559.                     HouseInfo[hid][hForSale] = 0;
  560.                     GivePlayerMoney(playerid, -HouseInfo[hid][hPrice]);
  561.                     format(str,sizeof(str),hText,HouseInfo[hid][hName],HouseInfo[hid][hOwner],HouseInfo[hid][hPrice],YesOrNo(HouseInfo[hid][hForSale]),OpenOrClose(HouseInfo[hid][hPrivacy]));
  562.                     Update3DTextLabelText(HouseInfo[hid][Text],-1,str);
  563.                     DestroyDynamicMapIcon(HouseIcon[hid]);
  564.                     HideCurrentTdMenu(playerid);
  565.                     HouseIcon[hid] = CreateDynamicMapIcon(HouseInfo[hid][hCpX],HouseInfo[hid][hCpY],HouseInfo[hid][hCpZ],32,-1);
  566.                 }
  567.                 else if(HouseInfo[hid][hForSale] == 1  && HouseInfo[hid][hSalePrice] > 0)
  568.                 {
  569.                     new str[256]; format(str,sizeof(str),"You already own %d house%s.",MAX_HOUSE_OWNED,AddS(MAX_HOUSE_OWNED));
  570.                     if(GetOwnedHouses(playerid) > MAX_HOUSE_OWNED) return SendClientMessage(playerid,-1,str);
  571.                     if(GetPlayerMoney(playerid) < HouseInfo[hid][hSalePrice]) return SendClientMessage(playerid,-1,"You can not afford to buy this house.");
  572.                     new ID = GetPlayerID(HouseInfo[hid][hOwner]);
  573.                     if(IsPlayerConnected(ID))
  574.                     {
  575.                         GivePlayerMoney(ID, HouseInfo[hid][hSalePrice]);
  576.                     }
  577.                     else
  578.                     {
  579.                         new file[128];
  580.                         format(file, sizeof(file), uPath, HouseInfo[hid][hOwner]);
  581.                         if(!dini_Exists(file))
  582.                         {
  583.                             dini_Create(file);
  584.                         }
  585.                         dini_Set(file,"HouseName",HouseInfo[hid][hName]);
  586.                         dini_Set(file,"Buyer",pName(playerid));
  587.                         dini_IntSet(file,"MoneyToPlayer",HouseInfo[hid][hSalePrice]);
  588.                         dini_IntSet(file,"MoneyToHouse",HouseInfo[hid][hStorage]);
  589.                     }
  590.                     format(HouseInfo[hid][hName], sizeof(str), "%s's House", pName(playerid));
  591.                     dini_Set(HouseFile(hid),"HouseName",HouseInfo[hid][hName]);
  592.                     format(HouseInfo[hid][hOwner], MAX_PLAYER_NAME, "%s", pName(playerid));
  593.                     dini_Set(HouseFile(hid),"Owner",HouseInfo[hid][hOwner]);
  594.                     dini_IntSet(HouseFile(hid),"HouseForSale",0);
  595.                     HouseInfo[hid][hStorage] = 0;
  596.                     dini_IntSet(HouseFile(hid),"HouseStorage",0);
  597.                     HouseInfo[hid][hPassword] = udb_hash("INVALID_PASSWORD");
  598.                     dini_IntSet(HouseFile(hid),"HousePassword",HouseInfo[hid][hPassword]);
  599.                     HouseInfo[hid][hForSale] = 0;
  600.                     GivePlayerMoney(playerid, -HouseInfo[hid][hSalePrice]);
  601.                     format(str,sizeof(str),hText,HouseInfo[hid][hName],HouseInfo[hid][hOwner],HouseInfo[hid][hPrice],YesOrNo(HouseInfo[hid][hForSale]),OpenOrClose(HouseInfo[hid][hPrivacy]));
  602.                     Update3DTextLabelText(HouseInfo[hid][Text],-1,str);
  603.                     DestroyDynamicMapIcon(HouseIcon[hid]);
  604.                     HideCurrentTdMenu(playerid);
  605.                     HouseIcon[hid] = CreateDynamicMapIcon(HouseInfo[hid][hCpX],HouseInfo[hid][hCpY],HouseInfo[hid][hCpZ],32,-1);
  606.                 }
  607.             }
  608.         }
  609.         if(row == 2)
  610.         {
  611.             ShowTdMenu(playerid,HMENUID+18);
  612.         }
  613.         if(row == 3)
  614.         {
  615.             IsPlayerInHouse[playerid][hid] = 1;
  616.             hCpIn[hid] = CreateDynamicCP(Interior[HouseInfo[hid][hInt]][iCpX],Interior[HouseInfo[hid][hInt]][iCpY],Interior[HouseInfo[hid][hInt]][iCpZ],1.5,-1,-1,-1,10);
  617.             SetPlayerInInterior(playerid,HouseInfo[hid][hInt]);
  618.             HideTdMenu(playerid,HMENUID+14);
  619.         }
  620.     }
  621.     if(menuid == HMENUID+13)
  622.     {
  623.         if(row == 1)
  624.         {
  625.             if(IsPlayerInDynamicCP(playerid,hCpOut[hid]))
  626.             {
  627.                 if(HouseInfo[hid][hForSale] == 1  && HouseInfo[hid][hSalePrice] == 0)
  628.                 {
  629.                     new str[256]; format(str,sizeof(str),"You already own %d house%s.",MAX_HOUSE_OWNED,AddS(MAX_HOUSE_OWNED));
  630.                     if(GetOwnedHouses(playerid) > MAX_HOUSE_OWNED) return SendClientMessage(playerid,-1,str);
  631.                     if(GetPlayerMoney(playerid) < HouseInfo[hid][hPrice]) return SendClientMessage(playerid,-1,"You can not afford to buy this house.");
  632.                     format(HouseInfo[hid][hName], sizeof(str), "%s's House", pName(playerid));
  633.                     dini_Set(HouseFile(hid),"HouseName",HouseInfo[hid][hName]);
  634.                     format(HouseInfo[hid][hOwner], MAX_PLAYER_NAME, "%s", pName(playerid));
  635.                     dini_Set(HouseFile(hid),"Owner",HouseInfo[hid][hOwner]);
  636.                     dini_IntSet(HouseFile(hid),"HouseForSale",0);
  637.                     HouseInfo[hid][hForSale] = 0;
  638.                     GivePlayerMoney(playerid, -HouseInfo[hid][hPrice]);
  639.                     format(str,sizeof(str),hText,HouseInfo[hid][hName],HouseInfo[hid][hOwner],HouseInfo[hid][hPrice],YesOrNo(HouseInfo[hid][hForSale]),OpenOrClose(HouseInfo[hid][hPrivacy]));
  640.                     Update3DTextLabelText(HouseInfo[hid][Text],-1,str);
  641.                     DestroyDynamicMapIcon(HouseIcon[hid]);
  642.                     HideCurrentTdMenu(playerid);
  643.                     HouseIcon[hid] = CreateDynamicMapIcon(HouseInfo[hid][hCpX],HouseInfo[hid][hCpY],HouseInfo[hid][hCpZ],32,-1);
  644.                 }
  645.                 else if(HouseInfo[hid][hForSale] == 1  && HouseInfo[hid][hSalePrice] > 0)
  646.                 {
  647.                     new str[256]; format(str,sizeof(str),"You already own %d house%s.",MAX_HOUSE_OWNED,AddS(MAX_HOUSE_OWNED));
  648.                     if(GetOwnedHouses(playerid) > MAX_HOUSE_OWNED) return SendClientMessage(playerid,-1,str);
  649.                     if(GetPlayerMoney(playerid) < HouseInfo[hid][hSalePrice]) return SendClientMessage(playerid,-1,"You can not afford to buy this house.");
  650.                     new ID = GetPlayerID(HouseInfo[hid][hOwner]);
  651.                     if(IsPlayerConnected(ID))
  652.                     {
  653.                         GivePlayerMoney(ID, HouseInfo[hid][hSalePrice]);
  654.                     }
  655.                     else
  656.                     {
  657.                         new file[128];
  658.                         format(file, sizeof(file), uPath, HouseInfo[hid][hOwner]);
  659.                         if(!dini_Exists(file))
  660.                         {
  661.                             dini_Create(file);
  662.                         }
  663.                         dini_Set(file,"HouseName",HouseInfo[hid][hName]);
  664.                         dini_Set(file,"Buyer",pName(playerid));
  665.                         dini_IntSet(file,"MoneyToPlayer",HouseInfo[hid][hSalePrice]);
  666.                         dini_IntSet(file,"MoneyToHouse",HouseInfo[hid][hStorage]);
  667.                     }
  668.                     format(HouseInfo[hid][hName], sizeof(str), "%s's House", pName(playerid));
  669.                     dini_Set(HouseFile(hid),"HouseName",HouseInfo[hid][hName]);
  670.                     format(HouseInfo[hid][hOwner], MAX_PLAYER_NAME, "%s", pName(playerid));
  671.                     dini_Set(HouseFile(hid),"Owner",HouseInfo[hid][hOwner]);
  672.                     dini_IntSet(HouseFile(hid),"HouseForSale",0);
  673.                     HouseInfo[hid][hStorage] = 0;
  674.                     dini_IntSet(HouseFile(hid),"HouseStorage",0);
  675.                     HouseInfo[hid][hPassword] = udb_hash("INVALID_PASSWORD");
  676.                     dini_IntSet(HouseFile(hid),"HousePassword",HouseInfo[hid][hPassword]);
  677.                     HouseInfo[hid][hForSale] = 0;
  678.                     GivePlayerMoney(playerid, -HouseInfo[hid][hSalePrice]);
  679.                     format(str,sizeof(str),hText,HouseInfo[hid][hName],HouseInfo[hid][hOwner],HouseInfo[hid][hPrice],YesOrNo(HouseInfo[hid][hForSale]),OpenOrClose(HouseInfo[hid][hPrivacy]));
  680.                     Update3DTextLabelText(HouseInfo[hid][Text],-1,str);
  681.                     DestroyDynamicMapIcon(HouseIcon[hid]);
  682.                     HideCurrentTdMenu(playerid);
  683.                     HouseIcon[hid] = CreateDynamicMapIcon(HouseInfo[hid][hCpX],HouseInfo[hid][hCpY],HouseInfo[hid][hCpZ],32,-1);
  684.                 }
  685.             }
  686.         }
  687.         if(row == 2)
  688.         {
  689.             ShowTdMenu(playerid,HMENUID+18);
  690.         }
  691.     }
  692.     if(menuid == HMENUID+11)
  693.     {
  694.         if(row == 1)
  695.         {
  696.             ShowTdMenu(playerid,HMENUID+18);
  697.         }
  698.     }
  699.     if(menuid == HMENUID+17)
  700.     {
  701.         if(row == 1)
  702.         {
  703.             IsPlayerInHouse[playerid][hid] = 1;
  704.             hCpIn[hid] = CreateDynamicCP(Interior[HouseInfo[hid][hInt]][iCpX],Interior[HouseInfo[hid][hInt]][iCpY],Interior[HouseInfo[hid][hInt]][iCpZ],1.5,-1,-1,-1,10);
  705.             SetPlayerInInterior(playerid,HouseInfo[hid][hInt]);
  706.             HideTdMenu(playerid,HMENUID+17);
  707.         }
  708.     }
  709.     if(menuid == HMENUID+12)
  710.     {
  711.         if(row == 1)
  712.         {
  713.             IsPlayerInHouse[playerid][hid] = 1;
  714.             hCpIn[hid] = CreateDynamicCP(Interior[HouseInfo[hid][hInt]][iCpX],Interior[HouseInfo[hid][hInt]][iCpY],Interior[HouseInfo[hid][hInt]][iCpZ],1.5,-1,-1,-1,10);
  715.             SetPlayerInInterior(playerid,HouseInfo[hid][hInt]);
  716.             HideTdMenu(playerid,HMENUID+12);
  717.         }
  718.         if(row == 2)
  719.         {
  720.             ShowTdMenu(playerid,HMENUID+18);
  721.         }
  722.     }
  723.     if(menuid == HMENUID)
  724.     {
  725.         if(row == 1)
  726.         {
  727.             ShowTdMenu(playerid,HMENUID+1);
  728.         }
  729.         if(row == 2)
  730.         {
  731.             ShowTdMenu(playerid,HMENUID+2);
  732.         }
  733.         if(row == 3)
  734.         {
  735.             ShowTdMenu(playerid,HMENUID+3);
  736.         }
  737.         if(row == 4)
  738.         {
  739.             ShowTdMenu(playerid,HMENUID+7);
  740.         }
  741.         if(row == 5)
  742.         {
  743.             ShowTdMenu(playerid,HMENUID+9);
  744.         }
  745.     }
  746.     if(menuid == HMENUID+2)
  747.     {
  748.         if(row == 1)
  749.         {
  750.             ShowTdMenu(playerid,HMENUID+10);
  751.         }
  752.         if(row == 2)
  753.         {
  754.             new str[256];
  755.             HouseInfo[hid][hForSale] = 0;
  756.             HouseInfo[hid][hSalePrice] = 0;
  757.             dini_IntSet(HouseFile(hid),"HouseForSale",0);
  758.             dini_IntSet(HouseFile(hid),"HouseSalePrice",0);
  759.             format(str,sizeof(str),hText,HouseInfo[hid][hName],HouseInfo[hid][hOwner],HouseInfo[hid][hPrice],YesOrNo(HouseInfo[hid][hForSale]),OpenOrClose(HouseInfo[hid][hPrivacy]));
  760.             Update3DTextLabelText(HouseInfo[hid][Text],-1,str);
  761.         }
  762.         if(row == 3)
  763.         {
  764.             new str[256];
  765.             new money = (HouseInfo[hid][hPrice] - (HouseInfo[hid][hPrice] / 4));
  766.             GivePlayerMoney(playerid,money);
  767.             format(HouseInfo[hid][hName], sizeof(str), "House For Sale!");
  768.             format(HouseInfo[hid][hOwner], sizeof(str), "No Owner");
  769.             dini_Set(HouseFile(hid),"HouseName","House For Sale!");
  770.             dini_Set(HouseFile(hid),"Owner","No Owner");
  771.             dini_IntSet(HouseFile(hid),"HouseForSale",1);
  772.             HouseInfo[hid][hForSale] = 1;
  773.             format(str,sizeof(str),hText,HouseInfo[hid][hName],HouseInfo[hid][hOwner],HouseInfo[hid][hPrice],YesOrNo(HouseInfo[hid][hForSale]),OpenOrClose(HouseInfo[hid][hPrivacy]));
  774.             Update3DTextLabelText(HouseInfo[hid][Text],-1,str);
  775.             ExitPlayerFromHouse(playerid,hid);
  776.             SendClientMessage(playerid,-1,"You sell your house.");
  777.             DestroyDynamicMapIcon(HouseIcon[hid]);
  778.             HouseIcon[hid] = CreateDynamicMapIcon(HouseInfo[hid][hCpX],HouseInfo[hid][hCpY],HouseInfo[hid][hCpZ],31,-1);
  779.         }
  780.     }
  781.     if(menuid == HMENUID+3)
  782.     {
  783.         if(row == 1)
  784.         {
  785.             ShowTdMenu(playerid,HMENUID+4);
  786.         }
  787.         if(row == 2)
  788.         {
  789.             ShowTdMenu(playerid,HMENUID+5);
  790.         }
  791.         if(row == 3)
  792.         {
  793.             new string[256];
  794.             ShowTdMenu(playerid,HMENUID+6);
  795.             format(string, sizeof(string), "You have $%d in your house storage.", HouseInfo[hid][hStorage]);
  796.             AddTdMenuInfoRowText(HMENUID+6,2,string);
  797.         }
  798.     }
  799.     if(menuid == HMENUID+7)
  800.     {
  801.         if(row == 1)
  802.         {
  803.             ShowTdMenu(playerid,HMENUID+8);
  804.         }
  805.         if(row == 2)
  806.         {
  807.             HouseInfo[hid][hPassword] = udb_hash("INVALID_PASSWORD");
  808.             dini_IntSet(HouseFile(hid),"HousePassword",HouseInfo[hid][hPassword]);
  809.             SendClientMessage(playerid,-1,"Successfully Removed");
  810.         }
  811.     }
  812.     if(menuid == HMENUID+9)
  813.     {
  814.         if(row == 1)
  815.         {
  816.             HouseInfo[hid][hPrivacy] = 1;
  817.             dini_IntSet(HouseFile(hid),"HousePrivacy",1);
  818.             new str[256];
  819.             format(str,sizeof(str),hText,HouseInfo[hid][hName],HouseInfo[hid][hOwner],HouseInfo[hid][hSalePrice],YesOrNo(HouseInfo[hid][hForSale]),OpenOrClose(HouseInfo[hid][hPrivacy]));
  820.             Update3DTextLabelText(HouseInfo[hid][Text],-1,str);
  821.         }
  822.         if(row == 2)
  823.         {
  824.             HouseInfo[hid][hPrivacy] = 0;
  825.             dini_IntSet(HouseFile(hid),"HousePrivacy",0);
  826.             new str[256];
  827.             format(str,sizeof(str),hText,HouseInfo[hid][hName],HouseInfo[hid][hOwner],HouseInfo[hid][hSalePrice],YesOrNo(HouseInfo[hid][hForSale]),OpenOrClose(HouseInfo[hid][hPrivacy]));
  828.             Update3DTextLabelText(HouseInfo[hid][Text],-1,str);
  829.         }
  830.     }
  831.     return 1;
  832. }
  833.  
  834. public Menu(mid,playerid,value[])
  835. {
  836.     new hid = GetPVarInt(playerid,"pHouseID");
  837.     if(mid == HMENUID+18)
  838.     {
  839.         if(strlen(value))
  840.         {
  841.             if(HouseInfo[hid][hPassword] == udb_hash(value))
  842.             {
  843.                 IsPlayerInHouse[playerid][hid] = 1;
  844.                 hCpIn[hid] = CreateDynamicCP(Interior[HouseInfo[hid][hInt]][iCpX],Interior[HouseInfo[hid][hInt]][iCpY],Interior[HouseInfo[hid][hInt]][iCpZ],1.5,-1,-1,-1,10);
  845.                 SetPlayerInInterior(playerid,HouseInfo[hid][hInt]);
  846.                 HideTdMenu(playerid,HMENUID+18);
  847.             }
  848.             else
  849.             {
  850.                 SendClientMessage(playerid,-1,"Wrong Password");
  851.             }
  852.         }
  853.     }
  854.     if(mid == HMENUID+1)
  855.     {
  856.         new str[256];
  857.         format(HouseInfo[hid][hName], 256,"%s", value);
  858.         dini_Set(HouseFile(hid),"HouseName",HouseInfo[hid][hName]);
  859.         format(str,sizeof(str),hText,HouseInfo[hid][hName],HouseInfo[hid][hOwner],HouseInfo[hid][hSalePrice],YesOrNo(HouseInfo[hid][hForSale]),OpenOrClose(HouseInfo[hid][hPrivacy]));
  860.         Update3DTextLabelText(HouseInfo[hid][Text],-1,str);
  861.         SendClientMessage(playerid,-1,"Successfully Changed");
  862.         ShowTdMenu(playerid,HMENUID);
  863.     }
  864.     if(mid == HMENUID+10)
  865.     {
  866.         new value2 = strval(value);
  867.         HouseInfo[hid][hForSale] = 1;
  868.         HouseInfo[hid][hSalePrice] = value2;
  869.         dini_IntSet(HouseFile(hid),"HouseForSale",1);
  870.         dini_IntSet(HouseFile(hid),"HouseSalePrice",value2);
  871.         new str[256];
  872.         format(str,sizeof(str),hText,HouseInfo[hid][hName],HouseInfo[hid][hOwner],HouseInfo[hid][hSalePrice],YesOrNo(HouseInfo[hid][hForSale]),OpenOrClose(HouseInfo[hid][hPrivacy]));
  873.         Update3DTextLabelText(HouseInfo[hid][Text],-1,str);
  874.         SendClientMessage(playerid,-1,"Successfully Seted");
  875.         ShowTdMenu(playerid,HMENUID+2);
  876.     }
  877.     if(mid == HMENUID+4)
  878.     {
  879.         new value2 = strval(value);
  880.         HouseInfo[hid][hStorage] = (HouseInfo[hid][hStorage] - value2);
  881.         dini_IntSet(HouseFile(hid),"HouseStorage",HouseInfo[hid][hStorage]);
  882.         GivePlayerMoney(playerid, value2);
  883.         SendClientMessage(playerid,-1,"Successfully Withdraw");
  884.         ShowTdMenu(playerid,HMENUID+3);
  885.     }
  886.     if(mid == HMENUID+5)
  887.     {
  888.         new value2 = strval(value);
  889.         HouseInfo[hid][hStorage] = (HouseInfo[hid][hStorage] + value2);
  890.         dini_IntSet(HouseFile(hid),"HouseStorage",HouseInfo[hid][hStorage]);
  891.         GivePlayerMoney(playerid, -value2);
  892.         SendClientMessage(playerid,-1,"Successfully Deposit");
  893.         ShowTdMenu(playerid,HMENUID+3);
  894.     }
  895.     if(mid == HMENUID+8)
  896.     {
  897.         HouseInfo[hid][hPassword] = udb_hash(value);
  898.         dini_IntSet(HouseFile(hid),"HousePassword",HouseInfo[hid][hPassword]);
  899.         SendClientMessage(playerid,-1,"Successfully Seted");
  900.         ShowTdMenu(playerid,HMENUID+7);
  901.     }
  902. }
  903. stock SetPlayerInInterior(playerid,Interiorid)
  904. {
  905.     SetPlayerInterior(playerid,Interior[Interiorid][iIntid]);
  906.     SetPlayerPos(playerid,Interior[Interiorid][iSpawnX],Interior[Interiorid][iSpawnY],Interior[Interiorid][iSpawnZ]);
  907.     SetPlayerFacingAngle(playerid,Interior[Interiorid][iSpawnA]);
  908.     SetCameraBehindPlayer(playerid);
  909. }
  910. stock SetPlayerPosEx(playerid,intrtiorid,Float:x,Float:y,Float:z,Float:ang)
  911. {
  912.     SetPlayerInterior(playerid,intrtiorid);
  913.     SetPlayerPos(playerid,x,y,z);
  914.     SetPlayerFacingAngle(playerid,ang);
  915.     SetCameraBehindPlayer(playerid);
  916. }
  917. stock ExitPlayerFromHouse(playerid,houseid)
  918. {
  919.     if(IsPlayerInHouse[playerid][houseid] == 1)
  920.     {
  921.         DestroyDynamicCP(hCpIn[houseid]);
  922.         SetPlayerPosEx(playerid,0,HouseInfo[houseid][hSpawnOutX],HouseInfo[houseid][hSpawnOutY],HouseInfo[houseid][hSpawnOutZ],HouseInfo[houseid][hSpawnOutA]);
  923.         IsPlayerInHouse[playerid][houseid] = 0;
  924.         DeletePVar(playerid,"pHouseID");
  925.     }
  926. }
  927.  
  928. public OnPlayerStateChange(playerid, newstate, oldstate)
  929. {
  930.     if(newstate == PLAYER_STATE_DRIVER)
  931.     {
  932.         foreach(Houses, hid)
  933.         {
  934.             if(GetPlayerVehicleID(playerid) == HouseCar[hid])
  935.             {
  936.                 IsOwner(playerid,hid)
  937.                 {
  938.                     SendClientMessage(playerid,-1,"Welcome Sir");
  939.                 }
  940.                 else
  941.                 {
  942.                     RemovePlayerFromVehicle(playerid);
  943.                 }
  944.             }
  945.         }
  946.     }
  947.     return 1;
  948. }
  949.  
  950. stock Float:GetPosInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
  951. {
  952.     new Float:a;
  953.     GetPlayerPos(playerid, x, y, a);
  954.     switch(IsPlayerInAnyVehicle(playerid))
  955.     {
  956.         case 0: GetPlayerFacingAngle(playerid, a);
  957.         case 1: GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
  958.     }
  959.     x += (distance * floatsin(-a, degrees));
  960.     y += (distance * floatcos(-a, degrees));
  961.     return a;
  962. }
  963. stock CreateHouse(playerid,Houseid,Price,Interiorid)
  964. {
  965.     new str[256];
  966.     new Float:X,Float:Y,Float:Z,Float:Angle;
  967.     GetPlayerPos(playerid, X, Y, Z);
  968.     GetPlayerFacingAngle(playerid, Angle);
  969.     HouseInfo[Houseid][hInt] = Interiorid;
  970.     HouseInfo[Houseid][hPrice] = Price;
  971.     HouseInfo[Houseid][hCpX] = X;
  972.     HouseInfo[Houseid][hCpY] = Y;
  973.     HouseInfo[Houseid][hCpZ] = Z;
  974.     HouseInfo[Houseid][hForSale] = 1;
  975.     HouseInfo[Houseid][hSalePrice] = Price;
  976.     HouseInfo[Houseid][hPrivacy] = 0;
  977.     HouseInfo[Houseid][hPassword] = udb_hash("INVALID_PASSWORD");
  978.     HouseInfo[Houseid][hStorage] = 0;
  979.     dini_Create(HouseFile(Houseid));
  980.     dini_Set(HouseFile(Houseid),"HouseName","House For Sale!");
  981.     dini_Set(HouseFile(Houseid),"Owner","No Owner");
  982.     dini_IntSet(HouseFile(Houseid),"HouseStorage",0);
  983.     dini_IntSet(HouseFile(Houseid),"HouseSalePrice",Price);
  984.     dini_IntSet(HouseFile(Houseid),"HouseInterior",Interiorid);
  985.     dini_IntSet(HouseFile(Houseid),"HouseForSale",1);
  986.     dini_IntSet(HouseFile(Houseid),"Price",Price);
  987.     dini_IntSet(HouseFile(Houseid),"HousePrivacy",0);
  988.     dini_IntSet(HouseFile(Houseid),"HousePassword",udb_hash("INVALID_PASSWORD"));
  989.     dini_FloatSet(HouseFile(Houseid),"CpX",X);
  990.     dini_FloatSet(HouseFile(Houseid),"CpY",Y);
  991.     dini_FloatSet(HouseFile(Houseid),"CpZ",Z);
  992.     format(HouseInfo[Houseid][hName],35,"House For Sale!");
  993.     format(HouseInfo[Houseid][hOwner],256,"No Owner");
  994.     format(str,sizeof(str),hText,HouseInfo[Houseid][hName],HouseInfo[Houseid][hOwner],Price,YesOrNo(HouseInfo[Houseid][hForSale]),OpenOrClose(HouseInfo[Houseid][hPrivacy]));
  995.     HouseInfo[Houseid][Text] = Create3DTextLabel(str,-1,X, Y, Z+0.7,20,0);
  996.     GetPosInFrontOfPlayer(playerid, X, Y, -2.5);
  997.     dini_FloatSet(HouseFile(Houseid),"SpawnOutX",X);
  998.     dini_FloatSet(HouseFile(Houseid),"SpawnOutY",Y);
  999.     dini_FloatSet(HouseFile(Houseid),"SpawnOutZ",Z);
  1000.     dini_FloatSet(HouseFile(Houseid),"SpawnOutAngle", (180.0 + Angle));
  1001.     HouseInfo[Houseid][hSpawnOutX] = X;
  1002.     HouseInfo[Houseid][hSpawnOutY] = Y;
  1003.     HouseInfo[Houseid][hSpawnOutZ] = Z;
  1004.     HouseInfo[Houseid][hSpawnOutA] = (180.0 + Angle);
  1005.     hCpOut[Houseid] = CreateDynamicCP(HouseInfo[Houseid][hCpX],HouseInfo[Houseid][hCpY],HouseInfo[Houseid][hCpZ],1.5,-1,-1,-1,MAX_DIST);
  1006.     hCpIn[Houseid] = CreateDynamicCP(Interior[HouseInfo[Houseid][hInt]][iCpX],Interior[HouseInfo[Houseid][hInt]][iCpY],Interior[HouseInfo[Houseid][hInt]][iCpZ],1.5,-1,-1,-1,MAX_DIST);
  1007.     Iter_Add(Houses, Houseid);
  1008. }
  1009.  
  1010. stock SpawnHouse(Houseid)
  1011. {
  1012.     hCpOut[Houseid] = CreateDynamicCP(HouseInfo[Houseid][hCpX],HouseInfo[Houseid][hCpY],HouseInfo[Houseid][hCpZ],1.5,-1,-1,-1,MAX_DIST);
  1013.     new str[256];
  1014.     if(HouseInfo[Houseid][hForSale] == 1)
  1015.     {
  1016.         format(str,sizeof(str),hText,HouseInfo[Houseid][hName],HouseInfo[Houseid][hOwner],HouseInfo[Houseid][hSalePrice],YesOrNo(HouseInfo[Houseid][hForSale]),OpenOrClose(HouseInfo[Houseid][hPrivacy]));
  1017.     }
  1018.     else
  1019.     {
  1020.         format(str,sizeof(str),hText,HouseInfo[Houseid][hName],HouseInfo[Houseid][hOwner],HouseInfo[Houseid][hPrice],YesOrNo(HouseInfo[Houseid][hForSale]),OpenOrClose(HouseInfo[Houseid][hPrivacy]));
  1021.     }
  1022.     HouseInfo[Houseid][Text] = Create3DTextLabel(str,-1,HouseInfo[Houseid][hCpX],HouseInfo[Houseid][hCpY],HouseInfo[Houseid][hCpZ]+0.7,20,0);
  1023.     HouseCar[Houseid] = CreateVehicle(HouseInfo[Houseid][vModel],HouseInfo[Houseid][hVehX],HouseInfo[Houseid][hVehY],HouseInfo[Houseid][hVehZ],HouseInfo[Houseid][hVehA],0,0,9999);
  1024.     if(!strcmp(HouseInfo[Houseid][hOwner], "No Owner", true))
  1025.     {
  1026.         HouseIcon[Houseid] = CreateDynamicMapIcon(HouseInfo[Houseid][hCpX],HouseInfo[Houseid][hCpY],HouseInfo[Houseid][hCpZ],31,-1);
  1027.     }
  1028.     else
  1029.     {
  1030.         HouseIcon[Houseid] = CreateDynamicMapIcon(HouseInfo[Houseid][hCpX],HouseInfo[Houseid][hCpY],HouseInfo[Houseid][hCpZ],32,-1);
  1031.     }
  1032. }
  1033.  
  1034. stock LoadHouses()
  1035. {
  1036.     Loop(Houseid,MAX_HOUSES,0)
  1037.     {
  1038.         if(fexist(HouseFile(Houseid)))
  1039.         {
  1040.             format(HouseInfo[Houseid][hName],35,"%s",dini_Get(HouseFile(Houseid),"HouseName"));
  1041.             format(HouseInfo[Houseid][hOwner],35,"%s",dini_Get(HouseFile(Houseid),"Owner"));
  1042.             HouseInfo[Houseid][hPassword] = dini_Int(HouseFile(Houseid),"HousePassword");
  1043.             HouseInfo[Houseid][hInt] = dini_Int(HouseFile(Houseid),"HouseInterior");
  1044.             HouseInfo[Houseid][hForSale] = dini_Int(HouseFile(Houseid),"HouseForSale");
  1045.             HouseInfo[Houseid][hSalePrice] = dini_Int(HouseFile(Houseid),"HouseSalePrice");
  1046.             HouseInfo[Houseid][hPrice] = dini_Int(HouseFile(Houseid),"Price");
  1047.             HouseInfo[Houseid][hStorage] = dini_Int(HouseFile(Houseid),"HouseStorage");
  1048.             HouseInfo[Houseid][hPrivacy] = dini_Int(HouseFile(Houseid),"HousePrivacy");
  1049.             HouseInfo[Houseid][hSpawnOutX] = dini_Float(HouseFile(Houseid),"SpawnOutX");
  1050.             HouseInfo[Houseid][hSpawnOutY] = dini_Float(HouseFile(Houseid),"SpawnOutY");
  1051.             HouseInfo[Houseid][hSpawnOutZ] = dini_Float(HouseFile(Houseid),"SpawnOutZ");
  1052.             HouseInfo[Houseid][hSpawnOutA] = dini_Float(HouseFile(Houseid),"SpawnOutAngle");
  1053.             HouseInfo[Houseid][hCpX] = dini_Float(HouseFile(Houseid),"CpX");
  1054.             HouseInfo[Houseid][hCpY] = dini_Float(HouseFile(Houseid),"CpY");
  1055.             HouseInfo[Houseid][hCpZ] = dini_Float(HouseFile(Houseid),"CpZ");
  1056.             HouseInfo[Houseid][vModel] = dini_Int(HouseFile(Houseid),"vModel");
  1057.             HouseInfo[Houseid][hVehX] = dini_Float(HouseFile(Houseid),"vX");
  1058.             HouseInfo[Houseid][hVehY] = dini_Float(HouseFile(Houseid),"vY");
  1059.             HouseInfo[Houseid][hVehZ] = dini_Float(HouseFile(Houseid),"vZ");
  1060.             HouseInfo[Houseid][hVehA] = dini_Float(HouseFile(Houseid),"vAng");
  1061.             SpawnHouse(Houseid);
  1062.             CH ++;
  1063.             Iter_Add(Houses, Houseid);
  1064.         }
  1065.     }
  1066.     return printf("Created Houses:%d\n",CH);
  1067. }
  1068. stock LoadInteriors()
  1069. {
  1070.     Loop(Intid,MAX_INTERIORS,0)
  1071.     {
  1072.         if(fexist(InteriorFile(Intid)))
  1073.         {
  1074.             Interior[Intid][iIntid] = dini_Int(InteriorFile(Intid),"Interior");
  1075.             Interior[Intid][iCpX] = dini_Float(InteriorFile(Intid),"CPX");
  1076.             Interior[Intid][iCpY] = dini_Float(InteriorFile(Intid),"CPY");
  1077.             Interior[Intid][iCpZ] = dini_Float(InteriorFile(Intid),"CPZ");
  1078.             Interior[Intid][iSpawnX] = dini_Float(InteriorFile(Intid),"SpawnX");
  1079.             Interior[Intid][iSpawnY] = dini_Float(InteriorFile(Intid),"SpawnY");
  1080.             Interior[Intid][iSpawnZ] = dini_Float(InteriorFile(Intid),"SpawnZ");
  1081.             CI ++;
  1082.         }
  1083.     }
  1084.     return printf("Houses Interiors Created:%d\n",CI);
  1085. }
  1086.  
  1087. public OnFilterScriptExit()
  1088. {
  1089.     Iter_Clear(Houses);
  1090.     return 1;
  1091. }
  1092.  
  1093. stock GetFreeHouseID()
  1094. {
  1095.     Loop(Houseid,MAX_HOUSES,0)
  1096.     {
  1097.         if(!fexist(HouseFile(Houseid)))
  1098.         {
  1099.             return Houseid;
  1100.         }
  1101.     }
  1102.     return -1;
  1103. }
  1104.  
  1105. stock GetOwnedHouses(playerid)
  1106. {
  1107.     new count;
  1108.     foreach(Houses, h)
  1109.     {
  1110.         IsOwner(playerid,h)
  1111.         {
  1112.             count++;
  1113.         }
  1114.     }
  1115.     return count;
  1116. }
  1117.  
  1118. stock LoadUserFile(playerid)
  1119. {
  1120.     new file[128];
  1121.     format(file, sizeof(file), uPath, pName(playerid));
  1122.     if(dini_Exists(file))
  1123.     {
  1124.         new value = (dini_Int(file,"MoneyToPlayer") + dini_Int(file,"MoneyToHouse"));
  1125.         GivePlayerMoney(playerid,(dini_Int(file,"MoneyToPlayer") + dini_Int(file,"MoneyToHouse")));
  1126.         new str[1000];
  1127.         format(str,sizeof(str),"Your house %s has been sold to %s while you were offline.",dini_Get(file,"HouseName"),dini_Get(file,"Buyer"));
  1128.         SendClientMessage(playerid,-1,str);
  1129.         format(str,sizeof(str),"You receive: $%d House Storage: $%d House Price: $%d",value,dini_Int(file,"MoneyToHouse"),dini_Int(file,"MoneyToPlayer"));
  1130.         SendClientMessage(playerid,-1,str);
  1131.         dini_Remove(file);
  1132.     }
  1133. }
  1134.  
  1135. stock YesOrNo(i)
  1136. {
  1137.     new yon[128];
  1138.     if(i == 0){format(yon,sizeof(yon),"No");}
  1139.     if(i == 1){format(yon,sizeof(yon),"Yes");}
  1140.     return yon;
  1141. }
  1142.  
  1143. stock OpenOrClose(i)
  1144. {
  1145.     new ooc[128];
  1146.     if(i == 0){format(ooc,sizeof(ooc),"Closed");}
  1147.     if(i == 1){format(ooc,sizeof(ooc),"Open");}
  1148.     return ooc;
  1149. }
  1150.  
  1151. stock AddS(amount) // By [03]Garsino.
  1152. {
  1153.     new returnstring[2];
  1154.     format(returnstring, 2, "");
  1155.     if(amount != 1 && amount != -1)
  1156.     {
  1157.         format(returnstring, 2, "s");
  1158.     }
  1159.     return returnstring;
  1160. }
  1161.  
  1162. stock pName(playerid)
  1163. {
  1164.     new Nick[MAX_PLAYER_NAME];
  1165.     GetPlayerName(playerid, Nick, MAX_PLAYER_NAME);
  1166.     return Nick;
  1167. }
  1168. stock HouseFile(houseid)
  1169. {
  1170.     new filename[128];
  1171.     format(filename, sizeof(filename), hPath, houseid);
  1172.     return filename;
  1173. }
  1174. stock InteriorFile(Interiorid)
  1175. {
  1176.     new filename[128];
  1177.     format(filename, sizeof(filename), iPath, Interiorid);
  1178.     return filename;
  1179. }
  1180. stock UserFile(playerid)
  1181. {
  1182.     new filename[128];
  1183.     format(filename, sizeof(filename), uPath, pName(playerid));
  1184.     return filename;
  1185. }
  1186.  
  1187. stock udb_hash(buf[]) // By DracoBlue
  1188. {
  1189.     new length = strlen(buf), s1 = 1, s2;
  1190.     Loop(n, length, 0)
  1191.     {
  1192.        s1 = (s1 + buf[n]) % 65521, s2 = (s2 + s1)     % 65521;
  1193.     }
  1194.     return (s2 << 16) + s1;
  1195. }
Advertisement
Add Comment
Please, Sign In to add comment