Guest User

iCasas v0.1.1

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