Advertisement
Guest User

Dynamic AirHouse v0.1 System.

a guest
Dec 23rd, 2014
3,777
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.86 KB | None | 0 0
  1. // This Is Air-House System
  2. // Plz Dont Remove Credits
  3. #define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #include <zcmd>
  7. #include <streamer>
  8. #include <foreach>
  9. #include <sscanf2>
  10. #include <dini>
  11.  
  12. #if defined FILTERSCRIPT
  13. #pragma tabsize 0
  14. #define MAX_HOUSES 501
  15. #define CGE "{2A8A07}"
  16. #define COE "{E600FF}"
  17. #define CWE "{FFFFFF}"
  18. #define COLOR_GREY 0xAFAFAFFF
  19. #define COLOR_DARKRED 0xAA3333FF
  20. #define COLOR_WHITE 0xFFFFFFFF
  21. #define COLOR_GREEN 0x33AA33FF
  22. #define COLOR_YELLOW 0xFFFF00FF
  23. #define COLOR_PURPLE 0xC2A2DAFF
  24. #define COLOR_ORANGE 0xFF9900FF
  25. #define COLOR_RED 0xFF0606FF
  26. #define COLOR_LIGHTBLUE 0x33CCFFFF
  27. #define COLOR_LIGHTRED 0xFF6347FF
  28.  
  29.  
  30.  
  31. public OnFilterScriptInit()
  32. {
  33. print("\n--------------------------------------");
  34. print(" ------------AirHouse V0.1--------------");
  35. print("--------------------------------------\n");
  36. CheckFiles();
  37. LoadHouses();
  38. return 1;
  39. }
  40.  
  41. public OnFilterScriptExit()
  42. {
  43. return 1;
  44. }
  45.  
  46. #else
  47.  
  48. main()
  49. {
  50. print("\n----------------------------------");
  51. print(" ----------Credit:AirBloG-----------");
  52. print("----------------------------------\n");
  53. CheckFiles();
  54. LoadHouses();
  55. }
  56.  
  57. #endif
  58. ////////////////////////////////////////////////////////////////////////////////
  59. enum pInfo
  60. {
  61. // Temp Values
  62. pLoggedIn,
  63. pSpawn,
  64. // Permanent Values
  65. pOwner,
  66. pLevel,
  67. pRented,
  68. pHours,
  69. pLocal,
  70. pMoney,
  71. pModel,
  72. pHouse,
  73. pVHouse,
  74. pMaskOn,
  75. pInt,
  76. pPhousekey,
  77. }
  78. new PlayerInfo[MAX_PLAYERS][pInfo];
  79. ////////////////////////////////////////////////////////////////////////////////
  80. enum houseInfo
  81. {
  82. hLevel,
  83. hPrice,
  84. hStatus,
  85. hOwner[32],
  86. Float:hX,
  87. Float:hY,
  88. Float:hZ,
  89. hOwned,
  90. hMoney,
  91. hTakings,
  92. hRentabil,
  93. hRent,
  94. hInt,
  95. hPickup,
  96. Text3D:hText,
  97. hSpawn
  98. }
  99. new HouseInfo[MAX_HOUSES][houseInfo];
  100. stock CheckFiles()
  101. {
  102. if(!dini_Exists("houses.cfg")) dini_Create("houses.cfg");
  103. return 1;
  104. }
  105. stock LoadHouses()
  106. {
  107. new binfo[21][32];
  108. new string[256];
  109. new File:file = fopen("Houses/houses.cfg", io_read);
  110. if(file)
  111. {
  112. new idx = 1;
  113. while(idx < MAX_HOUSES)
  114. {
  115. fread(file, string);
  116. split(string, binfo, '|');
  117. HouseInfo[idx][hLevel] = strval(binfo[0]);
  118. HouseInfo[idx][hPrice] = strval(binfo[1]);
  119. HouseInfo[idx][hStatus] = strval(binfo[2]);
  120. format(HouseInfo[idx][hOwner], 32, "%s", binfo[3]);
  121. HouseInfo[idx][hX] = floatstr(binfo[4]);
  122. HouseInfo[idx][hY] = floatstr(binfo[5]);
  123. HouseInfo[idx][hZ] = floatstr(binfo[6]);
  124. HouseInfo[idx][hMoney] = strval(binfo[7]);
  125. if(HouseInfo[idx][hLevel])
  126. {
  127. HouseInfo[idx][hPickup] = CreateDynamicPickup(1273, 1, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ], 0);
  128. if(!strcmp("The State", HouseInfo[idx][hOwner])) format(string, sizeof(string), ""COE"["CWE"%d, House (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\n"COE"Status"CWE" For Sale\n"CWE"$%d", idx, HouseInfo[idx][hLevel], HouseInfo[idx][hOwner], HouseInfo[idx][hPrice]);
  129. else format(string, sizeof(string), ""COE"["CWE"ID:%d, House (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\n"COE"Status"CWE" %s", idx, HouseInfo[idx][hLevel], HouseInfo[idx][hOwner], RHS(idx));
  130. HouseInfo[idx][hText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]+0.3, 15);
  131.  
  132. }
  133. idx++;
  134. }
  135. }
  136. print("Houses loaded successfully.");
  137. return 1;
  138. }
  139.  
  140. stock SaveHouses()
  141. {
  142. new idx = 1, File:file;
  143. new string[256];
  144. while(idx < MAX_HOUSES)
  145. {
  146. format(string, sizeof(string), "%d|%d|%d|%s|%f|%f|%f|%d\r\n",
  147. HouseInfo[idx][hLevel],
  148. HouseInfo[idx][hPrice],
  149. HouseInfo[idx][hStatus],
  150. HouseInfo[idx][hOwner],
  151. HouseInfo[idx][hX],
  152. HouseInfo[idx][hY],
  153. HouseInfo[idx][hZ],
  154. HouseInfo[idx][hMoney]
  155. );
  156. if(idx == 1)
  157. {
  158. file = fopen("Houses/houses.cfg", io_write);
  159. }
  160. else
  161. {
  162. file = fopen("Houses/houses.cfg", io_append);
  163. }
  164. fwrite(file, string);
  165. fclose(file);
  166. idx++;
  167. }
  168. print("Houses saved successfully.");
  169. }
  170. ////////////////////////////////////////////////////////////////////////////////
  171. public OnGameModeInit()
  172. {
  173. // Don't use these lines if it's a filterscript
  174. SetGameModeText("Blank Script");
  175. CheckFiles();
  176. LoadHouses();
  177. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  178. return 1;
  179. }
  180.  
  181. public OnGameModeExit()
  182. {
  183. return 1;
  184. }
  185.  
  186. public OnPlayerRequestClass(playerid, classid)
  187. {
  188. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  189. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  190. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  191. return 1;
  192. }
  193.  
  194. public OnPlayerConnect(playerid)
  195. {
  196. return 1;
  197. }
  198.  
  199. public OnPlayerDisconnect(playerid, reason)
  200. {
  201. return 1;
  202. }
  203.  
  204. public OnPlayerSpawn(playerid)
  205. {
  206. return 1;
  207. }
  208.  
  209. public OnPlayerDeath(playerid, killerid, reason)
  210. {
  211. return 1;
  212. }
  213.  
  214. public OnVehicleSpawn(vehicleid)
  215. {
  216. return 1;
  217. }
  218.  
  219. public OnVehicleDeath(vehicleid, killerid)
  220. {
  221. return 1;
  222. }
  223.  
  224. public OnPlayerText(playerid, text[])
  225. {
  226. return 1;
  227. }
  228.  
  229. public OnPlayerCommandText(playerid, cmdtext[])
  230. {
  231. if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  232. {
  233. // Do something here
  234. return 1;
  235. }
  236. return 0;
  237. }
  238.  
  239. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  240. {
  241. return 1;
  242. }
  243.  
  244. public OnPlayerExitVehicle(playerid, vehicleid)
  245. {
  246. return 1;
  247. }
  248.  
  249. public OnPlayerStateChange(playerid, newstate, oldstate)
  250. {
  251. return 1;
  252. }
  253.  
  254. public OnPlayerEnterCheckpoint(playerid)
  255. {
  256. return 1;
  257. }
  258.  
  259. public OnPlayerLeaveCheckpoint(playerid)
  260. {
  261. return 1;
  262. }
  263.  
  264. public OnPlayerEnterRaceCheckpoint(playerid)
  265. {
  266. return 1;
  267. }
  268.  
  269. public OnPlayerLeaveRaceCheckpoint(playerid)
  270. {
  271. return 1;
  272. }
  273.  
  274. public OnRconCommand(cmd[])
  275. {
  276. return 1;
  277. }
  278.  
  279. public OnPlayerRequestSpawn(playerid)
  280. {
  281. return 1;
  282. }
  283.  
  284. public OnObjectMoved(objectid)
  285. {
  286. return 1;
  287. }
  288. new ScriptMoneyUpdated[MAX_PLAYERS];
  289. new ScriptMoney[MAX_PLAYERS];
  290. forward SafeGivePlayerMoney(plyid, amounttogive);
  291. public SafeGivePlayerMoney(plyid, amounttogive)
  292. {
  293. new curHour, curMinute, curSecond;
  294. gettime(curHour, curMinute, curSecond);
  295. ScriptMoneyUpdated[plyid] = curSecond;
  296. if (amounttogive < 0)
  297. {
  298. GivePlayerMoney(plyid, amounttogive);
  299. ScriptMoney[plyid] = (ScriptMoney[plyid] + amounttogive);
  300. }
  301. else
  302. {
  303. ScriptMoney[plyid] = (ScriptMoney[plyid] + amounttogive);
  304. GivePlayerMoney(plyid, amounttogive);
  305. }
  306. return 1;
  307. }
  308. public OnPlayerObjectMoved(playerid, objectid)
  309. {
  310. return 1;
  311. }
  312.  
  313. public OnPlayerPickUpPickup(playerid, pickupid)
  314. {
  315. return 1;
  316. }
  317.  
  318. public OnVehicleMod(playerid, vehicleid, componentid)
  319. {
  320. return 1;
  321. }
  322.  
  323. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  324. {
  325. return 1;
  326. }
  327.  
  328. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  329. {
  330. return 1;
  331. }
  332.  
  333. public OnPlayerSelectedMenuRow(playerid, row)
  334. {
  335. return 1;
  336. }
  337.  
  338. public OnPlayerExitedMenu(playerid)
  339. {
  340. return 1;
  341. }
  342.  
  343. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  344. {
  345. return 1;
  346. }
  347.  
  348. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  349. {
  350. return 1;
  351. }
  352.  
  353. public OnRconLoginAttempt(ip[], password[], success)
  354. {
  355. return 1;
  356. }
  357.  
  358. public OnPlayerUpdate(playerid)
  359. {
  360. return 1;
  361. }
  362.  
  363. public OnPlayerStreamIn(playerid, forplayerid)
  364. {
  365. return 1;
  366. }
  367.  
  368. public OnPlayerStreamOut(playerid, forplayerid)
  369. {
  370. return 1;
  371. }
  372.  
  373. public OnVehicleStreamIn(vehicleid, forplayerid)
  374. {
  375. return 1;
  376. }
  377.  
  378. public OnVehicleStreamOut(vehicleid, forplayerid)
  379. {
  380. return 1;
  381. }
  382.  
  383. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  384. {
  385. return 1;
  386. }
  387.  
  388. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  389. {
  390. return 1;
  391. }
  392.  
  393. CMD:createhouse(playerid, params[])
  394. {
  395. new string[128];
  396.  
  397. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not an authorized to use this command.");
  398. for(new idx=1; idx<MAX_HOUSES; idx++)
  399. {
  400. if(!HouseInfo[idx][hLevel])
  401. {
  402. // Getting Business Setup
  403. new Float:X, Float:Y, Float:Z;
  404. GetPlayerPos(playerid, X, Y, Z);
  405. // Making Business
  406. HouseInfo[idx][hLevel] = 1;
  407. HouseInfo[idx][hPrice] = 955000;
  408. HouseInfo[idx][hStatus] = 0;
  409. format(HouseInfo[idx][hOwner], 32, "The State");
  410. HouseInfo[idx][hX] = X;
  411. HouseInfo[idx][hY] = Y;
  412. HouseInfo[idx][hZ] = Z;
  413. HouseInfo[idx][hMoney] = 0;
  414. HouseInfo[idx][hPickup] = CreateDynamicPickup(1273, 1, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ], 0);
  415. format(string, sizeof(string), ""COE"["CWE"ID:%d, House (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\n"COE"Status"CWE" For Sale\n"CWE"$%d", idx, HouseInfo[idx][hLevel], HouseInfo[idx][hOwner], HouseInfo[idx][hPrice]);
  416. HouseInfo[idx][hText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]+0.3, 15);
  417. Log("logs/house.log", string);
  418. idx = MAX_HOUSES;
  419. }
  420. }
  421. return 1;
  422. }
  423. CMD:deletehouse(playerid, params[])
  424. {
  425. new id, string[128];
  426. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not an authorized to use this command.");
  427. // if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
  428. if(sscanf(params, "i", id)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /deletehouse [houseid]");
  429. if(!HouseInfo[id][hLevel]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
  430. foreach(Player, i)
  431. {
  432. if(IsPlayerLoggedIn(i) && PlayerInfo[i][pHouse] == id)
  433. {
  434. PlayerInfo[i][pHouse] = 0;
  435. format(string, sizeof(string), " Administrator %s has deleted your house.", RPN(playerid));
  436. SendClientMessage(i, COLOR_WHITE, string);
  437. }
  438. }
  439. if(!strcmp("The State", HouseInfo[id][hOwner]))
  440. {
  441. format(string, sizeof(string), "{FF0000}Delete:{FF6347} %s has deleted house ID %d.", RPN(playerid), id);
  442. }
  443. else
  444. {
  445. format(string, sizeof(string), "{FF0000}Delete:{FF6347} %s has deleted %s's house. (ID %d)", RPN(playerid), HouseInfo[id][hOwner], id);
  446. }
  447. SendClientMessage(COLOR_DARKRED, 1, string);
  448. Log("logs/house.log", string);
  449. HouseInfo[id][hLevel] = 0;
  450. HouseInfo[id][hPrice] = 0;
  451. HouseInfo[id][hStatus] = 0;
  452. format(HouseInfo[id][hOwner], 32, "");
  453. HouseInfo[id][hX] = 0;
  454. HouseInfo[id][hY] = 0;
  455. HouseInfo[id][hZ] = 0;
  456. HouseInfo[id][hMoney] = 0;
  457. DestroyDynamicPickup(HouseInfo[id][hPickup]);
  458. DestroyDynamic3DTextLabel(HouseInfo[id][hText]);
  459. return 1;
  460. }
  461. CMD:hedit(playerid, params[])
  462. {
  463. new bizid, string[128], input;
  464.  
  465. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not an authorized to use this command.");
  466. // if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
  467. if(sscanf(params, "s[32]", params))
  468. {
  469. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /hedit [option] [houseid]");
  470. SendClientMessage(playerid, COLOR_GREY, "OPTIONS: location | price | level");
  471. return 1;
  472. }
  473. if(!strcmp(params, "location", true, 8))
  474. {
  475. if(sscanf(params, "s[32]i", params, bizid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /hedit location [house]");
  476. new idx = bizid;
  477. if(!HouseInfo[bizid][hLevel]) return SendClientMessage(playerid, COLOR_GREY, "Invalid house id.");
  478. GetPlayerPos(playerid, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]);
  479. DestroyDynamicPickup(HouseInfo[idx][hPickup]);
  480. HouseInfo[idx][hPickup] = CreateDynamicPickup(1273, 1, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ], 0);
  481. DestroyDynamic3DTextLabel(HouseInfo[idx][hText]);
  482. if(!strcmp("The State", HouseInfo[idx][hOwner])) format(string, sizeof(string), ""COE"["CWE"%d, House (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\n"COE"Status"CWE" For Sale\n"CWE"$%d", idx, HouseInfo[idx][hLevel], HouseInfo[idx][hOwner], HouseInfo[idx][hPrice]);
  483. else format(string, sizeof(string), ""COE"["CWE"%d, House (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\n"COE"Status"CWE" %s", idx, HouseInfo[idx][hLevel], HouseInfo[idx][hOwner], RHS(idx));
  484. HouseInfo[idx][hText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]+0.3, 15);
  485. }
  486. else if(!strcmp(params, "price", true, 5))
  487. {
  488. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not an authorized to use this command.");
  489. if(sscanf(params, "s[32]ii", params, bizid, input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /house price [house] [price]");
  490. new idx = bizid;
  491. if(!HouseInfo[idx][hLevel]) return SendClientMessage(playerid, COLOR_GREY, "Invalid house id.");
  492. if(strcmp("The State", HouseInfo[bizid][hOwner])) return SendClientMessage(playerid, COLOR_GREY, "You can't edit the price of owned businesses.");
  493. HouseInfo[bizid][hPrice] = input;
  494. format(string, sizeof(string), ""COE"["CWE"%d, House (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\n"COE"Status"CWE" For Sale\n"CWE"$%d", idx, HouseInfo[idx][hLevel], HouseInfo[idx][hOwner], HouseInfo[idx][hPrice]);
  495. UpdateDynamic3DTextLabelText(HouseInfo[bizid][hText], COLOR_WHITE, string);
  496.  
  497. }
  498. else if(!strcmp(params, "level", true, 5))
  499. {
  500. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not an authorized to use this command.");
  501. if(sscanf(params, "s[32]ii", params, bizid, input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /house level [houseid] [level]");
  502. new idx = bizid;
  503. //if(!HouseInfo[bizid][hLevel]) return SendClientMessage(playerid, COLOR_GREY, "Invalid house id.");
  504. if(input < 1 || input > 11) return SendClientMessage(playerid, COLOR_GREY, "Levels are between 1 and 11.");
  505. HouseInfo[bizid][hLevel] = input;
  506. if(!strcmp("The State", HouseInfo[idx][hOwner])) format(string, sizeof(string), ""COE"["CWE"%d, House (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\n"COE"Status"CWE" For Sale\n"CWE"$%d", idx, HouseInfo[idx][hLevel], HouseInfo[idx][hOwner], HouseInfo[idx][hPrice]);
  507. else format(string, sizeof(string), ""COE"["CWE"%d, House (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\n"COE"Status"CWE" %s", idx, HouseInfo[idx][hLevel], HouseInfo[idx][hOwner], RHS(idx));
  508. UpdateDynamic3DTextLabelText(HouseInfo[bizid][hText], COLOR_WHITE, string);
  509. }
  510. return 1;
  511. }
  512. CMD:gotohouse(playerid, params[])
  513. {
  514. new idx, string[128];
  515. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not an authorized to use this command.");
  516. // if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
  517. if(sscanf(params, "i", idx)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gotohouse [houseid]");
  518. if(!HouseInfo[idx][hLevel]) return SendClientMessage(playerid, COLOR_GREY, "Invalid house id.");
  519. SetPlayerVirtualWorld(playerid, 0);
  520. SetPlayerInterior(playerid, 0);
  521. SetPlayerPos(playerid, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]);
  522. format(string, sizeof(string), " You have teleported to house ID %d.", idx);
  523. SendClientMessage(playerid, COLOR_WHITE, string);
  524. return 1;
  525. }
  526.  
  527. CMD:buyhouse(playerid, params[])
  528. {
  529. new string[128], done;
  530.  
  531. if(PlayerInfo[playerid][pHouse]) return SendClientMessage(playerid, COLOR_GREY, "You already have a houses.");
  532. for(new idx=1; idx<MAX_HOUSES; idx++)
  533. {
  534. if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]))
  535. {
  536. if(!strcmp("The State", HouseInfo[idx][hOwner], false))
  537. {
  538. if(GetPlayerMoney(playerid) < HouseInfo[idx][hPrice]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this house.");
  539. GivePlayerMoney(playerid, -HouseInfo[idx][hPrice]);
  540. if(PlayerInfo[playerid][pHouse]) PlayerInfo[playerid][pVHouse] = idx;
  541. else PlayerInfo[playerid][pHouse] = idx;
  542. format(HouseInfo[idx][hOwner], 32, "%s", RPNU(playerid));
  543. format(string, sizeof(string), ""COE"["CWE"%d, House (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\n"COE"Status"CWE" %s", idx, HouseInfo[idx][hLevel], HouseInfo[idx][hOwner], RHS(idx));
  544. UpdateDynamic3DTextLabelText(HouseInfo[idx][hText], COLOR_WHITE, string);
  545. SendClientMessage(playerid, COLOR_GREEN, " You have successfully bought a house.");
  546. SendClientMessage(playerid, COLOR_WHITE, " Type /househelp to view your house commands.");
  547. format(string, sizeof(string), "%s has bought house id %d.", RPN(playerid), idx);
  548. Log("logs/house.log", string);
  549. idx = MAX_HOUSES;
  550. done = 1;
  551. }
  552. if(idx == MAX_HOUSES-1 && !done)
  553. {
  554. SendClientMessage(playerid, COLOR_GREY, "This house is owned by someone else.");
  555. }
  556. }
  557. if(idx == MAX_HOUSES-1 && !done)
  558. {
  559. SendClientMessage(playerid, COLOR_GREY, "You are not near a buyable house.");
  560. }
  561. }
  562. return 1;
  563. }
  564. CMD:exit(playerid,params[])
  565. {
  566. new done, string[128];
  567. if(IsPlayerInRangeOfPoint(playerid, 2, 243.9951,304.9418,999.1484) || IsPlayerInRangeOfPoint(playerid, 2, 2259.6702,-1135.8542,1050.6328) || IsPlayerInRangeOfPoint(playerid, 2, 2308.8254,-1212.8070,1049.0234) || IsPlayerInRangeOfPoint(playerid, 2, 260.7436,1237.5563,1084.2578)
  568. || IsPlayerInRangeOfPoint(playerid, 2, -42.5742,1405.6521,1084.4297) || IsPlayerInRangeOfPoint(playerid, 2, 2468.6787,-1698.2617,1013.5078) || IsPlayerInRangeOfPoint(playerid, 2, 2365.2183,-1135.4014,1050.8750) || IsPlayerInRangeOfPoint(playerid, 2, 2270.1270,-1210.4855,1047.5625)
  569. || IsPlayerInRangeOfPoint(playerid, 2, 2324.4424,-1149.2057,1050.7101) || IsPlayerInRangeOfPoint(playerid, 2, 83.0863,1322.3020,1083.8662) || IsPlayerInRangeOfPoint(playerid, 2, 225.6631,1022.3559,1084.0150)) // Houses
  570. {
  571. new idx;
  572. idx = GetPlayerVirtualWorld(playerid)-500;
  573. if(!done && idx < MAX_HOUSES && HouseInfo[idx][hLevel])
  574. {
  575. format(string, sizeof(string), "* %s pushes the door and exits the house.", RPN(playerid));
  576. if(PlayerInfo[playerid][pMaskOn] == 1)
  577. {
  578. format(string, sizeof(string), "* Stranger pushes the door and exits the house.");
  579. }
  580. else
  581. {
  582. format(string, sizeof(string), "* %s pushes the door and exits the house.", RPN(playerid));
  583. }
  584. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  585. SetPlayerPos(playerid, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]);
  586. SetPlayerInterior(playerid, 0);
  587. SetPlayerVirtualWorld(playerid, 0);
  588. done = 1;
  589. }
  590. }
  591. return 1;
  592. }
  593. CMD:hlock(playerid,params[])
  594. {
  595. new string[128], idx, done, lockdone;
  596. if(PlayerInfo[playerid][pHouse])
  597. {
  598. idx = PlayerInfo[playerid][pHouse];
  599. if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]))
  600. {
  601. if(!HouseInfo[PlayerInfo[playerid][pHouse]][hStatus])
  602. {
  603. HouseInfo[PlayerInfo[playerid][pHouse]][hStatus] = 1;
  604. format(string, sizeof(string), ""COE"["CWE"%d, House (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\n"COE"Status"CWE" %s", idx, HouseInfo[idx][hLevel], HouseInfo[idx][hOwner], RHS(idx));
  605. UpdateDynamic3DTextLabelText(HouseInfo[PlayerInfo[playerid][pHouse]][hText], COLOR_WHITE, string);
  606. format(string, sizeof(string), "* %s takes out their house keys and unlocks it.", RPN(playerid));
  607. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  608. GameTextForPlayer(playerid, "~g~House Unlocked", 3500, 3);
  609. }
  610. else if(HouseInfo[PlayerInfo[playerid][pHouse]][hStatus])
  611. {
  612. HouseInfo[PlayerInfo[playerid][pHouse]][hStatus] = 0;
  613. format(string, sizeof(string), ""COE"["CWE"%d, House (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\n"COE"Status"CWE" %s", idx, HouseInfo[idx][hLevel], HouseInfo[idx][hOwner], RHS(idx));
  614. UpdateDynamic3DTextLabelText(HouseInfo[PlayerInfo[playerid][pHouse]][hText], COLOR_WHITE, string);
  615. format(string, sizeof(string), "* %s takes out their house keys and locks it.", RPN(playerid));
  616. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  617. GameTextForPlayer(playerid, "~r~House Locked", 3500, 3);
  618. }
  619. done = 1;
  620. lockdone = 1;
  621. }
  622. }
  623. if(PlayerInfo[playerid][pVHouse] && !done)
  624. {
  625. idx = PlayerInfo[playerid][pVHouse];
  626. if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]))
  627. {
  628. if(!HouseInfo[PlayerInfo[playerid][pVHouse]][hStatus])
  629. {
  630. HouseInfo[PlayerInfo[playerid][pVHouse]][hStatus] = 1;
  631. format(string, sizeof(string), ""COE"["CWE"%d, House (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\n"COE"Status"CWE" %s", idx, HouseInfo[idx][hLevel], HouseInfo[idx][hOwner], RHS(idx));
  632. UpdateDynamic3DTextLabelText(HouseInfo[PlayerInfo[playerid][pVHouse]][hText], COLOR_WHITE, string);
  633. format(string, sizeof(string), "* %s takes out their house keys and unlocks it.", RPN(playerid));
  634. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  635. GameTextForPlayer(playerid, "~g~House Unlocked", 3500, 3);
  636. }
  637. else if(HouseInfo[PlayerInfo[playerid][pVHouse]][hStatus])
  638. {
  639. HouseInfo[PlayerInfo[playerid][pVHouse]][hStatus] = 0;
  640. format(string, sizeof(string), ""COE"["CWE"%d, House (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\n"COE"Status"CWE" %s", idx, HouseInfo[idx][hLevel], HouseInfo[idx][hOwner], RHS(idx));
  641. UpdateDynamic3DTextLabelText(HouseInfo[PlayerInfo[playerid][pVHouse]][hText], COLOR_WHITE, string);
  642. format(string, sizeof(string), "* %s takes out their house keys and locks it.", RPN(playerid));
  643. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  644. GameTextForPlayer(playerid, "~r~House Locked", 3500, 3);
  645. }
  646. lockdone = 1;
  647. return 1;
  648. }
  649. }
  650. return 1;
  651. if(!lockdone)
  652. {
  653. SendClientMessage(playerid, COLOR_GREY, "You are not near something you can lock/unlock.");
  654. }
  655. return 1;
  656. }
  657. CMD:sellhousetomarket(playerid, params[])
  658. {
  659. new string[128], done;
  660.  
  661. if(!PlayerInfo[playerid][pHouse] && !PlayerInfo[playerid][pVHouse]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a house.");
  662. if(sscanf(params, "s[8]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sellhousetomarket confirm");
  663. if(!strcmp(params, "confirm", true))
  664. {
  665. new idx = PlayerInfo[playerid][pHouse];
  666. if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[PlayerInfo[playerid][pHouse]][hX], HouseInfo[PlayerInfo[playerid][pHouse]][hY], HouseInfo[PlayerInfo[playerid][pHouse]][hZ]))
  667. {
  668. GivePlayerMoney(playerid, (75*HouseInfo[PlayerInfo[playerid][pHouse]][hPrice])/100);
  669. HouseInfo[PlayerInfo[playerid][pHouse]][hStatus] = 0;
  670. format(HouseInfo[PlayerInfo[playerid][pHouse]][hOwner], 32, "The State");
  671. format(string, sizeof(string), ""COE"["CWE"%d, House (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\n"COE"Status"CWE" For Sale\n"CWE"$%d", idx, HouseInfo[idx][hLevel], HouseInfo[idx][hOwner], HouseInfo[idx][hPrice]);
  672. UpdateDynamic3DTextLabelText(HouseInfo[PlayerInfo[playerid][pHouse]][hText], COLOR_WHITE, string);
  673. PlayerInfo[playerid][pHouse] = 0;
  674. SendClientMessage(playerid, COLOR_GREEN, " You have successfully sold your house to The State. (75 percent of the original price was paid back)");
  675. format(string, sizeof(string), "%s has sold house id %d to the market.", RPN(playerid), idx);
  676. Log("logs/house.log", string);
  677. done = 1;
  678. }
  679. if(!done)
  680. {
  681. idx = PlayerInfo[playerid][pVHouse];
  682. if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]))
  683. {
  684. GivePlayerMoney(playerid, (75*HouseInfo[idx][hPrice])/100);
  685. HouseInfo[idx][hStatus] = 0;
  686. format(HouseInfo[idx][hOwner], 32, "The State");
  687. format(string, sizeof(string), ""COE"["CWE"%d, House (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\n"COE"Status"CWE" For Sale\n"CWE"$%d", idx, HouseInfo[idx][hLevel], HouseInfo[idx][hOwner], HouseInfo[idx][hPrice]);
  688. UpdateDynamic3DTextLabelText(HouseInfo[idx][hText], COLOR_WHITE, string);
  689. PlayerInfo[playerid][pVHouse] = 0;
  690. SendClientMessage(playerid, COLOR_GREEN, " You have successfully sold your house to The State. (75 percent of the original price was paid back)");
  691. format(string, sizeof(string), "%s has sold house id %d to the market.", RPN(playerid), idx);
  692. Log("logs/house.log", string);
  693. done = 1;
  694. }
  695. }
  696. if(!done)
  697. {
  698. SendClientMessage(playerid, COLOR_GREY, "You are not near your house.");
  699. return 1;
  700. }
  701. }
  702. return 1;
  703. }
  704. CMD:hdeposit(playerid, params[])
  705. {
  706. new string[128], option[32], amount;
  707. new idx = PlayerInfo[playerid][pHouse];
  708.  
  709. if(!PlayerInfo[playerid][pHouse] && !PlayerInfo[playerid][pVHouse]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a house.");
  710. if(GetPlayerVirtualWorld(playerid)-500 != idx && !PlayerInfo[playerid][pVHouse]) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your house.");
  711. if(GetPlayerVirtualWorld(playerid)-500 != idx && PlayerInfo[playerid][pVHouse])
  712. {
  713. idx = PlayerInfo[playerid][pVHouse];
  714. if(GetPlayerVirtualWorld(playerid)-500 != idx) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your house.");
  715. }
  716. if(sscanf(params, "s[32]", option))
  717. {
  718. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /hdeposit [item]");
  719. SendClientMessage(playerid, COLOR_GREY, "ITEMS: money ");
  720. /* format(string, sizeof(string), "SAFE: $%d | %d Weed | %d Crack", HouseInfo[idx][hMoney], HouseInfo[idx][hWeed], HouseInfo[idx][hCrack]);
  721. SendClientMessage(playerid, COLOR_WHITE, string);
  722. format(string, sizeof(string), "SAFE: Weapon 1: %s (%d Ammo) | Weapon 2: %s (%d Ammo) | Weapon 3: %s (%d Ammo)", RWN(HouseInfo[idx][hGun][0]), HouseInfo[idx][hGunAmmo][0], RWN(HouseInfo[idx][hGun][1]), HouseInfo[idx][hGunAmmo][1], RWN(HouseInfo[idx][hGun][2]), HouseInfo[idx][hGunAmmo][2]);
  723. SendClientMessage(playerid, COLOR_WHITE, string);
  724. format(string, sizeof(string), "SAFE: Weapon 4: %s (%d Ammo) | Weapon 5: %s (%d Ammo)", RWN(HouseInfo[idx][hGun][3]), HouseInfo[idx][hGunAmmo][3], RWN(HouseInfo[idx][hGun][4]), HouseInfo[idx][hGunAmmo][4]);
  725. SendClientMessage(playerid, COLOR_WHITE, string);*/
  726. return 1;
  727. }
  728. if(sscanf(params, "s[32]", option))
  729. {
  730. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /hdeposit [item]");
  731. SendClientMessage(playerid, COLOR_GREY, "ITEMS: money");
  732. return 1;
  733. }
  734. if(!strcmp(option, "money", true, 5))
  735. {
  736.  
  737. if(sscanf(params, "s[32]i", option, amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /hsafe deposit money [amount]");
  738. if(GetPlayerMoney(playerid) < amount ) return SendClientMessage(playerid, COLOR_GREY, "Shoma in Andaze Pool Nadarid.");
  739. if(amount < 1) return SendClientMessage(playerid,COLOR_RED,"Money should be more than $1");
  740. HouseInfo[idx][hMoney] += amount;
  741. GivePlayerMoney(playerid, -amount);
  742. format(string, sizeof(string), "* %s opens their vault, puts $%d inside and closes it.", RPN(playerid), amount);
  743. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  744.  
  745.  
  746. }
  747. return 1;
  748. }
  749. CMD:hwithdraw(playerid, params[])
  750. {
  751. new string[128], option[32], amount;
  752. new idx = PlayerInfo[playerid][pHouse];
  753.  
  754. if(!PlayerInfo[playerid][pHouse] && !PlayerInfo[playerid][pVHouse]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a house.");
  755. if(GetPlayerVirtualWorld(playerid)-500 != idx && !PlayerInfo[playerid][pVHouse]) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your house.");
  756. if(GetPlayerVirtualWorld(playerid)-500 != idx && PlayerInfo[playerid][pVHouse])
  757. {
  758. idx = PlayerInfo[playerid][pVHouse];
  759. if(GetPlayerVirtualWorld(playerid)-500 != idx) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your house.");
  760. }
  761. if(sscanf(params, "s[32]", option))
  762. {
  763. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /hsafe withdraw [item]");
  764. SendClientMessage(playerid, COLOR_GREY, "ITEMS: money");
  765. /*format(string, sizeof(string), "SAFE: $%d | %d Weed | %d Crack", HouseInfo[idx][hMoney], HouseInfo[idx][hWeed], HouseInfo[idx][hCrack]);
  766. SendClientMessage(playerid, COLOR_WHITE, string);
  767. format(string, sizeof(string), "SAFE: Weapon 1: %s (%d Ammo) | Weapon 2: %s (%d Ammo) | Weapon 3: %s (%d Ammo)", RWN(HouseInfo[idx][hGun][0]), HouseInfo[idx][hGunAmmo][0], RWN(HouseInfo[idx][hGun][1]), HouseInfo[idx][hGunAmmo][1], RWN(HouseInfo[idx][hGun][2]), HouseInfo[idx][hGunAmmo][2]);
  768. SendClientMessage(playerid, COLOR_WHITE, string);
  769. format(string, sizeof(string), "SAFE: Weapon 4: %s (%d Ammo) | Weapon 5: %s (%d Ammo)", RWN(HouseInfo[idx][hGun][3]), HouseInfo[idx][hGunAmmo][3], RWN(HouseInfo[idx][hGun][4]), HouseInfo[idx][hGunAmmo][4]);
  770. SendClientMessage(playerid, COLOR_WHITE, string);*/
  771. return 1;
  772. }
  773. if(!strcmp(option, "money", true, 5))
  774. {
  775. if(sscanf(params, "s[32]i", option, amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /hsafe withdraw money [amount]");
  776. if(HouseInfo[idx][hMoney] < amount) return SendClientMessage(playerid, COLOR_GREY, "You don't have that much money in your house vault.");
  777. HouseInfo[idx][hMoney] -= amount;
  778. GivePlayerMoney(playerid, amount);
  779. format(string, sizeof(string), "* %s opens their vault, takes $%d and closes it.", RPN(playerid), amount);
  780. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  781. }
  782. return 1;
  783. }
  784. CMD:Househelp(playerid, params[])
  785. {
  786.  
  787. SendClientMessage(playerid, COLOR_ORANGE, ""COE"---------------------["CWE" HouseHelp "COE"]---------------------");
  788. SendClientMessage(playerid, COLOR_YELLOW, "[HOUSE]: {FFFFFF}/buyhouse /hdeposit /hwithdraw /hlock /houseupgrade /sellhousetomarket /heal");
  789. return 1;
  790. }
  791. CMD:heal(playerid, params[])
  792. {
  793. if(!IsAtHouse(playerid)) return SendClientMessage(playerid, COLOR_GREY, " Shoma Nistid Dar House");
  794. if(GetPlayerMoney(playerid) < 100) return SendClientMessage(playerid, COLOR_GREY, "You Dont Have This Much cash. ($100)");
  795. ShowPlayerDialog(playerid,829,DIALOG_STYLE_MSGBOX,"Health & Armor","================================\nThis will cost 100$\n\nType: Health & Armour Recovery","Pay","Enseraf");
  796. return 1;
  797. }
  798. CMD:enter(playerid,params[])
  799. {
  800. new string[128];
  801. for(new idx=1; idx<MAX_HOUSES; idx++) // Dynamic Houses
  802. {
  803. if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]))
  804. {
  805. if(!HouseInfo[idx][hStatus] && PlayerInfo[playerid][pHouse] != idx && PlayerInfo[playerid][pVHouse] != idx) return SendClientMessage(playerid, COLOR_GREY, "This house is locked.");
  806. format(string, sizeof(string), "* %s pushes the door and enters the house.", RPN(playerid));
  807. if(PlayerInfo[playerid][pMaskOn] == 1)
  808. {
  809. format(string, sizeof(string), "* Stranger pushes the door and enters the house.");
  810. }
  811. else
  812. {
  813. format(string, sizeof(string), "* %s pushes the door and enters the house.", RPN(playerid));
  814. }
  815. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  816. SetPlayerVirtualWorld(playerid, idx+500);
  817. if(HouseInfo[idx][hLevel] == 1)
  818. {
  819. SetPlayerPos(playerid, 243.9951,304.9418,999.1484);
  820. SetPlayerFacingAngle(playerid, 267.0980);
  821. SetCameraBehindPlayer(playerid);
  822. SetPlayerInterior(playerid, 1);
  823. }
  824. else if(HouseInfo[idx][hLevel] == 2)
  825. {
  826. SetPlayerPos(playerid, 2259.6702,-1135.8542,1050.6328);
  827. SetPlayerFacingAngle(playerid, 267.3974);
  828. SetCameraBehindPlayer(playerid);
  829. SetPlayerInterior(playerid, 10);
  830. }
  831. else if(HouseInfo[idx][hLevel] == 3)
  832. {
  833. SetPlayerPos(playerid, 2308.8254,-1212.8070,1049.0234);
  834. SetPlayerFacingAngle(playerid, 359.8550);
  835. SetCameraBehindPlayer(playerid);
  836. SetPlayerInterior(playerid, 6);
  837. }
  838. else if(HouseInfo[idx][hLevel] == 4)
  839. {
  840. SetPlayerPos(playerid, 260.7436,1237.5563,1084.2578);
  841. SetPlayerFacingAngle(playerid, 1.6415);
  842. SetCameraBehindPlayer(playerid);
  843. SetPlayerInterior(playerid, 9);
  844. }
  845. else if(HouseInfo[idx][hLevel] == 5)
  846. {
  847. SetPlayerPos(playerid, -42.5742,1405.6521,1084.4297);
  848. SetPlayerFacingAngle(playerid, 359.1347);
  849. SetCameraBehindPlayer(playerid);
  850. SetPlayerInterior(playerid, 8);
  851. }
  852. else if(HouseInfo[idx][hLevel] == 6)
  853. {
  854. SetPlayerPos(playerid, 2468.6787,-1698.2617,1013.5078);
  855. SetPlayerFacingAngle(playerid, 89.1791);
  856. SetCameraBehindPlayer(playerid);
  857. SetPlayerInterior(playerid, 2);
  858. }
  859. else if(HouseInfo[idx][hLevel] == 7)
  860. {
  861. SetPlayerPos(playerid, 2365.2183,-1135.4014,1050.8750);
  862. SetPlayerFacingAngle(playerid, 359.8550);
  863. SetCameraBehindPlayer(playerid);
  864. SetPlayerInterior(playerid, 8);
  865. }
  866. else if(HouseInfo[idx][hLevel] == 8)
  867. {
  868. SetPlayerPos(playerid, 2270.1270,-1210.4855,1047.5625);
  869. SetPlayerFacingAngle(playerid, 89.4224);
  870. SetCameraBehindPlayer(playerid);
  871. SetPlayerInterior(playerid, 10);
  872. }
  873. else if(HouseInfo[idx][hLevel] == 9)
  874. {
  875. SetPlayerPos(playerid, 2324.4424,-1149.2057,1050.7101);
  876. SetPlayerFacingAngle(playerid, 0.7248);
  877. SetCameraBehindPlayer(playerid);
  878. SetPlayerInterior(playerid, 12);
  879. }
  880. else if(HouseInfo[idx][hLevel] == 10)
  881. {
  882. SetPlayerPos(playerid, 83.0863,1322.3020,1083.8662);
  883. SetPlayerFacingAngle(playerid, 359.5183);
  884. SetCameraBehindPlayer(playerid);
  885. SetPlayerInterior(playerid, 9);
  886. }
  887. else if(HouseInfo[idx][hLevel] == 11)
  888. {
  889. SetPlayerPos(playerid, 225.6631,1022.3559,1084.0150);
  890. SetPlayerFacingAngle(playerid, 359.5183);
  891. SetCameraBehindPlayer(playerid);
  892. SetPlayerInterior(playerid, 7);
  893. }
  894. }
  895. }
  896. return 1;
  897. }
  898. CMD:houseupgrade(playerid, params[])
  899. {
  900. new string[128], idx = PlayerInfo[playerid][pHouse], price;
  901. if(!PlayerInfo[playerid][pHouse]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a house.");
  902. if(!PlayerInfo[playerid][pVHouse])
  903. {
  904. if(!IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ])) return SendClientMessage(playerid, COLOR_GREY, "You are not near your house.");
  905. }
  906. else
  907. {
  908. new done;
  909. if(!IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]))
  910. {
  911. done ++;
  912. idx = PlayerInfo[playerid][pVHouse];
  913. if(!IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ])) done ++;
  914. }
  915. if(done == 2) return SendClientMessage(playerid, COLOR_GREY, "You are not near your house.");
  916.  
  917. }
  918. if(sscanf(params, "s[8]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /houseupgrade confirm");
  919. if(HouseInfo[idx][hLevel] >= 11) return SendClientMessage(playerid, COLOR_GREY, "Your house already has the maximum level possible.");
  920. if(!strcmp(params, "confirm", true))
  921. {
  922. price = 500000;
  923. if(GetPlayerMoney(playerid) < price)
  924. {
  925. format(string, sizeof(string), "You need $%d to upgrade your house.", price);
  926. SendClientMessage(playerid, COLOR_GREY, string);
  927. return 1;
  928. }
  929. HouseInfo[idx][hLevel] ++;
  930. GivePlayerMoney(playerid, -price);
  931. format(string, sizeof(string), " You have upgraded your house to level %d.", HouseInfo[idx][hLevel]);
  932. SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
  933. format(string, sizeof(string), ""COE"["CWE"%d, House (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\n"COE"Status"CWE" %s", idx, HouseInfo[idx][hLevel], HouseInfo[idx][hOwner], RHS(idx));
  934. UpdateDynamic3DTextLabelText(HouseInfo[idx][hText], COLOR_WHITE, string);
  935. }
  936. return 1;
  937. }
  938. CMD:savehouses(playerid, params[])
  939. {
  940. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not rcon admin.");
  941. SaveHouses();
  942. new string[128];
  943. format(string, sizeof(string), "{FF0000}[Manual Save]{FF6347} houses are saved");
  944. SendClientMessageToAll(COLOR_LIGHTRED, string);
  945. return 1;
  946. }
  947. /*new playername[MAX_PLAYER_NAME];
  948.  
  949. CMD:makerentable(playerid,params[])
  950. {
  951. new tmp[256];
  952. new string[256];
  953. new idx;
  954. if(IsPlayerConnected(playerid))
  955. {
  956. new bouse = PlayerInfo[playerid][pPhousekey];
  957. GetPlayerName(playerid, playername, sizeof(playername));
  958. if (bouse != 255 && strcmp(playername, HouseInfo[PlayerInfo[playerid][pPhousekey]][hOwner], true) == 0)
  959. {
  960. tmp = strtok(params, idx);
  961. if(!strlen(tmp))
  962. {
  963. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setrentable [0/1]");
  964. }
  965. HouseInfo[bouse][hRentabil] = strval(tmp);
  966. SaveHouses();
  967. format(string, sizeof(string), "House rentable set to %d.", HouseInfo[bouse][hRentabil]);
  968. SendClientMessage(playerid, COLOR_WHITE, string);
  969. return 1;
  970. }
  971. else
  972. {
  973. SendClientMessage(playerid, COLOR_WHITE, " You don't own a house !");
  974. return 1;
  975. }
  976. }
  977. return 1;
  978. }
  979. CMD:setrent(playerid,params[])
  980. {
  981. new tmp[256];
  982. new string[256];
  983. new idx;
  984. if(IsPlayerConnected(playerid))
  985. {
  986. new bouse = PlayerInfo[playerid][pPhousekey];
  987. GetPlayerName(playerid, playername, sizeof(playername));
  988. if (bouse != 255 && strcmp(playername, HouseInfo[PlayerInfo[playerid][pPhousekey]][hOwner], true) == 0)
  989. {
  990. tmp = strtok(params, idx);
  991. if(!strlen(tmp))
  992. {
  993. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setrent [RentFee]");
  994. return 1;
  995. }
  996. if(strval(tmp) < 1 || strval(tmp) > 9999)
  997. {
  998. SendClientMessage(playerid, COLOR_WHITE, "Minimum rent is $1, Maximum rent is $9999.");
  999. return 1;
  1000. }
  1001. HouseInfo[bouse][hRent] = strval(tmp);
  1002. SaveHouses();
  1003. format(string, sizeof(string), "House rent set to $%s", FormatNumber(HouseInfo[bouse][hRent]));
  1004. SendClientMessage(playerid, COLOR_WHITE, string);
  1005. return 1;
  1006. }
  1007. else
  1008. {
  1009. SendClientMessage(playerid, COLOR_WHITE, " You don't own a house");
  1010. return 1;
  1011. }
  1012. }
  1013. return 1;
  1014. }
  1015. CMD:renthouse(playerid,params[])
  1016. {
  1017.  
  1018. if(IsPlayerConnected(playerid))
  1019. {
  1020. new Float:oldposx, Float:oldposy, Float:oldposz;
  1021. GetPlayerName(playerid, playername, sizeof(playername));
  1022. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  1023. for(new h = 0; h < sizeof(HouseInfo); h++)
  1024. {
  1025. if(PlayerToPoint(2.0, playerid, HouseInfo[h][hX], HouseInfo[h][hY], HouseInfo[h][hZ]) && HouseInfo[h][hOwned] == 1 && HouseInfo[h][hRentabil] == 1)
  1026. {
  1027. if(HouseInfo[h][hInsurance] == 1)
  1028. {
  1029. SCM(playerid, COLOR_CRS2, "** This house has no insurance and you can not rent a room.");
  1030. return 1;
  1031. }
  1032. if(PlayerInfo[playerid][pPhousekey] != 255 && strcmp(playername, HouseInfo[PlayerInfo[playerid][pPhousekey]][hOwner], true) == 0)
  1033. {
  1034. SendClientMessage(playerid, COLOR_WHITE, "** You already own a house, type /sellhouse if you want to rent this one.");
  1035. return 1;
  1036. }
  1037. if(GetPlayerMoney(playerid) > HouseInfo[h][hRent])
  1038. {
  1039. PlayerInfo[playerid][pPhousekey] = h;
  1040. PlayerInfo[playerid][pRented] = h;
  1041. PlayerInfo[playerid][pRented] = 1;
  1042. SafeGivePlayerMoney(playerid,-HouseInfo[h][hRent]);
  1043. HouseInfo[h][hTakings] = HouseInfo[h][hTakings]+HouseInfo[h][hRent];
  1044. // SetPlayerInterior(playerid,HouseInfo[h][hInt]);
  1045. // SetPlayerVirtualWorld(playerid,HouseInfo[h][hWorld]);
  1046. // PlayerInfo[playerid][pVirWorld] = HouseInfo[h][hWorld];
  1047. // SetPlayerMapIcon(playerid,h + 20,HouseInfo[h][hEntrancex],HouseInfo[h][hEntrancey],HouseInfo[h][hEntrancez],31,COLOR_LIGHTRED);
  1048. SetPlayerPos(playerid,HouseInfo[h][hX],HouseInfo[h][hY],HouseInfo[h][hZ]);
  1049. GameTextForPlayer(playerid, "~w~Welcome Home~n~You can exit at any time by moving to this door and press enter", 5000, 3);
  1050. PlayerInfo[playerid][pInt] = HouseInfo[h][hInt];
  1051. PlayerInfo[playerid][pLocal] = h;
  1052. SendClientMessage(playerid, COLOR_WHITE, "** Congratulations, You can enter and exit here anytime.");
  1053. SendClientMessage(playerid, COLOR_WHITE, "** Type /help to review the new property help section.");
  1054. OnPlayerUpdate(playerid);
  1055. return 1;
  1056. }
  1057. else
  1058. {
  1059. SendClientMessage(playerid, COLOR_WHITE, "You don't have the cash for that");
  1060. return 1;
  1061. }
  1062. }
  1063. }
  1064. }
  1065. return 1;
  1066. }
  1067. */
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081. /*forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
  1082. public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
  1083. {
  1084. if(IsPlayerConnected(playerid))
  1085. {
  1086. new Float:oldposx, Float:oldposy, Float:oldposz;
  1087. new Float:tempposx, Float:tempposy, Float:tempposz;
  1088. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  1089. tempposx = (oldposx -x);
  1090. tempposy = (oldposy -y);
  1091. tempposz = (oldposz -z);
  1092. //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
  1093. if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  1094. {
  1095. return 1;
  1096. }
  1097. }
  1098. return 0;
  1099. }
  1100.  
  1101. FormatNumber(number)
  1102. {
  1103. new Str[15];
  1104. format(Str, 15, "%d", number);
  1105.  
  1106. if (strlen(Str) < sizeof(Str))
  1107. {
  1108. if (number >= 1000 && number < 10000)
  1109. strins( Str, ",", 1, sizeof(Str));
  1110.  
  1111. else if (number >= 10000 && number < 100000)
  1112. strins(Str, ",", 2, sizeof(Str));
  1113.  
  1114. else if (number >= 100000 && number < 1000000)
  1115. strins(Str, ",", 3, sizeof(Str));
  1116.  
  1117. else if (number >= 1000000 && number < 10000000)
  1118. strins(Str, ",", 1, sizeof(Str)),strins(Str, ",", 5, sizeof(Str));
  1119.  
  1120. else if (number >= 10000000 && number < 100000000)
  1121. strins(Str, ",", 2, sizeof(Str)),strins(Str, ",", 6, sizeof(Str));
  1122.  
  1123. else if (number >= 100000000 && number < 1000000000)
  1124. strins(Str, ",", 3, sizeof(Str)),strins(Str, ",", 7, sizeof(Str));
  1125.  
  1126. else if (number >= 1000000000 && number < 10000000000)
  1127. strins(Str, ",", 1, sizeof(Str)),
  1128. strins(Str, ",", 5, sizeof(Str)),
  1129. strins(Str, ",", 9, sizeof(Str));
  1130. else format(Str, 10, "%d", number);
  1131. }
  1132. else format( Str, 15, "<BUG>" );
  1133. return Str;
  1134. }
  1135. strtok(const string[], &index)
  1136. {
  1137. new length = strlen(string);
  1138. while ((index < length) && (string[index] <= ' '))
  1139. {
  1140. index++;
  1141. }
  1142.  
  1143. new offset = index;
  1144. new result[20];
  1145. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  1146. {
  1147. result[index - offset] = string[index];
  1148. index++;
  1149. }
  1150. result[index - offset] = EOS;
  1151. return result;
  1152. }*/
  1153. stock split(const strsrc[], strdest[][], delimiter)
  1154. {
  1155. new i, li;
  1156. new aNum;
  1157. new len;
  1158. while(i <= strlen(strsrc))
  1159. {
  1160. if(strsrc[i] == delimiter || i == strlen(strsrc))
  1161. {
  1162. len = strmid(strdest[aNum], strsrc, li, i, 128);
  1163. strdest[aNum][len] = 0;
  1164. li = i+1;
  1165. aNum++;
  1166. }
  1167. i++;
  1168. }
  1169. return 1;
  1170. }
  1171. stock IsPlayerLoggedIn(playerid)
  1172. {
  1173. if(IsPlayerConnected(playerid))
  1174. {
  1175. if(PlayerInfo[playerid][pLoggedIn])
  1176. {
  1177. return 1;
  1178. }
  1179. }
  1180. return 0;
  1181. }
  1182. stock RPN(playerid)
  1183. {
  1184. new string[25];
  1185. if(PlayerInfo[playerid][pMaskOn] == 0)format(string, sizeof(string), "%s");
  1186. // else if(PlayerInfo[playerid][pMaskOn] == 1)format(string, sizeof(string), "Stranger");
  1187. return string;
  1188. }
  1189. stock Log(sz_fileName[], sz_input[]) {
  1190.  
  1191. new sz_logEntry[156], i_dateTime[2][3], File: fileHandle = fopen(sz_fileName, io_append);
  1192. gettime(i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2]);
  1193. getdate(i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2]);
  1194. format(sz_logEntry, sizeof(sz_logEntry), "[%i/%i/%i - %i:%i:%i] %s\r\n", i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2], i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2], sz_input);
  1195. fwrite(fileHandle, sz_logEntry);
  1196. return fclose(fileHandle);
  1197. }
  1198. stock RHS(bizid)
  1199. {
  1200. new string[16];
  1201. if(!HouseInfo[bizid][hStatus]) format(string, sizeof(string), "Closed");
  1202. else if(HouseInfo[bizid][hStatus]) format(string, sizeof(string), "Open");
  1203. return string;
  1204. }
  1205.  
  1206. stock RPNU(playerid)
  1207. {
  1208. new name[MAX_PLAYER_NAME];
  1209. GetPlayerName(playerid, name, sizeof(name));
  1210. return name;
  1211. }
  1212. stock SendNearbyMessage(playerid, Float:radius, string[], col1, col2, col3, col4, col5)
  1213. {
  1214. new Float:x, Float:y, Float:z;
  1215. GetPlayerPos(playerid, x, y, z);
  1216. new Float:ix, Float:iy, Float:iz;
  1217. new Float:cx, Float:cy, Float:cz;
  1218. foreach(Player, i)
  1219. {
  1220. if(IsPlayerLoggedIn(i))
  1221. {
  1222. if(GetPlayerInterior(playerid) == GetPlayerInterior(i) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
  1223. {
  1224. GetPlayerPos(i, ix, iy, iz);
  1225. cx = (x - ix);
  1226. cy = (y - iy);
  1227. cz = (z - iz);
  1228. if(((cx < radius/16) && (cx > -radius/16)) && ((cy < radius/16) && (cy > -radius/16)) && ((cz < radius/16) && (cz > -radius/16)))
  1229. {
  1230. SendClientMessage(i, col1, string);
  1231. }
  1232. else if(((cx < radius/8) && (cx > -radius/8)) && ((cy < radius/8) && (cy > -radius/8)) && ((cz < radius/8) && (cz > -radius/8)))
  1233. {
  1234. SendClientMessage(i, col2, string);
  1235. }
  1236. else if(((cx < radius/4) && (cx > -radius/4)) && ((cy < radius/4) && (cy > -radius/4)) && ((cz < radius/4) && (cz > -radius/4)))
  1237. {
  1238. SendClientMessage(i, col3, string);
  1239. }
  1240. else if(((cx < radius/2) && (cx > -radius/2)) && ((cy < radius/2) && (cy > -radius/2)) && ((cz < radius/2) && (cz > -radius/2)))
  1241. {
  1242. SendClientMessage(i, col4, string);
  1243. }
  1244. else if(((cx < radius) && (cx > -radius)) && ((cy < radius) && (cy > -radius)) && ((cz < radius) && (cz > -radius)))
  1245. {
  1246. SendClientMessage(i, col5, string);
  1247. }
  1248. }
  1249. }
  1250. }
  1251. return 1;
  1252. }
  1253.  
  1254. IsAtHouse(playerid)
  1255. {
  1256. if(IsPlayerConnected(playerid))
  1257. {
  1258. if(IsPlayerInRangeOfPoint(playerid, 20.0, 243.9951, 304.9418, 999.1484)) // House 1
  1259. {
  1260. return 1;
  1261. }
  1262. else if(IsPlayerInRangeOfPoint(playerid, 20.0, 2259.6702, -1135.8542, 1050.6328)) // House 2
  1263. {
  1264. return 1;
  1265. }
  1266. else if(IsPlayerInRangeOfPoint(playerid, 20.0, 2308.8254, -1212.8070, 1049.0234)) // House 3
  1267. {
  1268. return 1;
  1269. }
  1270. else if(IsPlayerInRangeOfPoint(playerid, 20.0, 260.7436, 1237.5563, 1084.2578)) // House 4
  1271. {
  1272. return 1;
  1273. }
  1274. else if(IsPlayerInRangeOfPoint(playerid, 20.0, -42.5742, 1405.6521, 1084.4297)) // House 5
  1275. {
  1276. return 1;
  1277. }
  1278. else if(IsPlayerInRangeOfPoint(playerid, 20.0, 2468.6787, -1698.2617, 1013.5078)) // House 6
  1279. {
  1280. return 1;
  1281. }
  1282. else if(IsPlayerInRangeOfPoint(playerid, 20.0, 2365.2183, -1135.4014, 1050.8750)) // House 7
  1283. {
  1284. return 1;
  1285. }
  1286. else if(IsPlayerInRangeOfPoint(playerid, 20.0, 2270.1270, -1210.4855, 1047.5625)) // House 8
  1287. {
  1288. return 1;
  1289. }
  1290. else if(IsPlayerInRangeOfPoint(playerid, 20.0, 2324.4424, -1149.2057, 1050.7101)) // House 9
  1291. {
  1292. return 1;
  1293. }
  1294. else if(IsPlayerInRangeOfPoint(playerid, 20.0, 83.0863, 1322.3020, 1083.8662)) // House 10
  1295. {
  1296. return 1;
  1297. }
  1298. else if(IsPlayerInRangeOfPoint(playerid, 30.0, 225.6631,1022.3559,1084.0150)) // House 11
  1299. {
  1300. return 1;
  1301. }
  1302. }
  1303. return 0;
  1304. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement