y_properties.inc 85 KB

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