Guest User

Untitled

a guest
Nov 28th, 2011
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.94 KB | None | 0 0
  1. //NAPRAVIO:SANDMAN
  2. //=======samo da znate ovo je napravljeno od aHouse sistema,nema level i nisam siguran da ce raditi
  3. #include <a_samp>
  4. #include <dudb>
  5. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  6.  
  7. #define MAX_STANOVA 50
  8. #define MAX_RENTCOST 1000
  9. #define MIN_RENTCOST 500
  10. #define MAX_BUY_CARS 8
  11. #define CAR_DELIVER_TIME 1
  12. new STAN_STATS = 0;
  13.  
  14.  
  15.  
  16.  
  17. #define Cost_Admiral 50000
  18. //----------------------------
  19. //----------------------------
  20. #define c_y 0xFFFF00AA
  21. #define c_r 0xAA3333AA
  22. new HousePickup[MAX_STANOVA];
  23. new playerinterior[MAX_PLAYERS]=-1;
  24. new inhousepickup[MAX_PLAYERS];
  25. new playericonhouse[MAX_PLAYERS];
  26. new Float:stanx, Float:stany, Float:stanz;
  27. new housemapicon[MAX_PLAYERS];
  28. new playerworld[MAX_PLAYERS];
  29.  
  30. forward rentfee();
  31.  
  32.  
  33. enum StanInfo
  34. {
  35. Name[24],
  36. Renter[24],
  37. Rentable,
  38. Rentcost,
  39. Cost,
  40. Sell,
  41. Interior,
  42. Virtualworld,
  43. Locked,
  44. Float:InteriorX,
  45. Float:InteriorY,
  46. Float:InteriorZ,
  47. Float:iconx,
  48. Float:icony,
  49. Float:iconz,
  50. Rentfee
  51. }
  52. new hInfo[MAX_STANOVA][StanInfo];
  53.  
  54.  
  55.  
  56.  
  57. #define FILTERSCRIPT
  58. #if defined FILTERSCRIPT
  59.  
  60. public OnFilterScriptInit()
  61. {
  62. print("\n--------------------------------------");
  63. print(" Stanovi");
  64. print("--------------------------------------\n");
  65.  
  66. AddStan(0, 1188.9827,-1017.8866,36.2344, 328.1465, 1478.4457,1084.4375, 0, 0, 15, 0);
  67. SetTimer("rentfee", 1*60*60*1000, 1);//1 hour
  68. SetTimer("newcar", CAR_DELIVER_TIME*60*10*1000,1);//1 hour
  69. return 0;
  70. }
  71.  
  72. public OnFilterScriptExit()
  73. {
  74. for(new i=0;i<MAX_STANOVA;i++)
  75. {
  76. DestroyPickup(HousePickup[i]);
  77.  
  78. }
  79. return 0;
  80. }
  81.  
  82. #else
  83. #endif
  84.  
  85. public OnPlayerCommandText(playerid, cmdtext[])
  86. {
  87. dcmd(kupistan,3,cmdtext);
  88. dcmd(prodajstan,4,cmdtext);
  89. dcmd(ulaz,10,cmdtext);
  90. dcmd(izlaz,10,cmdtext);
  91. dcmd(zakljucaj,4,cmdtext);
  92. dcmd(otkljucaj,6,cmdtext);
  93. dcmd(home,4,cmdtext);
  94. dcmd(stan,5,cmdtext);
  95. dcmd(stanstats,10,cmdtext);
  96. dcmd(getrent,7,cmdtext);
  97. dcmd(payrent,7,cmdtext);
  98.  
  99. return 0;
  100. }
  101.  
  102. AddStan(stanid, Float:iconX, Float:iconY, Float:iconZ, Float:interiorX, Float:interiorY, Float:interiorZ, Costa, Sella, Interiora, virtualworld)
  103. {
  104. new house[256];
  105. format(house, sizeof(house), "Stanovi/stanid%d",stanid);
  106. if(!dini_Exists(house))
  107. {
  108. dini_Create(house);
  109. format(hInfo[stanid][Name], 24, "STAN NA PRODAJU");
  110. dini_Set(house, "Name", "Prodaje se");
  111. format(hInfo[stanid][Renter], 24, "");
  112. dini_Set(house, "Renter", "ForRent");
  113. hInfo[stanid][Rentable] = 0;
  114. dini_IntSet(house, "Rentable", 0);
  115. hInfo[stanid][Rentcost] = 0;
  116. dini_IntSet(house, "Rentcost", 0);
  117. hInfo[stanid][Cost] = Costa;
  118. dini_IntSet(house, "Cijena", Costa);
  119. hInfo[stanid][Sell] = Sella;
  120. dini_IntSet(house, "Prodaja", Sella);
  121. hInfo[stanid][Interior] = Interiora;
  122. dini_IntSet(house, "Interior", Interiora);
  123. dini_IntSet(house, "Virtualworld", virtualworld);
  124. hInfo[stanid][Virtualworld] = virtualworld;
  125. hInfo[stanid][Locked] = 1;
  126. dini_IntSet(house, "Locked", 1);
  127. hInfo[stanid][InteriorX] = interiorX;
  128. hInfo[stanid][InteriorY] = interiorY;
  129. hInfo[stanid][InteriorZ] = interiorZ;
  130. dini_FloatSet(house, "X", interiorX);
  131. dini_FloatSet(house, "Y", interiorY);
  132. dini_FloatSet(house, "Z", interiorZ);
  133. dini_IntSet(house, "RentPay", 0);
  134. dini_IntSet(house, "RentGet", 0);
  135.  
  136. print("-");
  137. print("--------------House Created--------------");
  138. printf("- stanid: %d", stanid);
  139. printf("- Buy Cost: %d", Costa);
  140. printf("- Sell Cost: %d", Sella);
  141. printf("- Interior: %d", Interiora);
  142. printf("- VirtualWorld: %d", virtualworld);
  143. print("-----------------------------------------");
  144. print("-");
  145. }
  146. else
  147. {
  148. format(hInfo[stanid][Name], 24, dini_Get(house, "Ime"));
  149. format(hInfo[stanid][Renter], 24, dini_Get(house, "Renter"));
  150. hInfo[stanid][Rentable] = dini_Int(house, "Rentable");
  151. hInfo[stanid][Rentcost] = dini_Int(house, "Rentcost");
  152. hInfo[stanid][Cost] = dini_Int(house, "Cost");
  153. hInfo[stanid][Sell] = dini_Int(house, "Sell");
  154. hInfo[stanid][Interior] = dini_Int(house, "Interior");
  155. hInfo[stanid][Locked] = dini_Int(house, "Locked");
  156. hInfo[stanid][InteriorX] = dini_Float(house, "X");
  157. hInfo[stanid][InteriorY] = dini_Float(house, "Y");
  158. hInfo[stanid][InteriorZ] = dini_Float(house, "Z");
  159. hInfo[stanid][Virtualworld] = dini_Int(house, "Virtualworld");
  160. }
  161. hInfo[stanid][iconx]=iconX;
  162. hInfo[stanid][icony]=iconY;
  163. hInfo[stanid][iconz]=iconZ;
  164. format(house, sizeof(house), "Stanovi/stanid%d",stanid);
  165. if(strcmp(hInfo[playericonhouse[stanid]][Name],"Na prodaju",true)==0)
  166. {
  167. HousePickup[stanid] = CreatePickup(1273, 23, iconX, iconY, iconZ);//not bought
  168. }
  169. else
  170. {
  171. HousePickup[stanid] = CreatePickup(1272,23, iconX, iconY, iconZ);//bought
  172. }
  173. }
  174.  
  175.  
  176.  
  177. stock SpawnPlayerAtHouse(playerid)
  178. {
  179. new str1[256],pname[24],str[256];
  180. GetPlayerName(playerid, pname, sizeof(pname));
  181. format(str1, sizeof(str1), "Stanovi/Users/%s", udb_encode(pname));
  182. if (dini_Exists(str1))
  183. {
  184. if(dini_Int(str1,"stanid")!=-255)
  185. {
  186. new Float:x,Float:y,Float:z;
  187. str = dini_Get(str1,"SpawnInt");
  188. SetPlayerInterior(playerid, strval(str));
  189. playerinterior[playerid] = strval(str);
  190. x = dini_Float(str1,"SpawnX");
  191. y = dini_Float(str1,"SpawnY");
  192. z = dini_Float(str1,"SpawnZ");
  193. SetPlayerPos(playerid, x, y, z);
  194. }
  195. }
  196. return 1;
  197. }
  198.  
  199. public OnPlayerSpawn(playerid)
  200. {
  201. SpawnPlayerAtHouse(playerid);
  202. }
  203.  
  204. GetStanoviStats(playerid, pickupid)
  205. {
  206. for(new i=0;i<MAX_STANOVA;i++)
  207. {
  208. if(pickupid==HousePickup[i])
  209. {
  210. if(STAN_STATS==0)
  211. {
  212. new str2[256];
  213. format(str2, sizeof(str2), "Owned by: %s", hInfo[i][Name]);
  214. SendClientMessage(playerid, c_y, str2);
  215. if(strcmp(hInfo[i][Renter],"ForRent",true))
  216. {
  217. format(str2, sizeof(str2), "Rented by: %s", hInfo[i][Renter]);
  218. SendClientMessage(playerid, c_y, str2);
  219. }
  220. format(str2,sizeof(str2),"Cost: %i",hInfo[i][Cost]);
  221. SendClientMessage(playerid, c_y, str2);
  222. }
  223. inhousepickup[playerid] = GetTickCount();
  224. playericonhouse[playerid] = i;
  225. }
  226. }
  227. }
  228.  
  229. dcmd_prodajstan(playerid,params[])
  230. {
  231. #pragma unused params
  232. new timestamp = GetTickCount();
  233. if(timestamp - inhousepickup[playerid] > 5000)
  234. {
  235. SendClientMessage(playerid, c_r, "Nisi na ikoni od stana!");
  236. return 1;
  237. }
  238. new str[255],str1[256],pname[24];
  239. GetPlayerName(playerid, pname, 24);
  240. format(str1, sizeof(str1), "Stanovi/stanid%d", playericonhouse[playerid]);
  241. if (strcmp(hInfo[playericonhouse[playerid]][Name],pname,false)) return SendClientMessage(playerid, c_r, "This house isn't yours!");
  242. SendClientMessage(playerid, c_y, "You have sold your house!");
  243. format(str, sizeof(str), "%s has sold stanid 0",pname);
  244. print(str);
  245. GivePlayerMoney(playerid, hInfo[playericonhouse[playerid]][Sell]);
  246. dini_Set(str1, "Name", "ForSale");
  247. hInfo[playericonhouse[playerid]][Locked] = dini_IntSet(str1,"Locked",1);
  248. format(hInfo[playericonhouse[playerid]][Name],255,"Na prodaju");
  249. format(str1, sizeof(str1), "Stanovi/Users/%s", udb_encode(pname));
  250. if (!dini_Exists(str1)) dini_Create(str1);
  251. dini_IntSet(str1, "stanid", -255);
  252. DestroyPickup(HousePickup[playericonhouse[playerid]]);
  253. HousePickup[playericonhouse[playerid]] = CreatePickup(1273, 23, hInfo[playericonhouse[playerid]][iconx], hInfo[playericonhouse[playerid]][icony], hInfo[playericonhouse[playerid]][iconz]);
  254. RemovePlayerMapIcon(playerid, housemapicon[playerid]);
  255. return 1;
  256. }
  257.  
  258. dcmd_kupistan(playerid,params[])
  259. {
  260. #pragma unused params
  261. new timestamp = GetTickCount();
  262. if(timestamp - inhousepickup[playerid] > 5000)
  263. {
  264. SendClientMessage(playerid, c_r, "You are not in a house icon!");
  265. return 1;
  266. }
  267. new str[255],str1[255],pname[24];
  268. GetPlayerName(playerid, pname, 24);
  269. format(str1, sizeof(str1), "Stanovi/Users/%s", udb_encode(pname));
  270. if(dini_Exists(str1))
  271. {
  272. if (dini_Int(str1, "stanid")!=-255) return SendClientMessage(playerid, c_r, "Mozes kupiti samo jedan stan!");
  273. }
  274. format(str1, sizeof(str1), "Stanovi/stanid%d", playericonhouse[playerid]);
  275. if (strcmp(hInfo[playericonhouse[playerid]][Name],"ForSale",true)) return SendClientMessage(playerid, c_r, "This house isn't for sale!");
  276. if(GetPlayerMoney(playerid)<hInfo[playericonhouse[playerid]][Cost]) return SendClientMessage(playerid, c_r, "Not enough money!");
  277. SendClientMessage(playerid, c_y, "You have bought the house!");
  278. format(str, sizeof(str), "%s has bought stanid 0",pname);
  279. print(str);
  280. GivePlayerMoney(playerid, -hInfo[playericonhouse[playerid]][Cost]);
  281. dini_Set(str1, "Name", pname);
  282. hInfo[playericonhouse[playerid]][Name]=pname;
  283. hInfo[playericonhouse[playerid]][Locked] = dini_IntSet(str1,"Locked",0);
  284.  
  285. format(str1, sizeof(str1), "Stanovi/Users/%s", udb_encode(pname));
  286. if (!dini_Exists(str1)) dini_Create(str1);
  287. new Float:sy, Float:sx, Float:sz;
  288. dini_IntSet(str1, "stanid", playericonhouse[playerid]);
  289. if(!dini_Isset(str1,"Rentid"))
  290. {
  291. dini_IntSet(str1, "Rentid", -255);
  292. }
  293. GetPlayerPos(playerid, sx,sy,sz);
  294. dini_FloatSet(str1, "SpawnX", sx);
  295. dini_FloatSet(str1, "SpawnY", sy);
  296. dini_FloatSet(str1, "SpawnZ", sz);
  297. dini_IntSet(str1, "SpawnInt", GetPlayerInterior(playerid));
  298. DestroyPickup(HousePickup[playericonhouse[playerid]]);
  299. HousePickup[playericonhouse[playerid]] = CreatePickup(1272, 23, hInfo[playericonhouse[playerid]][iconx], hInfo[playericonhouse[playerid]][icony], hInfo[playericonhouse[playerid]][iconz]);
  300. return 1;
  301. }
  302.  
  303. dcmd_zakljucaj(playerid,params[])
  304. {
  305. #pragma unused params
  306. new timestamp = GetTickCount();
  307. if(timestamp - inhousepickup[playerid] > 5000)
  308. {
  309. SendClientMessage(playerid, c_r, "You are not in a house icon!");
  310. return 1;
  311. }
  312. new str1[256],pname[24];
  313. GetPlayerName(playerid, pname, 24);
  314. format(str1, sizeof(str1), "Stanovi/stanid%d", playericonhouse[playerid]);
  315. if(strcmp(hInfo[playericonhouse[playerid]][Name],pname,true)==0)
  316. {
  317. SendClientMessage(playerid, c_y, "Zakljucao si stan!");
  318. dini_IntSet(str1,"Locked",1);
  319. hInfo[playericonhouse[playerid]][Locked] = 1;
  320. }
  321. else if(strcmp(hInfo[playericonhouse[playerid]][Renter],pname,true)==0)
  322. {
  323. SendClientMessage(playerid, c_y, "Mozes zakljucati i imati samo jedan stan!");
  324. dini_IntSet(str1,"Locked",1);
  325. hInfo[playericonhouse[playerid]][Locked] = 1;
  326. }
  327. else
  328. {
  329. SendClientMessage(playerid, c_r, "This house isn't yours!");
  330. }
  331. return 1;
  332. }
  333.  
  334. dcmd_otkljucaj(playerid,params[])
  335. {
  336. #pragma unused params
  337. new timestamp = GetTickCount();
  338. if(timestamp - inhousepickup[playerid] > 5000)
  339. {
  340. SendClientMessage(playerid, c_r, "You are not in a house icon!");
  341. return 1;
  342. }
  343. new str1[256],pname[24];
  344. GetPlayerName(playerid, pname, 24);
  345. format(str1, sizeof(str1), "Stanovi/stanid%d", playericonhouse[playerid]);
  346. if(strcmp(hInfo[playericonhouse[playerid]][Name],pname,true)==0)
  347. {
  348. SendClientMessage(playerid, c_y, "You have unlocked your house!");
  349. dini_IntSet(str1,"Locked",0);
  350. hInfo[playericonhouse[playerid]][Locked] = 0;
  351. }
  352. else if(strcmp(hInfo[playericonhouse[playerid]][Renter],pname,true)==0)
  353. {
  354. SendClientMessage(playerid, c_y, "You have unlocked your house!");
  355. dini_IntSet(str1,"Locked",0);
  356. hInfo[playericonhouse[playerid]][Locked] = 0;
  357. }
  358. else
  359. {
  360. SendClientMessage(playerid, c_r, "This house isn't yours!");
  361. }
  362. return 1;
  363. }
  364.  
  365. dcmd_ulaz(playerid,params[])
  366. {
  367. #pragma unused params
  368. new timestamp = GetTickCount();
  369. if(timestamp - inhousepickup[playerid] > 5000)
  370. {
  371. SendClientMessage(playerid, c_r, "Nisi na ikoni od stana!");
  372. return 1;
  373. }
  374. new str1[255],pname[24];
  375. GetPlayerPos(playerid, stanx, stany, stanz);
  376. format(str1, sizeof(str1), "Stanovi/stanid%d", playericonhouse[playerid]);
  377. GetPlayerName(playerid, pname, 24);
  378. if(hInfo[playericonhouse[playerid]][Locked]==1) return SendClientMessage(playerid, c_r, "Ovaj stan je zakljucan!");
  379. playerworld[playerid] = GetPlayerVirtualWorld(playerid);
  380. SendClientMessage(playerid, c_y, "Usao si u stan!");
  381. SetPlayerVirtualWorld(playerid, hInfo[playericonhouse[playerid]][Virtualworld]);
  382. SetPlayerInterior(playerid, hInfo[playericonhouse[playerid]][Interior]);
  383. SetPlayerPos(playerid, hInfo[playericonhouse[playerid]][InteriorX], hInfo[playericonhouse[playerid]][InteriorY], hInfo[playericonhouse[playerid]][InteriorZ]);
  384. playerinterior[playerid] = hInfo[playericonhouse[playerid]][Interior];
  385. return 1;
  386. }
  387.  
  388. dcmd_izlaz(playerid,params[])
  389. {
  390. #pragma unused params
  391.  
  392. if(GetPlayerInterior(playerid)==playerinterior[playerid])
  393. {
  394. SetPlayerPos(playerid, stanx, stany, stanz);
  395. SetPlayerInterior(playerid, playerworld[playerid]);
  396. }
  397. else
  398. {
  399. SendClientMessage(playerid, c_r, "Nisi usao u stan!");
  400. }
  401. return 1;
  402. }
  403.  
  404. dcmd_home(playerid,params[])
  405. {
  406. #pragma unused params
  407. new str1[256],pname[24];
  408. GetPlayerName(playerid, pname, 24);
  409. format(str1, sizeof(str1), "Stanovi/Users/%s", udb_encode(pname));
  410. if(!dini_Exists(str1)) return SendClientMessage(playerid, c_r, "You don't own a house!");
  411. if(dini_Int(str1, "stanid")!=-255)
  412. {
  413. housemapicon[playerid] = SetPlayerMapIcon(playerid,31,hInfo[dini_Int(str1, "stanid")][iconx], hInfo[dini_Int(str1, "stanid")][icony], hInfo[dini_Int(str1, "stanid")][iconz],31,c_y);
  414. }
  415. else if (dini_Int(str1, "Rentid")!=-255)
  416. {
  417. housemapicon[playerid] = SetPlayerMapIcon(playerid,31,hInfo[dini_Int(str1, "Rentid")][iconx], hInfo[dini_Int(str1, "Rentid")][icony], hInfo[dini_Int(str1, "Rentid")][iconz],31,c_y);
  418. }
  419. else
  420. {
  421. SendClientMessage(playerid, c_r, "You don't own a house!");
  422. }
  423. return 1;
  424. }
  425.  
  426.  
  427. dcmd_stan(playerid,params[])
  428. {
  429. #pragma unused params
  430. SendClientMessage(playerid, c_y, "-------------");
  431. SendClientMessage(playerid, c_y, "STAN");
  432. SendClientMessage(playerid, c_y, "-------------");
  433. SendClientMessage(playerid, c_y, "/zakljucaj - Renter/Owner");
  434. SendClientMessage(playerid, c_y, "/otkljucaj - Renter/Owner");
  435. SendClientMessage(playerid, c_y, "-------------");
  436. return 1;
  437. }
  438.  
  439. dcmd_stanstats(playerid,params[])
  440. {
  441. #pragma unused params
  442. new timestamp = GetTickCount();
  443. if(timestamp - inhousepickup[playerid] > 5000)
  444. {
  445. SendClientMessage(playerid, c_r, "You are not in a house icon!");
  446. return 1;
  447. }
  448. new str[256];
  449. format(str, sizeof(str), "Owner: %s", hInfo[playericonhouse[playerid]][Name]);
  450. SendClientMessage(playerid, c_y, str);
  451. format(str, sizeof(str), "Cost: $%d", hInfo[playericonhouse[playerid]][Cost]);
  452. SendClientMessage(playerid, c_y, str);
  453. format(str, sizeof(str), "Renter: %s", hInfo[playericonhouse[playerid]][Renter]);
  454. SendClientMessage(playerid, c_y, str);
  455. format(str, sizeof(str), "Rentcost: $%d / hour", hInfo[playericonhouse[playerid]][Rentcost]);
  456. SendClientMessage(playerid, c_y, str);
  457. return 1;
  458. }
  459.  
  460. dcmd_getrent(playerid,params[])
  461. {
  462. #pragma unused params
  463. new timestamp = GetTickCount();
  464. if(timestamp - inhousepickup[playerid] > 5000)
  465. {
  466. SendClientMessage(playerid, c_r, "You are not in a house icon!");
  467. return 1;
  468. }
  469. new pname[24];
  470. GetPlayerName(playerid, pname, 24);
  471. if(strcmp(hInfo[playericonhouse[playerid]][Name],pname,true)==0)
  472. {
  473. new str[255];
  474. SendClientMessage(playerid, c_y, "You collected the money of the renter!");
  475. format(str, sizeof(str), "Stanovi/stanid%d", playericonhouse[playerid]);
  476. GivePlayerMoney(playerid, dini_Int(str, "RentGet"));
  477. dini_IntSet(str, "RentGet", 0);
  478. }
  479. else
  480. {
  481. SendClientMessage(playerid, c_r, "This house isn't yours!");
  482. }
  483. return 1;
  484. }
  485.  
  486. dcmd_payrent(playerid,params[])
  487. {
  488. #pragma unused params
  489. new timestamp = GetTickCount();
  490. if(timestamp - inhousepickup[playerid] > 5000)
  491. {
  492. SendClientMessage(playerid, c_r, "You are not in a house icon!");
  493. return 1;
  494. }
  495. new pname[24];
  496. GetPlayerName(playerid, pname, 24);
  497. if(strcmp(hInfo[playericonhouse[playerid]][Renter],pname,true)==0)
  498. {
  499. new str[255];
  500. format(str, sizeof(str), "Stanovi/stanid%d", playericonhouse[playerid]);
  501. if(GetPlayerMoney(playerid)<dini_Int(str, "RentPay")) return SendClientMessage(playerid, c_r, "You don't have enough money to pay the house owner!");
  502. SendClientMessage(playerid, c_y, "You have payed the money to the owner!");
  503. GivePlayerMoney(playerid, -dini_Int(str, "RentPay"));
  504. dini_IntSet(str, "RentPay", 0);
  505. }
  506. else
  507. {
  508. SendClientMessage(playerid, c_r, "You aren't renting this house!");
  509. }
  510. return 1;
  511. }
  512.  
  513.  
  514.  
  515. public rentfee()
  516. {
  517. new str[255],str2[255],pname[24];
  518. for(new stanid=0;stanid<MAX_STANOVA;stanid++)
  519. {
  520. print("f");
  521. format(str, sizeof(str), "Stanovi/stanid%d", stanid);
  522. if(strcmp(hInfo[stanid][Renter], "ForRent", true))
  523. {
  524. for(new ii=0;ii<MAX_PLAYERS;ii++)
  525. {
  526. if(IsPlayerConnected(ii))
  527. {
  528. GetPlayerName(ii, pname, 24);
  529. if(strcmp(hInfo[stanid][Renter], pname, true)==0)
  530. {
  531. format(str2, sizeof(str2), "Rentao si ovaj stan!", hInfo[stanid][Rentcost]);
  532. SendClientMessage(ii, c_y, str2);
  533. dini_IntSet(str, "RentGet", dini_Int(str, "RentGet")+hInfo[stanid][Rentcost]);
  534. dini_IntSet(str, "RentPay", dini_Int(str, "RentPay")+hInfo[stanid][Rentcost]);
  535. hInfo[stanid][Rentfee]=1;
  536. }
  537. }
  538. }
  539. if(hInfo[stanid][Rentfee]==0)
  540. {
  541. if(strcmp(hInfo[stanid][Renter],"ForRent"))
  542. {
  543. dini_IntSet(str, "RentGet", dini_Int(str, "RentGet")+hInfo[stanid][Rentcost]);
  544. dini_IntSet(str, "RentPay", dini_Int(str, "RentPay")+hInfo[stanid][Rentcost]);
  545. }
  546. }
  547. hInfo[stanid][Rentfee]=0;
  548. }
  549. }
  550. }
  551.  
  552. public OnPlayerPickUpPickup(playerid, pickupid)
  553. {
  554. GetStanoviStats(playerid, pickupid);
  555. return 0;
  556. }
  557.  
  558. stock sscanf(string[], format[], {Float,_}:...)
  559. {
  560. new
  561. formatPos = 0,
  562. stringPos = 0,
  563. paramPos = 2,
  564. paramCount = numargs();
  565. while (paramPos < paramCount && string[stringPos])
  566. {
  567. switch (format[formatPos++])
  568. {
  569. case '\0':
  570. {
  571. return 0;
  572. }
  573. case 'i', 'd':
  574. {
  575. new
  576. neg = 1,
  577. num = 0,
  578. ch = string[stringPos];
  579. if (ch == '-')
  580. {
  581. neg = -1;
  582. ch = string[++stringPos];
  583. }
  584. do
  585. {
  586. stringPos++;
  587. if (ch >= '0' && ch <= '9')
  588. {
  589. num = (num * 10) + (ch - '0');
  590. }
  591. else
  592. {
  593. return 1;
  594. }
  595. }
  596. while ((ch = string[stringPos]) && ch != ' ');
  597. setarg(paramPos, 0, num * neg);
  598. }
  599. case 'h', 'x':
  600. {
  601. new
  602. ch,
  603. num = 0;
  604. while ((ch = string[stringPos++]))
  605. {
  606. switch (ch)
  607. {
  608. case 'x', 'X':
  609. {
  610. num = 0;
  611. continue;
  612. }
  613. case '0' .. '9':
  614. {
  615. num = (num << 4) | (ch - '0');
  616. }
  617. case 'a' .. 'f':
  618. {
  619. num = (num << 4) | (ch - ('a' - 10));
  620. }
  621. case 'A' .. 'F':
  622. {
  623. num = (num << 4) | (ch - ('A' - 10));
  624. }
  625. case ' ':
  626. {
  627. break;
  628. }
  629. default:
  630. {
  631. return 1;
  632. }
  633. }
  634. }
  635. setarg(paramPos, 0, num);
  636. }
  637. case 'c':
  638. {
  639. setarg(paramPos, 0, string[stringPos++]);
  640. }
  641. case 'f':
  642. {
  643. new tmp[25];
  644. strmid(tmp, string, stringPos, stringPos+sizeof(tmp)-2);
  645. setarg(paramPos, 0, _:floatstr(tmp));
  646. }
  647. case 's', 'z':
  648. {
  649. new
  650. i = 0,
  651. ch;
  652. if (format[formatPos])
  653. {
  654. while ((ch = string[stringPos++]) && ch != ' ')
  655. {
  656. setarg(paramPos, i++, ch);
  657. }
  658. if (!i) return 1;
  659. }
  660. else
  661. {
  662. while ((ch = string[stringPos++]))
  663. {
  664. setarg(paramPos, i++, ch);
  665. }
  666. }
  667. stringPos--;
  668. setarg(paramPos, i, '\0');
  669. }
  670. default:
  671. {
  672. continue;
  673. }
  674. }
  675. while (string[stringPos] && string[stringPos] != ' ')
  676. {
  677. stringPos++;
  678. }
  679. while (string[stringPos] == ' ')
  680. {
  681. stringPos++;
  682. }
  683. paramPos++;
  684. }
  685. while (format[formatPos] == 'z') formatPos++;
  686. return format[formatPos];
  687. }
  688.  
  689.  
Advertisement
Add Comment
Please, Sign In to add comment