Guest User

Untitled

a guest
Jun 19th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.22 KB | None | 0 0
  1. CMD:createhouse(playerid,params[])
  2. {
  3. if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
  4. // If the player has an insufficient admin-level (he needs level 5 or RCON admin), exit the command
  5. // returning "SERVER: Unknown command" to the player
  6. if (INT_CheckPlayerAdminLevel(playerid, 5) == 0) return 0;
  7.  
  8. // Setup local variables
  9. new HPrice, MaxLevel, HouseID;
  10.  
  11. // Check if the player isn't inside a vehicle (the admin-player must be on foot to use this command)
  12. if (GetPlayerVehicleSeat(playerid) == -1)
  13. {
  14. if (sscanf(params, "ii", HPrice, MaxLevel)) return SendClientMessage(playerid, 0xFFFFFFFF, "Koristenje: /createhouse <price> <maxlevel (1-10)"");
  15. // Check if the player entered a proper maxlevel
  16. if ((MaxLevel >= 1) && (MaxLevel <= 10))
  17. {
  18. // Find the first free HouseID
  19. for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
  20. if (!IsValidDynamicPickup(AHouseData[HouseID][PickupID])) // Check if an empty house-index has been found (PickupID is 0)
  21. break; // Stop searching, the first free HouseID has been found now
  22.  
  23. // Check if the house-limit hasn't been reached yet
  24. // This would seem to double-check the pickup-id, but in case there was no free houseslot found (HouseID points
  25. // to the last index, the last index would hold a house, so be sure to not overwrite it
  26. if (!IsValidDynamicPickup(AHouseData[HouseID][PickupID]))
  27. {
  28. // Setup some local variables
  29. new Float:x, Float:y, Float:z, Msg[128];
  30. // Get the player's position
  31. GetPlayerPos(playerid, x, y, z);
  32. // Set some default data
  33. AHouseData[HouseID][Owned] = false;
  34. AHouseData[HouseID][Owner] = 0;
  35. AHouseData[HouseID][HouseX] = x;
  36. AHouseData[HouseID][HouseY] = y;
  37. AHouseData[HouseID][HouseZ] = z;
  38. AHouseData[HouseID][HouseLevel] = 1;
  39. AHouseData[HouseID][HouseMaxLevel] = MaxLevel;
  40. AHouseData[HouseID][HousePrice] = HPrice;
  41. AHouseData[HouseID][HouseOpened] = false;
  42. AHouseData[HouseID][Insurance] = false;
  43. AHouseData[HouseID][StaticHouse] = false;
  44. AHouseData[HouseID][CarSlots] = 1; // This must be equal to the house-level for a normal house
  45.  
  46. // Add the pickup and 3DText at the location of the house-entrance (where the player is standing when he creates the house)
  47. House_UpdateEntrance(HouseID);
  48.  
  49. // Save the house
  50. HouseFile_Save(HouseID);
  51.  
  52. // Inform the player that he created a new house
  53. format(Msg, 128, "{00FF00}You've succesfully created a house with ID: {FFFF00}%i", HouseID);
  54. SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  55. }
  56. else
  57. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You have to use a max-level from 1 to 10");
  58. }
  59. }
  60. else
  61. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You must be on foot to create a house");
  62.  
  63. // Let the server know that this was a valid command
  64. return 1;
  65. }
  66.  
  67. // Lets the player add new houses (a house that cannot be upgraded, has a fixed interior and a fixed amount of carslots)
  68. CMD:createstatichouse(playerid,params[])
  69. {
  70. // Setup local variables
  71. new HPrice, Carslots, HouseID, Interior;
  72.  
  73. // If a player hasn't logged in properly, he cannot use this command
  74. if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
  75. // If the player has an insufficient admin-level (he needs level 5 or RCON admin), exit the command
  76. // returning "SERVER: Unknown command" to the player
  77. if (INT_CheckPlayerAdminLevel(playerid, 5) == 0) return 0;
  78.  
  79. // Check if the player isn't inside a vehicle (the admin-player must be on foot to use this command)
  80. if (GetPlayerVehicleSeat(playerid) == -1)
  81. {
  82. if (!sscanf(params, "iii", HPrice, Carslots, Interior))
  83. {
  84. // Check if the player entered a proper amount of Carslots
  85. if ((Carslots >= 1) && (Carslots <= 10))
  86. {
  87. // Check if the player entered a valid interior
  88. if ((Interior >= 1) && (Interior <= 10))
  89. {
  90. // Find the first free HouseID
  91. for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
  92. if (!IsValidDynamicPickup(AHouseData[HouseID][PickupID])) // Check if an empty house-index has been found (PickupID is 0)
  93. break; // Stop searching, the first free HouseID has been found now
  94.  
  95. // Check if the house-limit hasn't been reached yet
  96. // This would seem to double-check the pickup-id, but in case there was no free houseslot found (HouseID points
  97. // to the last index, the last index would hold a house, so be sure to not overwrite it
  98. if (!IsValidDynamicPickup(AHouseData[HouseID][PickupID]))
  99. {
  100. // Setup some local variables
  101. new Float:x, Float:y, Float:z, Msg[128];
  102. // Get the player's position
  103. GetPlayerPos(playerid, x, y, z);
  104. // Set some default data
  105. AHouseData[HouseID][Owned] = false;
  106. AHouseData[HouseID][HouseX] = x;
  107. AHouseData[HouseID][HouseY] = y;
  108. AHouseData[HouseID][HouseZ] = z;
  109. AHouseData[HouseID][HouseLevel] = Interior; // The house-level indicates the static interior
  110. AHouseData[HouseID][HouseMaxLevel] = Interior;
  111. AHouseData[HouseID][HousePrice] = HPrice;
  112. AHouseData[HouseID][HouseOpened] = false;
  113. AHouseData[HouseID][Insurance] = false;
  114. AHouseData[HouseID][StaticHouse] = true;
  115. AHouseData[HouseID][CarSlots] = Carslots;
  116.  
  117. // Add the pickup and 3DText at the location of the house-entrance (where the player is standing when he creates the house)
  118. House_UpdateEntrance(HouseID);
  119.  
  120. // Save the house
  121. HouseFile_Save(HouseID);
  122.  
  123. // Inform the player that he created a new house
  124. format(Msg, 128, "{00FF00}You've succesfully created a static house with ID: {FFFF00}%i", HouseID);
  125. SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  126. }
  127. else
  128. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}The maximum amount of houses has been reached");
  129. }
  130. else
  131. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You have to use an interior-id from 1 to 10");
  132. }
  133. else
  134. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You have to use a max amount of carslots from 1 to 10");
  135. }
  136. }
  137. else
  138. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You must be on foot to create a house");
  139.  
  140. // Let the server know that this was a valid command
  141. return 1;
  142. }
Add Comment
Please, Sign In to add comment