y_properties.inc 84 KB

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