Guest User

iCasas v0.2.1

a guest
Jun 30th, 2018
1,433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.75 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. cLevel,
  27. cLevelMax,
  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.  
  75. if(newkeys == KEY_SECONDARY_ATTACK)
  76. {
  77. new id = GetPlayerNearestHouse(playerid);
  78.  
  79. if(id > -1)
  80. {
  81. SetPlayerPos(playerid, Casas[id][InteriorX], Casas[id][InteriorY], Casas[id][InteriorZ]);
  82. SetPlayerFacingAngle(playerid, Casas[id][InteriorA]);
  83. SetPlayerVirtualWorld(playerid, Casas[id][cID]);
  84. SetPlayerInterior(playerid, Casas[id][cInterior]);
  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. cache_get_value_name_int(i, "cLevel", Casas[i][cLevel]);
  133. cache_get_value_name_int(i, "cLevelMax", Casas[i][cLevelMax]);
  134.  
  135. cache_get_value_name_float(i, "cPosX", Casas[i][cPosX]);
  136. cache_get_value_name_float(i, "cPosY", Casas[i][cPosY]);
  137. cache_get_value_name_float(i, "cPosZ", Casas[i][cPosZ]);
  138. cache_get_value_name_float(i, "InteriorX", Casas[i][InteriorX]);
  139. cache_get_value_name_float(i, "InteriorY", Casas[i][InteriorY]);
  140. cache_get_value_name_float(i, "InteriorZ", Casas[i][InteriorZ]);
  141. cache_get_value_name_float(i, "InteriorA", Casas[i][InteriorA]);
  142.  
  143.  
  144. UpdateHouse(i);
  145. Iter_Add(HouseIterator, i);
  146. }
  147. }
  148. cache_delete(cache);
  149. return 1;
  150. }
  151. stock UpdateHouse(id)
  152. {
  153. new string[350];
  154. if(Casas[id][cComprado] == 0)
  155. {
  156. format(string, sizeof(string), "ID: {FFFF33}%d{FFFFFF}\nLevel: {FFFF33}%d{FFFFFF}|{FFFF33}%d\n\n{FFFFFF}Proprietario: {FFFF33}N/A.{FFFFFF}\nValor: {FFFF33}%dR${FFFFFF}.\nUse {FFFF33}/comprarcasa {FFFFFF}para comprar.", Casas[id][cID], Casas[id][cLevel], Casas[id][cLevelMax],Casas[id][cValor]);
  157.  
  158. 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);
  159. Casas[id][cPickUp] = CreateDynamicPickup((Casas[id][cComprado] != 0) ? (19522) : (1273), 23, Casas[id][cPosX], Casas[id][cPosY], Casas[id][cPosZ], 0, 0);
  160. Casas[id][cMapIcon] = CreateDynamicMapIcon(Casas[id][cPosX], Casas[id][cPosY], Casas[id][cPosZ], (Casas[id][cComprado] != 0) ? (32) : (31), 0, 0, 0);
  161. }else{
  162. format(string, sizeof(string), "ID: {FFFF33}%d{FFFFFF}\nLevel: {FFFF33}%d{FFFFFF}|{FFFF33}%d\n\nProprietario: {FFFF33}%s\nPressione {FFFF33}F{FFFFFF} para entrar na casa.", Casas[id][cID], Casas[id][cLevel], Casas[id][cLevelMax], Casas[id][cProprietario]);
  163. 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);
  164. Casas[id][cPickUp] = CreateDynamicPickup((Casas[id][cComprado] != 0) ? (19522) : (1273), 23, Casas[id][cPosX], Casas[id][cPosY], Casas[id][cPosZ], 0, 0);
  165. Casas[id][cMapIcon] = CreateDynamicMapIcon(Casas[id][cPosX], Casas[id][cPosY], Casas[id][cPosZ], (Casas[id][cComprado] != 0) ? (32) : (31), 0, 0, 0);
  166. }
  167.  
  168. return 1;
  169. }
  170. CreateHouse(price, levelmax ,Float:x, Float:y, Float:z ,Float: intx ,Float: inty , Float:intz, Float:inta)
  171. {
  172. new id = Iter_Free(HouseIterator);
  173.  
  174. if (id == cellmin)
  175. return -1;
  176.  
  177. Casas[id][cProprietario][0] = EOS;
  178. Casas[id][cComprado] = 0;
  179.  
  180. Casas[id][cValor] = price;
  181.  
  182. Casas[id][cLevel] = 0;
  183. Casas[id][cLevelMax] = levelmax;
  184.  
  185. Casas[id][cPosX] = x;
  186. Casas[id][cPosY] = y;
  187. Casas[id][cPosZ] = z;
  188.  
  189. Casas[id][InteriorX] = intx;
  190. Casas[id][InteriorY] = inty;
  191. Casas[id][InteriorZ] = intz;
  192. Casas[id][InteriorA] = inta;
  193.  
  194. switch(Casas[id][cLevel])
  195. {
  196. case 0:
  197. {
  198. Casas[id][InteriorX] = 2233.69;
  199. Casas[id][InteriorY] = -1115.26;
  200. Casas[id][InteriorZ] = 1050.88;
  201. Casas[id][InteriorA] = 358.4660;
  202. Casas[id][cInterior] = 5;
  203. }
  204. }
  205.  
  206. new query[300];
  207. mysql_format(ConexaoID, query, sizeof(query), "INSERT INTO `Casas` ( `cValor`, `cPosX`, `cPosY`, `cPosZ`, `cComprado` , `cInterior` , `InteriorX` , `InteriorY` , `InteriorZ` , `InteriorA`, `cLevelMax` , `cLevel` ) VALUES ( %i , %f , %f , %f, %i , %i , %f , %f , %f , %f , %i , %i )",
  208. Casas[id][cValor],
  209. Casas[id][cPosX],
  210. Casas[id][cPosY],
  211. Casas[id][cPosZ],
  212. Casas[id][cComprado],
  213. Casas[id][cInterior],
  214. Casas[id][InteriorX],
  215. Casas[id][InteriorY],
  216. Casas[id][InteriorZ],
  217. Casas[id][InteriorA],
  218. Casas[id][cLevelMax],
  219. Casas[id][cLevel]);
  220. mysql_tquery(ConexaoID, query, "OnInsertHouse", "i", id);
  221.  
  222.  
  223. Iter_Add(HouseIterator, id);
  224. return id;
  225. }
  226. forward OnInsertHouse(id);
  227. public OnInsertHouse(id)
  228. {
  229. new index = cache_insert_id();
  230. Casas[id][cID] = index;
  231. Casas[id][cVirtualWorld] = index;
  232. UpdateHouse(id);
  233. printf("[iCasas]Casa ID %i | %i inserida com sucesso na database.", index, Casas[id][cVirtualWorld]);
  234. }
  235. PlayerHaveHouse(playerid)
  236. {
  237. for (new i = 0; i < MAX_HOUSES; i ++)
  238. {
  239. if (!Casas[i][cComprado])
  240. continue;
  241.  
  242. if (!strcmp(Casas[i][cProprietario], GetPlayerNameEx(playerid)))
  243. return 1;
  244. }
  245. return 0;
  246. }
  247. GetPlayerNearestHouse(playerid, Float:range = 2.5)
  248. {
  249. foreach (new i : HouseIterator)
  250. {
  251. if (IsPlayerInRangeOfPoint(playerid, range, Casas[i][cPosX], Casas[i][cPosY], Casas[i][cPosZ]))
  252. return i;
  253. }
  254. return -1;
  255. }
  256. GetPlayerNearestExitHouse(playerid, Float:range = 2.5)
  257. {
  258. foreach (new i : HouseIterator)
  259. {
  260. if (IsPlayerInRangeOfPoint(playerid, range, Casas[i][InteriorX], Casas[i][InteriorY], Casas[i][InteriorZ]) && GetPlayerVirtualWorld(playerid) == Casas[i][cID])
  261. return i;
  262. }
  263. return -1;
  264. }
  265. CMD:criarcasa(playerid, params[])
  266. {
  267. if(!IsPlayerAdmin(playerid))
  268. return 0;
  269. new Float:x, Float:y, Float:z ,Float: intx,Float: inty, Float:intz, Float:inta , levelmax, price;
  270. new string [100];
  271. GetPlayerPos(playerid, x, y, z);
  272.  
  273. new id;
  274. if(sscanf(params, "ii", price, levelmax))
  275. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Digite /criarcasa [valor] [levelmax 0-10]"), 0;
  276. if(levelmax > 10 || levelmax < 0)
  277. return SendClientMessage(id, COR_ERRO, "[iCasas] Digite /criarcasa [valor] {6300af}[levelmax *0-10*]"), 0;
  278. id = CreateHouse(price, levelmax, x, y, z, intx, inty, intz, inta);
  279. if (id == -1)
  280. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Limite de casas atingido.");
  281.  
  282.  
  283. SendClientMessage(playerid, COR_AMARELO, "[iCasas] Casa criada com sucesso. ");
  284. format(string, sizeof(string), "[iCasas] Valor: $%d | LevelMax: [ %d ]", price, levelmax);
  285. SendClientMessage(playerid, COR_AMARELO, string);
  286. return 1;
  287. }
  288. CMD:editarcasa(playerid, params[])
  289. {
  290. if(!IsPlayerAdmin(playerid))
  291. return 0;
  292. new id = GetPlayerNearestHouse(playerid);
  293. new query[250], levelmax, level;
  294. new str[120];
  295.  
  296.  
  297. if (id == -1)
  298. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você não está em um ícone de uma casa");
  299. if(sscanf(params, "iii", Casas[id][cValor], Casas[id][cLevel] ,levelmax))
  300. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Digite /editarcasa [valor] [level *0-10*] [LevelMax 0-10]");
  301. if(levelmax > 10 || levelmax < 0 || level > levelmax || level < 0)
  302. return SendClientMessage(id, COR_ERRO, "[iCasas] Digite /criarcasa [valor] {6300af}[level *0-10*] [LevelMax *0-10*]");
  303.  
  304. switch(Casas[id][cLevel])
  305. {
  306. case 0:
  307. {
  308. Casas[id][InteriorX] = 2233.69;
  309. Casas[id][InteriorY] = -1115.26;
  310. Casas[id][InteriorZ] = 1050.88;
  311. Casas[id][InteriorA] = 358.4660;
  312. Casas[id][cInterior] = 5;
  313. }
  314. case 1:
  315. {
  316. Casas[id][InteriorX] = 2282.99;
  317. Casas[id][InteriorY] = -1140.28;
  318. Casas[id][InteriorZ] = 1050.89;
  319. Casas[id][InteriorA] = 358.4660;
  320. Casas[id][cInterior] = 11;
  321. }
  322. case 2:
  323. {
  324. Casas[id][InteriorX] = 2259.38;
  325. Casas[id][InteriorY] = -1135.89;
  326. Casas[id][InteriorZ] = 1050.64;
  327. Casas[id][InteriorA] = 275.3992;
  328. Casas[id][cInterior] = 10;
  329. }
  330. case 3:
  331. {
  332. Casas[id][InteriorX] = 2218.39;
  333. Casas[id][InteriorY] = -1076.21;
  334. Casas[id][InteriorZ] = 1050.48;
  335. Casas[id][InteriorA] = 95.2635;
  336. Casas[id][cInterior] = 1;
  337. }
  338. case 4:
  339. {
  340. Casas[id][InteriorX] = 2196.84;
  341. Casas[id][InteriorY] = -1204.36;
  342. Casas[id][InteriorZ] = 1049.02;
  343. Casas[id][InteriorA] = 94.0010;
  344. Casas[id][cInterior] = 6;
  345. }
  346. case 5:
  347. {
  348. Casas[id][InteriorX] = 2365.25;
  349. Casas[id][InteriorY] = -1135.58;
  350. Casas[id][InteriorZ] = 1050.88;
  351. Casas[id][InteriorA] = 359.0367;
  352. Casas[id][cInterior] = 8;
  353. }
  354. case 6:
  355. {
  356. Casas[id][InteriorX] = 2496.00;
  357. Casas[id][InteriorY] = -1692.08;
  358. Casas[id][InteriorZ] = 1014.74;
  359. Casas[id][InteriorA] = 177.8159;
  360. Casas[id][cInterior] = 3;
  361. }
  362. case 7:
  363. {
  364. Casas[id][InteriorX] = 140.28;
  365. Casas[id][InteriorY] = 1365.92;
  366. Casas[id][InteriorZ] = 1083.85;
  367. Casas[id][InteriorA] = 9.6901;
  368. Casas[id][cInterior] = 5;
  369. }
  370. case 8:
  371. {
  372. Casas[id][InteriorX] = 2317.77;
  373. Casas[id][InteriorY] = -1026.76;
  374. Casas[id][InteriorZ] = 1050.21;
  375. Casas[id][InteriorA] = 359.0367;
  376. Casas[id][cInterior] = 9;
  377. }
  378. case 9:
  379. {
  380. Casas[id][InteriorX] = 2324.41;
  381. Casas[id][InteriorY] = -1149.54;
  382. Casas[id][InteriorZ] = 1050.71;
  383. Casas[id][InteriorA] = 359.0367;
  384. Casas[id][cInterior] = 12;
  385. }
  386. case 10:
  387. {
  388. Casas[id][InteriorX] = 1260.6603;
  389. Casas[id][InteriorY] = -785.4005;
  390. Casas[id][InteriorZ] = 1091.9063;
  391. Casas[id][InteriorA] = 270.9891;
  392. Casas[id][cInterior] = 5;
  393. }
  394. }
  395.  
  396. mysql_format(ConexaoID, query, sizeof(query), "UPDATE `Casas` SET `cValor`='%i' , `cInterior`='%i' , `InteriorX`='%f' , `InteriorY`='%f' , `InteriorZ`='%f' , `InteriorA`='%f', `cLevel`='%i' , `cLevelMax`='%i' WHERE `cID`='%i' ",
  397. Casas[id][cValor],
  398. Casas[id][cInterior],
  399. Casas[id][InteriorX],
  400. Casas[id][InteriorY],
  401. Casas[id][InteriorZ],
  402. Casas[id][InteriorA],
  403. Casas[id][cLevel],
  404. levelmax,
  405. Casas[id][cID]);
  406. mysql_query(ConexaoID, query);
  407.  
  408.  
  409. format(str, sizeof(str), "[iCasas] Você atualizou a casa [ %d ]", Casas[id][cID]);
  410. SendClientMessage(playerid, COR_AMARELO, str);
  411. format(str, sizeof(str), "[iCasas] Novo Valor: $%d", Casas[id][cValor]);
  412. SendClientMessage(playerid, COR_AMARELO, str);
  413. format(str, sizeof(str), "[iCasas] Novo Level: [ %d ]", Casas[id][cLevel]);
  414. SendClientMessage(playerid, COR_AMARELO, str);
  415. format(str, sizeof(str), "[iCasas] Novo LevelMax: [ %d ]", levelmax);
  416. SendClientMessage(playerid, COR_AMARELO, str);
  417.  
  418.  
  419. DestroyDynamicMapIcon(Casas[id][cMapIcon]);
  420. DestroyDynamicPickup(Casas[id][cPickUp]);
  421. DestroyDynamic3DTextLabel(Casas[id][cText]);
  422.  
  423. UpdateHouse(id);
  424.  
  425. return 1;
  426. }
  427. CMD:atualizarcasa(playerid)
  428. {
  429. new id = GetPlayerNearestHouse(playerid);
  430. new query[350];
  431. new precoup;
  432.  
  433. if(id == -1)
  434. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você não está no ícone de uma casa.");
  435. if(Casas[id][cLevel] == Casas[id][cLevelMax])
  436. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Sua casa já está no level máximo.");
  437. if(!PlayerHaveHouse(playerid))
  438. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Essa não é sua casa");
  439. switch(Casas[id][cLevel])
  440. {
  441. case 0:
  442. {
  443. precoup = 1500;
  444. }
  445. case 1:
  446. {
  447. precoup = 2000;
  448. }
  449. case 2:
  450. {
  451. precoup = 2750;
  452. }
  453. case 3:
  454. {
  455. precoup = 3850;
  456. }
  457. case 4:
  458. {
  459. precoup = 4500;
  460. }
  461. case 5:
  462. {
  463. precoup = 8500;
  464. }
  465. case 6:
  466. {
  467. precoup = 16500;
  468. }
  469. case 7:
  470. {
  471. precoup = 25000;
  472. }
  473. case 8:
  474. {
  475. precoup = 35000;
  476. }
  477. case 9:
  478. {
  479. precoup = 1000000;
  480. }
  481. }
  482.  
  483. if(GetPlayerMoney(playerid) < precoup)
  484. {
  485. format(query, sizeof(query), "[iCasas] Você não tem {00ff04}$%d {FFFF00}para atualizar sua casa.", precoup);
  486. SendClientMessage(playerid, COR_ERRO, query);
  487. return 0;
  488. }
  489.  
  490. Casas[id][cLevel]++;
  491.  
  492. switch(Casas[id][cLevel])
  493. {
  494. case 0:
  495. {
  496. Casas[id][InteriorX] = 2233.69;
  497. Casas[id][InteriorY] = -1115.26;
  498. Casas[id][InteriorZ] = 1050.88;
  499. Casas[id][InteriorA] = 358.4660;
  500. Casas[id][cInterior] = 5;
  501. }
  502. case 1:
  503. {
  504. Casas[id][InteriorX] = 2282.99;
  505. Casas[id][InteriorY] = -1140.28;
  506. Casas[id][InteriorZ] = 1050.89;
  507. Casas[id][InteriorA] = 358.4660;
  508. Casas[id][cInterior] = 11;
  509. }
  510. case 2:
  511. {
  512. Casas[id][InteriorX] = 2259.38;
  513. Casas[id][InteriorY] = -1135.89;
  514. Casas[id][InteriorZ] = 1050.64;
  515. Casas[id][InteriorA] = 275.3992;
  516. Casas[id][cInterior] = 10;
  517. }
  518. case 3:
  519. {
  520. Casas[id][InteriorX] = 2218.39;
  521. Casas[id][InteriorY] = -1076.21;
  522. Casas[id][InteriorZ] = 1050.48;
  523. Casas[id][InteriorA] = 95.2635;
  524. Casas[id][cInterior] = 1;
  525. }
  526. case 4:
  527. {
  528. Casas[id][InteriorX] = 2196.84;
  529. Casas[id][InteriorY] = -1204.36;
  530. Casas[id][InteriorZ] = 1049.02;
  531. Casas[id][InteriorA] = 94.0010;
  532. Casas[id][cInterior] = 6;
  533. }
  534. case 5:
  535. {
  536. Casas[id][InteriorX] = 2365.25;
  537. Casas[id][InteriorY] = -1135.58;
  538. Casas[id][InteriorZ] = 1050.88;
  539. Casas[id][InteriorA] = 359.0367;
  540. Casas[id][cInterior] = 8;
  541. }
  542. case 6:
  543. {
  544. Casas[id][InteriorX] = 2496.00;
  545. Casas[id][InteriorY] = -1692.08;
  546. Casas[id][InteriorZ] = 1014.74;
  547. Casas[id][InteriorA] = 177.8159;
  548. Casas[id][cInterior] = 3;
  549. }
  550. case 7:
  551. {
  552. Casas[id][InteriorX] = 140.28;
  553. Casas[id][InteriorY] = 1365.92;
  554. Casas[id][InteriorZ] = 1083.85;
  555. Casas[id][InteriorA] = 9.6901;
  556. Casas[id][cInterior] = 5;
  557. }
  558. case 8:
  559. {
  560. Casas[id][InteriorX] = 2317.77;
  561. Casas[id][InteriorY] = -1026.76;
  562. Casas[id][InteriorZ] = 1050.21;
  563. Casas[id][InteriorA] = 359.0367;
  564. Casas[id][cInterior] = 9;
  565. }
  566. case 9:
  567. {
  568. Casas[id][InteriorX] = 2324.41;
  569. Casas[id][InteriorY] = -1149.54;
  570. Casas[id][InteriorZ] = 1050.71;
  571. Casas[id][InteriorA] = 359.0367;
  572. Casas[id][cInterior] = 12;
  573. }
  574. case 10:
  575. {
  576. Casas[id][InteriorX] = 1260.6603;
  577. Casas[id][InteriorY] = -785.4005;
  578. Casas[id][InteriorZ] = 1091.9063;
  579. Casas[id][InteriorA] = 270.9891;
  580. Casas[id][cInterior] = 5;
  581. }
  582. }
  583.  
  584. mysql_format(ConexaoID, query, sizeof(query), "UPDATE `Casas` SET `cLevel`='%i' , `InteriorX`='%f' , `InteriorY`='%f', `InteriorZ`='%f', `InteriorA`='%f' WHERE `cID`='%i' ",
  585. Casas[id][cLevel],
  586. Casas[id][InteriorX],
  587. Casas[id][InteriorY],
  588. Casas[id][InteriorZ],
  589. Casas[id][InteriorA],
  590. Casas[id][cID]);
  591. mysql_query(ConexaoID, query);
  592.  
  593. DestroyDynamicMapIcon(Casas[id][cMapIcon]);
  594. DestroyDynamicPickup(Casas[id][cPickUp]);
  595. DestroyDynamic3DTextLabel(Casas[id][cText]);
  596.  
  597. UpdateHouse(id);
  598.  
  599. GivePlayerMoney(playerid, -precoup);
  600.  
  601. format(query, sizeof(query), "[iCasas] Você atualizou sua cara para o nível [ %d ]", Casas[id][cLevel]);
  602. SendClientMessage(playerid, COR_AMARELO, query);
  603. format(query, sizeof(query), "[iCasas] {FFFF00}-$%d", precoup);
  604. SendClientMessage(playerid, COR_AMARELO, query);
  605. return 1;
  606. }
  607. CMD:comprarcasa(playerid, params[])
  608. {
  609. new id = GetPlayerNearestHouse(playerid);
  610.  
  611. if (id == -1)
  612. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você não está em um ícone de uma casa.");
  613.  
  614. if(Casas[id][cComprado] == 1)
  615. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Essa casa já possui um dono.");
  616. if(PlayerHaveHouse(playerid))
  617. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você já tem uma casa.");
  618.  
  619. if(GetPlayerMoney(playerid) < Casas[id][cValor])
  620. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você não tem dinheiro suficiente.");
  621.  
  622. GivePlayerMoney(playerid, -Casas[id][cValor]);
  623.  
  624. DestroyDynamicMapIcon(Casas[id][cMapIcon]);
  625. DestroyDynamicPickup(Casas[id][cPickUp]);
  626. DestroyDynamic3DTextLabel(Casas[id][cText]);
  627.  
  628. Casas[id][cComprado] = 1;
  629. Casas[id][cProprietario] = EOS;
  630. strcat(Casas[id][cProprietario], GetPlayerNameEx(playerid), MAX_PLAYER_NAME);
  631.  
  632. new query[140];
  633. new string[60];
  634. mysql_format(ConexaoID, query, sizeof(query), "UPDATE `Casas` SET `cProprietario`='%e', `cComprado`='%i', `cVirtualWorld`='%i' , `cLevel`='0' WHERE `cID`='%i' ", Casas[id][cProprietario], Casas[id][cComprado], Casas[id][cID], Casas[id][cID]);
  635. mysql_query(ConexaoID, query);
  636.  
  637. format(string, sizeof(string), "[iCasas] O(A) %s comprou a casa ID %d.", Casas[id][cProprietario], Casas[id][cID]);
  638. SendClientMessageToAll(COR_AMARELO, string);
  639. UpdateHouse(id);
  640. return 1;
  641. }
  642. CMD:vendercasa(playerid)
  643. {
  644. new id = GetPlayerNearestHouse(playerid);
  645. new Name[MAX_HOUSES];
  646. Name[id] = EOS;
  647. strcat(Name[id], GetPlayerNameEx(playerid), MAX_PLAYER_NAME);
  648. if (id == -1)
  649. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você não está em um ícone de uma casa.");
  650. if(Casas[id][cComprado] == 0)
  651. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Essa casa não possui um dono.");
  652. if(Casas[id][cProprietario] != Name[id])
  653. return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você não é dono dessa casa.");
  654.  
  655.  
  656. DestroyDynamicMapIcon(Casas[id][cMapIcon]);
  657. DestroyDynamicPickup(Casas[id][cPickUp]);
  658. DestroyDynamic3DTextLabel(Casas[id][cText]);
  659.  
  660. Casas[id][cLevel] = 0;
  661.  
  662. switch(Casas[id][cLevel])
  663. {
  664. case 0:
  665. {
  666. Casas[id][InteriorX] = 2233.69;
  667. Casas[id][InteriorY] = -1115.26;
  668. Casas[id][InteriorZ] = 1050.88;
  669. Casas[id][InteriorA] = 358.4660;
  670. Casas[id][cInterior] = 5;
  671. }
  672. }
  673.  
  674. new string[128];
  675. new query[250];
  676. GivePlayerMoney(playerid, Casas[id][cValor] * 75 / 100);
  677. format(string, sizeof(string), "[iCasas] O(A) %s[%d] vendeu a sua casa ID[ %d ].", Casas[id][cProprietario], playerid,Casas[id][cID]);
  678. SendClientMessageToAll(COR_AMARELO, string);
  679.  
  680. Casas[id][cComprado] = 0;
  681.  
  682.  
  683. mysql_format(ConexaoID, query, sizeof(query), "UPDATE `Casas` SET `cProprietario`=NULL , `cComprado`='0', `cLevel`='%i' , `InteriorX`='%f' , `InteriorY`='%f' , `InteriorZ`='%f' , `InteriorA`='%f' , `cInterior`='%i' WHERE `cID`='%i' ",
  684. Casas[id][cLevel],
  685. Casas[id][InteriorX],
  686. Casas[id][InteriorY],
  687. Casas[id][InteriorZ],
  688. Casas[id][InteriorA],
  689. Casas[id][cInterior],
  690. Casas[id][cID]);
  691. mysql_query(ConexaoID, query);
  692.  
  693.  
  694.  
  695. UpdateHouse(id);
  696. return 1;
  697. }
  698. CMD:excluircasa(playerid)
  699. {
  700. if(!IsPlayerAdmin(playerid))
  701. return 0;
  702. new id = GetPlayerNearestHouse(playerid);
  703. new query[200];
  704. if(id == -1)
  705. return SendClientMessage(playerid, COR_ERRO, "[iCasa] Você não está no ícone de uma casa");
  706.  
  707.  
  708. mysql_format(ConexaoID, query, sizeof(query), "UPDATE `Casas` SET `cProprietario`=NULL , `cComprado`='0' WHERE `cID`='%i' ", Casas[id][cID]);
  709. mysql_query(ConexaoID, query);
  710.  
  711. mysql_format(ConexaoID, query, sizeof(query), "DELETE FROM `Casas` WHERE `cID`='%d'", Casas[id][cID]);
  712. mysql_query(ConexaoID, query);
  713.  
  714. format(query, sizeof(query), "[iCasas] Você excluiu a casa [%d]", Casas[id][cID]);
  715. SendClientMessage(playerid, COR_AMARELO, query);
  716.  
  717. DestroyDynamicMapIcon(Casas[id][cMapIcon]);
  718. DestroyDynamicPickup(Casas[id][cPickUp]);
  719. DestroyDynamic3DTextLabel(Casas[id][cText]);
  720. return 1;
  721. }
Advertisement
Add Comment
Please, Sign In to add comment