Advertisement
Guest User

PPC_TRUCKing - imix - Forum samp

a guest
May 3rd, 2014
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.54 KB | None | 0 0
  1. // PPC_HOUSING
  2. Player_GetFreeHouseSlot(playerid)
  3. {
  4. for (new HouseIndex; HouseIndex < MAX_HOUSESPERPLAYER; HouseIndex++)
  5. if (APlayerData[playerid][Houses][HouseIndex] == 0)
  6. return HouseIndex;
  7. return -1;
  8. }
  9. House_GetMaxCarSlots(HouseID)
  10. {
  11. return AHouseData[HouseID][HouseLevel];
  12. }
  13. House_GetFreeCarSlot(HouseID)
  14. {
  15. new MaxCarSlots = House_GetMaxCarSlots(HouseID);
  16. for (new CarSlot; CarSlot < MaxCarSlots; CarSlot++)
  17. {
  18. if (AHouseData[HouseID][VehicleIDs][CarSlot] == 0)
  19. return CarSlot;
  20. }
  21. return -1;
  22. }
  23. House_SetOwner(playerid, HouseID)
  24. {
  25. new HouseSlotFree, Name[24], Msg[128], Msg1[128];
  26. HouseSlotFree = Player_GetFreeHouseSlot(playerid);
  27. if (HouseSlotFree != -1)
  28. {
  29. GetPlayerName(playerid, Name, sizeof(Name));
  30. APlayerData[playerid][Houses][HouseSlotFree] = HouseID;
  31. RewardPlayer(playerid, -AHouseData[HouseID][HousePrice], 0);
  32. AHouseData[HouseID][Owned] = true;
  33. format(AHouseData[HouseID][Owner], 24, Name);
  34. AHouseData[HouseID][HouseLevel] = 1;
  35. format(AHouseData[HouseID][HouseName], 100, TXT_DefaultHouseName, Name);
  36. House_UpdateEntrance(HouseID);
  37. PlayerFile_Save(playerid);
  38. format(Msg, 128, TXT_PlayerBoughtHouse, AHouseData[HouseID][HousePrice]);
  39. SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  40. format(Msg1, 128, TXT_PlayerBoughtHouseTxT, AHouseData[HouseID][HousePrice]);
  41. GameTextForPlayer(playerid, Msg1, 5000, 1);
  42. PlayerPlaySound(playerid, 1149, 0.0, 0.0, 0.0);
  43. }
  44. else
  45. SendClientMessage(playerid, 0xFFFFFFFF, TXT_PlayerOwnsMaxHouses);
  46.  
  47. return 1;
  48. }
  49. House_Exit(playerid, HouseID)
  50. {
  51. SetPlayerVirtualWorld(playerid, 0);
  52. SetPlayerInterior(playerid, 0);
  53. SetPlayerPos(playerid, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]);
  54. APlayerData[playerid][CurrentHouse] = 0;
  55. if (ExitHouseTimer > 0)
  56. {
  57. TogglePlayerControllable(playerid, 0);
  58. GameTextForPlayer(playerid, TXT_ExitHouseReloadEnv, ExitHouseTimer, 4);
  59. SetTimerEx("House_ExitTimer", ExitHouseTimer, false, "ii", playerid, HouseID);
  60. }
  61.  
  62. return 1;
  63. }
  64.  
  65. forward House_ExitTimer(playerid, HouseID);
  66. public House_ExitTimer(playerid, HouseID)
  67. {
  68. TogglePlayerControllable(playerid, 1);
  69. for (new CarSlot; CarSlot < 10; CarSlot++)
  70. if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
  71. SetVehicleToRespawn(AHouseData[HouseID][VehicleIDs][CarSlot]);
  72.  
  73. return 1;
  74. }
  75. House_CreateEntrance(HouseID)
  76. {
  77. new Msg[128], Float:x, Float:y, Float:z;
  78. x = AHouseData[HouseID][HouseX];
  79. y = AHouseData[HouseID][HouseY];
  80. z = AHouseData[HouseID][HouseZ];
  81. if (AHouseData[HouseID][Owned] == true)
  82. {
  83. AHouseData[HouseID][PickupID] = CreateDynamicPickup(1272, 1, x, y, z, 0);
  84. // Create the 3DText that appears above the house-pickup (displays the housename and the name of the owner)
  85. format(Msg, 128, TXT_PickupHouseOwned, AHouseData[HouseID][HouseName], AHouseData[HouseID][Owner], AHouseData[HouseID][HouseLevel]);
  86. AHouseData[HouseID][DoorText] = CreateDynamic3DTextLabel(Msg, 0x008080FF, x, y, z + 1.0, 50.0);
  87. // Add a streamed icon to the map (red house), type = 32, color = 0, world = 0, interior = 0, playerid = -1, drawdist = 150.0
  88. if (ShowBoughtHouses == true)
  89. AHouseData[HouseID][MapIconID] = CreateDynamicMapIcon(x, y, z, 32, 0, 0, 0, -1, 150.0);
  90. }
  91. else
  92. {
  93. // Create a green house-pickup (house is free)
  94. AHouseData[HouseID][PickupID] = CreateDynamicPickup(1273, 1, x, y, z, 0);
  95. // Create the 3DText that appears above the house-pickup (displays the price of the house)
  96. format(Msg, 128, TXT_PickupHouseForSale, AHouseData[HouseID][HousePrice], AHouseData[HouseID][HouseMaxLevel]);
  97. AHouseData[HouseID][DoorText] = CreateDynamic3DTextLabel(Msg, 0x008080FF, x, y, z + 1.0, 50.0);
  98. // Add a streamed icon to the map (green house), type = 31, color = 0, world = 0, interior = 0, playerid = -1, drawdist = 150.0
  99. AHouseData[HouseID][MapIconID] = CreateDynamicMapIcon(x, y, z, 31, 0, 0, 0, -1, 150.0);
  100. }
  101. }
  102. House_UpdateEntrance(HouseID)
  103. {
  104. // Setup local variables
  105. new Msg[128], Float:x, Float:y, Float:z;
  106.  
  107. // Get the coordinates of the house's pickup (usually near the door)
  108. x = AHouseData[HouseID][HouseX];
  109. y = AHouseData[HouseID][HouseY];
  110. z = AHouseData[HouseID][HouseZ];
  111.  
  112. // Destroy the pickup and map-icon near the house's entrance
  113. DestroyDynamicPickup(AHouseData[HouseID][PickupID]);
  114. DestroyDynamicMapIcon(AHouseData[HouseID][MapIconID]);
  115.  
  116. // Add a new pickup at the house's location (usually near the door), green = free, blue = owned
  117. if (AHouseData[HouseID][Owned] == true)
  118. {
  119. // Create a blue house-pickup (house is owned)
  120. AHouseData[HouseID][PickupID] = CreateDynamicPickup(1272, 1, x, y, z, 0);
  121. // Update the 3DText that appears above the house-pickup (displays the housename and the name of the owner)
  122. format(Msg, 128, TXT_PickupHouseOwned, AHouseData[HouseID][HouseName], AHouseData[HouseID][Owner], AHouseData[HouseID][HouseLevel]);
  123. UpdateDynamic3DTextLabelText(AHouseData[HouseID][DoorText], 0x008080FF, Msg);
  124. // Add a streamed icon to the map (red house), type = 32, color = 0, world = 0, interior = 0, playerid = -1, drawdist = 150.0
  125. if (ShowBoughtHouses == true)
  126. AHouseData[HouseID][MapIconID] = CreateDynamicMapIcon(x, y, z, 32, 0, 0, 0, -1, 150.0);
  127. }
  128. else
  129. {
  130. // Create a green house-pickup (house is free)
  131. AHouseData[HouseID][PickupID] = CreateDynamicPickup(1273, 1, x, y, z, 0);
  132. // Update the 3DText that appears above the house-pickup (displays the price of the house)
  133. format(Msg, 128, TXT_PickupHouseForSale, AHouseData[HouseID][HousePrice], AHouseData[HouseID][HouseMaxLevel]);
  134. UpdateDynamic3DTextLabelText(AHouseData[HouseID][DoorText], 0x008080FF, Msg);
  135. // Add a streamed icon to the map (green house), type = 31, color = 0, world = 0, interior = 0, playerid = -1, drawdist = 150.0
  136. AHouseData[HouseID][MapIconID] = CreateDynamicMapIcon(x, y, z, 31, 0, 0, 0, -1, 150.0);
  137. }
  138. }
  139. House_AddVehicle(HouseID, cModel, cPaint, cComponents[], Float:cx, Float:cy, Float:cz, Float:crot, Col1, Col2)
  140. {
  141. new vid, CarSlot;
  142. CarSlot = House_GetFreeCarSlot(HouseID);
  143. if (CarSlot != -1)
  144. {
  145. vid = CreateVehicle(cModel, cx, cy, cz, crot, Col1, Col2, 600);
  146. AHouseData[HouseID][VehicleIDs][CarSlot] = vid;
  147. AVehicleData[vid][Model] = cModel;
  148. AVehicleData[vid][PaintJob] = cPaint;
  149. if (cPaint != 0)
  150. ChangeVehiclePaintjob(vid, cPaint - 1);
  151. ChangeVehicleColor(vid, Col1, Col2);
  152. AVehicleData[vid][Color1] = Col1;
  153. AVehicleData[vid][Color2] = Col2;
  154. for (new i; i < 14; i++)
  155. {
  156. AVehicleData[vid][Components][i] = cComponents[i];
  157. if (AVehicleData[vid][Components][i] != 0)
  158. AddVehicleComponent(vid, AVehicleData[vid][Components][i]);
  159. }
  160. AVehicleData[vid][SpawnX] = cx;
  161. AVehicleData[vid][SpawnY] = cy;
  162. AVehicleData[vid][SpawnZ] = cz;
  163. AVehicleData[vid][SpawnRot] = crot;
  164. AVehicleData[vid][Fuel] = MaxFuel;
  165. AVehicleData[vid][Owned] = true;
  166. format(AVehicleData[vid][Owner], 24, AHouseData[HouseID][Owner]);
  167. AVehicleData[vid][BelongsToHouse] = HouseID;
  168. }
  169. else
  170. return 0;
  171. return vid;
  172. }
  173. House_ReplaceVehicle(HouseID, CarSlot)
  174. {
  175. // Setup local variables
  176. new vid, cModel, cPaint, cComponents[14], Float:cx, Float:cy, Float:cz, Float:crot, Col1, Col2, Float:Health, cFuel;
  177. new panels, doors, lights, tires;
  178.  
  179. // Get the data from the already existing vehicle that was parked before
  180. vid = AHouseData[HouseID][VehicleIDs][CarSlot];
  181. cModel = AVehicleData[vid][Model];
  182. cPaint = AVehicleData[vid][PaintJob];
  183. cFuel = AVehicleData[vid][Fuel];
  184. for (new i; i < 14; i++)
  185. cComponents[i] = AVehicleData[vid][Components][i];
  186. Col1 = AVehicleData[vid][Color1];
  187. Col2 = AVehicleData[vid][Color2];
  188. cx = AVehicleData[vid][SpawnX];
  189. cy = AVehicleData[vid][SpawnY];
  190. cz = AVehicleData[vid][SpawnZ];
  191. crot = AVehicleData[vid][SpawnRot];
  192. GetVehicleHealth(vid, Health);
  193. GetVehicleDamageStatus(vid, panels, doors, lights, tires);
  194.  
  195. // Delete the vehicle and clear the data
  196. Vehicle_Delete(vid);
  197.  
  198. // Create a new vehicle in the same carslot
  199. vid = House_AddVehicle(HouseID, cModel, cPaint, cComponents, Float:cx, Float:cy, Float:cz, Float:crot, Col1, Col2);
  200. // Update the fuel of the vehicle to the previous setting
  201. AVehicleData[vid][Fuel] = cFuel;
  202. // Update the health to what it was before and update the bodywork
  203. SetVehicleHealth(vid, Health);
  204. UpdateVehicleDamageStatus(vid, panels, doors, lights, tires);
  205.  
  206. return vid;
  207. }
  208.  
  209. // This function is used only when a player logs out (the vehicles are unloaded)
  210. House_RemoveVehicles(HouseID)
  211. {
  212. new vid;
  213. for (new CarSlot; CarSlot < 10; CarSlot++)
  214. {
  215. vid = AHouseData[HouseID][VehicleIDs][CarSlot];
  216. if (vid != 0)
  217. {
  218. DestroyVehicle(vid);
  219. AHouseData[HouseID][VehicleIDs][CarSlot] = 0;
  220. AVehicleData[vid][Owned] = false;
  221. AVehicleData[vid][Owner] = 0;
  222. AVehicleData[vid][Model] = 0;
  223. AVehicleData[vid][PaintJob] = 0;
  224. for (new i; i < 14; i++)
  225. AVehicleData[vid][Components][i] = 0;
  226. AVehicleData[vid][SpawnX] = 0.0;
  227. AVehicleData[vid][SpawnY] = 0.0;
  228. AVehicleData[vid][SpawnZ] = 0.0;
  229. AVehicleData[vid][SpawnRot] = 0.0;
  230. AVehicleData[vid][BelongsToHouse] = 0;
  231. }
  232. }
  233. }
  234. House_CalcSellPrice(HouseID)
  235. {
  236. new SellPrice, NumUpgrades, UpgradePrice;
  237. SellPrice = AHouseData[HouseID][HousePrice] / 2;
  238. NumUpgrades = AHouseData[HouseID][HouseLevel] - 1;
  239. UpgradePrice = ((AHouseData[HouseID][HousePrice] / 100) * HouseUpgradePercent) * NumUpgrades;
  240. SellPrice = SellPrice + UpgradePrice;
  241. return SellPrice;
  242. }
  243.  
  244. House_PlayerIsOwner(playerid, HouseID)
  245. {
  246. for (new i; i < MAX_HOUSESPERPLAYER; i++)
  247. {
  248. if (APlayerData[playerid][Houses][i] == HouseID)
  249. return 1;
  250. }
  251. return 0;
  252. }
  253. // /ircasa
  254. COMMAND:irparacasa(playerid, params[])
  255. {
  256. // Setup local variables
  257. new HouseList[1000];
  258.  
  259. // Send the command to all admins so they can see it
  260. SendAdminText(playerid, "/irparacasa", params);
  261.  
  262. // Check if the player has logged in
  263. if (APlayerData[playerid][LoggedIn] == true)
  264. {
  265. // Check if the player has a wanted level of less than 3
  266. if (GetPlayerWantedLevel(playerid) < 3)
  267. {
  268. // Check if the player is not jailed
  269. if (APlayerData[playerid][PlayerJailed] == 0)
  270. {
  271. // Check if the player is not inside a vehicle
  272. if (GetPlayerVehicleID(playerid) == 0)
  273. {
  274. // Ask to which house the player wants to add his vehicle
  275. for (new i; i < MAX_HOUSESPERPLAYER; i++)
  276. {
  277. // Check if this houseindex is occupied
  278. if (APlayerData[playerid][Houses][i] != 0)
  279. format(HouseList, 1000, "%s{00FF00}%s{FFFFFF}\n", HouseList, AHouseData[APlayerData[playerid][Houses][i]][HouseName]);
  280. else
  281. format(HouseList, 1000, "%s{FFFFFF}%s{FFFFFF}\n", HouseList, "Slot Vazio");
  282. }
  283. ShowPlayerDialog(playerid, DialogGoHome, DIALOG_STYLE_LIST, "Choose the house to go to:", HouseList, "Selecionar", "Cancelar");
  284. }
  285. else
  286. SendClientMessage(playerid, 0xFF0000FF, "Voce Precisa estar a pe para ir a Sua Casa");
  287. }
  288. else
  289. SendClientMessage(playerid, 0xFF0000FF, "Voce nao pode usar /irparacasa Preso");
  290. }
  291. else
  292. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Voce nao pode usar /irparacasa quando esta sendo Procurado");
  293. }
  294. else
  295. return 0;
  296.  
  297. // Let the server know that this was a valid command
  298. return 1;
  299. }
  300. // /usarcarro
  301. COMMAND:usarcarro(playerid, params[])
  302. {
  303. // Setup local variables
  304. new HouseList[1000];
  305.  
  306. // Send the command to all admins so they can see it
  307. SendAdminText(playerid, "/usarcarro", params);
  308.  
  309. // Check if the player has logged in
  310. if (APlayerData[playerid][LoggedIn] == true)
  311. {
  312. // Check if the player is not jailed
  313. if (APlayerData[playerid][PlayerJailed] == 0)
  314. {
  315. // Check if the player is not inside a vehicle
  316. if (GetPlayerVehicleID(playerid) == 0)
  317. {
  318. // Ask to which house the player wants to add his vehicle
  319. for (new i; i < MAX_HOUSESPERPLAYER; i++)
  320. {
  321. // Check if this houseindex is occupied
  322. if (APlayerData[playerid][Houses][i] != 0)
  323. format(HouseList, 1000, "%s{00FF00}%s{FFFFFF}\n", HouseList, AHouseData[APlayerData[playerid][Houses][i]][HouseName]);
  324. else
  325. format(HouseList, 1000, "%s{FFFFFF}%s{FFFFFF}\n", HouseList, "Slot Vazio");
  326. }
  327. ShowPlayerDialog(playerid, DialogGetCarSelectHouse, DIALOG_STYLE_LIST, "Escolha o Carro:", HouseList, "Selecionar", "Cancelar");
  328. }
  329. else
  330. SendClientMessage(playerid, 0xFF0000FF, "Voce Trouxe o Seu Veiculo a Sua Localizacao");
  331. }
  332. else
  333. SendClientMessage(playerid, 0xFF0000FF, "Voce Nao pode Usar /usarcarro Preso");
  334. }
  335. else
  336. return 0;
  337.  
  338. // Let the server know that this was a valid command
  339. return 1;
  340. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement