Guest User

iCasas v0.1

a guest
Jun 28th, 2018
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.26 KB | None | 0 0
  1. //======================================[ INCLUDES ]====================================||
  2. #include <a_samp>
  3. #include <sscanf2>
  4. #include <streamer>
  5. #include <a_mysql>
  6. #include <Pawn.CMD>
  7. #include <YSI\y_iterate>
  8. //======================================[ DEFINES ]====================================||
  9. #define MAX_HOUSES (64)
  10.  
  11. #define COR_ERRO 0xFF0000AA
  12. #define COR_AMARELO 0xFFFF00AA
  13.  
  14. #define HOST "localhost"
  15. #define USER "root"
  16. #define PASS ""
  17. #define DTBS "samp"
  18. //======================================[ ENUMS ]====================================||
  19. enum HouseInfos{
  20. cID,
  21. cProprietario[MAX_PLAYER_NAME],
  22. cValor,
  23. cInterior,
  24. cVirtualWorld,
  25. cComprado,
  26.  
  27. Text3D:cText,
  28. cMapIcon,
  29. cPickUp,
  30.  
  31. Float:cPosX,
  32. Float:cPosY,
  33. Float:cPosZ,
  34.  
  35. Float:InteriorX,
  36. Float:InteriorY,
  37. Float:InteriorZ,
  38. Float:InteriorA
  39.  
  40. }
  41. //======================================[ FILTERSCRIPT ]====================================||
  42. new Iterator:HouseIterator<MAX_HOUSES>;
  43. static Casas[MAX_HOUSES][HouseInfos];
  44. new MySQL: ConexaoID;
  45.  
  46.  
  47. public OnFilterScriptInit()
  48. {
  49. print("\n--------------------------------------");
  50. print(" iCasas v0.1 - - - - - - - - By: Cauezin");
  51. print("--------------------------------------\n");
  52. ConectarDB();
  53. DisableInteriorEnterExits();
  54. return 1;
  55. }
  56.  
  57. public OnFilterScriptExit()
  58. {
  59. return 1;
  60. }
  61. stock GetPlayerNameEx(playerid)
  62. {
  63. static Name[MAX_PLAYER_NAME];
  64. GetPlayerName(playerid, Name, sizeof(Name));
  65. return Name;
  66. }
  67. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  68. {
  69. if(newkeys == KEY_SECONDARY_ATTACK)
  70. {
  71. new id = GetPlayerNearestHouse(playerid);
  72. new string[64];
  73.  
  74. if(id > -1)
  75. {
  76. SetPlayerPos(playerid, Casas[id][InteriorX], Casas[id][InteriorY], Casas[id][InteriorZ]);
  77. SetPlayerFacingAngle(playerid, Casas[id][InteriorA]);
  78. SetPlayerVirtualWorld(playerid, Casas[id][cID]);
  79. SetPlayerInterior(playerid, Casas[id][cInterior]);
  80.  
  81. format(string, sizeof(string), "[Casas] Você entrou na casa [%d]", Casas[id][cID]);
  82. SendClientMessage(playerid, -1, string);
  83. }
  84. }
  85. if(newkeys == KEY_SECONDARY_ATTACK)
  86. {
  87. new id = GetPlayerNearestExitHouse(playerid);
  88. new Float: Ang;
  89. if(id > -1)
  90. {
  91. SetPlayerPos(playerid, Casas[id][cPosX], Casas[id][cPosY], Casas[id][cPosZ]);
  92. SetPlayerFacingAngle(playerid, GetPlayerFacingAngle(playerid, Ang));
  93. SetPlayerVirtualWorld(playerid, 0);
  94. SetPlayerInterior(playerid,0);
  95.  
  96. SendClientMessage(playerid, COR_AMARELO, "[iCasas] Você saiu dessa casa.");
  97. }
  98. }
  99. return 1;
  100. }
  101. stock ConectarDB()
  102. {
  103. ConexaoID = mysql_connect(HOST, USER, PASS, DTBS);
  104. if(ConexaoID == MYSQL_INVALID_HANDLE || mysql_errno(ConexaoID) != 0)
  105. {
  106. print("[MYSQL] Conexão falhou.");
  107. }else{
  108. print("[MYSQL] Conexão bem sucedida");
  109. CarregarCasasInfo();
  110. }
  111. }
  112. forward CarregarCasasInfo();
  113. public CarregarCasasInfo()
  114. {
  115. new Cache:cache = mysql_query(ConexaoID, "SELECT * FROM `Casas`", true);
  116.  
  117. if(cache_num_rows())
  118. {
  119. for(new i=0, rows = cache_num_rows(); i < rows; i++)
  120. {
  121. cache_get_value_name_int(i, "cID", Casas[i][cID]);
  122.  
  123. cache_get_value_name(i, "cProprietario", Casas[i][cProprietario], MAX_PLAYER_NAME);
  124. cache_get_value_name_int(i, "cValor", Casas[i][cValor]);
  125. cache_get_value_name_int(i, "cInterior", Casas[i][cInterior]);
  126. cache_get_value_name_int(i, "cVirtualWorld", Casas[i][cID]);
  127. cache_get_value_name_int(i, "cComprado", Casas[i][cComprado]);
  128.  
  129. cache_get_value_name_float(i, "cPosX", Casas[i][cPosX]);
  130. cache_get_value_name_float(i, "cPosY", Casas[i][cPosY]);
  131. cache_get_value_name_float(i, "cPosZ", Casas[i][cPosZ]);
  132. cache_get_value_name_float(i, "InteriorX", Casas[i][InteriorX]);
  133. cache_get_value_name_float(i, "InteriorY", Casas[i][InteriorY]);
  134. cache_get_value_name_float(i, "InteriorZ", Casas[i][InteriorZ]);
  135. cache_get_value_name_float(i, "InteriorA", Casas[i][InteriorA]);
  136.  
  137.  
  138. UpdateHouse(i);
  139. Iter_Add(HouseIterator, i);
  140. }
  141. }
  142. cache_delete(cache);
  143. return 1;
  144. }
  145. stock UpdateHouse(id)
  146. {
  147. new string[254];
  148. if(Casas[id][cComprado] == 0)
  149. {
  150. format(string, sizeof(string), "ID: {FFFF33}%d | %d{FFFFFF}\n\nProprietario: {FFFF33}N/A.{FFFFFF}\nValor: {FFFF33}%dR${FFFFFF}.\nUse {FFFF33}/comprarcasa {FFFFFF}para comprar.", Casas[id][cID], Casas[id][cVirtualWorld], Casas[id][cValor]);
  151.  
  152. Casas[id][cText] = CreateDynamic3DTextLabel(string, -1, Casas[id][cPosX], Casas[id][cPosY], Casas[id][cPosZ], 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, 0, 0);
  153. Casas[id][cPickUp] = CreateDynamicPickup((Casas[id][cComprado] != 0) ? (19522) : (1273), 23, Casas[id][cPosX], Casas[id][cPosY], Casas[id][cPosZ], 0, 0);
  154. Casas[id][cMapIcon] = CreateDynamicMapIcon(Casas[id][cPosX], Casas[id][cPosY], Casas[id][cPosZ], (Casas[id][cComprado] != 0) ? (32) : (31), 0, 0, 0);
  155. }else{
  156. format(string, sizeof(string), "ID: {FFFF33}%d{FFFFFF}\n\nProprietario: {FFFF33}%s\nUse {FFFF33}/entrar {FFFFFF}para entrar na casa.", Casas[id][cID], Casas[id][cProprietario]);
  157. Casas[id][cText] = CreateDynamic3DTextLabel(string, -1, Casas[id][cPosX], Casas[id][cPosY], Casas[id][cPosZ], 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, 0, 0);
  158. Casas[id][cPickUp] = CreateDynamicPickup((Casas[id][cComprado] != 0) ? (19522) : (1273), 23, Casas[id][cPosX], Casas[id][cPosY], Casas[id][cPosZ], 0, 0);
  159. Casas[id][cMapIcon] = CreateDynamicMapIcon(Casas[id][cPosX], Casas[id][cPosY], Casas[id][cPosZ], (Casas[id][cComprado] != 0) ? (32) : (31), 0, 0, 0);
  160. }
  161.  
  162. return 1;
  163. }
  164. CreateHouse(price, interior ,Float:x, Float:y, Float:z ,Float: intx ,Float: inty , Float:intz, Float:inta)
  165. {
  166. new id = Iter_Free(HouseIterator);
  167.  
  168. if (id == cellmin)
  169. return -1;
  170.  
  171. Casas[id][cProprietario][0] = EOS;
  172. Casas[id][cComprado] = 0;
  173.  
  174. Casas[id][cValor] = price;
  175.  
  176. Casas[id][cInterior] = interior;
  177.  
  178. Casas[id][cPosX] = x;
  179. Casas[id][cPosY] = y;
  180. Casas[id][cPosZ] = z;
  181.  
  182. Casas[id][InteriorX] = intx;
  183. Casas[id][InteriorY] = inty;
  184. Casas[id][InteriorZ] = intz;
  185. Casas[id][InteriorA] = inta;
  186.  
  187. if(interior == 0)
  188. {
  189. Casas[id][InteriorX] = 2196.84;
  190. Casas[id][InteriorY] = -1204.36;
  191. Casas[id][InteriorZ] = 1049.02;
  192. Casas[id][InteriorA] = 94.0010;
  193. Casas[id][cInterior] = 6;
  194. }
  195. if(interior == 1)
  196. {
  197. Casas[id][InteriorX] = 2259.38;
  198. Casas[id][InteriorY] = -1135.89;
  199. Casas[id][InteriorZ] = 1050.64;
  200. Casas[id][InteriorA] = 275.3992;
  201. Casas[id][cInterior] = 10;
  202. }
  203. if(interior == 2)
  204. {
  205. Casas[id][InteriorX] = 2282.99;
  206. Casas[id][InteriorY] = -1140.28;
  207. Casas[id][InteriorZ] = 1050.89;
  208. Casas[id][InteriorA] = 358.4660;
  209. Casas[id][cInterior] = 11;
  210. }
  211. if(interior == 3)
  212. {
  213. Casas[id][InteriorX] = 2233.69;
  214. Casas[id][InteriorY] = -1115.26;
  215. Casas[id][InteriorZ] = 1050.88;
  216. Casas[id][InteriorA] = 358.4660;
  217. Casas[id][cInterior] = 5;
  218. }
  219. if(interior == 4)
  220. {
  221. Casas[id][InteriorX] = 2218.39;
  222. Casas[id][InteriorY] = -1076.21;
  223. Casas[id][InteriorZ] = 1050.48;
  224. Casas[id][InteriorA] = 95.2635;
  225. Casas[id][cInterior] = 1;
  226. }
  227. if(interior == 5)
  228. {
  229. Casas[id][InteriorX] = 2496.00;
  230. Casas[id][InteriorY] = -1692.08;
  231. Casas[id][InteriorZ] = 1014.74;
  232. Casas[id][InteriorA] = 177.8159;
  233. Casas[id][cInterior] = 3;
  234. }
  235. if(interior == 6)
  236. {
  237. Casas[id][InteriorX] = 2365.25;
  238. Casas[id][InteriorY] = -1135.58;
  239. Casas[id][InteriorZ] = 1050.88;
  240. Casas[id][InteriorA] = 359.0367;
  241. Casas[id][cInterior] = 8;
  242. }
  243. if(interior == 7)
  244. {
  245. Casas[id][InteriorX] = 140.28;
  246. Casas[id][InteriorY] = 1365.92;
  247. Casas[id][InteriorZ] = 1083.85;
  248. Casas[id][InteriorA] = 9.6901;
  249. Casas[id][cInterior] = 5;
  250. }
  251. if(interior == 8)
  252. {
  253. Casas[id][InteriorX] = 2317.77;
  254. Casas[id][InteriorY] = -1026.76;
  255. Casas[id][InteriorZ] = 1050.21;
  256. Casas[id][InteriorA] = 359.0367;
  257. Casas[id][cInterior] = 9;
  258. }
  259. if(interior == 9)
  260. {
  261. Casas[id][InteriorX] = 2324.41;
  262. Casas[id][InteriorY] = -1149.54;
  263. Casas[id][InteriorZ] = 1050.71;
  264. Casas[id][InteriorA] = 359.0367;
  265. Casas[id][cInterior] = 12;
  266. }
  267. if(interior == 10)
  268. {
  269. Casas[id][InteriorX] = 1260.6603;
  270. Casas[id][InteriorY] = -785.4005;
  271. Casas[id][InteriorZ] = 1091.9063;
  272. Casas[id][InteriorA] = 270.9891;
  273. Casas[id][cInterior] = 5;
  274. }
  275.  
  276.  
  277.  
  278.  
  279. new query[300];
  280. mysql_format(ConexaoID, query, sizeof(query), "INSERT INTO `Casas` ( `cValor`, `cPosX`, `cPosY`, `cPosZ`, `cComprado` , `cInterior` , `InteriorX` , `InteriorY` , `InteriorZ` , `InteriorA` ) VALUES ( %i , %f , %f , %f, %i , %i , %f , %f , %f , %f )",
  281. Casas[id][cValor],
  282. Casas[id][cPosX],
  283. Casas[id][cPosY],
  284. Casas[id][cPosZ],
  285. Casas[id][cComprado],
  286. Casas[id][cInterior],
  287. Casas[id][InteriorX],
  288. Casas[id][InteriorY],
  289. Casas[id][InteriorZ],
  290. Casas[id][InteriorA]);
  291. mysql_tquery(ConexaoID, query, "OnInsertHouse", "i", id);
  292.  
  293.  
  294. Iter_Add(HouseIterator, id);
  295. return id;
  296. }
  297. forward OnInsertHouse(id);
  298. public OnInsertHouse(id)
  299. {
  300. new index = cache_insert_id();
  301. Casas[id][cID] = index;
  302. Casas[id][cVirtualWorld] = index;
  303. UpdateHouse(id);
  304. printf("[iCasas]Casa ID %i | %i inserida com sucesso na database.", index, Casas[id][cVirtualWorld]);
  305. }
  306. PlayerHaveHouse(playerid)
  307. {
  308. for (new i = 0; i < MAX_HOUSES; i ++)
  309. {
  310. if (!Casas[i][cComprado])
  311. continue;
  312.  
  313. if (!strcmp(Casas[i][cProprietario], GetPlayerNameEx(playerid)))
  314. return 1;
  315. }
  316. return 0;
  317. }
  318. GetPlayerNearestHouse(playerid, Float:range = 2.5)
  319. {
  320. foreach (new i : HouseIterator)
  321. {
  322. if (IsPlayerInRangeOfPoint(playerid, range, Casas[i][cPosX], Casas[i][cPosY], Casas[i][cPosZ]))
  323. return i;
  324. }
  325. return -1;
  326. }
  327. GetPlayerNearestExitHouse(playerid, Float:range = 2.5)
  328. {
  329. foreach (new i : HouseIterator)
  330. {
  331. if (IsPlayerInRangeOfPoint(playerid, range, Casas[i][InteriorX], Casas[i][InteriorY], Casas[i][InteriorZ]))
  332. return i;
  333. }
  334. return -1;
  335. }
  336. CMD:criarcasa(playerid, params[])
  337. {
  338. if(!IsPlayerAdmin(playerid))
  339. return 0;
  340. new Float:x, Float:y, Float:z ,Float: intx,Float: inty, Float:intz, Float:inta ,interior, price;
  341. new string [100];
  342. GetPlayerPos(playerid, x, y, z);
  343.  
  344. new id;
  345. if(sscanf(params, "ii", price, interior))
  346. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Digite /criarcasa [valor] [interior 0-10]"), 0;
  347. if(interior > 10 || interior < 0)
  348. return SendClientMessage(id, COR_ERRO, "[iCasas] Digite /criarcasa [valor] {6300af}[interior *0-10*]"), 0;
  349. id = CreateHouse(price,interior, x, y, z, intx, inty, intz, inta);
  350. if (id == -1)
  351. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Limite de casas atingido.");
  352.  
  353. format(string, sizeof(string), "[iCasas] Casa criada com sucesso Valor: %d | Interior: %d", price, interior);
  354. SendClientMessage(playerid, COR_AMARELO, string);
  355. return 1;
  356. }
  357. CMD:editarcasa(playerid, params[])
  358. {
  359. if(!IsPlayerAdmin(playerid))
  360. return 0;
  361. new id = GetPlayerNearestHouse(playerid);
  362. new query[250], interior;
  363. new str[120];
  364.  
  365.  
  366. if (id == -1)
  367. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você não está em um ícone de uma casa");
  368. if(sscanf(params, "ii", Casas[id][cValor], interior))
  369. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Digite /editarcasa [valor] [interior 0-10]");
  370. if(Casas[id][cInterior] > 10 || Casas[id][cInterior] < 0)
  371. return SendClientMessage(id, COR_ERRO, "[iCasas] Digite /criarcasa [valor] {6300af}[interior *0-10*]");
  372.  
  373. if(interior == 0)
  374. {
  375. Casas[id][InteriorX] = 2196.84;
  376. Casas[id][InteriorY] = -1204.36;
  377. Casas[id][InteriorZ] = 1049.02;
  378. Casas[id][InteriorA] = 94.0010;
  379. Casas[id][cInterior] = 6;
  380. }
  381. if(interior == 1)
  382. {
  383. Casas[id][InteriorX] = 2259.38;
  384. Casas[id][InteriorY] = -1135.89;
  385. Casas[id][InteriorZ] = 1050.64;
  386. Casas[id][InteriorA] = 275.3992;
  387. Casas[id][cInterior] = 10;
  388. }
  389. if(interior == 2)
  390. {
  391. Casas[id][InteriorX] = 2282.99;
  392. Casas[id][InteriorY] = -1140.28;
  393. Casas[id][InteriorZ] = 1050.89;
  394. Casas[id][InteriorA] = 358.4660;
  395. Casas[id][cInterior] = 11;
  396. }
  397. if(interior == 3)
  398. {
  399. Casas[id][InteriorX] = 2233.69;
  400. Casas[id][InteriorY] = -1115.26;
  401. Casas[id][InteriorZ] = 1050.88;
  402. Casas[id][InteriorA] = 358.4660;
  403. Casas[id][cInterior] = 5;
  404. }
  405. if(interior == 4)
  406. {
  407. Casas[id][InteriorX] = 2218.39;
  408. Casas[id][InteriorY] = -1076.21;
  409. Casas[id][InteriorZ] = 1050.48;
  410. Casas[id][InteriorA] = 95.2635;
  411. Casas[id][cInterior] = 1;
  412. }
  413. if(interior == 5)
  414. {
  415. Casas[id][InteriorX] = 2496.00;
  416. Casas[id][InteriorY] = -1692.08;
  417. Casas[id][InteriorZ] = 1014.74;
  418. Casas[id][InteriorA] = 177.8159;
  419. Casas[id][cInterior] = 3;
  420. }
  421. if(interior == 6)
  422. {
  423. Casas[id][InteriorX] = 2365.25;
  424. Casas[id][InteriorY] = -1135.58;
  425. Casas[id][InteriorZ] = 1050.88;
  426. Casas[id][InteriorA] = 359.0367;
  427. Casas[id][cInterior] = 8;
  428. }
  429. if(interior == 7)
  430. {
  431. Casas[id][InteriorX] = 140.28;
  432. Casas[id][InteriorY] = 1365.92;
  433. Casas[id][InteriorZ] = 1083.85;
  434. Casas[id][InteriorA] = 9.6901;
  435. Casas[id][cInterior] = 5;
  436. }
  437. if(interior == 8)
  438. {
  439. Casas[id][InteriorX] = 2317.77;
  440. Casas[id][InteriorY] = -1026.76;
  441. Casas[id][InteriorZ] = 1050.21;
  442. Casas[id][InteriorA] = 359.0367;
  443. Casas[id][cInterior] = 9;
  444. }
  445. if(interior == 9)
  446. {
  447. Casas[id][InteriorX] = 2324.41;
  448. Casas[id][InteriorY] = -1149.54;
  449. Casas[id][InteriorZ] = 1050.71;
  450. Casas[id][InteriorA] = 359.0367;
  451. Casas[id][cInterior] = 12;
  452. }
  453. if(interior == 10)
  454. {
  455. Casas[id][InteriorX] = 1260.6603;
  456. Casas[id][InteriorY] = -785.4005;
  457. Casas[id][InteriorZ] = 1091.9063;
  458. Casas[id][InteriorA] = 270.9891;
  459. Casas[id][cInterior] = 5;
  460. }
  461.  
  462. mysql_format(ConexaoID, query, sizeof(query), "UPDATE `Casas` SET `cValor`='%i' , `cInterior`='%i' , `InteriorX`='%f' , `InteriorY`='%f' , `InteriorZ`='%f' , `InteriorA`='%f' WHERE `cID`='%i' ",
  463. Casas[id][cValor],
  464. Casas[id][cInterior],
  465. Casas[id][InteriorX],
  466. Casas[id][InteriorY],
  467. Casas[id][InteriorZ],
  468. Casas[id][InteriorA],
  469. Casas[id][cID]);
  470. mysql_query(ConexaoID, query);
  471.  
  472.  
  473. format(str, sizeof(str), "[iCasas] Você atualizou a casa [%d] | Valor: %d | Interior: %d.", Casas[id][cID], Casas[id][cValor], interior);
  474. SendClientMessage(playerid, COR_AMARELO, str);
  475.  
  476. DestroyDynamicMapIcon(Casas[id][cMapIcon]);
  477. DestroyDynamicPickup(Casas[id][cPickUp]);
  478. DestroyDynamic3DTextLabel(Casas[id][cText]);
  479.  
  480. UpdateHouse(id);
  481.  
  482. return 1;
  483. }
  484. CMD:comprarcasa(playerid, params[])
  485. {
  486. new id = GetPlayerNearestHouse(playerid);
  487.  
  488. if (id == -1)
  489. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você não está em um ícone de uma casa.");
  490.  
  491. if(Casas[id][cComprado] == 1)
  492. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Essa casa já possui um dono.");
  493. if(PlayerHaveHouse(playerid))
  494. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você já tem uma casa.");
  495.  
  496. if(GetPlayerMoney(playerid) < Casas[id][cValor])
  497. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você não tem dinheiro suficiente.");
  498.  
  499. GivePlayerMoney(playerid, -Casas[id][cValor]);
  500.  
  501. DestroyDynamicMapIcon(Casas[id][cMapIcon]);
  502. DestroyDynamicPickup(Casas[id][cPickUp]);
  503. DestroyDynamic3DTextLabel(Casas[id][cText]);
  504.  
  505. Casas[id][cComprado] = 1;
  506. Casas[id][cProprietario] = EOS;
  507. strcat(Casas[id][cProprietario], GetPlayerNameEx(playerid), MAX_PLAYER_NAME);
  508.  
  509. new query[140];
  510. new string[60];
  511. mysql_format(ConexaoID, query, sizeof(query), "UPDATE `Casas` SET `cProprietario`='%e', `cComprado`='%i', `cVirtualWorld`='%i' WHERE `cID`='%i' ", Casas[id][cProprietario], Casas[id][cComprado], Casas[id][cID], Casas[id][cID]);
  512. mysql_query(ConexaoID, query);
  513.  
  514. format(string, sizeof(string), "[iCasas] O(A) %s comprou a casa ID %d.", Casas[id][cProprietario], Casas[id][cID]);
  515. SendClientMessageToAll(COR_AMARELO, string);
  516. UpdateHouse(id);
  517. return 1;
  518. }
  519. CMD:vendercasa(playerid)
  520. {
  521. new id = GetPlayerNearestHouse(playerid);
  522. new Name[MAX_HOUSES];
  523. Name[id] = EOS;
  524. strcat(Name[id], GetPlayerNameEx(playerid), MAX_PLAYER_NAME);
  525. if (id == -1)
  526. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você não está em um ícone de uma casa.");
  527. if(Casas[id][cComprado] == 0)
  528. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Essa casa não possui um dono.");
  529. if(Casas[id][cProprietario] != Name[id])
  530. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você não é dono dessa casa.");
  531.  
  532.  
  533. DestroyDynamicMapIcon(Casas[id][cMapIcon]);
  534. DestroyDynamicPickup(Casas[id][cPickUp]);
  535. DestroyDynamic3DTextLabel(Casas[id][cText]);
  536.  
  537.  
  538. new string[128];
  539. new query[150];
  540. GivePlayerMoney(playerid, Casas[id][cValor] * 75 / 100);
  541. format(string, sizeof(string), "[iCasas] O(A) %s vendeu a sua casa ID %d.", Casas[id][cProprietario], Casas[id][cID]);
  542. SendClientMessageToAll(COR_AMARELO, string);
  543.  
  544. Casas[id][cComprado] = 0;
  545.  
  546.  
  547. mysql_format(ConexaoID, query, sizeof(query), "UPDATE `Casas` SET `cProprietario`=NULL , `cComprado`='0' WHERE `cID`='%i' ", Casas[id][cID]);
  548. mysql_query(ConexaoID, query);
  549.  
  550.  
  551.  
  552. UpdateHouse(id);
  553. return 1;
  554. }
  555. CMD:excluircasa(playerid)
  556. {
  557. if(!IsPlayerAdmin(playerid))
  558. return 0;
  559. new id = GetPlayerNearestHouse(playerid);
  560. new query[200];
  561. if(id == -1)
  562. return SendClientMessage(playerid, COR_ERRO, "[iCasa] Você não está no ícone de uma casa");
  563.  
  564. mysql_format(ConexaoID, query, sizeof(query), "DELETE FROM `Casas` WHERE `cID`='%d'", Casas[id][cID]);
  565. mysql_query(ConexaoID, query);
  566.  
  567. format(query, sizeof(query), "[iCasas] Você excluiu a casa [%d]", Casas[id][cID]);
  568. SendClientMessage(playerid, COR_AMARELO, query);
  569.  
  570. DestroyDynamicMapIcon(Casas[id][cMapIcon]);
  571. DestroyDynamicPickup(Casas[id][cPickUp]);
  572. DestroyDynamic3DTextLabel(Casas[id][cText]);
  573. return 1;
  574. }
Advertisement
Add Comment
Please, Sign In to add comment