y_properties_entry.inc 78 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370
  1. #if defined _INC_y_properties
  2. #endinput
  3. #endif
  4. #define _INC_y_properties
  5. /*
  6. Legal:
  7. Version: MPL 1.1
  8. The contents of this file are subject to the Mozilla Public License Version
  9. 1.1 the "License"; you may not use this file except in compliance with
  10. the License. You may obtain a copy of the License at
  11. http://www.mozilla.org/MPL/
  12. Software distributed under the License is distributed on an "AS IS" basis,
  13. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  14. for the specific language governing rights and limitations under the
  15. License.
  16. The Original Code is the YSI framework.
  17. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  18. Portions created by the Initial Developer are Copyright C 2011
  19. the Initial Developer. All Rights Reserved.
  20. Contributors:
  21. Y_Less
  22. koolk
  23. JoeBullet/Google63
  24. g_aSlice/Slice
  25. Misiur
  26. samphunter
  27. tianmeta
  28. maddinat0r
  29. spacemud
  30. Crayder
  31. Dayvison
  32. Ahmad45123
  33. Zeex
  34. irinel1996
  35. Yiin-
  36. Chaprnks
  37. Konstantinos
  38. Masterchen09
  39. Southclaws
  40. PatchwerkQWER
  41. m0k1
  42. paulommu
  43. udan111
  44. Thanks:
  45. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  46. ZeeX - Very productive conversations.
  47. koolk - IsPlayerinAreaEx code.
  48. TheAlpha - Danish translation.
  49. breadfish - German translation.
  50. Fireburn - Dutch translation.
  51. yom - French translation.
  52. 50p - Polish translation.
  53. Zamaroht - Spanish translation.
  54. Los - Portuguese translation.
  55. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes for
  56. me to strive to better.
  57. Pixels^ - Running XScripters where the idea was born.
  58. Matite - Pestering me to release it and using it.
  59. Very special thanks to:
  60. Thiadmer - PAWN, whose limits continue to amaze me!
  61. Kye/Kalcor - SA:MP.
  62. SA:MP Team past, present and future - SA:MP.
  63. Optional plugins:
  64. Gamer_Z - GPS.
  65. Incognito - Streamer.
  66. Me - sscanf2, fixes2, Whirlpool.
  67. */
  68. #include "..\..\YSI_Core\y_utils"
  69. #if defined MAX_PROP_NAME
  70. #if MAX_PROP_NAME < (39 - PLAYER_BIT_ARRAY)
  71. #undef MAX_PROP_NAME
  72. #endif
  73. #endif
  74. #if !defined MAX_PROP_NAME
  75. #define MAX_PROP_NAME (39 - PLAYER_BIT_ARRAY)
  76. #endif
  77. #if !defined MAX_PROPERTIES
  78. #define MAX_PROPERTIES 256
  79. #endif
  80. #if !defined MAX_CHECKPOINTS
  81. #define MAX_CHECKPOINTS MAX_PROPERTIES
  82. #endif
  83. #if !defined GROUP_PROPERTY_BITS
  84. #if MAX_PROPERTIES <= 32
  85. #define GROUP_PROPERTY_BITS 2
  86. #else
  87. #define GROUP_PROPERTY_BITS Bit_Bits(MAX_PROPERTIES)
  88. #endif
  89. #endif
  90. #if !defined PLAYER_BIT_ARRAY
  91. #define PLAYER_BIT_ARRAY Bit_Bits(MAX_PLAYERS)
  92. #endif
  93. #define NO_PROPERTY -1
  94. #define NO_CHECKPOINT -1
  95. #if !defined WEAPON_ARMOUR
  96. #define WEAPON_ARMOUR 100
  97. #endif
  98. #define PROPERTY_SELL_PERCENT 60
  99. #define PROPERTY_INCREASE_PERCENT 125
  100. #define WEAPON_DATA_OFFSET (PLAYER_BIT_ARRAY - 2)
  101. #define WEAPON_DATA (((getarg(pos++) & 0xFFF) << 20) | (getarg(pos++) & 0xFFFFF))
  102. #define WEAPON_DATA_REM (((dat[pos++] & 0xFFF) << 20) | (dat[pos++] & 0xFFFFF))
  103. #define WEAPON(%1) ((%1) << 24)
  104. #define Property_OnPlayerLeaveCheckpointEx Property_OnPlayerLeaveCP
  105. #define Property_OnPlayerEnterCheckpointEx Property_OnPlayerEnterCP
  106. enum e_PROP_FLAGS:(+= 0x10000)
  107. {
  108. e_PROP_FLAGS_LINK = 0x0000FFFF,
  109. e_PROP_FLAGS_TYPES = 0x00FF0000,
  110. e_PROP_FLAGS_TYPE_PROP = 0x00010000,
  111. e_PROP_FLAGS_TYPE_BANK,
  112. e_PROP_FLAGS_TYPE_AMMU,
  113. e_PROP_FLAGS_TYPE_TELS,
  114. e_PROP_FLAGS_TYPE_TELT,
  115. e_PROP_FLAGS_TYPE_MONP,
  116. e_PROP_FLAGS_TYPE_HOUS,
  117. e_PROP_FLAGS_TYPE_MONA = 0x00100000,
  118. e_PROP_FLAGS_TYPE_RSRC,
  119. e_PROP_FLAGS_FLAGS = 0xFF000000,
  120. e_PROP_FLAGS_CUST_1 = 0x01000000,
  121. e_PROP_FLAGS_CUST_2 = 0x02000000,
  122. e_PROP_FLAGS_CUST_3 = 0x04000000,
  123. e_PROP_FLAGS_CUST_4 = 0x08000000,
  124. e_PROP_FLAGS_CUST_5 = 0x10000000,
  125. e_PROP_FLAGS_ACTIVE = 0x80000000
  126. }
  127. enum E_PROP_DATA
  128. {
  129. E_PROP_DATA_NAME[MAX_PROP_NAME],
  130. e_PROP_FLAGS:E_PROP_DATA_FLAGS,
  131. E_PROP_DATA_DATA_1,
  132. E_PROP_DATA_DATA_2,
  133. Bit:E_PROP_DATA_PLAYERS[PLAYER_BIT_ARRAY]
  134. }
  135. enum E_PROP_AMMU
  136. {
  137. Menu:E_PROP_AMMU_MENU,
  138. E_PROP_AMMU_DATA
  139. }
  140. static
  141. YSI_g_sProperties[MAX_PROPERTIES][E_PROP_DATA],
  142. YSI_g_sMoney[MAX_PLAYERS],
  143. YSI_g_sPropCount[MAX_PLAYERS],
  144. YSI_g_sHouseCount[MAX_PLAYERS],
  145. BitArray:YSI_g_sPlayerProperties[MAX_PLAYERS]<MAX_PROPERTIES>,
  146. YSI_g_sSpawnWeapons[MAX_PLAYERS][13],
  147. YSI_g_sShopMenu[MAX_PLAYERS][E_PROP_AMMU],
  148. YSI_g_sRebuyDelay,
  149. #if defined _YSI_VISUAL_PICKUPS
  150. YSI_g_sPickupPointers[MAX_DYN_PICKUPS],
  151. YSI_g_sPickupProps,
  152. YSI_g_sPickupTimer[MAX_PLAYERS] = {-1, ...},
  153. YSI_g_sPlayerPickup[MAX_PLAYERS] = {NO_PICKUP, ...},
  154. #endif
  155. YSI_g_sAreaPointers[MAX_AREAS],
  156. YSI_g_sCheckpointPointers[MAX_CHECKPOINTS],
  157. YSI_g_sMaxPlayerHouses = cellmax,
  158. YSI_g_sMaxPlayerProps = cellmax,
  159. YSI_g_sCurrentHouse[MAX_PLAYERS] = {-1, ...};
  160. loadtext core[ysi_properties];
  161. /*-------------------------------------------------------------------------*//**
  162. * <param name="prop">Property to check.</param>
  163. *//*------------------------------------------------------------------------**/
  164. P:D(bool:Property_IsActive(prop));
  165. #define Property_IsActive(%1) \
  166. ((%1) < MAX_PROPERTIES && (%1) >= 0 && YSI_g_sProperties[(%1)][E_PROP_DATA_FLAGS] & e_PROP_FLAGS_ACTIVE)
  167. /*-------------------------------------------------------------------------*//**
  168. * <remarks>
  169. * Allows people to own as many properties as they like at once.
  170. * </remarks>
  171. *//*------------------------------------------------------------------------**/
  172. P:D(Property_ResetMaxProperties());
  173. #define Property_ResetMaxProperties() \
  174. Property_SetMaxProperties(cellmax)
  175. /*-------------------------------------------------------------------------*//**
  176. * <param name="slot">Custom flag to set.</param>
  177. * <param name="value">Value to set it to.</param>
  178. * <remarks>
  179. * Can't be changed except from 0 to 1.
  180. * </remarks>
  181. *//*------------------------------------------------------------------------**/
  182. P:D(Property_SetOption(slot,value));
  183. #define Property_SetOption(%1,%2) \
  184. ((%2) ? e_PROP_FLAGS_CUST_%1 : e_PROP_FLAGS:0)
  185. /*-------------------------------------------------------------------------*//**
  186. * <param name="slot">Custom flag to get.</param>
  187. * <param name="flags">flags cell to get it from.</param>
  188. *//*------------------------------------------------------------------------**/
  189. P:D(Property_GetOption(slot,e_PROP_FLAGS:flags));
  190. #define Property_GetOption(%1,%2) \
  191. (e_PROP_FLAGS_CUST_%1 & e_PROP_FLAGS:(%2))
  192. /*-------------------------------------------------------------------------*//**
  193. * <param name="playerid">Player to gice a weapon to.</param>
  194. * <param name="slot">Weapon slot to give.</param>
  195. * <param name="ammo">Ammo to give.</param>
  196. * <remarks>
  197. * Gives a player a weapon by slot instead of weaponid or assignes armour.
  198. * </remarks>
  199. *//*------------------------------------------------------------------------**/
  200. P:D(Property_GivePlayerWeapon(playerid,slot,ammo));
  201. #define Property_GivePlayerWeapon(%1,%2,%3) \
  202. if ((%2) == 39) SetPlayerArmour((%1), 100.0); else GivePlayerWeapon(%1, Property_GetWeaponFromSlot(%2), %3)
  203. /*-------------------------------------------------------------------------*//**
  204. * <param name="delay">Time till a property can be bought again.</param>
  205. *//*------------------------------------------------------------------------**/
  206. stock Property_SetRebuyDelay(delay)
  207. {
  208. YSI_g_sRebuyDelay = delay;
  209. }
  210. /*-------------------------------------------------------------------------*//**
  211. * <param name="property">Property to check.</param>
  212. * <returns>
  213. * Is the property a valid active property.
  214. * </returns>
  215. *//*------------------------------------------------------------------------**/
  216. stock Property_IsValid(property)
  217. {
  218. return Property_IsActive(property);
  219. }
  220. /*-------------------------------------------------------------------------*//**
  221. * <param name="playerid">Player to check.</param>
  222. * <param name="prop">Property to check.</param>
  223. * <param name="flags">Property flags for ownership type.</param>
  224. *//*------------------------------------------------------------------------**/
  225. P:D(bool:Property_IsOwner(playerid,prop,e_PROP_FLAGS:flags));
  226. #define Property_IsOwner(%1,%2,%3) \
  227. ((Property_GetOption(2, (%3))) ? (!Bit_GetBit(YSI_g_sProperties[(%2)][E_PROP_DATA_PLAYERS], (%1))) : (!(_:YSI_g_sProperties[(%2)][E_PROP_DATA_PLAYERS][0] == (%1))))
  228. /*-------------------------------------------------------------------------*//**
  229. * <param name="count">Number of ownable properties.</param>
  230. * <remarks>
  231. * Sets the number of properties a player can own at once.
  232. * </remarks>
  233. *//*------------------------------------------------------------------------**/
  234. stock Property_SetMaxProperties(count)
  235. {
  236. YSI_g_sMaxPlayerProps = count;
  237. }
  238. /*-------------------------------------------------------------------------*//**
  239. * <param name="count">Number of ownable houses.</param>
  240. * <remarks>
  241. * Sets the number of houses a player can own at once.
  242. * </remarks>
  243. *//*------------------------------------------------------------------------**/
  244. stock Property_SetMaxHouses(count)
  245. {
  246. YSI_g_sMaxPlayerHouses = count;
  247. }
  248. /*-------------------------------------------------------------------------*//**
  249. * <param name="property">Property to get the type of.</param>
  250. * <returns>
  251. * 0 if invalid or type.
  252. * </returns>
  253. *//*------------------------------------------------------------------------**/
  254. stock Property_GetType(property)
  255. {
  256. if (!Property_IsActive(property)) return 0;
  257. return _:(YSI_g_sProperties[property][E_PROP_DATA_FLAGS] & e_PROP_FLAGS_TYPES);
  258. }
  259. /*-------------------------------------------------------------------------*//**
  260. * <remarks>
  261. * Sets variable initial states.
  262. * </remarks>
  263. *//*------------------------------------------------------------------------**/
  264. HOOK__ OnScriptInit()
  265. {
  266. P:2("Property_Property() start");
  267. P:5("Property_Property() 0");
  268. //Timer_Add("Property_Loop", PROPERTY_LOOP_GRANULARITY);
  269. P:5("Property_Property() 1");
  270. #if defined _YSI_CORE_COMMANDS
  271. ycmd("buy");
  272. ycmd("bank");
  273. ycmd("properties");
  274. ycmd("balance");
  275. ycmd("withdraw");
  276. ycmd("sell");
  277. ycmd("enter");
  278. ycmd("exit");
  279. #endif
  280. P:5("Property_Property() 2");
  281. for (new i = 0; i < MAX_AREAS; i++) YSI_g_sAreaPointers[i] = NO_PROPERTY;
  282. P:5("Property_Property() 3");
  283. for (new i = 0; i < MAX_CHECKPOINTS; i++) YSI_g_sCheckpointPointers[i] = NO_PROPERTY;
  284. #if defined _YSI_VISUAL_PICKUPS
  285. P:4("Property_Property() 4 " #MAX_DYN_PICKUPS);
  286. for (new i = 0; i < MAX_DYN_PICKUPS; i++) YSI_g_sPickupPointers[i] = NO_PROPERTY;
  287. #endif
  288. P:2("Property_Property() end");
  289. return 1;
  290. }
  291. /*-------------------------------------------------------------------------*//**
  292. * <param name="property">Property to destroy.</param>
  293. *//*------------------------------------------------------------------------**/
  294. stock DestroyProperty(property)
  295. {
  296. if (!Property_IsActive(property)) return 0;
  297. new
  298. e_PROP_FLAGS:flags = YSI_g_sProperties[property][E_PROP_DATA_FLAGS];
  299. YSI_g_sProperties[property][E_PROP_DATA_FLAGS] = e_PROP_FLAGS:0;
  300. if (flags & e_PROP_FLAGS_TYPES >= e_PROP_FLAGS_TYPE_MONA)
  301. {
  302. YSI_g_sAreaPointers[_:(flags & e_PROP_FLAGS_LINK)] = NO_PROPERTY;
  303. Area_Delete(_:(flags & e_PROP_FLAGS_LINK));
  304. }
  305. else
  306. {
  307. #if defined _YSI_VISUAL_PICKUPS
  308. if ((flags & e_PROP_FLAGS_TYPES > e_PROP_FLAGS_TYPE_PROP) && Property_GetOption(5, flags))
  309. {
  310. Pickup_Remove(_:(flags & e_PROP_FLAGS_LINK));
  311. YSI_g_sPickupPointers[_:(flags & e_PROP_FLAGS_LINK)] = NO_PROPERTY;
  312. }
  313. else
  314. #endif
  315. {
  316. YSI_g_sCheckpointPointers[_:(flags & e_PROP_FLAGS_LINK)] = NO_PROPERTY;
  317. DestroyCheckpoint(_:(flags & e_PROP_FLAGS_LINK));
  318. }
  319. }
  320. for (new i = 0; i < MAX_PLAYERS; i++) Bit_Set(YSI_g_sPlayerProperties[i], property, 0, GROUP_PROPERTY_BITS);
  321. return 1;
  322. }
  323. /*-------------------------------------------------------------------------*//**
  324. * <param name="extX">X position of the external marker.</param>
  325. * <param name="extY">Y position of the external marker.</param>
  326. * <param name="extZ">Z position of the external marker.</param>
  327. * <param name="intX">X position of the internal marker.</param>
  328. * <param name="intY">Y position of the internal marker.</param>
  329. * <param name="intZ">Z position of the internal marker.</param>
  330. * <param name="interior">Interior ID of the house.</param>
  331. * <param name="world">Virtual world of the house.</param>
  332. * <param name="price">Price of the house.</param>
  333. * <param name="checkpoint">Use a checkpoint instead of a pickup.</param>
  334. * <remarks>
  335. * Creates a buyable property (business).
  336. * </remarks>
  337. *//*------------------------------------------------------------------------**/
  338. stock CreateHouse(Float:extX, Float:extY, Float:extZ, Float:intX, Float:intY, Float:intZ, interior, world, price, checkpoint = 0)
  339. {
  340. P:2("CreateHouse() start 1");
  341. P:2("CreateHouse() start 2");
  342. new
  343. i;
  344. while (i < MAX_PROPERTIES && Property_IsActive(i))
  345. {
  346. i++;
  347. }
  348. if (i == MAX_PROPERTIES) return NO_PROPERTY;
  349. new
  350. cp;
  351. P:4("CreateHouse() Make");
  352. #if defined _YSI_VISUAL_PICKUPS
  353. if (!checkpoint)
  354. {
  355. if ((cp = Pickup_Add(1273, extX, extY, extZ, 0, -1)) == NO_PICKUP) return NO_PROPERTY;
  356. YSI_g_sPickupProps++;
  357. }
  358. else
  359. #else
  360. checkpoint = 1;
  361. #endif
  362. #pragma tabsize 4
  363. if ((cp = CreateCheckpoint(extX, extY, extZ, 3.0)) == NO_CHECKPOINT) return NO_PROPERTY;
  364. #pragma tabsize 4
  365. P:4("CreateHouse() Made");
  366. YSI_g_sProperties[i][E_PROP_DATA_FLAGS] = e_PROP_FLAGS_TYPE_HOUS | e_PROP_FLAGS_ACTIVE | e_PROP_FLAGS:cp | Property_SetOption(1, checkpoint);
  367. YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][0] = Bit:INVALID_PLAYER_ID;
  368. YSI_g_sProperties[i][E_PROP_DATA_DATA_1] = interior;
  369. YSI_g_sProperties[i][E_PROP_DATA_DATA_2] = world;
  370. P:4("CreateHouse() Save pos");
  371. YSI_g_sProperties[i][E_PROP_DATA_NAME][0] = _:extX;
  372. YSI_g_sProperties[i][E_PROP_DATA_NAME][1] = _:extY;
  373. YSI_g_sProperties[i][E_PROP_DATA_NAME][2] = _:extZ;
  374. YSI_g_sProperties[i][E_PROP_DATA_NAME][3] = _:intX;
  375. YSI_g_sProperties[i][E_PROP_DATA_NAME][4] = _:intY;
  376. YSI_g_sProperties[i][E_PROP_DATA_NAME][5] = _:intZ;
  377. YSI_g_sProperties[i][E_PROP_DATA_NAME][6] = price;
  378. P:4("CreateHouse() Save ID");
  379. #if defined _YSI_VISUAL_PICKUPS
  380. if (!checkpoint)
  381. {
  382. YSI_g_sPickupPointers[cp] = i;
  383. }
  384. else
  385. #endif
  386. #pragma tabsize 4
  387. YSI_g_sCheckpointPointers[cp] = i;
  388. #pragma tabsize 4
  389. return i;
  390. }
  391. /*-------------------------------------------------------------------------*//**
  392. * <param name="name">Name of the property.</param>
  393. * <param name="x">X position.</param>
  394. * <param name="y">Y position.</param>
  395. * <param name="z">Z position.</param>
  396. * <param name="price">Cost of the property.</param>
  397. * <param name="reward">Money earnt from the property periodically.</param>
  398. * <param name="interval">How often you earn money.</param>
  399. * <param name="sell">Wether you need to seel the property of people can just buy you out.</param>
  400. * <param name="multi">Wether more than one person can own this property at once.</param>
  401. * <param name="reduce">Wether selling this property gets you less then you paid for it.</param>
  402. * <param name="increase">Wether buying this property will put the price up for the future.</param>
  403. * <param name="property">Wether this property uses a pickup instead of a checkpoint.</param>
  404. * <remarks>
  405. * Creates a buyable property (business).
  406. * </remarks>
  407. *//*------------------------------------------------------------------------**/
  408. stock CreateProperty(name[], Float:x, Float:y, Float:z, price, reward, interval = 60000, sell = 0, multi = 0, reduce = 0, increase = 0, pickup = 0)
  409. {
  410. new
  411. i;
  412. while (i < MAX_PROPERTIES && Property_IsActive(i))
  413. {
  414. i++;
  415. }
  416. if (i == MAX_PROPERTIES) return NO_PROPERTY;
  417. new
  418. cp;
  419. #if defined _YSI_VISUAL_PICKUPS
  420. if (pickup)
  421. {
  422. if ((cp = Pickup_Add(1273, x, y, z, 0, -1)) == NO_PICKUP) return NO_PROPERTY;
  423. YSI_g_sPickupProps++;
  424. }
  425. else
  426. #endif
  427. #pragma tabsize 4
  428. if ((cp = CreateCheckpoint(x, y, z, 3.0)) == NO_CHECKPOINT) return NO_PROPERTY;
  429. #pragma tabsize 4
  430. YSI_g_sProperties[i][E_PROP_DATA_FLAGS] = e_PROP_FLAGS_TYPE_PROP | e_PROP_FLAGS_ACTIVE | e_PROP_FLAGS:cp | Property_SetOption(1, sell) | Property_SetOption(2, multi) | Property_SetOption(3, reduce) | Property_SetOption(4, increase) | Property_SetOption(5, pickup);
  431. if (multi) Bit_SetAll(YSI_g_sProperties[i][E_PROP_DATA_PLAYERS], 0, PLAYER_BIT_ARRAY);
  432. else YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][0] = Bit:INVALID_PLAYER_ID;
  433. YSI_g_sProperties[i][E_PROP_DATA_NAME][MAX_PROP_NAME - 1] = interval & 0xFFFFF;
  434. YSI_g_sProperties[i][E_PROP_DATA_DATA_1] = (interval & 0xFFFFF) | ((price & 0x00000FFF) << 20);
  435. YSI_g_sProperties[i][E_PROP_DATA_DATA_2] = (reward & 0x3FFFF) | ((price & 0x03FFF000) << 6);
  436. if (!isnull(name)) strcpy(YSI_g_sProperties[i][E_PROP_DATA_NAME], name, MAX_PROP_NAME - 1);
  437. else YSI_g_sProperties[i][E_PROP_DATA_NAME][0] = '\0';
  438. #if defined _YSI_VISUAL_PICKUPS
  439. if (pickup)
  440. {
  441. YSI_g_sPickupPointers[cp] = i;
  442. }
  443. else
  444. #endif
  445. #pragma tabsize 4
  446. YSI_g_sCheckpointPointers[cp] = i;
  447. #pragma tabsize 4
  448. return i;
  449. }
  450. /*-------------------------------------------------------------------------*//**
  451. * <param name="x">X position.</param>
  452. * <param name="y">Y position.</param>
  453. * <param name="z">Z position.</param>
  454. * <param name="name">Name of the bank.</param>
  455. *//*------------------------------------------------------------------------**/
  456. stock CreateBank(Float:x, Float:y, Float:z, name[] = "")
  457. {
  458. new
  459. i;
  460. while (i < MAX_PROPERTIES)
  461. {
  462. if (!Property_IsActive(i)) break;
  463. i++;
  464. }
  465. if (i == MAX_PROPERTIES) return NO_PROPERTY;
  466. new
  467. cp = CreateCheckpoint(x, y, z, 3.0);
  468. if (cp == NO_CHECKPOINT) return NO_PROPERTY;
  469. YSI_g_sProperties[i][E_PROP_DATA_FLAGS] = e_PROP_FLAGS_TYPE_BANK | e_PROP_FLAGS_ACTIVE | e_PROP_FLAGS:cp;
  470. if (!isnull(name)) strcpy(YSI_g_sProperties[i][E_PROP_DATA_NAME], name, MAX_PROP_NAME);
  471. else YSI_g_sProperties[i][E_PROP_DATA_NAME][0] = '\0';
  472. YSI_g_sCheckpointPointers[cp] = i;
  473. return i;
  474. }
  475. /*-------------------------------------------------------------------------*//**
  476. * <param name="x">X position.</param>
  477. * <param name="y">Y position.</param>
  478. * <param name="z">Z position.</param>
  479. * <param name="spawn">Wether you spawn with the weapon.</param>
  480. * <param name="instant">Wether you get the weapon as soon as you buy it.</param>
  481. * <param name=""></param>
  482. * <remarks>
  483. * spawn and instant can BOTH be 1. The format of the additional parameters
  484. * is:
  485. *
  486. * weapon, ammo, price
  487. *
  488. * They MUST come in sets of three of the function will fail. Weapon is in
  489. * the form of the WEAPON_ defines in a_samp or WEAPON_ARMOUR.
  490. * </remarks>
  491. *//*------------------------------------------------------------------------**/
  492. stock CreateAmmunation(Float:x, Float:y, Float:z, spawn, instant, ...)
  493. {
  494. new
  495. num = numargs();
  496. if (((num) <= 5) || (((num - 5) / 3) * 3 != (num - 5))) return NO_PROPERTY;
  497. new
  498. i;
  499. while (i < MAX_PROPERTIES)
  500. {
  501. if (!Property_IsActive(i)) break;
  502. i++;
  503. }
  504. if (i == MAX_PROPERTIES) return NO_PROPERTY;
  505. new
  506. cp = CreateCheckpoint(x, y, z, 3.0);
  507. if (cp == NO_CHECKPOINT) return NO_PROPERTY;
  508. YSI_g_sProperties[i][E_PROP_DATA_FLAGS] = e_PROP_FLAGS_TYPE_AMMU | e_PROP_FLAGS_ACTIVE | e_PROP_FLAGS:cp | Property_SetOption(1, spawn) | Property_SetOption(2, instant);
  509. new
  510. pos = 5,
  511. count;
  512. while (pos < num)
  513. {
  514. switch (getarg(pos++))
  515. {
  516. case WEAPON_BRASSKNUCKLE:
  517. YSI_g_sProperties[i][E_PROP_DATA_DATA_1] = WEAPON_DATA;
  518. case WEAPON_GOLFCLUB:
  519. YSI_g_sProperties[i][E_PROP_DATA_DATA_2] = WEAPON_DATA;
  520. case WEAPON_NITESTICK:
  521. YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][0] = Bit:WEAPON_DATA;
  522. case WEAPON_KNIFE:
  523. YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][1] = Bit:WEAPON_DATA;
  524. case WEAPON_BAT:
  525. #if PLAYER_BIT_ARRAY > 2
  526. YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][2] = Bit:WEAPON_DATA;
  527. #else
  528. YSI_g_sProperties[i][E_PROP_DATA_NAME][0 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  529. #endif
  530. case WEAPON_SHOVEL:
  531. #if PLAYER_BIT_ARRAY > 3
  532. YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][3] = Bit:WEAPON_DATA;
  533. #else
  534. YSI_g_sProperties[i][E_PROP_DATA_NAME][1 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  535. #endif
  536. case WEAPON_POOLSTICK:
  537. #if PLAYER_BIT_ARRAY > 4
  538. YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][4] = Bit:WEAPON_DATA;
  539. #else
  540. YSI_g_sProperties[i][E_PROP_DATA_NAME][2 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  541. #endif
  542. case WEAPON_KATANA:
  543. #if PLAYER_BIT_ARRAY > 5
  544. YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][5] = Bit:WEAPON_DATA;
  545. #else
  546. YSI_g_sProperties[i][E_PROP_DATA_NAME][3 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  547. #endif
  548. case WEAPON_CHAINSAW:
  549. #if PLAYER_BIT_ARRAY > 6
  550. YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][6] = Bit:WEAPON_DATA;
  551. #else
  552. YSI_g_sProperties[i][E_PROP_DATA_NAME][4 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  553. #endif
  554. case WEAPON_DILDO:
  555. #if PLAYER_BIT_ARRAY > 7
  556. YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][7] = Bit:WEAPON_DATA;
  557. #else
  558. YSI_g_sProperties[i][E_PROP_DATA_NAME][5 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  559. #endif
  560. case WEAPON_DILDO2:
  561. #if PLAYER_BIT_ARRAY > 8
  562. YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][8] = Bit:WEAPON_DATA;
  563. #else
  564. YSI_g_sProperties[i][E_PROP_DATA_NAME][6 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  565. #endif
  566. case WEAPON_VIBRATOR:
  567. #if PLAYER_BIT_ARRAY > 9
  568. YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][9] = Bit:WEAPON_DATA;
  569. #else
  570. YSI_g_sProperties[i][E_PROP_DATA_NAME][7 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  571. #endif
  572. case WEAPON_VIBRATOR2:
  573. #if PLAYER_BIT_ARRAY > 10
  574. YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][10] = Bit:WEAPON_DATA;
  575. #else
  576. YSI_g_sProperties[i][E_PROP_DATA_NAME][8 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  577. #endif
  578. case WEAPON_FLOWER:
  579. #if PLAYER_BIT_ARRAY > 11
  580. YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][11] = Bit:WEAPON_DATA;
  581. #else
  582. YSI_g_sProperties[i][E_PROP_DATA_NAME][9 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  583. #endif
  584. case WEAPON_CANE:
  585. #if PLAYER_BIT_ARRAY > 12
  586. YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][12] = Bit:WEAPON_DATA;
  587. #else
  588. YSI_g_sProperties[i][E_PROP_DATA_NAME][10 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  589. #endif
  590. case WEAPON_GRENADE:
  591. #if PLAYER_BIT_ARRAY > 13
  592. YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][13] = Bit:WEAPON_DATA;
  593. #else
  594. YSI_g_sProperties[i][E_PROP_DATA_NAME][11 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  595. #endif
  596. case WEAPON_TEARGAS:
  597. #if PLAYER_BIT_ARRAY > 14
  598. YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][14] = Bit:WEAPON_DATA;
  599. #else
  600. YSI_g_sProperties[i][E_PROP_DATA_NAME][12 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  601. #endif
  602. case WEAPON_MOLTOV:
  603. #if PLAYER_BIT_ARRAY > 15
  604. YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][15] = Bit:WEAPON_DATA;
  605. #else
  606. YSI_g_sProperties[i][E_PROP_DATA_NAME][13 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  607. #endif
  608. case WEAPON_COLT45:
  609. YSI_g_sProperties[i][E_PROP_DATA_NAME][14 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  610. case WEAPON_SILENCED:
  611. YSI_g_sProperties[i][E_PROP_DATA_NAME][15 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  612. case WEAPON_DEAGLE:
  613. YSI_g_sProperties[i][E_PROP_DATA_NAME][16 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  614. case WEAPON_SHOTGUN:
  615. YSI_g_sProperties[i][E_PROP_DATA_NAME][17 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  616. case WEAPON_SAWEDOFF:
  617. YSI_g_sProperties[i][E_PROP_DATA_NAME][18 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  618. case WEAPON_SHOTGSPA:
  619. YSI_g_sProperties[i][E_PROP_DATA_NAME][19 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  620. case WEAPON_UZI:
  621. YSI_g_sProperties[i][E_PROP_DATA_NAME][20 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  622. case WEAPON_MP5:
  623. YSI_g_sProperties[i][E_PROP_DATA_NAME][21 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  624. case WEAPON_AK47:
  625. YSI_g_sProperties[i][E_PROP_DATA_NAME][22 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  626. case WEAPON_M4:
  627. YSI_g_sProperties[i][E_PROP_DATA_NAME][23 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  628. case WEAPON_TEC9:
  629. YSI_g_sProperties[i][E_PROP_DATA_NAME][24 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  630. case WEAPON_RIFLE:
  631. YSI_g_sProperties[i][E_PROP_DATA_NAME][25 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  632. case WEAPON_SNIPER:
  633. YSI_g_sProperties[i][E_PROP_DATA_NAME][26 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  634. case WEAPON_ROCKETLAUNCHER:
  635. YSI_g_sProperties[i][E_PROP_DATA_NAME][27 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  636. case WEAPON_FLAMETHROWER:
  637. YSI_g_sProperties[i][E_PROP_DATA_NAME][28 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  638. case WEAPON_MINIGUN:
  639. YSI_g_sProperties[i][E_PROP_DATA_NAME][29 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  640. case WEAPON_SATCHEL:
  641. YSI_g_sProperties[i][E_PROP_DATA_NAME][30 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  642. case WEAPON_SPRAYCAN:
  643. YSI_g_sProperties[i][E_PROP_DATA_NAME][31 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  644. case WEAPON_FIREEXTINGUISHER:
  645. YSI_g_sProperties[i][E_PROP_DATA_NAME][32 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  646. case WEAPON_CAMERA:
  647. YSI_g_sProperties[i][E_PROP_DATA_NAME][33 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  648. case WEAPON_PARACHUTE:
  649. YSI_g_sProperties[i][E_PROP_DATA_NAME][34 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  650. case WEAPON_ARMOUR:
  651. YSI_g_sProperties[i][E_PROP_DATA_NAME][35 - WEAPON_DATA_OFFSET] = WEAPON_DATA;
  652. default:
  653. {
  654. pos += 2;
  655. count--;
  656. }
  657. }
  658. count++;
  659. }
  660. YSI_g_sProperties[i][E_PROP_DATA_NAME][MAX_PROP_NAME - 1] = count;
  661. YSI_g_sCheckpointPointers[cp] = i;
  662. return i;
  663. }
  664. /*-------------------------------------------------------------------------*//**
  665. * <param name="area">Reference to a defined area.</param>
  666. * <param name="money">How much you earn.</param>
  667. * <param name="interval">How often you earn.</param>
  668. * <remarks>
  669. * This function has internal checking for invalid areas so you can just pass
  670. * the return from an Area_ funtion directly.
  671. * </remarks>
  672. *//*------------------------------------------------------------------------**/
  673. stock CreateMoneyArea(area, money = 100, interval = 10000)
  674. {
  675. if (area == NO_AREA) return NO_PROPERTY;
  676. new
  677. i;
  678. while (i < MAX_PROPERTIES)
  679. {
  680. if (!Property_IsActive(i)) break;
  681. i++;
  682. }
  683. if (i == MAX_PROPERTIES) return NO_PROPERTY;
  684. YSI_g_sProperties[i][E_PROP_DATA_FLAGS] = e_PROP_FLAGS_TYPE_MONA | e_PROP_FLAGS_ACTIVE | e_PROP_FLAGS:area;
  685. YSI_g_sProperties[i][E_PROP_DATA_DATA_1] = money;
  686. YSI_g_sProperties[i][E_PROP_DATA_DATA_2] = interval;
  687. YSI_g_sProperties[i][E_PROP_DATA_NAME][0] = interval;
  688. YSI_g_sAreaPointers[area] = i;
  689. return i;
  690. }
  691. /*-------------------------------------------------------------------------*//**
  692. * <param name="x">X position.</param>
  693. * <param name="y">Y position.</param>
  694. * <param name="z">Z position.</param>
  695. * <param name="s">Size of checkpoint.</param>
  696. * <param name="money">How much you earn.</param>
  697. * <param name="interval">How often you earn.</param>
  698. * <remarks>
  699. * Like CreateMoneyArea but you must be in a checkpoint.
  700. * </remarks>
  701. *//*------------------------------------------------------------------------**/
  702. stock CreateMoneyPoint(Float:x, Float:y, Float:z, Float:s, money = 100, interval = 10000)
  703. {
  704. new
  705. i;
  706. while (i < MAX_PROPERTIES)
  707. {
  708. if (!Property_IsActive(i)) break;
  709. i++;
  710. }
  711. if (i == MAX_PROPERTIES) return NO_PROPERTY;
  712. new
  713. cp = CreateCheckpoint(x, y, z, s);
  714. if (cp == NO_CHECKPOINT) return NO_PROPERTY;
  715. YSI_g_sProperties[i][E_PROP_DATA_FLAGS] = e_PROP_FLAGS_TYPE_MONP | e_PROP_FLAGS_ACTIVE | e_PROP_FLAGS:cp;
  716. YSI_g_sProperties[i][E_PROP_DATA_DATA_1] = money;
  717. YSI_g_sProperties[i][E_PROP_DATA_DATA_2] = interval;
  718. YSI_g_sProperties[i][E_PROP_DATA_NAME][0] = interval;
  719. YSI_g_sCheckpointPointers[cp] = i;
  720. return i;
  721. }
  722. /*-------------------------------------------------------------------------*//**
  723. * <param name="sx">Start X.</param>
  724. * <param name="sy">Start Y.</param>
  725. * <param name="sz">Start Z.</param>
  726. * <param name="tz">Target X.</param>
  727. * <param name="ty">Target Y.</param>
  728. * <param name="tz">Target Z.</param>
  729. * <param name="cost">Price to use the teleport.</param>
  730. * <param name="name">Name of the destination.</param>
  731. * <remarks>
  732. * Will teleport you the moment you step in.
  733. * </remarks>
  734. *//*------------------------------------------------------------------------**/
  735. stock CreateTeleport(Float:sx, Float:sy, Float:sz, Float:tx, Float:ty, Float:tz, cost = 0, name[] = "")
  736. {
  737. new
  738. i;
  739. while (i < MAX_PROPERTIES)
  740. {
  741. if (!Property_IsActive(i)) break;
  742. i++;
  743. }
  744. if (i == MAX_PROPERTIES) return NO_PROPERTY;
  745. new
  746. cp = CreateCheckpoint(sx, sy, sz, 3.0);
  747. if (cp == NO_CHECKPOINT) return NO_PROPERTY;
  748. YSI_g_sProperties[i][E_PROP_DATA_FLAGS] = e_PROP_FLAGS_TYPE_TELS | e_PROP_FLAGS_ACTIVE | e_PROP_FLAGS:cp;
  749. YSI_g_sProperties[i][E_PROP_DATA_DATA_1] = cost;
  750. YSI_g_sProperties[i][E_PROP_DATA_DATA_2] = _:tx;
  751. YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][0] = Bit:ty;
  752. YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][1] = Bit:tz;
  753. if (!isnull(name)) strcpy(YSI_g_sProperties[i][E_PROP_DATA_NAME], name, MAX_PROP_NAME);
  754. else YSI_g_sProperties[i][E_PROP_DATA_NAME][0] = '\0';
  755. YSI_g_sCheckpointPointers[cp] = i;
  756. return i;
  757. }
  758. /*-------------------------------------------------------------------------*//**
  759. * <param name="area">Reference to a defined area.</param>
  760. * <param name="kick">Wether they should be kicked out not hurt.</param>
  761. * <param name="health">How much health should be removed every itteration they're in.</param>
  762. * <param name="invert">Not allowed to leave the area rather than enter.</param>
  763. * <param name="name">Name of the area.</param>
  764. * <remarks>
  765. * If kick is 1 people will simply be constantly replaced outside the area
  766. * from the direction they came.
  767. * </remarks>
  768. *//*------------------------------------------------------------------------**/
  769. stock CreateForbiddenArea(area, kick = 0, health = 1000, invert = 0, name[] = "")
  770. {
  771. if (area == NO_AREA) return NO_PROPERTY;
  772. new
  773. i;
  774. while (i < MAX_PROPERTIES)
  775. {
  776. if (!Property_IsActive(i)) break;
  777. i++;
  778. }
  779. if (i == MAX_PROPERTIES) return NO_PROPERTY;
  780. YSI_g_sProperties[i][E_PROP_DATA_FLAGS] = e_PROP_FLAGS_TYPE_RSRC | e_PROP_FLAGS_ACTIVE | e_PROP_FLAGS:area | Property_SetOption(1, kick) | Property_SetOption(2, invert);
  781. YSI_g_sProperties[i][E_PROP_DATA_DATA_2] = health;
  782. if (!isnull(name)) strcpy(YSI_g_sProperties[i][E_PROP_DATA_NAME], name, MAX_PROP_NAME);
  783. else YSI_g_sProperties[i][E_PROP_DATA_NAME][0] = '\0';
  784. YSI_g_sAreaPointers[area] = i;
  785. return i;
  786. }
  787. /*-------------------------------------------------------------------------*//**
  788. * <param name="playerid">Player who entered an area.</param>
  789. * <param name="area">Area they entered.</param>
  790. * <remarks>
  791. * Internal callback from YSI_areas.
  792. * </remarks>
  793. *//*------------------------------------------------------------------------**/
  794. Property_OnPlayerEnterArea(playerid, area)
  795. {
  796. new
  797. prop = YSI_g_sAreaPointers[area];
  798. if (prop == NO_PROPERTY)
  799. {
  800. return 0;
  801. }
  802. if (YSI_g_sProperties[prop][E_PROP_DATA_FLAGS] & e_PROP_FLAGS_TYPES == e_PROP_FLAGS_TYPE_RSRC)
  803. {
  804. if (!Property_GetOption(2, YSI_g_sProperties[prop][E_PROP_DATA_FLAGS]))
  805. {
  806. if (YSI_g_sProperties[prop][E_PROP_DATA_NAME][0]) Text_SendFormat(playerid, "YSI_FORBIDDEN_2", YSI_g_sProperties[prop][E_PROP_DATA_NAME]);
  807. else Text_Send(playerid, $YSI_FORBIDDEN);
  808. Bit_Set(YSI_g_sPlayerProperties[playerid], prop, 1, GROUP_PROPERTY_BITS);
  809. }
  810. }
  811. else Bit_Set(YSI_g_sPlayerProperties[playerid], prop, 1, GROUP_PROPERTY_BITS);
  812. return 1;
  813. }
  814. /*-------------------------------------------------------------------------*//**
  815. * <param name="playerid">Player who left an area.</param>
  816. * <param name="areaid">Area they left.</param>
  817. * <remarks>
  818. * Internal callback from YSI_areas.
  819. * </remarks>
  820. *//*------------------------------------------------------------------------**/
  821. Property_OnPlayerLeaveArea(playerid, area)
  822. {
  823. new
  824. prop = YSI_g_sAreaPointers[area];
  825. if (prop == NO_PROPERTY)
  826. {
  827. return 0;
  828. }
  829. Bit_Set(YSI_g_sPlayerProperties[playerid], prop, (YSI_g_sProperties[prop][E_PROP_DATA_FLAGS] & e_PROP_FLAGS_TYPES == e_PROP_FLAGS_TYPE_RSRC && Property_GetOption(2, YSI_g_sProperties[prop][E_PROP_DATA_FLAGS])));
  830. return 1;
  831. }
  832. /*-------------------------------------------------------------------------*//**
  833. * <param name="playerid">Player who connected.</param>
  834. * <remarks>
  835. * Internal callback.
  836. * </remarks>
  837. *//*------------------------------------------------------------------------**/
  838. HOOK__ OnPlayerConnect(playerid)
  839. {
  840. YSI_g_sShopMenu[playerid][E_PROP_AMMU_MENU] = Menu:-1;
  841. Bit_SetAll(YSI_g_sPlayerProperties[playerid], false, GROUP_PROPERTY_BITS);
  842. for (new i = 0; i < 13; i++) YSI_g_sSpawnWeapons[playerid][i] = 0;
  843. YSI_g_sMoney[playerid] = 0;
  844. return 1;
  845. }
  846. /*-------------------------------------------------------------------------*//**
  847. * <param name="playerid">Player who connected.</param>
  848. * <remarks>
  849. * Internal callback.
  850. * </remarks>
  851. *//*------------------------------------------------------------------------**/
  852. HOOK__ OnPlayerDisconnect(playerid, reason)
  853. {
  854. FOREACH__ (new property : Bits(YSI_g_sPlayerProperties[playerid]))
  855. {
  856. new
  857. e_PROP_FLAGS:flags = YSI_g_sProperties[property][E_PROP_DATA_FLAGS];
  858. if (flags & e_PROP_FLAGS_ACTIVE)
  859. {
  860. if ((flags & e_PROP_FLAGS_TYPES) == e_PROP_FLAGS_TYPE_PROP)
  861. {
  862. if (Property_GetOption(2, flags))
  863. {
  864. if (_:Bit_GetBit(YSI_g_sProperties[property][E_PROP_DATA_PLAYERS], playerid))
  865. {
  866. Bit_Set(YSI_g_sProperties[property][E_PROP_DATA_PLAYERS], playerid, false);//, PLAYER_BIT_ARRAY);
  867. }
  868. }
  869. else
  870. {
  871. if (_:(YSI_g_sProperties[property][E_PROP_DATA_PLAYERS][0] == Bit:playerid))
  872. {
  873. YSI_g_sProperties[property][E_PROP_DATA_PLAYERS][0] = Bit:INVALID_PLAYER_ID;
  874. }
  875. }
  876. #pragma tabsize 4
  877. #if defined _YSI_VISUAL_PICKUPS
  878. if (Property_GetOption(5, flags))
  879. Pickup_Show(_:(flags & e_PROP_FLAGS_LINK), 1);
  880. else
  881. #endif
  882. Checkpoint_SetVisible(_:(flags & e_PROP_FLAGS_LINK), 1);
  883. #pragma tabsize 4
  884. }
  885. else if ((flags & e_PROP_FLAGS_TYPES) == e_PROP_FLAGS_TYPE_HOUS)
  886. {
  887. if (_:(YSI_g_sProperties[property][E_PROP_DATA_PLAYERS][0] == Bit:playerid))
  888. {
  889. YSI_g_sProperties[property][E_PROP_DATA_PLAYERS][0] = Bit:INVALID_PLAYER_ID;
  890. }
  891. }
  892. }
  893. }
  894. Bit_SetAll(YSI_g_sPlayerProperties[playerid], false);
  895. YSI_g_sPropCount[playerid] = 0;
  896. YSI_g_sHouseCount[playerid] = 0;
  897. YSI_g_sCurrentHouse[playerid] = -1;
  898. //YSI_g_sPickupTimer[playerid] = -1;
  899. //YSI_g_sPlayerPickup[playerid] = NO_PICKUP;
  900. //#pragma unused reason
  901. return 1;
  902. }
  903. /*-------------------------------------------------------------------------*//**
  904. * <param name="playerid">Player who spawned.</param>
  905. * <remarks>
  906. * Internal callback.
  907. * </remarks>
  908. *//*------------------------------------------------------------------------**/
  909. HOOK__ OnPlayerSpawn(playerid)
  910. {
  911. for (new i = 0; i < 12; i++) if (YSI_g_sSpawnWeapons[playerid][i]) GivePlayerWeapon(playerid, (YSI_g_sSpawnWeapons[playerid][i] >> 24) & 0xFF, YSI_g_sSpawnWeapons[playerid][i] & 0xFFFFFF);
  912. if (YSI_g_sSpawnWeapons[playerid][12]) SetPlayerArmour(playerid, 100.0);
  913. return 1;
  914. }
  915. /*-------------------------------------------------------------------------*//**
  916. * <param name="playerid">Player who left a checkpoint.</param>
  917. * <param name="cpid">Checkpoint they left.</param>
  918. * <remarks>
  919. * Internal callback from YSI_checkpoints.
  920. * </remarks>
  921. *//*------------------------------------------------------------------------**/
  922. HOOK__ OnPlayerLeaveCPEx(playerid, cpid)
  923. {
  924. new
  925. cp = YSI_g_sCheckpointPointers[cpid];
  926. if (cp == NO_CHECKPOINT)
  927. {
  928. return 0;
  929. }
  930. new
  931. flags = YSI_g_sProperties[cp][E_PROP_DATA_FLAGS],
  932. type = _:(_:flags & _:e_PROP_FLAGS_TYPES);
  933. if ((type != _:e_PROP_FLAGS_TYPE_HOUS || YSI_g_sProperties[cp][E_PROP_DATA_PLAYERS][0] != Bit:playerid) && (type != _:e_PROP_FLAGS_TYPE_PROP || !Property_IsOwner(playerid, cp, flags)))
  934. {
  935. Bit_Set(YSI_g_sPlayerProperties[playerid], cp, false);//, GROUP_PROPERTY_BITS);
  936. }
  937. return 1;
  938. }
  939. #if defined _YSI_VISUAL_PICKUPS
  940. /*---------------------------------------------------------------------*//**
  941. *
  942. * <param name="playerid">Player who picked up a pickup.</param>
  943. * <param name="pickupid">Pickup they picked up.</param>
  944. * <remarks>
  945. * Internal callback from YSI_pickups.
  946. * </remarks>
  947. *//*--------------------------------------------------------------------**/
  948. Property_OnPlayerPickUpPickup(playerid, pickupid)
  949. {
  950. P:2("Property_OnPlayerPickUpPickup() start");
  951. if (YSI_g_sPickupTimer[playerid] == -1)
  952. {
  953. P:4("Property_OnPlayerPickUpPickup() No timer");
  954. if (pickupid >= MAX_DYN_PICKUPS)
  955. {
  956. return 0;
  957. }
  958. P:4("Property_OnPlayerPickUpPickup() Valid pickup");
  959. new
  960. prop = YSI_g_sPickupPointers[pickupid];
  961. if (prop == NO_PROPERTY)
  962. {
  963. return 0;
  964. }
  965. P:4("Property_OnPlayerPickUpPickup() Valid property");
  966. YSI_g_sPlayerPickup[playerid] = pickupid;
  967. Bit_Set(YSI_g_sPlayerProperties[playerid], prop, 1, GROUP_PROPERTY_BITS);
  968. switch (_:(YSI_g_sProperties[prop][E_PROP_DATA_FLAGS] & e_PROP_FLAGS_TYPES))
  969. {
  970. case e_PROP_FLAGS_TYPE_PROP:
  971. {
  972. new
  973. data1 = YSI_g_sProperties[prop][E_PROP_DATA_DATA_2] & 0x3FFFF,
  974. data2 = ((YSI_g_sProperties[prop][E_PROP_DATA_DATA_2] >>> 6) & 0x03FFF000) | ((YSI_g_sProperties[prop][E_PROP_DATA_DATA_1] >>> 20) & 0x00000FFF);
  975. Text_SendFormat(playerid, "YSI_PROP_NAME", YSI_g_sProperties[prop][E_PROP_DATA_NAME], data1, data2);
  976. if (Property_GetOption(2, YSI_g_sProperties[prop][E_PROP_DATA_FLAGS]))
  977. {
  978. if (Bit_GetBit(YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS], playerid)) Text_Send(playerid, $YSI_PROP_YOURS);
  979. else Text_SendFormat(playerid, "YSI_PROP_BUY", "buy");
  980. }
  981. else
  982. {
  983. new
  984. owner = _:YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS][0];
  985. if (owner == playerid) Text_Send(playerid, $YSI_PROP_YOURS);
  986. else if (IsPlayerConnected(owner)) Text_SendFormat(playerid, "YSI_PROP_OWNER", ReturnPlayerName(owner), owner);
  987. if (owner != playerid) Text_SendFormat(playerid, "YSI_PROP_BUY", "buy");
  988. }
  989. }
  990. case e_PROP_FLAGS_TYPE_HOUS:
  991. {
  992. new
  993. owner = _:YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS][0];
  994. if (owner == INVALID_PLAYER_ID) Text_SendFormat(playerid, "YSI_PROP_BUY_HOUSE", "buy", YSI_g_sProperties[prop][E_PROP_DATA_NAME][6]);
  995. else if (owner == playerid) Text_SendFormat(playerid, "YSI_PROP_ENTER", "enter", "exit");
  996. else Text_SendFormat(playerid, "YSI_PROP_HOUSE_OWNED", ReturnPlayerName(owner));
  997. }
  998. }
  999. YSI_g_sPickupTimer[playerid] = SetTimerEx("Property_PickupTimeCheck", 500, 1, "ii", playerid, pickupid);
  1000. }
  1001. P:2("Property_OnPlayerPickUpPickup() end");
  1002. return 1;
  1003. }
  1004. /*---------------------------------------------------------------------*//**
  1005. *
  1006. * <param name="playerid">Player who is on a pickup.</param>
  1007. * <param name="pickupid">Pickup to check.</param>
  1008. *
  1009. * Checks if a player has moved away from a pickup.
  1010. * </remarks>
  1011. *//*--------------------------------------------------------------------**/
  1012. public Property_PickupTimeCheck(playerid, pickupid)
  1013. {
  1014. if (!Pickup_IsPlayerOnPickup(playerid, pickupid))
  1015. {
  1016. KillTimer(YSI_g_sPickupTimer[playerid]);
  1017. YSI_g_sPickupTimer[playerid] = -1;
  1018. YSI_g_sPlayerPickup[playerid] = NO_PICKUP;
  1019. new
  1020. prop = YSI_g_sPickupPointers[pickupid];
  1021. if (prop != NO_PROPERTY)
  1022. {
  1023. new
  1024. flags = _:YSI_g_sProperties[prop][E_PROP_DATA_FLAGS],
  1025. type = flags & _:e_PROP_FLAGS_TYPES;
  1026. if ((type != _:e_PROP_FLAGS_TYPE_HOUS || YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS][0] != Bit:playerid) && (type != _:e_PROP_FLAGS_TYPE_PROP || !Property_IsOwner(playerid, prop, flags)))
  1027. {
  1028. Bit_Set(YSI_g_sPlayerProperties[playerid], prop, 0, GROUP_PROPERTY_BITS);
  1029. }
  1030. }
  1031. }
  1032. }
  1033. #endif
  1034. /*-------------------------------------------------------------------------*//**
  1035. * <param name="playerid">Player who entered a checkpoint.</param>
  1036. * <param name="cpid">Checkpoint they entered.</param>
  1037. * <remarks>
  1038. * Internal callback from YSI_checkpoints.
  1039. * </remarks>
  1040. *//*------------------------------------------------------------------------**/
  1041. Property_OnPlayerEnterCheckpointEx(playerid, cpid)
  1042. {
  1043. if (cpid >= MAX_CHECKPOINTS)
  1044. {
  1045. return 0;
  1046. }
  1047. new
  1048. prop = YSI_g_sCheckpointPointers[cpid];
  1049. if (prop == NO_PROPERTY)
  1050. {
  1051. return 0;
  1052. }
  1053. new
  1054. e_PROP_FLAGS:flag = YSI_g_sProperties[prop][E_PROP_DATA_FLAGS];
  1055. switch (flag & e_PROP_FLAGS_TYPES)
  1056. {
  1057. case e_PROP_FLAGS_TYPE_PROP:
  1058. {
  1059. Text_SendFormat(playerid, "YSI_PROP_NAME", YSI_g_sProperties[prop][E_PROP_DATA_NAME], ((YSI_g_sProperties[prop][E_PROP_DATA_DATA_2] >>> 6) & 0x03FFF000) | ((YSI_g_sProperties[prop][E_PROP_DATA_DATA_1] >>> 20) & 0x00000FFF), YSI_g_sProperties[prop][E_PROP_DATA_DATA_2] & 0x3FFFF);
  1060. if (Property_GetOption(2, flag))
  1061. {
  1062. if (Bit_GetBit(YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS], playerid)) Text_Send(playerid, $YSI_PROP_YOURS);
  1063. else Text_SendFormat(playerid, "YSI_PROP_BUY", "buy");
  1064. }
  1065. else
  1066. {
  1067. new
  1068. owner = _:YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS][0];
  1069. if (owner == playerid) Text_Send(playerid, $YSI_PROP_YOURS);
  1070. else if (IsPlayerConnected(owner)) Text_SendFormat(playerid, "YSI_PROP_OWNER", ReturnPlayerName(owner), owner);
  1071. if (owner != playerid) Text_SendFormat(playerid, "YSI_PROP_BUY", "buy");
  1072. }
  1073. }
  1074. case e_PROP_FLAGS_TYPE_HOUS:
  1075. {
  1076. new
  1077. owner = _:YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS][0];
  1078. if (owner == INVALID_PLAYER_ID) Text_SendFormat(playerid, "YSI_PROP_BUY_HOUSE", "buy", YSI_g_sProperties[prop][E_PROP_DATA_NAME][6]);
  1079. else if (owner == playerid) Text_SendFormat(playerid, "YSI_PROP_ENTER", "enter", "exit");
  1080. else Text_SendFormat(playerid, "YSI_PROP_HOUSE_OWNED", ReturnPlayerName(owner));
  1081. }
  1082. case e_PROP_FLAGS_TYPE_AMMU:
  1083. {
  1084. Property_GenerateAmmuMenu(playerid, prop, 0, 0);
  1085. TogglePlayerControllable(playerid, 0);
  1086. }
  1087. case e_PROP_FLAGS_TYPE_BANK:
  1088. {
  1089. if (YSI_g_sProperties[prop][E_PROP_DATA_NAME][0]) Text_SendFormat(playerid, "YSI_BANK_NAME", YSI_g_sProperties[prop][E_PROP_DATA_NAME]);
  1090. else Text_Send(playerid, $YSI_BANK_WELCOME);
  1091. Text_SendFormat(playerid, "YSI_BANK_HELP1", "bank");
  1092. Text_SendFormat(playerid, "YSI_BANK_HELP2", "withdraw");
  1093. Text_SendFormat(playerid, "YSI_BANK_HELP3", "balance");
  1094. Text_SendFormat(playerid, "YSI_BANK_BALANCE", YSI_g_sMoney[playerid]);
  1095. }
  1096. case e_PROP_FLAGS_TYPE_TELS:
  1097. {
  1098. if (GetPlayerMoney(playerid) >= YSI_g_sProperties[prop][E_PROP_DATA_DATA_1])
  1099. {
  1100. GivePlayerMoney(playerid, -YSI_g_sProperties[prop][E_PROP_DATA_DATA_1]);
  1101. SetPlayerPos(playerid, Float:YSI_g_sProperties[prop][E_PROP_DATA_DATA_2], Float:YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS][0], Float:YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS][1]);
  1102. if (YSI_g_sProperties[prop][E_PROP_DATA_NAME][0]) Text_SendFormat(playerid, "YSI_TELS_NAME", YSI_g_sProperties[prop][E_PROP_DATA_NAME]);
  1103. else Text_Send(playerid, $YSI_TELS_TELE);
  1104. }
  1105. else Text_SendFormat(playerid, "YSI_TELS_MONEY", YSI_g_sProperties[prop][E_PROP_DATA_DATA_1]);
  1106. return 1;
  1107. }
  1108. case e_PROP_FLAGS_TYPE_MONP: {}
  1109. default:
  1110. {
  1111. return 0;
  1112. }
  1113. }
  1114. Bit_Set(YSI_g_sPlayerProperties[playerid], prop, 1, GROUP_PROPERTY_BITS);
  1115. return 1;
  1116. }
  1117. /*-------------------------------------------------------------------------*//**
  1118. * <param name="ammu">Ammunation to get the weapon from.</param>
  1119. * <param name="slot">Number of active slots to skip.</param>
  1120. * <param name="page">Start slot.</param>
  1121. * <remarks>
  1122. * Gets the slot active weapon from page start. If you want the first one
  1123. * use page = 0 and slot = 0. If you want the second use page = 0 and slot
  1124. * = 1 or slot = 0 and page > position of first.
  1125. * </remarks>
  1126. *//*------------------------------------------------------------------------**/
  1127. static stock Property_GetWeapon(ammu, slot, &page = 0)
  1128. {
  1129. new
  1130. weapon;
  1131. while (page < 40)
  1132. {
  1133. if (!page)
  1134. {
  1135. weapon = YSI_g_sProperties[ammu][E_PROP_DATA_DATA_1];
  1136. }
  1137. else if (page == 1)
  1138. {
  1139. weapon = YSI_g_sProperties[ammu][E_PROP_DATA_DATA_2];
  1140. }
  1141. else if (page < PLAYER_BIT_ARRAY + 2)
  1142. {
  1143. weapon = _:YSI_g_sProperties[ammu][E_PROP_DATA_PLAYERS][page - 2];
  1144. }
  1145. else
  1146. {
  1147. weapon = YSI_g_sProperties[ammu][E_PROP_DATA_NAME][page - (PLAYER_BIT_ARRAY + 2)];
  1148. }
  1149. if (weapon)
  1150. {
  1151. if (!slot) return weapon;
  1152. else slot--;
  1153. }
  1154. page++;
  1155. }
  1156. return 0;
  1157. }
  1158. /*-------------------------------------------------------------------------*//**
  1159. * <param name="weapon">Weapon slot to get the name of.</param>
  1160. * <remarks>
  1161. * Gets a real weapon name based on the slot of the weapon, not the weapon id.
  1162. * </remarks>
  1163. *//*------------------------------------------------------------------------**/
  1164. static stock Property_WeaponName(weapon)
  1165. {
  1166. static
  1167. names[][18] =
  1168. {
  1169. "Brassknuckle", "Golfclub", "Night Stick", "Knife",
  1170. "Bat", "Shovel", "Poolstick", "Katana",
  1171. "Chainsaw", "Dildo", "Dildo 2", "Vibrator",
  1172. "Vibrator 2", "Flower", "Cane", "Grenade",
  1173. "Teargas", "Molotov", "Colt 45", "Silenced Pistol",
  1174. "Desert Eagle", "Shotgun", "Sawnoff", "Spaz 9",
  1175. "Uzi", "MP5", "AK47", "M4",
  1176. "TEC9", "Rifle", "Sniper Rifle", "Rocket Launcher",
  1177. "Flame Thrower", "Minigun", "Satchel Charge", "Spraycan",
  1178. "Fire Extinguisher", "Camera", "Parachute", "Armour"
  1179. },
  1180. none[18] = "NONE";
  1181. if (weapon >=0 && weapon < sizeof (names)) return names[weapon];
  1182. else return none;
  1183. }
  1184. /*-------------------------------------------------------------------------*//**
  1185. * <param name="data">Compressed data.</param>
  1186. * <remarks>
  1187. * Extracts the cost from the passed data.
  1188. * </remarks>
  1189. *//*------------------------------------------------------------------------**/
  1190. P:D(Property_WeaponCost(data));
  1191. #define Property_WeaponCost(%1) \
  1192. ((%1) & 0xFFFFF)
  1193. /*-------------------------------------------------------------------------*//**
  1194. * <param name="data">Compressed data.</param>
  1195. * <remarks>
  1196. * Extracts the ammo from the passed data.
  1197. * </remarks>
  1198. *//*------------------------------------------------------------------------**/
  1199. P:D(Property_WeaponAmmo(data));
  1200. #define Property_WeaponAmmo(%1) \
  1201. ((%1) >> 20)
  1202. /*-------------------------------------------------------------------------*//**
  1203. * <param name="playerid">Player who left a menu.</param>
  1204. * <remarks>
  1205. * Internal callback.
  1206. * </remarks>
  1207. *//*------------------------------------------------------------------------**/
  1208. #define Property_OnPlayerExitedMenu Property_OnPlayerExited
  1209. Property_OnPlayerExitedMenu(playerid)
  1210. {
  1211. if (GetPlayerMenu(playerid) == YSI_g_sShopMenu[playerid][E_PROP_AMMU_MENU])
  1212. {
  1213. new
  1214. data = YSI_g_sShopMenu[playerid][E_PROP_AMMU_DATA];
  1215. if (data & 0x01)
  1216. {
  1217. Property_GenerateAmmuMenu(playerid, data >> 16, 0, 0);
  1218. return 1;
  1219. }
  1220. }
  1221. YSI_g_sShopMenu[playerid][E_PROP_AMMU_MENU] = Menu:-1;
  1222. TogglePlayerControllable(playerid, 1);
  1223. YSI_g_sShopMenu[playerid][E_PROP_AMMU_DATA] = 0;
  1224. return 0;
  1225. }
  1226. /*-------------------------------------------------------------------------*//**
  1227. * <param name="slot">Data slot to translate.</param>
  1228. * <returns>
  1229. * weaponid represented by that slot.
  1230. * </returns>
  1231. *//*------------------------------------------------------------------------**/
  1232. static stock Property_GetWeaponFromSlot(slot)
  1233. {
  1234. if (slot < 18) return slot + 1;
  1235. else if (slot < 33) return slot + 4;
  1236. else if (slot < 36) return slot + 5;
  1237. else if (slot < 38) return slot + 6;
  1238. else if (slot == 38) return WEAPON_PARACHUTE;
  1239. else if (slot == 39) return WEAPON_ARMOUR;
  1240. else return 0;
  1241. }
  1242. /*-------------------------------------------------------------------------*//**
  1243. * <param name="playerid">Player to save the weapon for.</param>
  1244. * <param name="weaponslot">Slot of the weapon.</param>
  1245. * <param name="ammo">Ammo to save.</param>
  1246. * <remarks>
  1247. * Saves weapons based on slots so you only have 13 spawn weapons based on
  1248. * real weapon slots (armour is slot 12). This is similar to weapon slot
  1249. * sorting but it's sorting slots which are packed from original weapon
  1250. * numbers and missing some.
  1251. * </remarks>
  1252. *//*------------------------------------------------------------------------**/
  1253. stock Property_SavePlayerWeapon(playerid, weaponslot, ammo)
  1254. {
  1255. new
  1256. slot,
  1257. weapon;
  1258. switch (weaponslot)
  1259. {
  1260. case 0: slot = 0, weapon = WEAPON(WEAPON_BRASSKNUCKLE);
  1261. case 1, 2, 3, 4, 5, 6, 7, 8: slot = 1, weapon = WEAPON(weaponslot + 1);
  1262. case 18, 19, 20: slot = 2, weapon = WEAPON(weaponslot + 4);
  1263. case 21, 22, 23: slot = 3, weapon = WEAPON(weaponslot + 4);
  1264. case 24, 25, 28: slot = 4, weapon = WEAPON(weaponslot + 4);
  1265. case 26, 27: slot = 5, weapon = WEAPON(weaponslot + 4);
  1266. case 29, 30: slot = 6, weapon = WEAPON(weaponslot + 4);
  1267. case 31: slot = 7, weapon = WEAPON(WEAPON_ROCKETLAUNCHER);
  1268. case 32, 33: slot = 7, weapon = WEAPON(weaponslot + 5);
  1269. case 15, 16, 17: slot = 8, weapon = WEAPON(weaponslot + 1);
  1270. case 34: slot = 8, weapon = WEAPON(WEAPON_SATCHEL);
  1271. case 35, 36, 37: slot = 9, weapon = WEAPON(weaponslot + 6);
  1272. case 9, 10, 11, 12, 13, 14: slot = 10, weapon = WEAPON(weaponslot + 1);
  1273. case 38: slot = 11, weapon = WEAPON(WEAPON_PARACHUTE);
  1274. case 39: slot = 12, weapon = 1;
  1275. default: return;
  1276. }
  1277. if (YSI_g_sSpawnWeapons[playerid][slot] & 0xFF000000 == weapon) YSI_g_sSpawnWeapons[playerid][slot] += ammo & 0x00FFFFFF;
  1278. else YSI_g_sSpawnWeapons[playerid][slot] = (weapon & 0xFF000000) | (ammo & 0x00FFFFFF);
  1279. }
  1280. /*-------------------------------------------------------------------------*//**
  1281. * <param name="playerid">Player to get the weapon for.</param>
  1282. * <param name="slot">Slot to get.</param>
  1283. * <param name="weaponslot">Return for the weapon type.</param>
  1284. * <param name="ammo">Return for the ammo.</param>
  1285. * <remarks>
  1286. * Gets a player's stored for spawn weapons.
  1287. * </remarks>
  1288. *//*------------------------------------------------------------------------**/
  1289. stock Property_GetSlotWeapon(playerid, slot, &weapon, &ammo)
  1290. {
  1291. if (playerid < 0 || playerid >= MAX_PLAYERS || slot < 0 || slot >= 13) return;
  1292. weapon = (YSI_g_sSpawnWeapons[playerid][slot] & 0xFF000000) >> 24;
  1293. ammo = YSI_g_sSpawnWeapons[playerid][slot] & 0x00FFFFFF;
  1294. }
  1295. /*-------------------------------------------------------------------------*//**
  1296. * <param name="playerid">Player to save weapons for.</param>
  1297. * <remarks>
  1298. * Saves a players current spawn weapon data to an ini (i.e. their save file).
  1299. * 110953013 is props in adler32
  1300. * </remarks>
  1301. *//*------------------------------------------------------------------------**/
  1302. stock Property_SaveWeapons(playerid)
  1303. {
  1304. if (playerid >= 0 && playerid < MAX_PLAYERS)
  1305. {
  1306. new
  1307. str[8] = "wslot";
  1308. for (new i = 0; i <= 12; i++)
  1309. {
  1310. if (i >= 10)
  1311. {
  1312. new
  1313. tens = i / 10;
  1314. str[5] = tens + '0';
  1315. str[6] = (i - (tens * 10)) + '0';
  1316. str[7] = '\0';
  1317. }
  1318. else
  1319. {
  1320. str[5] = i + '0';
  1321. str[6] = '\0';
  1322. }
  1323. Player_WriteInt(str, YSI_g_sSpawnWeapons[playerid][i]);
  1324. }
  1325. }
  1326. }
  1327. /*-------------------------------------------------------------------------*//**
  1328. * <param name="playerid">Player to load weapons for.</param>
  1329. * <param name="identifier">Slot data.</param>
  1330. * <param name="text">Weapon data.</param>
  1331. * <remarks>
  1332. * Called when a player logs in to load their previous weapons.
  1333. * </remarks>
  1334. *//*------------------------------------------------------------------------**/
  1335. stock Property_LoadWeapons(playerid, identifier[], text[])
  1336. {
  1337. if (playerid >= 0 && playerid < MAX_PLAYERS)
  1338. {
  1339. if (strcmp(identifier, "wslot", false, 5)) return;
  1340. new
  1341. slot = strval(identifier[5]);
  1342. if (slot < 0 || slot > 12) return;
  1343. YSI_g_sSpawnWeapons[playerid][slot] = strval(text);
  1344. }
  1345. }
  1346. /*-------------------------------------------------------------------------*//**
  1347. * <param name="playerid">Player to save bank for.</param>
  1348. * <remarks>
  1349. * Saves a players current bank data to an ini (i.e. their save file).
  1350. * </remarks>
  1351. *//*------------------------------------------------------------------------**/
  1352. stock Property_SaveBank(playerid)
  1353. {
  1354. if (playerid >= 0 && playerid < MAX_PLAYERS)
  1355. {
  1356. Player_WriteInt("bankmoney", YSI_g_sMoney[playerid]);
  1357. }
  1358. }
  1359. /*-------------------------------------------------------------------------*//**
  1360. * <param name="playerid">Player to get bank for.</param>
  1361. * <returns>
  1362. * Money in bank.
  1363. * </returns>
  1364. * <remarks>
  1365. * </remarks>
  1366. *//*------------------------------------------------------------------------**/
  1367. stock Property_GetBank(playerid)
  1368. {
  1369. if (playerid >= 0 && playerid < MAX_PLAYERS) return YSI_g_sMoney[playerid];
  1370. return 0;
  1371. }
  1372. /*-------------------------------------------------------------------------*//**
  1373. * <param name="playerid">Player to load bank for.</param>
  1374. * <param name="identifier">Identifier name to check.</param>
  1375. * <param name="text">Possibly bank amount.</param>
  1376. * <remarks>
  1377. * Called when a player logs in to load their previous banked money.
  1378. * </remarks>
  1379. *//*------------------------------------------------------------------------**/
  1380. stock Property_LoadBank(playerid, identifier[], text[])
  1381. {
  1382. if (playerid >= 0 && playerid < MAX_PLAYERS && !strcmp(identifier, "bankmoney"))
  1383. {
  1384. YSI_g_sMoney[playerid] = strval(text);
  1385. }
  1386. }
  1387. /*-------------------------------------------------------------------------*//**
  1388. * <param name="playerid">Player who selected a row.</param>
  1389. * <param name="row">Row they selected.</param>
  1390. * <remarks>
  1391. * Internal callback.
  1392. * </remarks>
  1393. *//*------------------------------------------------------------------------**/
  1394. #define Property_OnPlayerSelectedMenuRow Property_OnPlayerSelectedRow
  1395. Property_OnPlayerSelectedMenuRow(playerid, row)
  1396. {
  1397. if (GetPlayerMenu(playerid) == YSI_g_sShopMenu[playerid][E_PROP_AMMU_MENU])
  1398. {
  1399. new
  1400. data = YSI_g_sShopMenu[playerid][E_PROP_AMMU_DATA],
  1401. slot = (data >> 8) & 0xFF,
  1402. ammu = data >> 16,
  1403. count = YSI_g_sProperties[ammu][E_PROP_DATA_NAME][MAX_PROP_NAME - 1];
  1404. if (data & 0x01)
  1405. {
  1406. new
  1407. weapon,
  1408. flags = _:YSI_g_sProperties[ammu][E_PROP_DATA_FLAGS],
  1409. wdat;
  1410. wdat = Property_GetWeapon(ammu, slot, weapon);
  1411. if (GetPlayerMoney(playerid) >= Property_WeaponCost(wdat))
  1412. {
  1413. if (Property_GetOption(1, flags)) Property_SavePlayerWeapon(playerid, weapon, Property_WeaponAmmo(wdat));
  1414. if (Property_GetOption(2, flags)) Property_GivePlayerWeapon(playerid, weapon, Property_WeaponAmmo(wdat));
  1415. GivePlayerMoney(playerid, 0 - Property_WeaponCost(wdat));
  1416. }
  1417. else Text_Send(playerid, $YSI_AMMU_NO_MONEY);
  1418. Property_GenerateAmmuMenu(playerid, ammu, 0, 0);
  1419. }
  1420. else
  1421. {
  1422. if (count > slot && row == 11) Property_GenerateAmmuMenu(playerid, ammu, 0, slot);
  1423. else if (count > 12)
  1424. {
  1425. if (slot > 11 && row == 0) Property_GenerateAmmuMenu(playerid, ammu, 0, ((slot - 12) / 11) * 11);
  1426. else Property_GenerateAmmuMenu(playerid, ammu, 1, ((slot - 1) / 11) * 10 + row);
  1427. }
  1428. else
  1429. {
  1430. Property_GenerateAmmuMenu(playerid, ammu, 1, row);
  1431. }
  1432. }
  1433. return 1;
  1434. }
  1435. else YSI_g_sShopMenu[playerid][E_PROP_AMMU_MENU] = Menu:-1;
  1436. return 0;
  1437. }
  1438. /*-------------------------------------------------------------------------*//**
  1439. * <param name="playerid">Player who watns the menu.</param>
  1440. * <param name="ammu">Ammunation they're in.</param>
  1441. * <param name="stage">Current menu view if any.</param>
  1442. * <param name="page">Current menu page.</param>
  1443. * <remarks>
  1444. * If slot is 0 the main selection will be displayed and page will represent
  1445. * the offset from the start if there are more than 12 weapons for sale. If
  1446. * stage is 1 the individual confirmation menu for one weapon will show and
  1447. * page will determine which weapon to show.
  1448. * </remarks>
  1449. *//*------------------------------------------------------------------------**/
  1450. static stock Property_GenerateAmmuMenu(playerid, ammu, stage, page)
  1451. {
  1452. new
  1453. Menu:menu = CreateMenu("Ammunation", 2, 270.0, 150.0, 200.0, 50.0),
  1454. slot = page;
  1455. SetMenuColumnHeader(menu, 0, "Weapon");
  1456. SetMenuColumnHeader(menu, 1, "Price");
  1457. if (stage)
  1458. {
  1459. new
  1460. start,
  1461. weapon = Property_GetWeapon(ammu, page, start);
  1462. if (weapon)
  1463. {
  1464. AddMenuItem(menu, 0, Property_WeaponName(start));
  1465. AddMenuItem(menu, 1, numstr(Property_WeaponCost(weapon)));
  1466. }
  1467. }
  1468. else
  1469. {
  1470. new
  1471. weapon,
  1472. start,
  1473. row,
  1474. end = page + 12,
  1475. next = page,
  1476. money = GetPlayerMoney(playerid);
  1477. if (YSI_g_sProperties[ammu][E_PROP_DATA_NAME][MAX_PROP_NAME - 1] - page > 12) end--;
  1478. if (YSI_g_sProperties[ammu][E_PROP_DATA_NAME][MAX_PROP_NAME - 1] > 12 && page)
  1479. {
  1480. end--;
  1481. AddMenuItem(menu, 0, "Back...");
  1482. AddMenuItem(menu, 1, " ");
  1483. }
  1484. while (slot < end && (weapon = Property_GetWeapon(ammu, next, start)))
  1485. {
  1486. new
  1487. cost = Property_WeaponCost(weapon);
  1488. AddMenuItem(menu, 0, Property_WeaponName(start));
  1489. AddMenuItem(menu, 1, numstr(cost));
  1490. if (cost > money) DisableMenuRow(menu, row);
  1491. slot++;
  1492. row++;
  1493. start++;
  1494. next = 0;
  1495. }
  1496. if (end != 12 && Property_GetWeapon(ammu, 0, start))
  1497. {
  1498. AddMenuItem(menu, 0, "Next...");
  1499. AddMenuItem(menu, 1, " ");
  1500. }
  1501. }
  1502. YSI_g_sShopMenu[playerid][E_PROP_AMMU_MENU] = menu;
  1503. YSI_g_sShopMenu[playerid][E_PROP_AMMU_DATA] = ((ammu & 0xFFFF) << 16) | ((slot & 0xFF) << 8) | (stage ? 1 : 0) | 2;
  1504. ShowMenuForPlayer(menu, playerid);
  1505. DestroyMenu(menu);
  1506. }
  1507. /*-------------------------------------------------------------------------*//**
  1508. * Command:
  1509. * sell
  1510. * Parameters:
  1511. * <id> - Property to sell.
  1512. * </returns>
  1513. * <remarks>
  1514. * Sells a property you own if it can be sold.
  1515. * </remarks>
  1516. *//*------------------------------------------------------------------------**/
  1517. YCMD:sell(playerid, params[], help)
  1518. {
  1519. P:2("ycmd_sell() start");
  1520. if (help)
  1521. {
  1522. Text_Send(playerid, $YSI_SELL_HELP_1);
  1523. Text_Send(playerid, $YSI_SELL_HELP_2);
  1524. Text_Send(playerid, $YSI_SELL_HELP_3);
  1525. Text_Send(playerid, $YSI_SELL_HELP_4);
  1526. }
  1527. else
  1528. {
  1529. P:3("ycmd_sell() not help %d", params[0]);
  1530. if (params[0] >= '0' && params[0] <= '9')
  1531. {
  1532. P:5("ycmd_sell() params OK");
  1533. new
  1534. prop = strval(params);
  1535. if (Property_IsActive(prop))
  1536. {
  1537. new
  1538. e_PROP_FLAGS:flag = YSI_g_sProperties[prop][E_PROP_DATA_FLAGS];
  1539. if ((flag & e_PROP_FLAGS_TYPES) == e_PROP_FLAGS_TYPE_PROP)
  1540. {
  1541. if (Property_GetOption(1, flag))
  1542. {
  1543. if (Property_GetOption(2, flag))
  1544. {
  1545. if (Bit_GetBit(YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS], playerid)) Bit_Set(YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS], playerid, 0, PLAYER_BIT_ARRAY);
  1546. else return Text_Send(playerid, $YSI_SELL_CANT);
  1547. }
  1548. else
  1549. {
  1550. if (_:YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS][0] == playerid) YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS][0] = Bit:INVALID_PLAYER_ID;
  1551. else return Text_Send(playerid, $YSI_SELL_CANT);
  1552. }
  1553. new
  1554. cost = ((((YSI_g_sProperties[prop][E_PROP_DATA_DATA_2] >>> 6) & 0x03FFF000) | ((YSI_g_sProperties[prop][E_PROP_DATA_DATA_1] >>> 20) & 0x00000FFF)) * ((Property_GetOption(3, flag)) ? PROPERTY_SELL_PERCENT : 100)) / 100;
  1555. Text_SendFormat(playerid, "YSI_SELL_SOLD", cost);
  1556. #pragma tabsize 4
  1557. #if defined _YSI_VISUAL_PICKUPS
  1558. if (Property_GetOption(5, flag))
  1559. Pickup_Show(_:(flag & e_PROP_FLAGS_LINK), 1);
  1560. else
  1561. #endif
  1562. Checkpoint_SetVisible(_:(flag & e_PROP_FLAGS_LINK), 1);
  1563. #pragma tabsize 4
  1564. GivePlayerMoney(playerid, cost);
  1565. YSI_g_sPropCount[playerid]--;
  1566. Bit_Set(YSI_g_sPlayerProperties[playerid], prop, 0, GROUP_PROPERTY_BITS);
  1567. }
  1568. else Text_Send(playerid, $YSI_SELL_CANT);
  1569. return 1;
  1570. }
  1571. else if ((flag & e_PROP_FLAGS_TYPES) == e_PROP_FLAGS_TYPE_PROP)
  1572. {
  1573. if (_:YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS][0] == playerid)
  1574. {
  1575. new
  1576. cost = YSI_g_sProperties[prop][E_PROP_DATA_NAME][0];
  1577. Text_SendFormat(playerid, "YSI_SELL_SOLD", cost);
  1578. GivePlayerMoney(playerid, cost);
  1579. YSI_g_sHouseCount[playerid]--;
  1580. Bit_Set(YSI_g_sPlayerProperties[playerid], prop, 0, GROUP_PROPERTY_BITS);
  1581. YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS][0] = Bit:INVALID_PLAYER_ID;
  1582. }
  1583. else Text_Send(playerid, $YSI_SELL_CANT);
  1584. return 1;
  1585. }
  1586. }
  1587. }
  1588. Text_Send(playerid, $YSI_SELL_NO_ID);
  1589. }
  1590. return 1;
  1591. }
  1592. /*-------------------------------------------------------------------------*//**
  1593. * <param name="playerid">Player who is banking money.</param>
  1594. * <param name="amount">Amount of money they're banking.</param>
  1595. * <remarks>
  1596. * Does banks and withdrawls.
  1597. * </remarks>
  1598. *//*------------------------------------------------------------------------**/
  1599. stock Property_Bank(playerid, amount)
  1600. {
  1601. if (IsPlayerInCheckpoint(playerid))
  1602. {
  1603. new
  1604. cpid = Checkpoint_Get(playerid),
  1605. prop = YSI_g_sCheckpointPointers[cpid];
  1606. if (prop != NO_PROPERTY)
  1607. {
  1608. new
  1609. e_PROP_FLAGS:flag = YSI_g_sProperties[prop][E_PROP_DATA_FLAGS];
  1610. if (flag & e_PROP_FLAGS_TYPES == e_PROP_FLAGS_TYPE_BANK)
  1611. {
  1612. if ((amount > 0) ? (GetPlayerMoney(playerid) >= amount) : (YSI_g_sMoney[playerid] + amount >= 0))
  1613. {
  1614. YSI_g_sMoney[playerid] += amount;
  1615. GivePlayerMoney(playerid, -amount);
  1616. }
  1617. else return 0;
  1618. }
  1619. else Text_Send(playerid, $YSI_BANK_NOT);
  1620. }
  1621. else Text_Send(playerid, $YSI_BANK_NOT);
  1622. }
  1623. else Text_Send(playerid, $YSI_BANK_CP);
  1624. return 1;
  1625. }
  1626. /*-------------------------------------------------------------------------*//**
  1627. * Command:
  1628. * bank
  1629. * Parameters:
  1630. * <amount> - Value to bank.
  1631. * </returns>
  1632. * <remarks>
  1633. * Calls Property_Bank with positive input amount.
  1634. * </remarks>
  1635. *//*------------------------------------------------------------------------**/
  1636. YCMD:bank(playerid, params[], help)
  1637. {
  1638. if (help)
  1639. {
  1640. Text_Send(playerid, $YSI_BANK_HELP_1);
  1641. Text_Send(playerid, $YSI_BANK_HELP_2);
  1642. Text_Send(playerid, $YSI_BANK_HELP_3);
  1643. Text_SendFormat(playerid, "YSI_BANK_HELP_4", "bank");
  1644. }
  1645. else
  1646. {
  1647. new
  1648. bank = strval(params);
  1649. if (Property_Bank(playerid, bank)) Text_SendFormat(playerid, "YSI_BANK_BANKED", bank, YSI_g_sMoney[playerid]);
  1650. else Text_Send(playerid, $YSI_BANK_INSUFFICIENT);
  1651. }
  1652. return 1;
  1653. }
  1654. /*-------------------------------------------------------------------------*//**
  1655. * Command:
  1656. * balance
  1657. * Parameters:
  1658. * -
  1659. * </returns>
  1660. * <remarks>
  1661. * Displays how much you have in the bank. Does not require you to be in a
  1662. * bank.
  1663. * </remarks>
  1664. *//*------------------------------------------------------------------------**/
  1665. YCMD:balance(playerid, params[], help)
  1666. {
  1667. if (help) Text_Send(playerid, $YSI_BAL_HELP);
  1668. else Text_SendFormat(playerid, "YSI_BANK_BALANCE", YSI_g_sMoney[playerid]);
  1669. return 1;
  1670. }
  1671. /*-------------------------------------------------------------------------*//**
  1672. * Command:
  1673. * withdraw
  1674. * Parameters:
  1675. * <amount> - Amount to withdraw.
  1676. * </returns>
  1677. * <remarks>
  1678. * Calls Property_Bank with negative input amount.
  1679. * </remarks>
  1680. *//*------------------------------------------------------------------------**/
  1681. YCMD:withdraw(playerid, params[], help)
  1682. {
  1683. if (help)
  1684. {
  1685. Text_Send(playerid, $YSI_WITH_HELP1);
  1686. Text_Send(playerid, $YSI_WITH_HELP2);
  1687. Text_Send(playerid, $YSI_WITH_HELP3);
  1688. Text_SendFormat(playerid, "YSI_WITH_HELP4", "withdraw");
  1689. }
  1690. else
  1691. {
  1692. new
  1693. bank = -strval(params);
  1694. if (Property_Bank(playerid, bank)) Text_SendFormat(playerid, "YSI_WITHDREW", bank, YSI_g_sMoney[playerid]);
  1695. else Text_Send(playerid, $YSI_BANK_INSUFFUCUENT);
  1696. }
  1697. return 1;
  1698. }
  1699. /*-------------------------------------------------------------------------*//**
  1700. * Command:
  1701. * buy
  1702. * Parameters:
  1703. * -
  1704. * </returns>
  1705. * <remarks>
  1706. * Allows you to purchase the property you are at.
  1707. * </remarks>
  1708. *//*------------------------------------------------------------------------**/
  1709. YCMD:buy(playerid, params[], help)
  1710. {
  1711. P:2("ycmd_buy() start");
  1712. if (help)
  1713. {
  1714. Text_Send(playerid, $YSI_BUY_HELP_1);
  1715. Text_Send(playerid, $YSI_BUY_HELP_2);
  1716. Text_Send(playerid, $YSI_BUY_HELP_3);
  1717. Text_Send(playerid, $YSI_BUY_HELP_4);
  1718. }
  1719. else
  1720. {
  1721. P:3("ycmd_buy() Not help");
  1722. new
  1723. cpid,
  1724. prop = NO_PROPERTY;
  1725. if (IsPlayerInCheckpoint(playerid))
  1726. {
  1727. P:4("ycmd_buy() Checkpoint");
  1728. cpid = Checkpoint_Get(playerid);
  1729. if (cpid != NO_CHECKPOINT)
  1730. {
  1731. prop = YSI_g_sCheckpointPointers[cpid];
  1732. }
  1733. }
  1734. #if defined _YSI_VISUAL_PICKUPS
  1735. #pragma tabsize 4
  1736. else if (YSI_g_sPickupTimer[playerid] != -1)
  1737. {
  1738. cpid = YSI_g_sPlayerPickup[playerid];
  1739. if (cpid != NO_PICKUP)
  1740. {
  1741. prop = YSI_g_sPickupPointers[cpid];
  1742. }
  1743. P:4("ycmd_buy() Pickup %d", cpid);
  1744. }
  1745. #pragma tabsize 4
  1746. #endif
  1747. else
  1748. {
  1749. P:4("ycmd_buy() Not in a checkpoint");
  1750. Text_Send(playerid, $YSI_PROP_CP);
  1751. return 1;
  1752. }
  1753. P:4("ycmd_buy() Prop %d", prop);
  1754. if (prop != NO_PROPERTY)
  1755. {
  1756. new
  1757. e_PROP_FLAGS:flag = YSI_g_sProperties[prop][E_PROP_DATA_FLAGS];
  1758. if (flag & e_PROP_FLAGS_TYPES == e_PROP_FLAGS_TYPE_PROP)
  1759. {
  1760. if (YSI_g_sPropCount[playerid] < YSI_g_sMaxPlayerProps)
  1761. {
  1762. new
  1763. price = ((YSI_g_sProperties[prop][E_PROP_DATA_DATA_2] >>> 6) & 0x03FFF000) | ((YSI_g_sProperties[prop][E_PROP_DATA_DATA_1] >>> 20) & 0x00000FFF);
  1764. if (GetPlayerMoney(playerid) >= price)
  1765. {
  1766. if (Property_GetOption(2, flag))
  1767. {
  1768. if (Bit_GetBit(YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS], playerid))
  1769. {
  1770. Text_Send(playerid, $YSI_PROP_OWN);
  1771. return 1;
  1772. }
  1773. Bit_Set(YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS], playerid, 1, PLAYER_BIT_ARRAY);
  1774. }
  1775. else
  1776. {
  1777. new
  1778. owner = _:YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS][0];
  1779. if (owner == playerid)
  1780. {
  1781. Text_Send(playerid, $YSI_PROP_OWN);
  1782. return 1;
  1783. }
  1784. if (IsPlayerConnected(owner))
  1785. {
  1786. GivePlayerMoney(owner, price);
  1787. Text_SendFormat(owner, "YSI_PROP_OUT", YSI_g_sProperties[prop][E_PROP_DATA_NAME], ReturnPlayerName(playerid), playerid);
  1788. }
  1789. YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS][0] = Bit:playerid;
  1790. if (Property_GetOption(1, flag))
  1791. {
  1792. #if defined _YSI_VISUAL_PICKUPS
  1793. if (Property_GetOption(5, flag))
  1794. Pickup_Show(cpid, 0);
  1795. else
  1796. #endif
  1797. Checkpoint_SetVisible(cpid, 0);
  1798. }
  1799. else if (YSI_g_sRebuyDelay)
  1800. {
  1801. SetTimerEx("Property_ResetRebuy", YSI_g_sRebuyDelay, 0, "i", prop);
  1802. #if defined _YSI_VISUAL_PICKUPS
  1803. if (Property_GetOption(5, flag))
  1804. Pickup_Show(cpid, 0);
  1805. else
  1806. #endif
  1807. Checkpoint_SetVisible(cpid, 0);
  1808. }
  1809. }
  1810. YSI_g_sPropCount[playerid]++;
  1811. GivePlayerMoney(playerid, -price);
  1812. Text_SendFormat(playerid, "YSI_PROP_BOUGHT", YSI_g_sProperties[prop][E_PROP_DATA_NAME], price);
  1813. Text_SendToAllFormat("YSI_PROP_ANN", ReturnPlayerName(playerid), YSI_g_sProperties[prop][E_PROP_DATA_NAME]);
  1814. if (Property_GetOption(4, flag))
  1815. {
  1816. price = (price * PROPERTY_INCREASE_PERCENT) / 100;
  1817. YSI_g_sProperties[prop][E_PROP_DATA_DATA_1] = (YSI_g_sProperties[prop][E_PROP_DATA_DATA_1] & 0xFFFFF) | ((price & 0x00000FFF) << 20);
  1818. YSI_g_sProperties[prop][E_PROP_DATA_DATA_2] = (YSI_g_sProperties[prop][E_PROP_DATA_DATA_2] & 0x3FFFF) | ((price & 0x03FFF000) << 6);
  1819. }
  1820. if (Property_GetOption(1, flag)) Text_SendFormat(playerid, "YSI_PROP_SELL", "sell", prop, (price * ((Property_GetOption(3, flag)) ? PROPERTY_SELL_PERCENT : 100)) / 100);
  1821. }
  1822. else Text_Send(playerid, $YSI_PROP_AFFORD);
  1823. }
  1824. else Text_Send(playerid, $YSI_PROP_MAX);
  1825. }
  1826. else if (flag & e_PROP_FLAGS_TYPES == e_PROP_FLAGS_TYPE_HOUS)
  1827. {
  1828. if (YSI_g_sHouseCount[playerid] < YSI_g_sMaxPlayerHouses)
  1829. {
  1830. new
  1831. owner = _:YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS][0];
  1832. if (owner == INVALID_PLAYER_ID)
  1833. {
  1834. new
  1835. price = YSI_g_sProperties[prop][E_PROP_DATA_NAME][6];
  1836. if (GetPlayerMoney(playerid) >= price)
  1837. {
  1838. YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS][0] = Bit:playerid;
  1839. YSI_g_sHouseCount[playerid]++;
  1840. GivePlayerMoney(playerid, -price);
  1841. Text_SendFormat(playerid, "YSI_PROP_BOUGHT_HOUSE", price);
  1842. Text_SendFormat(playerid, "YSI_PROP_SELL", "sell", prop, price);
  1843. }
  1844. else Text_Send(playerid, $YSI_PROP_AFFORD);
  1845. }
  1846. else if (owner == playerid) Text_Send(playerid, $YSI_PROP_YOURS);
  1847. else Text_SendFormat(playerid, "YSI_PROP_HOUSE_OWNED", ReturnPlayerName(owner));
  1848. }
  1849. else Text_Send(playerid, $YSI_PROP_MAX_HOUSE);
  1850. }
  1851. else Text_Send(playerid, $YSI_PROP_NOT);
  1852. }
  1853. else Text_Send(playerid, $YSI_PROP_NOT);
  1854. }
  1855. return 1;
  1856. #pragma unused params
  1857. }
  1858. /*-------------------------------------------------------------------------*//**
  1859. * <param name="prop">Property to make available.</param>
  1860. * <remarks>
  1861. * Makes a property available for purchase after a delay.
  1862. * </remarks>
  1863. *//*------------------------------------------------------------------------**/
  1864. forward Property_ResetRebuy(property);
  1865. public Property_ResetRebuy(property)
  1866. {
  1867. if (Property_IsActive(property))
  1868. {
  1869. new
  1870. e_PROP_FLAGS:flag = YSI_g_sProperties[property][E_PROP_DATA_FLAGS];
  1871. if ((flag & e_PROP_FLAGS_TYPES) == e_PROP_FLAGS_TYPE_PROP)
  1872. {
  1873. #pragma tabsize 4
  1874. #if defined _YSI_VISUAL_PICKUPS
  1875. if (Property_GetOption(5, flag))
  1876. Pickup_Show(_:(flag & e_PROP_FLAGS_LINK), 1);
  1877. else
  1878. #endif
  1879. Checkpoint_SetVisible(_:(flag & e_PROP_FLAGS_LINK), 1);
  1880. #pragma tabsize 4
  1881. }
  1882. }
  1883. }
  1884. /*-------------------------------------------------------------------------*//**
  1885. * <remarks>
  1886. * Does the main processing for the library. Removes or kills people in areas
  1887. * they shouldn't be and gives out money to people who earnt it.
  1888. * </remarks>
  1889. *//*------------------------------------------------------------------------**/
  1890. ptask Property_Loop[500](i)
  1891. {
  1892. static
  1893. Float:s_fLastGoodPos[MAX_PLAYERS][3];//,
  1894. // sLastTick = 0;
  1895. //new
  1896. // currentTick = GetTickCount(),
  1897. // elapse = currentTick - sLastTick;
  1898. /*for (new i = 0; i < MAX_PROPERTIES; i++)
  1899. {
  1900. new
  1901. flags = YSI_g_sProperties[i][E_PROP_DATA_FLAGS];
  1902. if (flags & _:e_PROP_FLAGS_ACTIVE)
  1903. {
  1904. switch (flags & _:e_PROP_FLAGS_TYPES)
  1905. {
  1906. case e_PROP_FLAGS_TYPE_MONP, e_PROP_FLAGS_TYPE_MONA:
  1907. {
  1908. new
  1909. time = YSI_g_sProperties[i][E_PROP_DATA_DATA_2];
  1910. if (!time) time = YSI_g_sProperties[i][E_PROP_DATA_NAME][0];
  1911. time -= elapse;
  1912. if (time < 0) time = 0;
  1913. YSI_g_sProperties[i][E_PROP_DATA_DATA_2] = time;
  1914. }
  1915. case e_PROP_FLAGS_TYPE_PROP:
  1916. {
  1917. new
  1918. time = YSI_g_sProperties[i][E_PROP_DATA_NAME][MAX_PROP_NAME - 1];
  1919. if (!time) time = YSI_g_sProperties[i][E_PROP_DATA_DATA_1] & 0x000FFFFF;
  1920. time -= elapse;
  1921. if (time <= 0) time = 0;
  1922. YSI_g_sProperties[i][E_PROP_DATA_NAME][MAX_PROP_NAME - 1] = time;
  1923. }
  1924. }
  1925. }
  1926. }
  1927. FOREACH__ (Player, i)
  1928. {*/
  1929. P:3("Property_Loop() foreach start");
  1930. new
  1931. money,
  1932. bad;
  1933. for (new j = 0; j < GROUP_PROPERTY_BITS; j++)
  1934. {
  1935. new
  1936. props = _:YSI_g_sPlayerProperties[i][j],
  1937. slot = 1,
  1938. bit;
  1939. while (props)
  1940. {
  1941. if (props & slot)
  1942. {
  1943. new
  1944. property = (j * 32) + bit,
  1945. flags = YSI_g_sProperties[property][E_PROP_DATA_FLAGS];
  1946. if (flags & _:e_PROP_FLAGS_ACTIVE)
  1947. {
  1948. switch (flags & _:e_PROP_FLAGS_TYPES)
  1949. {
  1950. case e_PROP_FLAGS_TYPE_MONP, e_PROP_FLAGS_TYPE_MONA:
  1951. if (!YSI_g_sProperties[property][E_PROP_DATA_DATA_2]) GivePlayerMoney(i, YSI_g_sProperties[property][E_PROP_DATA_DATA_1]);
  1952. case e_PROP_FLAGS_TYPE_PROP:
  1953. {
  1954. if (((Property_GetOption(2, flags)) ? (_:Bit_GetBit(YSI_g_sProperties[property][E_PROP_DATA_PLAYERS], i)) : (_:(YSI_g_sProperties[property][E_PROP_DATA_PLAYERS][0] == Bit:i))) && !YSI_g_sProperties[property][E_PROP_DATA_NAME][MAX_PROP_NAME - 1]) money += YSI_g_sProperties[property][E_PROP_DATA_DATA_2] & 0x3FFFF;
  1955. }
  1956. case e_PROP_FLAGS_TYPE_RSRC:
  1957. {
  1958. if (Property_GetOption(1, flags))
  1959. {
  1960. SetPlayerPos(i, s_fLastGoodPos[i][0], s_fLastGoodPos[i][1], s_fLastGoodPos[i][2]);
  1961. bad = 1;
  1962. }
  1963. else
  1964. {
  1965. new Float:health;
  1966. GetPlayerHealth(i, health);
  1967. SetPlayerHealth(i, health - YSI_g_sProperties[property][E_PROP_DATA_DATA_2]);
  1968. }
  1969. }
  1970. }
  1971. }
  1972. props ^= slot;
  1973. }
  1974. slot <<= 1;
  1975. bit++;
  1976. }
  1977. }
  1978. if (money)
  1979. {
  1980. Text_Send(i, $YSI_PROP_EARNT, money);
  1981. GivePlayerMoney(i, money);
  1982. }
  1983. if (!bad) GetPlayerPos(i, s_fLastGoodPos[i][0], s_fLastGoodPos[i][1], s_fLastGoodPos[i][2]);
  1984. P:3("Property_Loop() foreach end");
  1985. //}
  1986. //sLastTick = currentTick;
  1987. }
  1988. /*-------------------------------------------------------------------------*//**
  1989. * <param name="flags">Property data to check.</param>
  1990. * <param name="playerid">Player to check for.</param>
  1991. *//*------------------------------------------------------------------------**/
  1992. P:D(bool:Property_IsPlayerProperty(e_PROP_FLAGS:flags,playerid));
  1993. #define Property_IsPlayerProperty(%1,%2) \
  1994. ((%1) & e_PROP_FLAGS_ACTIVE && (%1) & e_PROP_FLAGS_TYPES == e_PROP_FLAGS_TYPE_PROP && Checkpoint_HasPlayerNoWorld(_:((%1) & e_PROP_FLAGS_LINK), (%2)))
  1995. /*-------------------------------------------------------------------------*//**
  1996. * <param name="playerid">Player to count for.</param>
  1997. * <remarks>
  1998. * Gets the number of properties this player could theoretically own.
  1999. * </remarks>
  2000. *//*------------------------------------------------------------------------**/
  2001. stock Property_GetPlayerPropCount(playerid)
  2002. {
  2003. new
  2004. count;
  2005. for (new i = 0; i < MAX_PROPERTIES; i++)
  2006. {
  2007. new
  2008. e_PROP_FLAGS:flags = YSI_g_sProperties[i][E_PROP_DATA_FLAGS];
  2009. if (Property_IsPlayerProperty(flags, playerid)) count++;
  2010. }
  2011. return count;
  2012. }
  2013. /*-------------------------------------------------------------------------*//**
  2014. * <param name="playerid">Player to get properties of.</param>
  2015. * <param name="properties">Array to return properties in.</param>
  2016. * <remarks>
  2017. * Gets the properties currently owned by this player.
  2018. * </remarks>
  2019. *//*------------------------------------------------------------------------**/
  2020. stock Property_GetPropertyBits(playerid, Bit:properties[])
  2021. {
  2022. if (playerid < 0 || playerid >= MAX_PLAYERS) return 0;
  2023. for (new i = 0; i < MAX_PROPERTIES; i++)
  2024. {
  2025. new
  2026. e_PROP_FLAGS:flags = YSI_g_sProperties[i][E_PROP_DATA_FLAGS];
  2027. if (flags & e_PROP_FLAGS_ACTIVE && flags & e_PROP_FLAGS_TYPES == e_PROP_FLAGS_TYPE_PROP && ((Property_GetOption(2, flags)) ? (_:Bit_GetBit(YSI_g_sProperties[i][E_PROP_DATA_PLAYERS], playerid)) : (_:(_:YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][0] == playerid)))) Bit_Set(properties, i, 1, GROUP_PROPERTY_BITS);
  2028. }
  2029. return 1;
  2030. }
  2031. /*-------------------------------------------------------------------------*//**
  2032. * Command:
  2033. * properties
  2034. * Parameters:
  2035. * <page> - Page of properties to view (optional).
  2036. * </returns>
  2037. * <remarks>
  2038. * Lista all properties available to a player and who owns them.
  2039. * </remarks>
  2040. *//*------------------------------------------------------------------------**/
  2041. YCMD:properties(playerid, params[], help)
  2042. {
  2043. if (help)
  2044. {
  2045. Text_Send(playerid, $YSI_LIST_HELP_1);
  2046. Text_Send(playerid, $YSI_LIST_HELP_2);
  2047. Text_Send(playerid, $YSI_LIST_HELP_3);
  2048. return 1;
  2049. }
  2050. new
  2051. props = Property_GetPlayerPropCount(playerid),
  2052. pages = (props + 7) / 8,
  2053. page = strval(params);
  2054. if (props > 8)
  2055. {
  2056. if (page)
  2057. {
  2058. if (page <= pages)
  2059. {
  2060. for (new i = 0, j = 0, k = (page - 1) * 8, n = k + 8; i < MAX_PROPERTIES && j < n; i++)
  2061. {
  2062. new
  2063. e_PROP_FLAGS:flags = YSI_g_sProperties[i][E_PROP_DATA_FLAGS];
  2064. if (Property_IsPlayerProperty(flags, playerid))
  2065. {
  2066. if (j >= k)
  2067. {
  2068. if (Property_GetOption(2, flags)) Text_SendFormat(playerid, "YSI_LIST_MULTI", YSI_g_sProperties[i][E_PROP_DATA_NAME], Bit_GetCount(YSI_g_sProperties[i][E_PROP_DATA_PLAYERS], PLAYER_BIT_ARRAY));
  2069. else Text_SendFormat(playerid, "YSI_LIST_FORM", YSI_g_sProperties[i][E_PROP_DATA_NAME], ReturnPlayerName(_:YSI_g_sProperties[i][E_PROP_DATA_PLAYERS][0]));
  2070. }
  2071. j++;
  2072. }
  2073. }
  2074. }
  2075. else Text_SendFormat(playerid, "YSI_LIST_PAGES", "properties", pages);
  2076. }
  2077. else
  2078. {
  2079. Text_Send(playerid, $YSI_LIST_MORE);
  2080. Text_SendFormat(playerid, "YSI_LIST_PAGES", "properties", pages);
  2081. }
  2082. }
  2083. else if (props)
  2084. {
  2085. for (new j = 0, i = 0; i < props && j < MAX_PROPERTIES; j++)
  2086. {
  2087. new
  2088. e_PROP_FLAGS:flags = YSI_g_sProperties[j][E_PROP_DATA_FLAGS];
  2089. if (Property_IsPlayerProperty(flags, playerid))
  2090. {
  2091. if (Property_GetOption(2, flags)) Text_SendFormat(playerid, "YSI_LIST_MULTI", YSI_g_sProperties[j][E_PROP_DATA_NAME], Bit_GetCount(YSI_g_sProperties[j][E_PROP_DATA_PLAYERS], PLAYER_BIT_ARRAY));
  2092. else Text_SendFormat(playerid, "YSI_LIST_FORM", YSI_g_sProperties[j][E_PROP_DATA_NAME], ReturnPlayerName(_:YSI_g_sProperties[j][E_PROP_DATA_PLAYERS][0]));
  2093. i++;
  2094. }
  2095. }
  2096. }
  2097. else Text_Send(playerid, $YSI_LIST_NONE);
  2098. return 1;
  2099. }
  2100. /*-------------------------------------------------------------------------*//**
  2101. * <param name="property">Property to get link of.</param>
  2102. * <remarks>
  2103. * Returns a reference to the area or checkpoint used by this property or
  2104. * NO_PROPERTY on fail.
  2105. * </remarks>
  2106. *//*------------------------------------------------------------------------**/
  2107. stock Property_GetLink(property)
  2108. {
  2109. if (Property_IsActive(property)) return _:(YSI_g_sProperties[property][E_PROP_DATA_FLAGS] & e_PROP_FLAGS_LINK);
  2110. return NO_PROPERTY;
  2111. }
  2112. /*-------------------------------------------------------------------------*//**
  2113. * Command:
  2114. * enter
  2115. * Parameters:
  2116. * -
  2117. * </returns>
  2118. * <remarks>
  2119. * Allows you to enter a house you own.
  2120. * </remarks>
  2121. *//*------------------------------------------------------------------------**/
  2122. YCMD:enter(playerid, params[], help)
  2123. {
  2124. P:2("ycmd_enter() start");
  2125. if (help)
  2126. {
  2127. Text_Send(playerid, $YSI_ENTER_HELP_1);
  2128. Text_Send(playerid, $YSI_ENTER_HELP_2);
  2129. }
  2130. else
  2131. {
  2132. P:3("ycmd_enter() Not help");
  2133. new
  2134. cpid,
  2135. prop = NO_PROPERTY;
  2136. if (IsPlayerInCheckpoint(playerid))
  2137. {
  2138. P:4("ycmd_enter() Checkpoint");
  2139. cpid = Checkpoint_Get(playerid);
  2140. if (cpid != NO_CHECKPOINT)
  2141. {
  2142. prop = YSI_g_sCheckpointPointers[cpid];
  2143. }
  2144. }
  2145. #if defined _YSI_VISUAL_PICKUPS
  2146. #pragma tabsize 4
  2147. else if (YSI_g_sPickupTimer[playerid] != -1)
  2148. {
  2149. cpid = YSI_g_sPlayerPickup[playerid];
  2150. if (cpid != NO_PICKUP)
  2151. {
  2152. prop = YSI_g_sPickupPointers[cpid];
  2153. }
  2154. P:4("ycmd_enter() Pickup %d", cpid);
  2155. }
  2156. #endif
  2157. #pragma tabsize 4
  2158. P:4("ycmd_enter() Prop %d", prop);
  2159. if (prop != NO_PROPERTY)
  2160. {
  2161. new
  2162. e_PROP_FLAGS:flag = YSI_g_sProperties[prop][E_PROP_DATA_FLAGS];
  2163. if (flag & e_PROP_FLAGS_TYPES == e_PROP_FLAGS_TYPE_HOUS)
  2164. {
  2165. if (_:YSI_g_sProperties[prop][E_PROP_DATA_PLAYERS][0] == playerid)
  2166. {
  2167. SetPlayerInterior(playerid, YSI_g_sProperties[prop][E_PROP_DATA_DATA_1]);
  2168. SetPlayerVirtualWorld(playerid, YSI_g_sProperties[prop][E_PROP_DATA_DATA_2]);
  2169. SetPlayerPos(playerid, Float:YSI_g_sProperties[prop][E_PROP_DATA_NAME][3], Float:YSI_g_sProperties[prop][E_PROP_DATA_NAME][4], Float:YSI_g_sProperties[prop][E_PROP_DATA_NAME][5]);
  2170. YSI_g_sCurrentHouse[playerid] = prop;
  2171. }
  2172. else Text_Send(playerid, $YSI_ENTER_NOT_YOURS);
  2173. }
  2174. else Text_Send(playerid, $YSI_ENTER_NO_HOUSE);
  2175. }
  2176. else Text_Send(playerid, $YSI_ENTER_NO_HOUSE);
  2177. }
  2178. return 1;
  2179. #pragma unused params
  2180. }
  2181. /*-------------------------------------------------------------------------*//**
  2182. * Command:
  2183. * exit
  2184. * Parameters:
  2185. * -
  2186. * </returns>
  2187. * <remarks>
  2188. * Allows you to exit a house you own.
  2189. * </remarks>
  2190. *//*------------------------------------------------------------------------**/
  2191. YCMD:exit(playerid, params[], help)
  2192. {
  2193. P:2("ycmd_enter() start");
  2194. if (help)
  2195. {
  2196. Text_Send(playerid, $YSI_EXIT_HELP_1);
  2197. }
  2198. else
  2199. {
  2200. new
  2201. prop = YSI_g_sCurrentHouse[playerid];
  2202. if (prop != -1)
  2203. {
  2204. if (IsPlayerInRangeOfPoint(playerid, 3.0, Float:YSI_g_sProperties[prop][E_PROP_DATA_NAME][3], Float:YSI_g_sProperties[prop][E_PROP_DATA_NAME][4], Float:YSI_g_sProperties[prop][E_PROP_DATA_NAME][5]))
  2205. {
  2206. YSI_g_sCurrentHouse[playerid] = -1;
  2207. SetPlayerInterior(playerid, 0);
  2208. SetPlayerVirtualWorld(playerid, 0);
  2209. SetPlayerPos(playerid, Float:YSI_g_sProperties[prop][E_PROP_DATA_NAME][0], Float:YSI_g_sProperties[prop][E_PROP_DATA_NAME][1], Float:YSI_g_sProperties[prop][E_PROP_DATA_NAME][2]);
  2210. }
  2211. else Text_Send(playerid, $YSI_EXIT_NEAR);
  2212. }
  2213. else Text_Send(playerid, $YSI_EXIT_NOT_IN);
  2214. }
  2215. return 1;
  2216. }