Guest User

IsPlayerInArea Maker FIX

a guest
Jan 6th, 2015
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. #include <a_samp>
  2. #include <YSI\y_commands>
  3.  
  4. #define DIALOG_IPIA_MAKER (204)
  5. #define DIALOG_IPIA_SAVE (205)
  6.  
  7.  
  8. #define ResetAll() for(new i;i < 4;i++) AreaInfo[i] = 0.0
  9.  
  10. new Float:AreaInfo[6];
  11.  
  12. YCMD:area(playerid, params[], help)
  13. {
  14. #pragma unused params, help
  15. return ShowPlayerDialog(playerid, DIALOG_IPIA_MAKER, DIALOG_STYLE_LIST, "IsPlayerInArea Maker", "Save the first point\nSave the second point\n{F58282}Create IsPlayerInArea\nReset All points, and Save Again", "Select", "Cancel"), 1;
  16. }
  17.  
  18. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  19. {
  20. switch (dialogid)
  21. {
  22. case DIALOG_IPIA_MAKER:
  23. {
  24. if(!response) return 0;
  25. switch(listitem)
  26. {
  27. case 0:
  28. {
  29. GetPlayerPos(playerid, AreaInfo[0], AreaInfo[1], AreaInfo[2]);
  30. SendClientMessage(playerid, 0xCC9900FF, "Minimum X and Y and Z created.");
  31. }
  32. case 1:
  33. {
  34. GetPlayerPos(playerid, AreaInfo[3], AreaInfo[4], AreaInfo[5]);
  35. SendClientMessage(playerid, 0xCC9900FF, "Maximum X and Y and Z created.");
  36. }
  37. case 2: ShowPlayerDialog(playerid, DIALOG_IPIA_SAVE, DIALOG_STYLE_INPUT, " ", "{F58282}Type the file name inside the box", "Save", "Cancel");
  38. default:
  39. {
  40. if(!IsUseOne() && !IsUseTwo()) return SendClientMessage(playerid, 0xFF0000FF, "you cannot reset the point until you save some point!");
  41.  
  42. ResetAll();
  43. SendClientMessage(playerid, 0xCC9900FF, "The points has reseted successfully!");
  44. }
  45. }
  46. }
  47. case DIALOG_IPIA_SAVE:
  48. {
  49. if(!response) return ShowPlayerDialog(playerid, DIALOG_IPIA_MAKER, DIALOG_STYLE_LIST, "IsPlayerInArea Maker", "Save the first point\nSave the second point\n{F58282}Create IsPlayerInArea\nReset All points, and Save Again", "Select", "Cancel"), 1;
  50. if(!IsUseOne() && !IsUseTwo()) return SendClientMessage(playerid, 0xFF0000FF, "You have to save two points!");
  51. if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_IPIA_SAVE, DIALOG_STYLE_INPUT, " ", "{F58282}Type the file name inside the box", "Save", "Cancel");
  52.  
  53. new string[128];
  54. new filename[64];
  55. format(filename, sizeof(filename), "IsPlayerInArea_%s.ini", inputtext);
  56. format(string, sizeof(string), "IsPlayerInArea(playerid, %f, %f,%f, %f, %f,%f);\r\n",
  57. (AreaInfo[0] < AreaInfo[3]) ? AreaInfo[0] : AreaInfo[3],
  58. (AreaInfo[1] < AreaInfo[4]) ? AreaInfo[1] : AreaInfo[4],
  59. (AreaInfo[2] < AreaInfo[5]) ? AreaInfo[2] : AreaInfo[5],
  60. (AreaInfo[0] > AreaInfo[3]) ? AreaInfo[0] : AreaInfo[3],
  61. (AreaInfo[1] > AreaInfo[4]) ? AreaInfo[1] : AreaInfo[4],
  62. (AreaInfo[2] > AreaInfo[5]) ? AreaInfo[2] : AreaInfo[5]
  63. );
  64.  
  65. new File:pos=fopen(filename, io_append);
  66. fwrite(pos, string);
  67. fclose(pos);
  68.  
  69. new dialogstring[128];
  70. format(dialogstring, sizeof(dialogstring), "\nIsPlayerInArea saved under the name {F58282}IsPlayerInArea_%s.ini {a9c4e4}inside the scriptfiles folder!\n", inputtext);
  71. ShowPlayerDialog(playerid, 206, DIALOG_STYLE_MSGBOX, " ", dialogstring, "Exit", "");
  72. ResetAll();
  73. }
  74. }
  75. return 1;
  76. }
  77.  
  78. stock IsUseOne() return AreaInfo[0] != 0.0 ? true:false;
  79. stock IsUseTwo() return AreaInfo[3] != 0.0 ? true:false;
  80.  
  81. IsPlayerInArea(playerid, Float:MinX, Float:MinY, Float:MinZ,Float:MaxX, Float:MaxY,Float:MaxZ)
  82. {
  83. new Float:X, Float:Y, Float:Z;
  84. GetPlayerPos(playerid, X, Y, Z);
  85. return (X >= MinX && X <= MaxX && Y >= MinY && Y <= MaxY && Z >= MinZ && Z <= MaxZ) ? 1 : 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment