Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.34 KB | None | 0 0
  1. COMMAND:buildhouse(playerid, params[])
  2. {
  3. if(pData[playerdid][Buildstage] == NO_BUILD_STAGE)
  4. {
  5. if(GetPVarInt(playerid, "AdminLevel") >= 5)
  6. {
  7. new slot;
  8.  
  9. slot = FindEmptySlot[builders];
  10.  
  11. if(slot != 1)
  12. {
  13. builders[slot][E_BUILDER_ID] = playerid;
  14. pData[playerid][Buildstage] = STAGE_BUILD_START;
  15. pData[playerid][Buildslot] = slot;
  16.  
  17. SendClientMessage(playerid, white, "You are now creating a house. Type /buildhouse at the OUTSIDE position to save the outside position.");
  18. return 1;
  19. }
  20. return SendClientMessage(playerid, white, "All building slots are taken! Please wait until one is free.");
  21. }
  22. return 0;
  23. }
  24. switch(pData[playerid][Buildstage])
  25. {
  26. case STAGE_BUILD_START:
  27. {
  28. GetPlayerPos(playerid, builder[pData[playerid][Buildslot]][][x], builder[pData[playerid][Buildslot]][][y], builder[pData[playerid][Buildslot]][][z]);
  29. GetPlayerFacingAngle(playerid, builder[pData[playerid][Buildslot]][][rotation]);
  30.  
  31. pData[playerid][Buildstage] = STAGE_BUILD_TYPE;
  32.  
  33. SendClientMessage(playerid, white, "Outside position saved. Type /buildhouse <type> (TYPES - 1: SMALL, 2: MEDIUM, 3: LARGE)");
  34. return 1;
  35. }
  36. case STAGE_BUILD_TYPE
  37. {
  38. new hType = strval(params), cArray[MAX_HOUSE_TYPES] = {-1,...}, Counter = 0, result;
  39.  
  40. if(!isnull(params))
  41. {
  42. for(new a = 0; a < sizeof(cData); a++)
  43. {
  44. if(cData[a][Type] == hType)
  45. {
  46. Counter++;
  47. cArray[Counter] = a;
  48. }
  49. result = random(Counter);
  50.  
  51. builder[pData[playerid][Buildslot]][x2] = cData[cArray[result]][ix];
  52. builder[pData[playerid][Buildslot]][y2] = cData[cArray[result]][iy];
  53. builder[pData[playerid][Buildslot]][z2] = cData[result][iz];
  54. builder[pData[playerid][Buildslot]][rotation2] = cData[cArray[result]][iz];
  55. builder[pData[playerid][Buildslot]][interior] = cData[cArray[result]][iinterior];
  56.  
  57. pData[playerid][Buildstage] = STAGE_BUILD_PRICE;
  58.  
  59. SendClientMessage(playerid, white, "Use /buildhouse <price> to set the price.");
  60. }
  61. }
  62. return SendClientMessage(playerid, white, "Usage: /buildhouse <type> (TYPES: 1: SMALL, 2: MEDIUM, 3: LARGE)");
  63. }
  64. case STAGE_BUILD_PRICE:
  65. {
  66. builder[pData[playerid][Buildslot]][price] = strval(params);
  67.  
  68. if(!isnull(params))
  69. {
  70. new HouseID = HouseCount+1;
  71.  
  72. builder[pData[playerid][Buildslot]][x] = hData[HouseID][x];
  73. builder[pData[playerid][Buildslot]][y] = hData[HouseID][y];
  74. builder[pData[playerid][Buildslot]][z] = hData[HouseID][z];
  75. builder[pData[playerid][Buildslot]][rotation] = hData[HouseID][rotation];
  76. builder[pData[playerid][Buildslot]][x2] = hData[HouseID][x2];
  77. builder[pData[playerid][Buildslot]][y2] = hData[HouseID][y2];
  78. builder[pData[playerid][Buildslot]][z2] = hData[HouseID][z2];
  79. builder[pData[playerid][Buildslot]][rotation2] = hData[HouseID][rotation2];
  80. builder[pData[playerid][Buildslot]][interior] = hData[HouseID][interior];
  81. builder[pData[playerid][Buildslot]][price] = hData[HouseID][price];
  82.  
  83. format(bigstr, sizeof(bigstr), "INSERT INTO `houses` (`owner`, `x`, `y`, `z`, `rotation`, `x2`, `y2`, `z2`, `rotation2`, `interior`, `price`, `HouseID`) VALUES ('none', %f, %f, %f, %f, %f, %f, %f, %f, %d, %d, %d)", hData[HouseID][x], hData[HouseID][y], hData[HouseID][z], hData[HouseID][rotation], hData[HouseID][x2], hData[HouseID][y2], hData[HouseID][z2], hData[HouseID][rotation2], hData[HouseID][interior], hData[HouseID][price], HouseID);
  84. mysql_query(bigstr);
  85. mysql_free_result();
  86.  
  87. DestroyDynamicPickup(HousePickup[HouseID]);
  88. HousePickup[HouseID] = CreateDynamicPickup(HOUSE_AVAILABLE_PICKUP, 23, hData[HouseID][x], hData[HouseID][y], hData[HouseID][z], -1, 0, -1, HOUSE_PICKUP_DISTANCE);
  89.  
  90. DestroyDynamicMapIcon(HouseMap[HouseID]);
  91. HouseMap[HouseID] = CreateDynamicMapIcon(hData[HouseID][x], hData[HouseID][y], hData[HouseID][z], HOUSE_AVAILABLE_MAP, 0, 0, 0, -1, HOUSE_MAP_DISTANCE);
  92.  
  93. HouseCount = HouseID;
  94. pData[playerid][Buildslot] = -1;
  95. pData[playerid][Buildstage] = NO_BUILD_STAGE;
  96.  
  97. }
  98. return SendClientMessage(playerid, white, "Usage: /createhouse <price>");
  99. }
  100. }
  101. return 1;
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement