Guest User

[___]PotH3Ad

a guest
Apr 28th, 2010
1,012
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 39.71 KB | None | 0 0
  1. //Version 0.8
  2. //Fixed minor bug with messages/dialogs (Thanks to [LF]Mr.Lucci for reporting this)
  3. //Added House Purchase & Sell Messages (Optional)
  4. //Fixed a bug after setting a house's virtual world.
  5. //Added virtual world's & Owner in /hinfo dialog
  6.  
  7. #include <a_samp>
  8. #include <dini>
  9. #include <zcmd>
  10. #include <streamer>
  11.  
  12. //|0 = Disable | 1 = Enable
  13. #define HMESSAGES 1 //Enable House purchase/sell messages.
  14.  
  15. #define DABOX 9164
  16. #define MAX_HOUSES 100
  17.  
  18. #define COLOR_BLUE 0x1C10EFFF
  19. #define COLOR_RED 0xC93639FF
  20.  
  21. #define ADMINLINE IsPlayerAdmin(playerid)
  22.  
  23. new hfile[256];
  24. new idfile[256];
  25.  
  26. new HEnterCP[MAX_HOUSES];
  27. new HExitCP[MAX_HOUSES];
  28. new Text3D:HLabel[MAX_HOUSES];
  29. new HMarker[MAX_HOUSES];
  30.  
  31. public OnFilterScriptInit()
  32. {
  33.     SetTimer("UpdateHouses", 15000, 1);
  34.     for(new i=0; i<TotalHouses(); i++)
  35.     {
  36.         DisableInteriorEnterExits();
  37.         format(hfile, sizeof(hfile), "/Houses/%d.ini", i);
  38.         new Float:ECPX; ECPX = dini_Float(hfile, "ECPX");
  39.         new Float:ECPY; ECPY = dini_Float(hfile, "ECPY");
  40.         new Float:ECPZ; ECPZ = dini_Float(hfile, "ECPZ");
  41.         new Float:ICPX; ICPX = dini_Float(hfile, "ICPX");
  42.         new Float:ICPY; ICPY = dini_Float(hfile, "ICPY");
  43.         new Float:ICPZ; ICPZ = dini_Float(hfile, "ICPZ");
  44.         new hname[256]; hname = dini_Get(hfile, "Name");
  45.         new hprice; hprice = dini_Int(hfile, "Price");
  46.         new howner[256]; howner = dini_Get(hfile, "Owner");
  47.         new hworld; hworld = dini_Int(hfile, "World");
  48.         new str[250]; format(str, sizeof(str), "Name: %s\nPrice: %d\nOwner: %s", hname, hprice, howner);
  49.         if(dini_Int(hfile, "CPSet") == 1) {
  50.             HEnterCP[i] = CreateDynamicCP(ECPX, ECPY, ECPZ, 1, -1, -1, -1, 25);
  51.             HExitCP[i] = CreateDynamicCP(ICPX, ICPY, ICPZ, 1, hworld, -1, -1, 25);
  52.             HLabel[i] = CreateDynamic3DTextLabel(str, COLOR_BLUE, ECPX, ECPY, ECPZ+1, 40, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 40.0);
  53.             HMarker[i] = CreateDynamicMapIcon(ECPX, ECPY, ECPZ, 31, 0, -1, -1, -1, 45);
  54.         }
  55.     }
  56.     return 1;
  57. }
  58.  
  59. public OnFilterScriptExit()
  60. {
  61.     DestroyAllDynamicCPs();
  62.     DestroyAllDynamic3DTextLabels();
  63.     DestroyAllDynamicMapIcons();
  64. }
  65.  
  66. CMD:hcreate(playerid, params[]) {
  67.     format(idfile, sizeof(idfile), "/Houses/ids.ini");
  68.     if(IsEditing(playerid) == 1) return SendClientMessage(playerid, COLOR_RED, "You are already editing a house!");
  69.     if(!ADMINLINE) return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
  70.     if(!dini_Exists(idfile)) dini_Create(idfile), dini_IntSet(idfile, "ID", 0);
  71.     else dini_IntSet(idfile, "ID", dini_Int(idfile, "ID")+1);
  72.  
  73.     new str[128];
  74.     format(hfile, sizeof(hfile), "/Houses/%d.ini", dini_Int(idfile, "ID"));
  75.  
  76.     dini_Create(hfile);
  77.     SetPVarInt(playerid, "EditID", dini_Int(idfile, "ID"));
  78.     SetPVarInt(playerid, "Editing", 1);
  79.     format(str, sizeof(str), "You are now editing House [ID:%d]", dini_Int(idfile, "ID"));
  80.     SendClientMessage(playerid, COLOR_BLUE, str);
  81.     ShowPlayerDialog(playerid, DABOX, DIALOG_STYLE_LIST, "House Edit - Menu", "Entrance Checkpoint\nExit Checkpoint\nSet Enter Coords\nSet Exit Coords\nSet House Name\nSet House Price\nTeleport\nSet Virtual World", "Ok", "Cancel");
  82.     return 1;
  83. }
  84. CMD:hedit(playerid, params[]) {
  85.     if(IsEditing(playerid) == 0) return SendClientMessage(playerid, COLOR_RED, "You have not yet created a house!");
  86.     if(!ADMINLINE) return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
  87.     ShowPlayerDialog(playerid, DABOX, DIALOG_STYLE_LIST, "House Edit - Menu", "Entrance Checkpoint\nExit Checkpoint\nSet Enter Coords\nSet Exit Coords\nSet House Name\nSet House Price\nTeleport\nSet Virtual World", "Ok", "Cancel");
  88.     return 1;
  89. }
  90. CMD:hsetcp(playerid, params[]) {
  91.     format(hfile, sizeof(hfile), "/Houses/%d.ini", GetPlayerHouseID(playerid));
  92.     if(IsEditing(playerid) == 0) return SendClientMessage(playerid, COLOR_RED, "You are not editing a house!");
  93.     if(!ADMINLINE) return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
  94.  
  95.     new Float:X, Float:Y, Float:Z;
  96.     GetPlayerPos(playerid, X, Y, Z);
  97.  
  98.     dini_FloatSet(hfile, "ECPX", X);
  99.     dini_FloatSet(hfile, "ECPY", Y);
  100.     dini_FloatSet(hfile, "ECPZ", Z);
  101.     dini_IntSet(hfile, "CPSet", 1);
  102.  
  103.     DestroyDynamicMapIcon(HMarker[GetPlayerHouseID(playerid)]);
  104.     DestroyDynamicCP(HEnterCP[GetPlayerHouseID(playerid)]);
  105.     HEnterCP[GetPlayerHouseID(playerid)] = CreateDynamicCP(X, Y, Z, 1, -1, -1, -1, 25);
  106.     HMarker[GetPlayerHouseID(playerid)] = CreateDynamicMapIcon(X, Y, Z, 31, 0, -1, -1, -1, 45);
  107.  
  108.     new str[128];
  109.     format(str, sizeof(str), "House [ID:%d]'s enter checkpoint has been set to - X: %f, Y: %f, Z: %f.", GetPlayerHouseID(playerid), X, Y, Z);
  110.     ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Edit - Enter CP", str, "Ok", "Cancel");
  111.     SendClientMessage(playerid, COLOR_BLUE, str);
  112.     return 1;
  113. }
  114. CMD:hsetenterpos(playerid, params[]) {
  115.     format(hfile, sizeof(hfile), "/Houses/%d.ini", GetPlayerHouseID(playerid));
  116.     if(IsEditing(playerid) == 0) return SendClientMessage(playerid, COLOR_RED, "You are not editing a house!");
  117.     if(!ADMINLINE) return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
  118.  
  119.     new Float:X, Float:Y, Float:Z;
  120.     GetPlayerPos(playerid, X, Y, Z);
  121.  
  122.     dini_FloatSet(hfile, "ENTX", X);
  123.     dini_FloatSet(hfile, "ENTY", Y);
  124.     dini_FloatSet(hfile, "ENTZ", Z);
  125.     dini_IntSet(hfile, "Interior", GetPlayerInterior(playerid));
  126.  
  127.     new str[128];
  128.     format(str, sizeof(str), "House [ID:%d]'s enter position has been set to - X: %f, Y: %f, Z: %f [Interior:%d]", GetPlayerHouseID(playerid), X, Y, Z, GetPlayerInterior(playerid));
  129.     ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Edit - Enter Coords", str, "Ok", "Cancel");
  130.     SendClientMessage(playerid, COLOR_BLUE, str);
  131.     return 1;
  132. }
  133. CMD:hsetexitpos(playerid, params[]) {
  134.     format(hfile, sizeof(hfile), "/Houses/%d.ini", GetPlayerHouseID(playerid));
  135.     if(IsEditing(playerid) == 0) return SendClientMessage(playerid, COLOR_RED, "You are not editing a house!");
  136.     if(!ADMINLINE) return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
  137.  
  138.     new Float:X, Float:Y, Float:Z;
  139.     GetPlayerPos(playerid, X, Y, Z);
  140.  
  141.     dini_FloatSet(hfile, "EXITX", X);
  142.     dini_FloatSet(hfile, "EXITY", Y);
  143.     dini_FloatSet(hfile, "EXITZ", Z);
  144.     dini_IntSet(hfile, "Interior2", GetPlayerInterior(playerid));
  145.  
  146.     new str[128];
  147.     format(str, sizeof(str), "House [ID:%d] exit position has been set to - X: %f, Y: %f, Z: %f.", GetPlayerHouseID(playerid), X, Y, Z);
  148.     ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Edit - Exit Coords", str, "Ok", "Cancel");
  149.     SendClientMessage(playerid, COLOR_BLUE, str);
  150.     return 1;
  151. }
  152. CMD:hsetintcp(playerid, params[]) {
  153.     format(hfile, sizeof(hfile), "/Houses/%d.ini", GetPlayerHouseID(playerid));
  154.     if(IsEditing(playerid) == 0) return SendClientMessage(playerid, COLOR_RED, "You are not editing a house!");
  155.     if(!ADMINLINE) return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
  156.  
  157.     new Float:X, Float:Y, Float:Z;
  158.     GetPlayerPos(playerid, X, Y, Z);
  159.  
  160.     dini_FloatSet(hfile, "ICPX", X);
  161.     dini_FloatSet(hfile, "ICPY", Y);
  162.     dini_FloatSet(hfile, "ICPZ", Z);
  163.     new hworld; hworld = dini_Int(hfile, "World");
  164.  
  165.     DestroyDynamicCP(HExitCP[GetPlayerHouseID(playerid)]);
  166.     HExitCP[GetPlayerHouseID(playerid)] = CreateDynamicCP(X, Y, Z, 1, hworld, -1, -1, 25);
  167.  
  168.     new str[128];
  169.     format(str, sizeof(str), "House [ID:%d] exit checkpoint has been set to - X: %f, Y: %f, Z: %f.", GetPlayerHouseID(playerid), X, Y, Z);
  170.     ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Edit - Exit CP", str, "Ok", "Cancel");
  171.     SendClientMessage(playerid, COLOR_BLUE, str);
  172.     return 1;
  173. }
  174. CMD:hsetname(playerid, params[]) {
  175.     format(hfile, sizeof(hfile), "/Houses/%d.ini", GetPlayerHouseID(playerid));
  176.     if(IsEditing(playerid) == 0) return SendClientMessage(playerid, COLOR_RED, "You are not editing a house!");
  177.     if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: '/hsetname <name>'");
  178.     if(!ADMINLINE) return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
  179.  
  180.     new hname[128];
  181.     sscanf(params, "s", hname);
  182.     dini_Set(hfile, "Name", hname);
  183.  
  184.     new Float:ECPX; ECPX = dini_Float(hfile, "ECPX");
  185.     new Float:ECPY; ECPY = dini_Float(hfile, "ECPY");
  186.     new Float:ECPZ; ECPZ = dini_Float(hfile, "ECPZ");
  187.  
  188.     new hprice; hprice = dini_Int(hfile, "Price");
  189.     new howner[256]; howner = dini_Get(hfile, "Owner");
  190.     new str[250]; format(str, sizeof(str), "Name: %s\nPrice: %d\nOwner: %s", hname, hprice, howner);
  191.  
  192.     DestroyDynamic3DTextLabel(HLabel[GetPlayerHouseID(playerid)]);
  193.     HLabel[GetPlayerHouseID(playerid)] = CreateDynamic3DTextLabel(str, COLOR_BLUE, ECPX, ECPY, ECPZ+1, 40, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 40.0);
  194.  
  195.     format(str, sizeof(str), "House [ID:%d] name is now '%s'!", GetPlayerHouseID(playerid), hname);
  196.     ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Edit - Set Name", str, "Ok", "Cancel");
  197.     SendClientMessage(playerid, COLOR_BLUE, str);
  198.     return 1;
  199. }
  200. CMD:hsetworld(playerid, params[]) {
  201.     format(hfile, sizeof(hfile), "/Houses/%d.ini", GetPlayerHouseID(playerid));
  202.     if(IsEditing(playerid) == 0) return SendClientMessage(playerid, COLOR_RED, "You are not editing a house!");
  203.     if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: '/hsetworld <worldid>'");
  204.     if(!ADMINLINE) return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
  205.  
  206.     new hworld;
  207.     sscanf(params, "i", hworld);
  208.     dini_IntSet(hfile, "World", hworld);
  209.  
  210.     new str[128];
  211.     format(str, sizeof(str), "House [ID:%d]'s virtual world is now '%d'!", GetPlayerHouseID(playerid), hworld);
  212.     ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Edit - Set World", str, "Ok", "Cancel");
  213.     SendClientMessage(playerid, COLOR_BLUE, str);
  214.     return 1;
  215. }
  216. CMD:hsetprice(playerid, params[]) {
  217.     format(hfile, sizeof(hfile), "/Houses/%d.ini", GetPlayerHouseID(playerid));
  218.     if(IsEditing(playerid) == 0) return SendClientMessage(playerid, COLOR_RED, "You are not editing a house!");
  219.     if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: '/hsetprice <price>'");
  220.     if(!ADMINLINE) return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
  221.  
  222.     new hprice;
  223.     sscanf(params, "i", hprice);
  224.     dini_IntSet(hfile, "Price", hprice);
  225.  
  226.     new Float:ECPX; ECPX = dini_Float(hfile, "ECPX");
  227.     new Float:ECPY; ECPY = dini_Float(hfile, "ECPY");
  228.     new Float:ECPZ; ECPZ = dini_Float(hfile, "ECPZ");
  229.  
  230.     new howner[256]; howner = dini_Get(hfile, "Owner");
  231.     new hname[256]; hname = dini_Get(hfile, "Name");
  232.     new str[250]; format(str, sizeof(str), "Name: %s\nPrice: %d\nOwner: %s", hname, hprice, howner);
  233.  
  234.     DestroyDynamic3DTextLabel(HLabel[GetPlayerHouseID(playerid)]);
  235.     HLabel[GetPlayerHouseID(playerid)] = CreateDynamic3DTextLabel(str, COLOR_BLUE, ECPX, ECPY, ECPZ+1, 40, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 40.0);
  236.  
  237.     format(str, sizeof(str), "House [ID:%d]'s price is now '%d'!", GetPlayerHouseID(playerid), hprice);
  238.     ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Edit - Set Price", str, "Ok", "Exit");
  239.     SendClientMessage(playerid, COLOR_BLUE, str);
  240.     return 1;
  241. }
  242. CMD:hcancel(playerid, params[]) {
  243.     format(idfile, sizeof(idfile), "/Houses/ids.ini");
  244.     format(hfile, sizeof(hfile), "/Houses/%d.ini", GetPlayerHouseID(playerid));
  245.     if(IsEditing(playerid) == 0) return SendClientMessage(playerid, COLOR_RED, "You are not currently editing a house!");
  246.     if(!ADMINLINE) return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
  247.  
  248.     DestroyDynamicCP(HExitCP[GetPlayerHouseID(playerid)]);
  249.     DestroyDynamicCP(HEnterCP[GetPlayerHouseID(playerid)]);
  250.     DestroyDynamic3DTextLabel(HLabel[GetPlayerHouseID(playerid)]);
  251.     DestroyDynamicMapIcon(HMarker[GetPlayerHouseID(playerid)]);
  252.  
  253.     dini_Remove(hfile);
  254.     dini_IntSet(idfile, "ID", dini_Int(idfile, "ID")-1);
  255.     SetPVarInt(playerid, "EditID", -1);
  256.     SetPVarInt(playerid, "Editing", 0);
  257.     SendClientMessage(playerid, COLOR_BLUE, "You have canceled the current house editing!");
  258.     return 1;
  259. }
  260. CMD:hdone(playerid, params[]) {
  261.     if(IsEditing(playerid) == 0) return SendClientMessage(playerid, COLOR_RED, "You are not currently editing a house!");
  262.     if(!ADMINLINE) return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
  263.  
  264.     new str[50];
  265.     format(str, sizeof(str), "You have finished editing House [ID:%d]!", GetPlayerHouseID(playerid));
  266.     SendClientMessage(playerid, COLOR_BLUE, str);
  267.     SetPVarInt(playerid, "EditID", -1);
  268.     SetPVarInt(playerid, "Editing", 0);
  269.     return 1;
  270. }
  271. CMD:hopen(playerid, params[]) {
  272.     if(IsEditing(playerid) == 1) return SendClientMessage(playerid, COLOR_RED, "You are already editing a house!");
  273.     if(!ADMINLINE) return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
  274.     new hid;
  275.     sscanf(params, "i", hid);
  276.     format(hfile, sizeof(hfile), "/Houses/%d.ini", hid);
  277.     if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: '/hopen <houseid>'");
  278.     if(!dini_Exists(hfile)) return SendClientMessage(playerid, COLOR_RED, "ERROR: That house id does not exist!");
  279.  
  280.     SetPVarInt(playerid, "EditID", hid);
  281.     SetPVarInt(playerid, "Editing", 1);
  282.     new str[50];
  283.     format(str, sizeof(str), "You are now editing House [ID:%d]", hid);
  284.     SendClientMessage(playerid, COLOR_BLUE, str);
  285.     ShowPlayerDialog(playerid, DABOX, DIALOG_STYLE_LIST, "House Edit - Menu", "Entrance Checkpoint\nExit Checkpoint\nSet Enter Coords\nSet Exit Coords\nSet House Name\nSet House Price\nTeleport\nSet Virtual World", "Ok", "Cancel");
  286.     return 1;
  287. }
  288. CMD:hgoto(playerid, params[]) {
  289.     format(hfile, sizeof(hfile), "/Houses/%d.ini", GetPlayerHouseID(playerid));
  290.     if(IsEditing(playerid) == 0) return SendClientMessage(playerid, COLOR_RED, "You are not editing a house!");
  291.     if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: '/hgoto [enter/exit]'");
  292.     if(!ADMINLINE) return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
  293.  
  294.     if(strcmp(params,"enter",true) == 0) {
  295.         new Float:X; X = dini_Float(hfile, "ENTX");
  296.         new Float:Y; Y = dini_Float(hfile, "ENTY");
  297.         new Float:Z; Z = dini_Float(hfile, "ENTZ");
  298.         new Interior; Interior = dini_Int(hfile, "Interior");
  299.         new hworld; hworld = dini_Int(hfile, "World");
  300.         SetPlayerAt(playerid, X, Y, Z, Interior, hworld);
  301.         SendClientMessage(playerid, COLOR_BLUE, "Teleported to entrance coords.");
  302.     }
  303.     else if(strcmp(params, "exit", true) == 0) {
  304.         new Float:X; X = dini_Float(hfile, "EXITX");
  305.         new Float:Y; Y = dini_Float(hfile, "EXITY");
  306.         new Float:Z; Z = dini_Float(hfile, "EXITZ");
  307.         SetPlayerAt(playerid, X, Y, Z, 0, 0);
  308.         SendClientMessage(playerid, COLOR_BLUE, "Teleported to exit coords.");
  309.     }
  310.     else {
  311.         SendClientMessage(playerid, COLOR_BLUE, "USAGE: '/hgoto [enter/exit]'");
  312.     }
  313.     return 1;
  314. }
  315. CMD:hdelete(playerid, params[]) {
  316.     new hid;
  317.     sscanf(params, "i", hid);
  318.     format(hfile, sizeof(hfile), "/Houses/%d.ini", hid);
  319.     if(!dini_Exists(hfile)) return SendClientMessage(playerid, COLOR_RED, "ERROR: That house id does not exist!");
  320.     if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: '/hdelete <houseid>'");
  321.     if(!ADMINLINE) return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
  322.     if(hid == GetPlayerHouseID(playerid))
  323.     {
  324.         SetPVarInt(playerid, "EditID", hid);
  325.         SetPVarInt(playerid, "Editing", 1);
  326.     }
  327.     new str[50];
  328.     format(str, sizeof(str), "You have deleted House [ID:%d]", hid);
  329.     SendClientMessage(playerid, COLOR_BLUE, str);
  330.     ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Edit - Delete", str, "Ok", "Exit");
  331.     return 1;
  332. }
  333. CMD:hdebug(playerid, params[]) {
  334.     new hid;
  335.     sscanf(params, "i", hid);
  336.     if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "You must enter a house ID.");
  337.     if(!ADMINLINE) return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
  338.     format(idfile, sizeof(idfile), "/Houses/ids.ini");
  339.     format(hfile, sizeof(hfile), "/Houses/%d.ini", GetPlayerHouseID(playerid));
  340.     new id; id = dini_Int(idfile, "ID");
  341.     new thouses; thouses = TotalHouses();
  342.     new str[128];
  343.     format(str, sizeof(str), "ID File: %d\nTotal Houses: %d\n", id, thouses);
  344.     ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Debug", str, "", "Exit");
  345.     return 1;
  346. }
  347. CMD:hinfo(playerid, params[]) {
  348.     new hid;
  349.     sscanf(params, "i", hid);
  350.     format(hfile, sizeof(hfile), "/Houses/%d.ini", hid);
  351.     if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "You must enter a house ID.");
  352.     if(!dini_Exists(hfile)) return SendClientMessage(playerid, COLOR_RED, "This House ID does not exist!");
  353.     if(!ADMINLINE) return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
  354.     new hname[256]; hname = dini_Get(hfile, "Name");
  355.     new hprice; hprice = dini_Int(hfile, "Price");
  356.     new Interior; Interior = dini_Int(hfile, "Interior");
  357.     new howner[256]; howner = dini_Get(hfile, "Owner");
  358.     new hworld; hworld = dini_Int(hfile, "World");
  359.     new str[128];
  360.     format(str, sizeof(str), "House Name: %s\nOwner: %s\nPrice: %d\nInterior: %d\nVirtual World: %d", hname, howner, hprice, Interior, hworld);
  361.     ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Info", str, "", "Exit");
  362.     return 1;
  363. }
  364. CMD:hcmds(playerid, params[]) {
  365.     if(ADMINLINE) ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Commands", "/hdelete <houseid>\n/hgoto <entercp/exitcp>\nhopen <houseid>\n/hdone\n/hcancel\n/hsetprice\n/hsetname\n/hsetintcp\n/hsetcp\n/hsetexitpos\n/hsetenterpos\n/hedit\n/hcreate\n/hdebug\n/hinfo <houseid>\n", "", "Exit");
  366.     else if(!ADMINLINE) return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
  367.     return 1;
  368. }
  369.  
  370. public OnPlayerEnterDynamicCP(playerid, checkpointid)
  371. {
  372.     for(new x=0; x<TotalHouses(); x++)
  373.     {
  374.         if(checkpointid == HEnterCP[x])
  375.         {
  376.             if(IsEditing(playerid) == 1) return 1;
  377.             SetPVarInt(playerid, "EntID", x);
  378.             ShowPlayerDialog(playerid, DABOX+2, DIALOG_STYLE_LIST, "House Menu", "Enter House\nPurchase House\nSet Password\nSell House", "Ok", "Cancel");
  379.         }
  380.         else if(checkpointid == HExitCP[x])
  381.         {
  382.             if(IsEditing(playerid) == 1) return 1;
  383.             format(hfile, sizeof(hfile), "/Houses/%d.ini", x);
  384.             new Float:EXITX; EXITX = dini_Float(hfile, "EXITX");
  385.             new Float:EXITY; EXITY = dini_Float(hfile, "EXITY");
  386.             new Float:EXITZ; EXITZ = dini_Float(hfile, "EXITZ");
  387.             new Interior2; Interior2 = dini_Int(hfile, "Interior2");
  388.             SetPlayerAt(playerid, EXITX, EXITY, EXITZ, Interior2, 0);
  389.             SetPVarInt(playerid, "EntID", -1);
  390.         }
  391.     }
  392.     return 1;
  393. }
  394.  
  395. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  396. {
  397.     if(dialogid == DABOX)
  398.     {
  399.         if(response)
  400.         {
  401.               if(IsEditing(playerid) == 0) return SendClientMessage(playerid, COLOR_RED, "You are not editing a house!");
  402.               switch(listitem)
  403.               {
  404.                     case 0:
  405.                     {
  406.                         format(hfile, sizeof(hfile), "/Houses/%d.ini", GetPlayerHouseID(playerid));
  407.                         new Float:X, Float:Y, Float:Z;
  408.                         GetPlayerPos(playerid, X, Y, Z);
  409.  
  410.                         dini_FloatSet(hfile, "ECPX", X);
  411.                         dini_FloatSet(hfile, "ECPY", Y);
  412.                         dini_FloatSet(hfile, "ECPZ", Z);
  413.                         dini_IntSet(hfile, "CPSet", 1);
  414.  
  415.                         DestroyDynamicMapIcon(HMarker[GetPlayerHouseID(playerid)]);
  416.                         DestroyDynamicCP(HEnterCP[GetPlayerHouseID(playerid)]);
  417.                         HEnterCP[GetPlayerHouseID(playerid)] = CreateDynamicCP(X, Y, Z, 1, -1, -1, -1, 25);
  418.                         HMarker[GetPlayerHouseID(playerid)] = CreateDynamicMapIcon(X, Y, Z, 31, 0, -1, -1, -1, 45);
  419.  
  420.                         new str[128];
  421.                         format(str, sizeof(str), "House [ID:%d] enter checkpoint has been set to\n X: %f, Y: %f, Z: %f.", GetPlayerHouseID(playerid), X, Y, Z);
  422.                         ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Edit - Enter CP", str, "Ok", "Cancel");
  423.                         SendClientMessage(playerid, COLOR_BLUE, str);
  424.                     }
  425.                     case 1:
  426.                     {
  427.                         format(hfile, sizeof(hfile), "/Houses/%d.ini", GetPlayerHouseID(playerid));
  428.                         new Float:X, Float:Y, Float:Z;
  429.                         GetPlayerPos(playerid, X, Y, Z);
  430.  
  431.                         dini_FloatSet(hfile, "ICPX", X);
  432.                         dini_FloatSet(hfile, "ICPY", Y);
  433.                         dini_FloatSet(hfile, "ICPZ", Z);
  434.                         new hworld; hworld = dini_Int(hfile, "World");
  435.  
  436.                         DestroyDynamicCP(HExitCP[GetPlayerHouseID(playerid)]);
  437.                         HExitCP[GetPlayerHouseID(playerid)] = CreateDynamicCP(X, Y, Z, 1, hworld, -1, -1, 25);
  438.  
  439.                         new str[128];
  440.                         format(str, sizeof(str), "House [ID:%d] exit checkpoint has been set to -\n X: %f, Y: %f, Z: %f.", GetPlayerHouseID(playerid), X, Y, Z);
  441.                         ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Edit - Exit CP", str, "Ok", "Cancel");
  442.                         SendClientMessage(playerid, COLOR_BLUE, str);
  443.                     }
  444.                     case 2:
  445.                     {
  446.                         format(hfile, sizeof(hfile), "/Houses/%d.ini", GetPlayerHouseID(playerid));
  447.                         new Float:X, Float:Y, Float:Z;
  448.                         GetPlayerPos(playerid, X, Y, Z);
  449.  
  450.                         dini_FloatSet(hfile, "ENTX", X);
  451.                         dini_FloatSet(hfile, "ENTY", Y);
  452.                         dini_FloatSet(hfile, "ENTZ", Z);
  453.                         dini_IntSet(hfile, "Interior", GetPlayerInterior(playerid));
  454.  
  455.                         new str[128];
  456.                         format(str, sizeof(str), "House [ID:%d] enter position has been set to -\n X: %f, Y: %f, Z: %f [Interior:%d]", GetPlayerHouseID(playerid), X, Y, Z, GetPlayerInterior(playerid));
  457.                         ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Edit - Enter Position", str, "Ok", "Cancel");
  458.                         SendClientMessage(playerid, COLOR_BLUE, str);
  459.                     }
  460.                     case 3:
  461.                     {
  462.                         format(hfile, sizeof(hfile), "/Houses/%d.ini", GetPlayerHouseID(playerid));
  463.                         new Float:X, Float:Y, Float:Z;
  464.                         GetPlayerPos(playerid, X, Y, Z);
  465.  
  466.                         dini_FloatSet(hfile, "EXITX", X);
  467.                         dini_FloatSet(hfile, "EXITY", Y);
  468.                         dini_FloatSet(hfile, "EXITZ", Z);
  469.                         dini_IntSet(hfile, "Interior2", GetPlayerInterior(playerid));
  470.  
  471.                         new str[128];
  472.                         format(str, sizeof(str), "House [ID:%d] exit position has been set to -\n X: %f, Y: %f, Z: %f.", GetPlayerHouseID(playerid), X, Y, Z);
  473.                         ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Edit - Exit Position", str, "Ok", "Cancel");
  474.                         SendClientMessage(playerid, COLOR_BLUE, str);
  475.                     }
  476.                     case 4:
  477.                     {
  478.                         ShowPlayerDialog(playerid, DABOX+1, DIALOG_STYLE_INPUT, "House Edit - Set House Name", "Type in the name you would like for your house.", "Ok", "Cancel");
  479.                     }
  480.                     case 5:
  481.                     {
  482.                         ShowPlayerDialog(playerid, DABOX+3, DIALOG_STYLE_INPUT, "House Edit - Set House Price", "Type in the price you would like for your house.", "Ok", "Cancel");
  483.                     }
  484.                     case 6:
  485.                     {
  486.                         ShowPlayerDialog(playerid, DABOX+6, DIALOG_STYLE_LIST, "House - Teleport", "Tele to Enter CP\nTele to Exit CP", "Ok", "Cancel");
  487.                     }
  488.                     case 7:
  489.                     {
  490.                         ShowPlayerDialog(playerid, DABOX+7, DIALOG_STYLE_INPUT, "House Edit - Set World", "Type in the virtual world you would like.", "Ok", "Cancel");
  491.                     }
  492.               }
  493.         }
  494.         return 1;
  495.     }
  496.     if(dialogid == DABOX+1)
  497.     {
  498.         if(response)
  499.         {
  500.               if(IsEditing(playerid) == 0) return SendClientMessage(playerid, COLOR_RED, "You are not editing a house!");
  501.               if(!strlen(inputtext)) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must enter a house name below!");
  502.               {
  503.                     format(hfile, sizeof(hfile), "/Houses/%d.ini", GetPlayerHouseID(playerid));
  504.  
  505.                     new aname[128];
  506.                     format(aname, sizeof(aname), "%s", inputtext);
  507.  
  508.                     dini_Set(hfile, "Name", aname);
  509.  
  510.                     new Float:ECPX; ECPX = dini_Float(hfile, "ECPX");
  511.                     new Float:ECPY; ECPY = dini_Float(hfile, "ECPY");
  512.                     new Float:ECPZ; ECPZ = dini_Float(hfile, "ECPZ");
  513.  
  514.                     new hprice; hprice = dini_Int(hfile, "Price");
  515.                     new howner[256]; howner = dini_Get(hfile, "Owner");
  516.                     new str[250]; format(str, sizeof(str), "Name: %s\nPrice: %d\nOwner: %s", aname, hprice, howner);
  517.  
  518.                     DestroyDynamic3DTextLabel(HLabel[GetPlayerHouseID(playerid)]);
  519.                     HLabel[GetPlayerHouseID(playerid)] = CreateDynamic3DTextLabel(str, COLOR_BLUE, ECPX, ECPY, ECPZ+1, 40, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 40.0);
  520.  
  521.                     format(str, sizeof(str), "House [ID:%d]'s name is now '%s'!", GetPlayerHouseID(playerid), aname);
  522.                     ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Edit - Set Name", str, "Ok", "Cancel");
  523.               }
  524.         }
  525.         return 1;
  526.     }
  527.     if(dialogid == DABOX+2)
  528.     {
  529.         if(response)
  530.         {
  531.               switch(listitem)
  532.               {
  533.                     case 0:
  534.                     {
  535.                         format(hfile, sizeof(hfile), "/Houses/%d.ini", GetEntID(playerid));
  536.                         new howner[256]; howner = dini_Get(hfile, "Owner");
  537.                         new nigname[MAX_PLAYER_NAME]; nigname = pName(playerid);
  538.                         if(dini_Int(hfile, "PassSet") == 1 && strfind(howner, nigname, true) == -1)
  539.                         {
  540.                             ShowPlayerDialog(playerid, DABOX+5, DIALOG_STYLE_INPUT, "House - Password", "Type in the password for this house to enter.", "Ok", "Cancel");
  541.                             return 1;
  542.                         }
  543.                         new Float:ENTX; ENTX = dini_Float(hfile, "ENTX");
  544.                         new Float:ENTY; ENTY = dini_Float(hfile, "ENTY");
  545.                         new Float:ENTZ; ENTZ = dini_Float(hfile, "ENTZ");
  546.                         new Interior = dini_Int(hfile, "Interior");
  547.                         new hworld; hworld = dini_Int(hfile, "World");
  548.                         SetPlayerAt(playerid, ENTX, ENTY, ENTZ, Interior, hworld);
  549.                     }
  550.                     case 1:
  551.                     {
  552.                         format(hfile, sizeof(hfile), "/Houses/%d.ini", GetEntID(playerid));
  553.                         new nigname[MAX_PLAYER_NAME]; nigname = pName(playerid);
  554.                         new hprice; hprice = dini_Int(hfile, "Price");
  555.                         new howner[256]; howner = dini_Get(hfile, "Owner");
  556.                         new hname[256]; hname = dini_Get(hfile, "Name");
  557.                         if(GetPlayerMoney(playerid) < hprice) return ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House - Purchase", "You do not have enough money to purchase\nthis house!", "Ok", "");
  558.                         if(strfind(howner, nigname, true) != -1) return ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House - Purchase", "You already own this house!", "Ok", "");
  559.                         dini_Set(hfile, "Owner", pName(playerid));
  560.                         GivePlayerMoney(playerid, -hprice);
  561.                         PlayerPlaySound(playerid, 1058, 0, 0, 0);
  562.                         PlayerPlaySound(playerid, 1149, 0, 0, 0);
  563.                         ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House - Purchase", "You have successfully purchased this house!", "", "Exit");
  564.                         #if HMESSAGES == 1
  565.                         new str[128];
  566.                         format(str, sizeof(str), "%s purchased the House '%s' [ID:%d] for $%d!", pName(playerid), hname, GetEntID(playerid), hprice);
  567.                         SendClientMessageToAll(COLOR_BLUE, str);
  568.                         #endif
  569.                     }
  570.                     case 2:
  571.                     {
  572.                         format(hfile, sizeof(hfile), "/Houses/%d.ini", GetEntID(playerid));
  573.                         new howner[256]; howner = dini_Get(hfile, "Owner");
  574.                         new nigname[MAX_PLAYER_NAME]; nigname = pName(playerid);
  575.                         if(strfind(howner, nigname, true) == -1) return ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House - Options", "You are not the owner of this house!", "Ok", "");
  576.                         ShowPlayerDialog(playerid, DABOX+4, DIALOG_STYLE_INPUT, "House - Set Password", "Type in a password you would like for your house.", "Ok", "Cancel");
  577.                     }
  578.                     case 3:
  579.                     {
  580.                         format(hfile, sizeof(hfile), "/Houses/%d.ini", GetEntID(playerid));
  581.                         new howner[256]; howner = dini_Get(hfile, "Owner");
  582.                         new nigname[MAX_PLAYER_NAME]; nigname = pName(playerid);
  583.                         if(strfind(howner, nigname, true) == -1) return ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House - Options", "You are not the owner of this house!", "Ok", "");
  584.                         ShowPlayerDialog(playerid, DABOX+8, DIALOG_STYLE_INPUT, "House - Sell House", "Are you sure you want to sell this house?\nType Yes or No", "Ok", "Cancel");
  585.                     }
  586.               }
  587.         }
  588.         return 1;
  589.     }
  590.     if(dialogid == DABOX+3)
  591.     {
  592.         if(response)
  593.         {
  594.               if(IsEditing(playerid) == 0) return SendClientMessage(playerid, COLOR_RED, "You are not editing a house!");
  595.               if(!strlen(inputtext)) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must enter a price below!");
  596.               {
  597.                     format(hfile, sizeof(hfile), "/Houses/%d.ini", GetPlayerHouseID(playerid));
  598.  
  599.                     new hprice;
  600.                     sscanf(inputtext, "i", hprice);
  601.  
  602.                     dini_IntSet(hfile, "Price", hprice);
  603.  
  604.                     new Float:ECPX; ECPX = dini_Float(hfile, "ECPX");
  605.                     new Float:ECPY; ECPY = dini_Float(hfile, "ECPY");
  606.                     new Float:ECPZ; ECPZ = dini_Float(hfile, "ECPZ");
  607.  
  608.                     new howner[256]; howner = dini_Get(hfile, "Owner");
  609.                     new hname[256]; hname = dini_Get(hfile, "Name");
  610.                     new str[250]; format(str, sizeof(str), "Name: %s\nPrice: %d\nOwner: %s", hname, hprice, howner);
  611.  
  612.                     DestroyDynamic3DTextLabel(HLabel[GetPlayerHouseID(playerid)]);
  613.                     HLabel[GetPlayerHouseID(playerid)] = CreateDynamic3DTextLabel(str, COLOR_BLUE, ECPX, ECPY, ECPZ+1, 40, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 40.0);
  614.  
  615.                     format(str, sizeof(str), "House [ID:%d]'s price is now '%d'!", GetPlayerHouseID(playerid), hprice);
  616.                     ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Edit - Set Price", str, "Ok", "");
  617.               }
  618.         }
  619.         return 1;
  620.     }
  621.     if(dialogid == DABOX+4)
  622.     {
  623.         if(response)
  624.         {
  625.               if(!strlen(inputtext)) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must enter a price below!");
  626.               {
  627.                     format(hfile, sizeof(hfile), "/Houses/%d.ini", GetEntID(playerid));
  628.  
  629.                     new hpass[128];
  630.                     sscanf(inputtext, "s", hpass);
  631.                     dini_Set(hfile, "Password", hpass);
  632.                     dini_IntSet(hfile, "PassSet", 1);
  633.  
  634.                     new str[128];
  635.                     format(str, sizeof(str), "The password for House [ID:%d] is now '%s'!", GetEntID(playerid), hpass);
  636.                     ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Options - Set Password", str, "Ok", "");
  637.               }
  638.         }
  639.         return 1;
  640.     }
  641.     if(dialogid == DABOX+5)
  642.     {
  643.         if(response)
  644.         {
  645.               if(!strlen(inputtext)) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must enter a password below!");
  646.               {
  647.                     format(hfile, sizeof(hfile), "/Houses/%d.ini", GetEntID(playerid));
  648.  
  649.                     new hpass[128];
  650.                     sscanf(inputtext, "s", hpass);
  651.                     new matchpass[256]; matchpass = dini_Get(hfile, "Password");
  652.  
  653.                     if(strfind(matchpass, hpass, true) == -1) return ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House - Password", "Incorrect password...", "Ok", "");
  654.                     else {
  655.                         new Float:ENTX; ENTX = dini_Float(hfile, "ENTX");
  656.                         new Float:ENTY; ENTY = dini_Float(hfile, "ENTY");
  657.                         new Float:ENTZ; ENTZ = dini_Float(hfile, "ENTZ");
  658.                         new Interior = dini_Int(hfile, "Interior");
  659.                         new hworld = dini_Int(hfile, "World");
  660.                         SetPlayerAt(playerid, ENTX, ENTY, ENTZ, Interior, hworld);
  661.                     }
  662.               }
  663.         }
  664.         return 1;
  665.     }
  666.     if(dialogid == DABOX+6)
  667.     {
  668.         if(response)
  669.         {
  670.               if(IsEditing(playerid) == 0) return SendClientMessage(playerid, COLOR_RED, "You are not editing a house!");
  671.               switch(listitem)
  672.               {
  673.                     case 0:
  674.                     {
  675.                         new Float:X; X = dini_Float(hfile, "ENTX");
  676.                         new Float:Y; Y = dini_Float(hfile, "ENTY");
  677.                         new Float:Z; Z = dini_Float(hfile, "ENTZ");
  678.                         new Interior; Interior = dini_Int(hfile, "Interior");
  679.                         new hworld; hworld = dini_Int(hfile, "World");
  680.                         SetPlayerAt(playerid, X, Y, Z, Interior, hworld);
  681.                         ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Edit - Enter CP", "Successfully teleported to entrance coords.", "Ok", "");
  682.                     }
  683.                     case 1:
  684.                     {
  685.                         new Float:X; X = dini_Float(hfile, "EXITX");
  686.                         new Float:Y; Y = dini_Float(hfile, "EXITY");
  687.                         new Float:Z; Z = dini_Float(hfile, "EXITZ");
  688.                         new Interior2; Interior2 = dini_Int(hfile, "Interior2");
  689.                         SetPlayerAt(playerid, X, Y, Z, Interior2, 0);
  690.                         ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Edit - Exit CP", "Successfully teleported to exit coords.", "Ok", "");
  691.                     }
  692.               }
  693.         }
  694.         return 1;
  695.     }
  696.     if(dialogid == DABOX+7)
  697.     {
  698.         if(response)
  699.         {
  700.               if(IsEditing(playerid) == 0) return SendClientMessage(playerid, COLOR_RED, "You are not editing a house!");
  701.               if(!strlen(inputtext)) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must enter a price below!");
  702.               {
  703.                     format(hfile, sizeof(hfile), "/Houses/%d.ini", GetPlayerHouseID(playerid));
  704.  
  705.                     new hworld;
  706.                     sscanf(inputtext, "i", hworld);
  707.  
  708.                     dini_IntSet(hfile, "World", hworld);
  709.                    
  710.                     SetPlayerVirtualWorld(playerid, hworld);
  711.  
  712.                     new str[128];
  713.                     format(str, sizeof(str), "House [ID:%d]'s virtual world is now '%d'!", GetPlayerHouseID(playerid), hworld);
  714.                     ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House Edit - Set World", str, "Ok", "");
  715.               }
  716.         }
  717.         return 1;
  718.     }
  719.     if(dialogid == DABOX+8)
  720.     {
  721.         if(response)
  722.         {
  723.             format(hfile, sizeof(hfile), "/Houses/%d.ini", GetEntID(playerid));
  724.             new howner[256]; howner = dini_Get(hfile, "Owner");
  725.             new nigname[MAX_PLAYER_NAME]; nigname = pName(playerid);
  726.             if(strfind(howner, nigname, true) == -1) return ShowPlayerDialog(playerid, DABOX-1, DIALOG_STYLE_MSGBOX, "House - Options", "You are not the owner of this house!", "Ok", "");
  727.             if(strfind(inputtext,"Yes",true) == 0)
  728.             {
  729.                 new hprice; hprice = dini_Int(hfile, "Price");
  730.                 new hname[256]; hname = dini_Get(hfile, "Name");
  731.                 dini_Set(hfile, "Owner", "None");
  732.                 GivePlayerMoney(playerid, hprice);
  733.                 #if HMESSAGES == 1
  734.                 new str[128];
  735.                 format(str, sizeof(str), "%s sold the House '%s' [ID:%d] [Price: %d]!", pName(playerid), hname, GetEntID(playerid), hprice);
  736.                 SendClientMessageToAll(COLOR_BLUE, str);
  737.                 #endif
  738.             }
  739.             else if(strfind(inputtext,"No",true) == 0)
  740.             {
  741.                 SendClientMessage(playerid, COLOR_RED, "You decided not to sell your house...");
  742.             }
  743.         }
  744.         return 1;
  745.     }
  746.     return 0;
  747. }
  748.  
  749. stock pName(playerid)
  750. {
  751.     new gName[MAX_PLAYER_NAME];
  752.     GetPlayerName(playerid, gName, sizeof(gName));
  753.     return gName;
  754. }
  755.  
  756. stock IsEditing(playerid)
  757. {
  758.     return GetPVarInt(playerid, "Editing");
  759. }
  760.  
  761. stock GetPlayerHouseID(playerid)
  762. {
  763.     return GetPVarInt(playerid, "EditID");
  764. }
  765.  
  766. stock GetEntID(playerid)
  767. {
  768.     return GetPVarInt(playerid, "EntID");
  769. }
  770.  
  771. stock TotalHouses()
  772. {
  773.     new tehcount;
  774.     for(new i=0; i<MAX_HOUSES; i++)
  775.     {
  776.         format(hfile, sizeof(hfile), "/Houses/%d.ini", i);
  777.         if(dini_Exists(hfile)) tehcount++;
  778.     }
  779.     return tehcount;
  780. }
  781.  
  782. forward UpdateHouses();
  783. public UpdateHouses()
  784. {
  785.     for(new i=0; i<TotalHouses(); i++)
  786.     {
  787.         DisableInteriorEnterExits();
  788.         format(hfile, sizeof(hfile), "/Houses/%d.ini", i);
  789.         new Float:ECPX; ECPX = dini_Float(hfile, "ECPX");
  790.         new Float:ECPY; ECPY = dini_Float(hfile, "ECPY");
  791.         new Float:ECPZ; ECPZ = dini_Float(hfile, "ECPZ");
  792.         new Float:ICPX; ICPX = dini_Float(hfile, "ICPX");
  793.         new Float:ICPY; ICPY = dini_Float(hfile, "ICPY");
  794.         new Float:ICPZ; ICPZ = dini_Float(hfile, "ICPZ");
  795.         new hname[256]; hname = dini_Get(hfile, "Name");
  796.         new hprice; hprice = dini_Int(hfile, "Price");
  797.         new howner[256]; howner = dini_Get(hfile, "Owner");
  798.         new hworld; hworld = dini_Int(hfile, "World");
  799.         new str[250]; format(str, sizeof(str), "Name: %s\nPrice: %d\nOwner: %s", hname, hprice, howner);
  800.         DestroyDynamicMapIcon(HMarker[i]);
  801.         DestroyDynamicCP(HEnterCP[i]);
  802.         DestroyDynamicCP(HExitCP[i]);
  803.         DestroyDynamic3DTextLabel(HLabel[i]);
  804.         if(dini_Int(hfile, "CPSet") == 1) {
  805.             HEnterCP[i] = CreateDynamicCP(ECPX, ECPY, ECPZ, 1, -1, -1, -1, 25);
  806.             HExitCP[i] = CreateDynamicCP(ICPX, ICPY, ICPZ, 1, hworld, -1, -1, 25);
  807.             HLabel[i] = CreateDynamic3DTextLabel(str, COLOR_BLUE, ECPX, ECPY, ECPZ+1, 40, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 40.0);
  808.             HMarker[i] = CreateDynamicMapIcon(ECPX, ECPY, ECPZ, 31, 0, -1, -1, -1, 45);
  809.         }
  810.     }
  811.     return 1;
  812. }
  813.  
  814. stock SetPlayerAt(playerid, Float:X, Float:Y, Float:Z, interiorid, virtualworld)
  815. {
  816.     SetPlayerPos(playerid, X, Y, Z);
  817.     SetPlayerInterior(playerid, interiorid);
  818.     SetPlayerVirtualWorld(playerid, virtualworld);
  819.     return 1;
  820. }
  821.  
  822. stock sscanf(string[], format[], {Float,_}:...)
  823. {
  824.     #if defined isnull
  825.         if (isnull(string))
  826.     #else
  827.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  828.     #endif
  829.         {
  830.             return format[0];
  831.         }
  832.     #pragma tabsize 4
  833.     new
  834.         formatPos = 0,
  835.         stringPos = 0,
  836.         paramPos = 2,
  837.         paramCount = numargs(),
  838.         delim = ' ';
  839.     while (string[stringPos] && string[stringPos] <= ' ')
  840.     {
  841.         stringPos++;
  842.     }
  843.     while (paramPos < paramCount && string[stringPos])
  844.     {
  845.         switch (format[formatPos++])
  846.         {
  847.             case '\0':
  848.             {
  849.                 return 0;
  850.             }
  851.             case 'i', 'd':
  852.             {
  853.                 new
  854.                     neg = 1,
  855.                     num = 0,
  856.                     ch = string[stringPos];
  857.                 if (ch == '-')
  858.                 {
  859.                     neg = -1;
  860.                     ch = string[++stringPos];
  861.                 }
  862.                 do
  863.                 {
  864.                     stringPos++;
  865.                     if ('0' <= ch <= '9')
  866.                     {
  867.                         num = (num * 10) + (ch - '0');
  868.                     }
  869.                     else
  870.                     {
  871.                         return -1;
  872.                     }
  873.                 }
  874.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  875.                 setarg(paramPos, 0, num * neg);
  876.             }
  877.             case 'h', 'x':
  878.             {
  879.                 new
  880.                     num = 0,
  881.                     ch = string[stringPos];
  882.                 do
  883.                 {
  884.                     stringPos++;
  885.                     switch (ch)
  886.                     {
  887.                         case 'x', 'X':
  888.                         {
  889.                             num = 0;
  890.                             continue;
  891.                         }
  892.                         case '0' .. '9':
  893.                         {
  894.                             num = (num << 4) | (ch - '0');
  895.                         }
  896.                         case 'a' .. 'f':
  897.                         {
  898.                             num = (num << 4) | (ch - ('a' - 10));
  899.                         }
  900.                         case 'A' .. 'F':
  901.                         {
  902.                             num = (num << 4) | (ch - ('A' - 10));
  903.                         }
  904.                         default:
  905.                         {
  906.                             return -1;
  907.                         }
  908.                     }
  909.                 }
  910.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  911.                 setarg(paramPos, 0, num);
  912.             }
  913.             case 'c':
  914.             {
  915.                 setarg(paramPos, 0, string[stringPos++]);
  916.             }
  917.             case 'f':
  918.             {
  919.                 setarg(paramPos, 0, _:floatstr(string[stringPos]));
  920.             }
  921.             case 'p':
  922.             {
  923.                 delim = format[formatPos++];
  924.                 continue;
  925.             }
  926.             case '\'':
  927.             {
  928.                 new
  929.                     end = formatPos - 1,
  930.                     ch;
  931.                 while ((ch = format[++end]) && ch != '\'') {}
  932.                 if (!ch)
  933.                 {
  934.                     return -1;
  935.                 }
  936.                 format[end] = '\0';
  937.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  938.                 {
  939.                     if (format[end + 1])
  940.                     {
  941.                         return -1;
  942.                     }
  943.                     return 0;
  944.                 }
  945.                 format[end] = '\'';
  946.                 stringPos = ch + (end - formatPos);
  947.                 formatPos = end + 1;
  948.             }
  949.             case 'u':
  950.             {
  951.                 new
  952.                     end = stringPos - 1,
  953.                     id = 0,
  954.                     bool:num = true,
  955.                     ch;
  956.                 while ((ch = string[++end]) && ch != delim)
  957.                 {
  958.                     if (num)
  959.                     {
  960.                         if ('0' <= ch <= '9')
  961.                         {
  962.                             id = (id * 10) + (ch - '0');
  963.                         }
  964.                         else
  965.                         {
  966.                             num = false;
  967.                         }
  968.                     }
  969.                 }
  970.                 if (num && IsPlayerConnected(id))
  971.                 {
  972.                     setarg(paramPos, 0, id);
  973.                 }
  974.                 else
  975.                 {
  976.                     #if !defined foreach
  977.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  978.                         #define __SSCANF_FOREACH__
  979.                     #endif
  980.                     string[end] = '\0';
  981.                     num = false;
  982.                     new
  983.                         name[MAX_PLAYER_NAME];
  984.                     id = end - stringPos;
  985.                     foreach (Player, playerid)
  986.                     {
  987.                         GetPlayerName(playerid, name, sizeof (name));
  988.                         if (!strcmp(name, string[stringPos], true, id))
  989.                         {
  990.                             setarg(paramPos, 0, playerid);
  991.                             num = true;
  992.                             break;
  993.                         }
  994.                     }
  995.                     if (!num)
  996.                     {
  997.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  998.                     }
  999.                     string[end] = ch;
  1000.                     #if defined __SSCANF_FOREACH__
  1001.                         #undef foreach
  1002.                         #undef __SSCANF_FOREACH__
  1003.                     #endif
  1004.                 }
  1005.                 stringPos = end;
  1006.             }
  1007.             case 's', 'z':
  1008.             {
  1009.                 new
  1010.                     i = 0,
  1011.                     ch;
  1012.                 if (format[formatPos])
  1013.                 {
  1014.                     while ((ch = string[stringPos++]) && ch != delim)
  1015.                     {
  1016.                         setarg(paramPos, i++, ch);
  1017.                     }
  1018.                     if (!i)
  1019.                     {
  1020.                         return -1;
  1021.                     }
  1022.                 }
  1023.                 else
  1024.                 {
  1025.                     while ((ch = string[stringPos++]))
  1026.                     {
  1027.                         setarg(paramPos, i++, ch);
  1028.                     }
  1029.                 }
  1030.                 stringPos--;
  1031.                 setarg(paramPos, i, '\0');
  1032.             }
  1033.             default:
  1034.             {
  1035.                 continue;
  1036.             }
  1037.         }
  1038.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  1039.         {
  1040.             stringPos++;
  1041.         }
  1042.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  1043.         {
  1044.             stringPos++;
  1045.         }
  1046.         paramPos++;
  1047.     }
  1048.     do
  1049.     {
  1050.         if ((delim = format[formatPos++]) > ' ')
  1051.         {
  1052.             if (delim == '\'')
  1053.             {
  1054.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  1055.             }
  1056.             else if (delim != 'z')
  1057.             {
  1058.                 return delim;
  1059.             }
  1060.         }
  1061.     }
  1062.     while (delim > ' ');
  1063.     return 0;
  1064. }
Advertisement
Add Comment
Please, Sign In to add comment