PPC_Dialogs.inc 115 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930
  1. // Process the Register-dialog
  2. Dialog_Register(playerid, response, inputtext[])
  3. {
  4. new file[100], Name[MAX_PLAYER_NAME]; // Setup local variables
  5. GetPlayerName(playerid, Name, sizeof(Name)); // Get the playername
  6. format(file, sizeof(file), PlayerFile, Name); // Construct the complete filename for this player's account
  7. switch (response) // Check which button was clicked
  8. {
  9. case 1: // Player clicked "Register"
  10. {
  11. // Check if the player entered a password
  12. if(strlen(inputtext)>0)
  13. {
  14. // Store the password
  15. format(APlayerData[playerid][PlayerPassword], 50, "%s", inputtext);
  16. // Create the file and save default data to it, then reload it (so all data is put into the correct place)
  17. PlayerFile_Create(playerid);
  18. PlayerFile_Load(playerid);
  19. // Send a message to the client to inform him that his account has been registered
  20. SendClientMessage(playerid, 0xFFFFFFFF, TXT_AccountRegistered);
  21. APlayerData[playerid][LoggedIn] = true; // The player has logged in properly
  22. }
  23. else
  24. {
  25. SendClientMessage(playerid, 0xFFFFFFFF, TXT_WrongPassword);
  26. Kick(playerid);
  27. }
  28. }
  29. case 0: // Player clicked "Cancel"
  30. {
  31. // Show a message that the player must be registered to play on this server
  32. SendClientMessage(playerid, 0xFFFFFFFF, TXT_PlayerMustRegister);
  33. // Kick the player
  34. Kick(playerid);
  35. }
  36. }
  37. return 1;
  38. }
  39. // Process the login-dialog
  40. Dialog_Login(playerid, response, inputtext[])
  41. {
  42. switch (response) // Check which button was clicked
  43. {
  44. case 1: // Player clicked "Login"
  45. {
  46. // Check if the player entered a password
  47. if (strlen(inputtext) > 0)
  48. {
  49. // Check if the entered password is the same as the password saved in the player's account
  50. if (strcmp(APlayerData[playerid][PlayerPassword], inputtext, false) == 0)
  51. {
  52. APlayerData[playerid][LoggedIn] = true; // The player has logged in properly
  53. BankFile_Load(playerid); // Load your bank account (if it exists, the player will be notified about this)
  54. SendClientMessage(playerid, 0xFFFFFFFF, TXT_LoggedIn); // Send a message to the client to inform him that he logged in properly
  55. }
  56. else
  57. {
  58. SendClientMessage(playerid, 0xFFFFFFFF, TXT_WrongPassword);
  59. Kick(playerid);
  60. }
  61. }
  62. else
  63. {
  64. SendClientMessage(playerid, 0xFFFFFFFF, TXT_WrongPassword);
  65. Kick(playerid);
  66. }
  67. }
  68. case 0: // Player clicked "Cancel"
  69. {
  70. // Show a message that the player must be logged in to play on this server
  71. SendClientMessage(playerid, 0xFFFFFFFF, TXT_PlayerMustLogin);
  72. // Kick the player
  73. Kick(playerid);
  74. }
  75. }
  76. return 1;
  77. }
  78. // Process the rescue dialog
  79. Dialog_Rescue(playerid, response, listitem)
  80. {
  81. // Just close the dialog if the player clicked "Cancel"
  82. if(!response) return 1;
  83. // Check the class of the player
  84. switch (APlayerData[playerid][PlayerClass])
  85. {
  86. case ClassTruckDriver:
  87. {
  88. // Set the spawn coordinates based on the selection in the list
  89. switch (listitem)
  90. {
  91. case 0: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), -525.0, -502.0, 26.0, 0.0, 0, 0, 0, 0, 0, 0);
  92. case 1: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), -74.7, -1137.5, 4.5, 0.0, 0, 0, 0, 0, 0, 0);
  93. case 2: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), 1457.0, 975.5, 11.0, 0.0, 0, 0, 0, 0, 0, 0);
  94. case 3: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), -2136.0, -247.5, 36.5, 270.0, 0, 0, 0, 0, 0, 0);
  95. case 4: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), 1766.5, -2040.7, 14.0, 270.0, 0, 0, 0, 0, 0, 0);
  96. case 5: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), -546.0, 2594.0, 54.0, 270.0, 0, 0, 0, 0, 0, 0);
  97. case 6: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), 332.0, 900.0, 25.0, 205.0, 0, 0, 0, 0, 0, 0);
  98. case 7: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), -1575.0, -2724.0, 49.0, 146.0, 0, 0, 0, 0, 0, 0);
  99. }
  100. }
  101. case ClassBusDriver:
  102. {
  103. // Set the spawn coordinates based on the selection in the list
  104. switch (listitem)
  105. {
  106. case 0: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), 1809.0, -1905.0, 13.6, 90.0, 0, 0, 0, 0, 0, 0);
  107. case 1: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), -1983.0, 110.0, 27.7, 180.0, 0, 0, 0, 0, 0, 0);
  108. case 2: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), 1060.0, 1260.0, 11.0, 270.0, 0, 0, 0, 0, 0, 0);
  109. }
  110. }
  111. case ClassPilot:
  112. {
  113. // Set the spawn coordinates based on the selection in the list
  114. switch (listitem)
  115. {
  116. case 0: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), 2010.0, -2345.0, 13.6, 90.0, 0, 0, 0, 0, 0, 0);
  117. case 1: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), -1211.0, -105.0, 14.2, 135.0, 0, 0, 0, 0, 0, 0);
  118. case 2: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), 1630.0, 1615.0, 10.9, 90.0, 0, 0, 0, 0, 0, 0);
  119. }
  120. }
  121. case ClassPolice:
  122. {
  123. // Set the spawn coordinates based on the selection in the list
  124. switch (listitem)
  125. {
  126. case 0: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), 1568.5, -1693.5, 6.0, 180.0, 0, 0, 0, 0, 0, 0);
  127. case 1: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), -1590.0, 716.25, -5.0, 270.0, 0, 0, 0, 0, 0, 0);
  128. case 2: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), 2275.0, 2460.0, 10.9, 90.0, 0, 0, 0, 0, 0, 0);
  129. }
  130. }
  131. case ClassCourier:
  132. {
  133. // Set the spawn coordinates based on the selection in the list
  134. switch (listitem)
  135. {
  136. case 0: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), 798.0, -618.75, 16.4, 0.0, 0, 0, 0, 0, 0, 0);
  137. case 1: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), -1849.25, -135.0, 12.0, 90.0, 0, 0, 0, 0, 0, 0);
  138. case 2: SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), 1050.5, 1931.0, 10.9, 270.0, 0, 0, 0, 0, 0, 0);
  139. }
  140. }
  141. }
  142. SpawnPlayer(playerid); // Force the player to spawn at the requested coordinates
  143. SendClientMessage(playerid, 0xFFFFFFFF, TXT_PlayerRescued); // Send the player a message that using "/rescue" costs $200
  144. // Reduce the player's money by 200
  145. RewardPlayer(playerid, -200, 0);
  146. return 1;
  147. }
  148. // Process the BuyLicense dialog
  149. Dialog_BuyLicenses(playerid, response, listitem)
  150. {
  151. // Just close the dialog if the player clicked "Cancel"
  152. if(!response) return 1;
  153. switch (listitem)
  154. {
  155. case 0: // Player wants to buy a trucker license
  156. {
  157. // Check if the player is a trucker
  158. if (APlayerData[playerid][PlayerClass] == ClassTruckDriver)
  159. {
  160. // Check if the player hasn't acquired his trucker's license yet
  161. if (APlayerData[playerid][TruckerLicense] == 0)
  162. {
  163. // Check if the player has enough money and enough score
  164. if ((APlayerData[playerid][PlayerMoney] >= 50000) && (APlayerData[playerid][PlayerScore] >= 100))
  165. {
  166. // Withdraw the money and score from the player's account
  167. RewardPlayer(playerid, -50000, -100);
  168. // Give the player the trucker's license
  169. APlayerData[playerid][TruckerLicense] = 1;
  170. // Let the player know he acquired his trucker's license
  171. SendClientMessage(playerid, 0xFFFFFFFF, TXT_TruckerLicenseBought);
  172. }
  173. else
  174. SendClientMessage(playerid, 0xFFFFFFFF, TXT_TruckerLicenseNotEnoughMoney);
  175. }
  176. else
  177. SendClientMessage(playerid, 0xFFFFFFFF, TXT_TruckerLicenseOwned);
  178. }
  179. else
  180. SendClientMessage(playerid, 0xFFFFFFFF, TXT_TruckerLicenseWrongClass);
  181. }
  182. case 1: // Player wants to buy a busdriver license
  183. {
  184. // Check if the player is a busdriver
  185. if (APlayerData[playerid][PlayerClass] == ClassBusDriver)
  186. {
  187. // Check if the player hasn't acquired his busdriver's license yet
  188. if (APlayerData[playerid][BusLicense] == 0)
  189. {
  190. // Check if the player has enough money and enough score
  191. if ((APlayerData[playerid][PlayerMoney] >= 25000) && (APlayerData[playerid][PlayerScore] >= 50))
  192. {
  193. // Withdraw the money and score from the player's account
  194. RewardPlayer(playerid, -25000, -50);
  195. // Give the player the busdriver's license
  196. APlayerData[playerid][BusLicense] = 1;
  197. // Let the player know he acquired his busdriver's license
  198. SendClientMessage(playerid, 0xFFFFFFFF, TXT_BusLicenseBought);
  199. }
  200. else
  201. SendClientMessage(playerid, 0xFFFFFFFF, TXT_BusLicenseNotEnoughMoney);
  202. }
  203. else
  204. SendClientMessage(playerid, 0xFFFFFFFF, TXT_BusLicenseOwned);
  205. }
  206. else
  207. SendClientMessage(playerid, 0xFFFFFFFF, TXT_BusLicenseWrongClass);
  208. }
  209. }
  210. return 1;
  211. }
  212. // Process the work dialog for licensed truckers (show the list of loads after the player selected to choose his own load)
  213. Dialog_TruckerSelectJobMethod(playerid, response, listitem)
  214. {
  215. // Setup local variables
  216. new ProductList[50], NumProducts, TotalLoadList[1000];
  217. // Just close the dialog if the player clicked "Cancel"
  218. if(!response) return 1;
  219. // Select what to do after the player chose "Select your own load" or "Auto assigned load"
  220. switch (listitem)
  221. {
  222. case 0: // Let the player choose his own load
  223. {
  224. switch (GetVehicleModel(GetPlayerVehicleID(playerid))) // Check the vehicle-model of the player to decide which loads the player can carry
  225. {
  226. case VehicleFlatbed, VehicleDFT30: // If the player's vehicle is a "Flatbed" or "DFT-30"
  227. ProductList = Product_GetList(PCV_TruckerNoTrailer, NumProducts); // Build a list of products defined for truckers without a trailer
  228. case VehicleCementTruck: // If the player's vehicle is a "CementTruck"
  229. ProductList = Product_GetList(PCV_TruckerCementTruck, NumProducts); // Build a list of products defined for truckers witha cement truck
  230. case VehicleLineRunner, VehicleTanker, VehicleRoadTrain: // If the player's vehicle is a "LineRunner", "Tanker" or "RoadTrain"
  231. {
  232. switch (GetVehicleModel(GetVehicleTrailer(GetPlayerVehicleID(playerid)))) // Select the loads based on the trailer model of the player
  233. {
  234. case VehicleTrailerCargo, VehicleTrailerCargo2: // A cargo-trailer is attached
  235. ProductList = Product_GetList(PCV_TruckerCargoTrailer, NumProducts); // Build a list of products defined for truckers with a cargo-trailer
  236. case VehicleTrailerOre: // An Ore-trailer is attached
  237. ProductList = Product_GetList(PCV_TruckerOreTrailer, NumProducts); // Build a list of products defined for truckers with an ore-trailer
  238. case VehicleTrailerFluids: // A fluids-trailer is attached
  239. ProductList = Product_GetList(PCV_TruckerFluidsTrailer, NumProducts); // Build a list of products defined for truckers with a fluids-trailer
  240. }
  241. }
  242. }
  243. // Build the List with product-names
  244. for (new i; i < NumProducts; i++)
  245. format(TotalLoadList, 1000, "%s%s\n", TotalLoadList, ALoads[ProductList[i]][LoadName]);
  246. // Let the player choose a load
  247. ShowPlayerDialog(playerid, DialogTruckerSelectLoad, DIALOG_STYLE_LIST, TXT_TruckerDialogSelectLoad, TotalLoadList, TXT_DialogButtonSelect, TXT_DialogButtonCancel);
  248. }
  249. case 1: Trucker_StartRandomJob(playerid); // Start a random trucker-job
  250. }
  251. return 1;
  252. }
  253. // Process the selected load and create the startlocation-dialog
  254. Dialog_TruckerSelectLoad(playerid, response, listitem)
  255. {
  256. // Setup local variables
  257. new TotalStartLocList[1000], ProductList[50], NumProducts, ProductID, LocID;
  258. // Just close the dialog if the player clicked "Cancel"
  259. if(!response) return 1;
  260. // First get the list of products again, so we can retrieve the selected load from it
  261. switch (GetVehicleModel(GetPlayerVehicleID(playerid))) // Check the vehicle-model of the player
  262. {
  263. case VehicleFlatbed, VehicleDFT30: // If the player's vehicle is a "Flatbed" or "DFT-30"
  264. ProductList = Product_GetList(PCV_TruckerNoTrailer, NumProducts); // Build a list of products defined for truckers without a trailer
  265. case VehicleCementTruck: // If the player's vehicle is a "CementTruck"
  266. ProductList = Product_GetList(PCV_TruckerCementTruck, NumProducts); // Build a list of products defined for truckers witha cement truck
  267. case VehicleLineRunner, VehicleTanker, VehicleRoadTrain: // If the player's vehicle is a "LineRunner", "Tanker" or "RoadTrain"
  268. {
  269. switch (GetVehicleModel(GetVehicleTrailer(GetPlayerVehicleID(playerid)))) // Select the loads based on the trailer model of the player
  270. {
  271. case VehicleTrailerCargo, VehicleTrailerCargo2: // A cargo-trailer is attached
  272. ProductList = Product_GetList(PCV_TruckerCargoTrailer, NumProducts); // Build a list of products defined for truckers with a cargo-trailer
  273. case VehicleTrailerOre: // An Ore-trailer is attached
  274. ProductList = Product_GetList(PCV_TruckerOreTrailer, NumProducts); // Build a list of products defined for truckers with an ore-trailer
  275. case VehicleTrailerFluids: // A fluids-trailer is attached
  276. ProductList = Product_GetList(PCV_TruckerFluidsTrailer, NumProducts); // Build a list of products defined for truckers with a fluids-trailer
  277. }
  278. }
  279. }
  280. // Store the selected LoadID in the player's account
  281. APlayerData[playerid][LoadID] = ProductList[listitem];
  282. ProductID = APlayerData[playerid][LoadID];
  283. // Build a list of start-locations for this product
  284. for (new i; i < 30; i++)
  285. {
  286. // Get the location-id
  287. LocID = ALoads[ProductID][FromLocations][i];
  288. // Check if it a valid location-id (not 0)
  289. if (LocID != 0)
  290. format(TotalStartLocList, 1000, "%s%s\n", TotalStartLocList, ALocations[LocID][LocationName]); // Add the location-name to the list
  291. else
  292. break; // As soon as an invalid location-id has been found, stop adding entries to the location-list
  293. }
  294. // Ask the player to choose a start-location
  295. ShowPlayerDialog(playerid, DialogTruckerStartLoc, DIALOG_STYLE_LIST, TXT_TruckerDialogSelectStartLoc, TotalStartLocList, TXT_DialogButtonSelect, TXT_DialogButtonCancel); // Let the player choose a starting location
  296. return 1;
  297. }
  298. // Process the selected startlocation and create the endlocation-dialog
  299. Dialog_TruckerSelectStartLoc(playerid, response, listitem)
  300. {
  301. // Setup local variables
  302. new ProductID, LocID, TotalEndLocList[1000];
  303. // Just close the dialog if the player clicked "Cancel"
  304. if(!response) return 1;
  305. // Get the LoadID that's stored in the player's account
  306. ProductID = APlayerData[playerid][LoadID];
  307. // Store the chosen start-location in the player's account
  308. APlayerData[playerid][JobLoc1] = ALoads[ProductID][FromLocations][listitem];
  309. // Build a list of end-locations for this product
  310. for (new i; i < 30; i++)
  311. {
  312. // Get the location-id
  313. LocID = ALoads[ProductID][ToLocations][i];
  314. // Check if it a valid location-id (not 0)
  315. if (LocID != 0)
  316. format(TotalEndLocList, 1000, "%s%s\n", TotalEndLocList, ALocations[LocID][LocationName]); // Add the location-name to the list
  317. else
  318. break; // As soon as an invalid location-id has been found, stop adding entries to the location-list
  319. }
  320. // Ask the player to choose an end-location
  321. ShowPlayerDialog(playerid, DialogTruckerEndLoc, DIALOG_STYLE_LIST, TXT_TruckerDialogSelectEndLoc, TotalEndLocList, TXT_DialogButtonSelect, TXT_DialogButtonCancel); // Let the player choose a endlocation
  322. return 1;
  323. }
  324. // Process the selected endlocation and start the job
  325. Dialog_TruckerSelectEndLoc(playerid, response, listitem)
  326. {
  327. // Setup local variables
  328. new RouteText[128], loadName[50], startlocName[50], endlocName[50], LoadMsg[128], Float:x, Float:y, Float:z, ProductID;
  329. // Just close the dialog if the player clicked "Cancel"
  330. if(!response) return 1;
  331. // Get the LoadID that's stored in the player's account
  332. ProductID = APlayerData[playerid][LoadID];
  333. // Store the chosen end-location in the player's account
  334. APlayerData[playerid][JobLoc2] = ALoads[ProductID][ToLocations][listitem];
  335. // Get the names for the load, startlocation and endlocation
  336. format(loadName, 50, "%s", ALoads[ProductID][LoadName]);
  337. format(startlocName, 50, "%s", ALocations[APlayerData[playerid][JobLoc1]][LocationName]);
  338. format(endlocName, 50, "%s", ALocations[APlayerData[playerid][JobLoc2]][LocationName]);
  339. // Job has started
  340. APlayerData[playerid][JobStarted] = true;
  341. // Store the vehicleID (required to be able to check if the player left his vehicle)
  342. APlayerData[playerid][VehicleID] = GetPlayerVehicleID(playerid);
  343. // Store the trailerID (required to be able to check if the player lost his trailer)
  344. APlayerData[playerid][TrailerID] = GetVehicleTrailer(GetPlayerVehicleID(playerid));
  345. // Set jobstep to 1 (going to load the goods)
  346. APlayerData[playerid][JobStep] = 1;
  347. // Combine all data into a string for the TextDraw (the player can see this all the time) to describe the mission
  348. format(RouteText, 255, TXT_HaulingCargoFromToPickup, loadName, startlocName, endlocName);
  349. // Set the TextDraw so the player can see it
  350. TextDrawSetString(APlayerData[playerid][MissionText], RouteText);
  351. // Grab the x, y, z positions for the first location
  352. x = ALocations[APlayerData[playerid][JobLoc1]][LocX];
  353. y = ALocations[APlayerData[playerid][JobLoc1]][LocY];
  354. z = ALocations[APlayerData[playerid][JobLoc1]][LocZ];
  355. // Create a checkpoint where the player should load the goods
  356. SetPlayerCheckpoint(playerid, x, y, z, 7);
  357. // Set the job-fail-time for the global vehicle-timer
  358. APlayerData[playerid][VehicleTimerTime] = Job_TimeToFailMission;
  359. // Inform the player that he must load his goods
  360. format(LoadMsg, 128, TXT_PickupCargoAt, loadName, startlocName);
  361. SendClientMessage(playerid, 0xFFFFFFFF, LoadMsg);
  362. return 1;
  363. }
  364. // Process the work dialog for licensed busdrivers (show the list of busroutes after the player selected to choose his own route)
  365. Dialog_BusSelectJobMethod(playerid, response, listitem)
  366. {
  367. // Setup local variables
  368. new BusLine, Description[100], TotalRouteList[500];
  369. // Just close the dialog if the player clicked "Cancel"
  370. if(!response) return 1;
  371. // Check if the player already started a job
  372. if (APlayerData[playerid][JobStarted] == false)
  373. {
  374. // Select what to do after the player chose "Choose your own busroute" or "Auto assigned busroute"
  375. switch (listitem)
  376. {
  377. case 0: // Let the player choose his own busroute
  378. {
  379. // Construct the list of busroutes
  380. for (new i; i < sizeof(ABusRoutes); i++)
  381. {
  382. // Get the data about the route
  383. BusLine = ABusRoutes[i][LineNumber];
  384. format(Description, 100, ABusRoutes[i][RouteDescription]);
  385. // Add the busline to the list
  386. format(TotalRouteList, 500, "%s%sLine %i (%s)", TotalRouteList, "\n", BusLine, Description);
  387. }
  388. // Let the player choose a busroute
  389. ShowPlayerDialog(playerid, DialogBusSelectRoute, DIALOG_STYLE_LIST, TXT_SelectBusRoute, TotalRouteList, TXT_DialogButtonSelect, TXT_DialogButtonCancel);
  390. }
  391. case 1: BusDriver_StartJob(playerid, random(sizeof(ABusRoutes))); // Start a random job
  392. }
  393. }
  394. else // Send a message to let the player know he already has a job
  395. SendClientMessage(playerid, 0xFFFFFFFF, TXT_BusdriverAlreadyDoingJob);
  396. return 1;
  397. }
  398. // Process the work dialog for licensed busdrivers (let the player start the job he selects from the busroute-list)
  399. Dialog_BusSelectRoute(playerid, response, listitem)
  400. {
  401. // Just close the dialog if the player clicked "Cancel"
  402. if(!response) return 1;
  403. // The selected listitem is automatically the busroute, so start the job based on the item selected in the busroute-list
  404. BusDriver_StartJob(playerid, listitem);
  405. return 1;
  406. }
  407. // Process the chosen quantity for courier job
  408. Dialog_CourierSelectQuant(playerid, response, listitem)
  409. {
  410. // Just close the dialog if the player clicked "Cancel"
  411. if(!response) return 1;
  412. // Listitem 0 represent maximum 2 houses to deliver a package, listitem 1 is max 5 houses, item 2 is max 10 houses
  413. switch (listitem)
  414. {
  415. case 0: APlayerData[playerid][CourierMaxStep] = 2;
  416. case 1: APlayerData[playerid][CourierMaxStep] = 5;
  417. case 2: APlayerData[playerid][CourierMaxStep] = 10;
  418. }
  419. // Start the job
  420. Courier_BeginJob(playerid);
  421. return 1;
  422. }
  423. // Process the bike dialog
  424. Dialog_Bike(playerid, response, listitem)
  425. {
  426. // Just close the dialog if the player clicked "Cancel"
  427. if(!response) return 1;
  428. // Setup local variables
  429. new Float:x, Float:y, Float:z, Float:rot, CarID, msg[120], vID, pName[24];
  430. new engine,lights,alarm,doors,bonnet,boot,objective;
  431. // Get the player's position and name
  432. GetPlayerPos(playerid, x, y, z);
  433. GetPlayerFacingAngle(playerid, rot);
  434. GetPlayerName(playerid, pName, 24);
  435. // Spawn the motorcycle based on the selection in the list, and spawn it 5 units north of the player
  436. switch (listitem)
  437. {
  438. case 0: CarID = VehicleBike; // Bike
  439. case 1: CarID = VehicleBMX; // BMX
  440. case 2: CarID = VehicleMountainBike; // Mountain Bike
  441. case 3: CarID = VehicleFaggio; // Faggio
  442. case 4: CarID = VehiclePizzaBoy; // Pizzaboy
  443. case 5: CarID = VehicleBF400; // BF-400
  444. case 6: CarID = VehicleNRG500; // NRG-500
  445. case 7: CarID = VehiclePCJ600; // PCJ-600
  446. case 8: CarID = VehicleFCR900; // FCR-900
  447. case 9: CarID = VehicleFreeway; // Freeway
  448. case 10: CarID = VehicleWayfarer; // Wayfarer
  449. case 11: CarID = VehicleSanchez; // Sanchez
  450. case 12: CarID = VehicleQuad; // Quad
  451. }
  452. // Spawn the vehicle based on the selection in the list with a random color
  453. // Also set max-fuel and save the model for the vehicle
  454. vID = Vehicle_Create(CarID, x, y, z, rot, random(126), random(126), 600);
  455. // Put the player in the vehicle
  456. PutPlayerInVehicle(playerid, vID, 0);
  457. // Turn on the engine and lights
  458. GetVehicleParamsEx(vID, engine, lights, alarm, doors, bonnet, boot, objective);
  459. SetVehicleParamsEx(vID, 1, 1, alarm, doors, bonnet, boot, objective);
  460. // Store the player's current location and interior-id, otherwise anti-airbreak hack code could kick you
  461. GetPlayerPos(playerid, APlayerData[playerid][PreviousX], APlayerData[playerid][PreviousY], APlayerData[playerid][PreviousZ]);
  462. APlayerData[playerid][PreviousInt] = GetPlayerInterior(playerid);
  463. // Inform all players about it
  464. format(msg, 120, TXT_PlayerSpawnedVehicle, pName, vID, CarID, x, y, z);
  465. SendClientMessageToAll(0xFFFFFFFF, msg);
  466. return 1;
  467. }
  468. // Process the car dialog
  469. Dialog_Car(playerid, response, listitem)
  470. {
  471. // Just close the dialog if the player clicked "Cancel"
  472. if(!response)
  473. {
  474. // Reset the FirstCar (so the list won't start at an unexpected location in the list, but back at the start of the list)
  475. APlayerData[playerid][DialogCarFirstCar] = 0;
  476. return 1; // Exit the function
  477. }
  478. // Process the selected listitem
  479. switch (listitem)
  480. {
  481. case 10: // Player chooses the empty line between the carlist and "Next...", so refresh the current list
  482. {
  483. // Refresh the current list of cars and let the player choose one (show dialog)
  484. CarList_Create(playerid);
  485. // Exit the function
  486. return 1;
  487. }
  488. case 11: // Player chooses "Next..."
  489. {
  490. // Add 10 to the FirstCar, so the list will start further down the array (will show the next 10 cars)
  491. APlayerData[playerid][DialogCarFirstCar] = APlayerData[playerid][DialogCarFirstCar] + 10;
  492. // Create a new list of cars and show the dialog
  493. CarList_Create(playerid);
  494. }
  495. default: // Player chooses a car
  496. {
  497. // Setup local variables
  498. new Float:x, Float:y, Float:z, Float:rot, CarIndex, msg[128], vID, pName[24];
  499. new engine,lights,alarm,doors,bonnet,boot,objective;
  500. // FirstCar is the index of the first car in the list, so select the proper index when a car is chosen by the player
  501. CarIndex = APlayerData[playerid][DialogCarFirstCar] + listitem;
  502. // Get the player's position and name
  503. GetPlayerPos(playerid, x, y, z);
  504. GetPlayerFacingAngle(playerid, rot);
  505. GetPlayerName(playerid, pName, 24);
  506. // Spawn the vehicle based on the selection in the list with a random color
  507. // Also set max-fuel and save the model for the vehicle
  508. vID = Vehicle_Create(ACars[CarIndex][CarModel], x, y, z, rot, random(126), random(126), 600);
  509. // Put the player in the vehicle
  510. PutPlayerInVehicle(playerid, vID, 0);
  511. // Turn on the engine and lights
  512. GetVehicleParamsEx(vID, engine, lights, alarm, doors, bonnet, boot, objective);
  513. SetVehicleParamsEx(vID, 1, 1, alarm, doors, bonnet, boot, objective);
  514. // Store the player's current location and interior-id, otherwise anti-airbreak hack code could kick you
  515. GetPlayerPos(playerid, APlayerData[playerid][PreviousX], APlayerData[playerid][PreviousY], APlayerData[playerid][PreviousZ]);
  516. APlayerData[playerid][PreviousInt] = GetPlayerInterior(playerid);
  517. // Inform all players about it
  518. format(msg, 120, TXT_PlayerSpawnedVehicle, pName, vID, ACars[CarIndex][CarModel], x, y, z);
  519. SendClientMessageToAll(0xFFFFFFFF, msg);
  520. // Also, after spawning a vehicle, reset FirstCar (so next time, the list starts from the start)
  521. APlayerData[playerid][DialogCarFirstCar] = 0;
  522. }
  523. }
  524. return 1;
  525. }
  526. // Process the Plane dialog
  527. Dialog_Plane(playerid, response, listitem)
  528. {
  529. // Just close the dialog if the player clicked "Cancel"
  530. if(!response)
  531. {
  532. // Reset the FirstPlane (so the list won't start at an unexpected location in the list, but back at the start of the list)
  533. APlayerData[playerid][DialogPlaneFirstPlane] = 0;
  534. return 1; // Exit the function
  535. }
  536. // Process the selected listitem
  537. switch (listitem)
  538. {
  539. case 10: // Player chooses the empty line between the Planelist and "Next...", so refresh the current list
  540. {
  541. // Refresh the current list of Planes and let the player choose one (show dialog)
  542. PlaneList_Create(playerid);
  543. // Exit the function
  544. return 1;
  545. }
  546. case 11: // Player chooses "Next..."
  547. {
  548. // Add 10 to the FirstPlane, so the list will start further down the array (will show the next 10 Planes)
  549. APlayerData[playerid][DialogPlaneFirstPlane] = APlayerData[playerid][DialogPlaneFirstPlane] + 10;
  550. // Create a new list of Planes and show the dialog
  551. PlaneList_Create(playerid);
  552. }
  553. default: // Player chooses a Plane
  554. {
  555. // Setup local variables
  556. new Float:x, Float:y, Float:z, Float:rot, PlaneIndex, msg[128], vID, pName[24];
  557. new engine,lights,alarm,doors,bonnet,boot,objective;
  558. // FirstPlane is the index of the first Plane in the list, so select the proper index when a Plane is chosen by the player
  559. PlaneIndex = APlayerData[playerid][DialogPlaneFirstPlane] + listitem;
  560. // Get the player's position and name
  561. GetPlayerPos(playerid, x, y, z);
  562. GetPlayerFacingAngle(playerid, rot);
  563. GetPlayerName(playerid, pName, 24);
  564. // Spawn the vehicle based on the selection in the list with a random color
  565. // Also set max-fuel and save the model for the vehicle
  566. vID = Vehicle_Create(APlanes[PlaneIndex][PlaneModel], x, y, z, rot, random(126), random(126), 600);
  567. // Put the player in the vehicle
  568. PutPlayerInVehicle(playerid, vID, 0);
  569. // Turn on the engine and lights
  570. GetVehicleParamsEx(vID, engine, lights, alarm, doors, bonnet, boot, objective);
  571. SetVehicleParamsEx(vID, 1, 1, alarm, doors, bonnet, boot, objective);
  572. // Store the player's current location and interior-id, otherwise anti-airbreak hack code could kick you
  573. GetPlayerPos(playerid, APlayerData[playerid][PreviousX], APlayerData[playerid][PreviousY], APlayerData[playerid][PreviousZ]);
  574. APlayerData[playerid][PreviousInt] = GetPlayerInterior(playerid);
  575. // Inform the player about it
  576. format(msg, 128, TXT_PlayerSpawnedVehicle, pName, vID, APlanes[PlaneIndex][PlaneModel], x, y, z);
  577. SendClientMessageToAll(0xFFFFFFFF, msg);
  578. // Also, after spawning a vehicle, reset FirstPlane (so next time, the list starts from the start)
  579. APlayerData[playerid][DialogPlaneFirstPlane] = 0;
  580. }
  581. }
  582. return 1;
  583. }
  584. // Process the Trailer dialog
  585. Dialog_Trailer(playerid, response, listitem)
  586. {
  587. // Just close the dialog if the player clicked "Cancel"
  588. if(!response)
  589. {
  590. // Reset the FirstTrailer (so the list won't start at an unexpected location in the list, but back at the start of the list)
  591. APlayerData[playerid][DialogTrailerFirstTrailer] = 0;
  592. return 1; // Exit the function
  593. }
  594. // Process the selected listitem
  595. switch (listitem)
  596. {
  597. case 10: // Player chooses the empty line between the Trailerlist and "Next...", so refresh the current list
  598. {
  599. // Refresh the current list of Trailers and let the player choose one (show dialog)
  600. TrailerList_Create(playerid);
  601. // Exit the function
  602. return 1;
  603. }
  604. case 11: // Player chooses "Next..."
  605. {
  606. // Add 10 to the FirstTrailer, so the list will start further down the array (will show the next 10 Trailers)
  607. APlayerData[playerid][DialogTrailerFirstTrailer] = APlayerData[playerid][DialogTrailerFirstTrailer] + 10;
  608. // Create a new list of Trailers and show the dialog
  609. TrailerList_Create(playerid);
  610. }
  611. default: // Player chooses a Trailer
  612. {
  613. // Setup local variables
  614. new Float:x, Float:y, Float:z, TrailerIndex, msg[128], vID, pName[24];
  615. // FirstTrailer is the index of the first Trailer in the list, so select the proper index when a Trailer is chosen by the player
  616. TrailerIndex = APlayerData[playerid][DialogTrailerFirstTrailer] + listitem;
  617. // Get the player's position and name
  618. GetPlayerPos(playerid, x, y, z);
  619. GetPlayerName(playerid, pName, 24);
  620. // Spawn the vehicle based on the selection in the list with a random color, and spawn it 10 units north of the player
  621. // Also set max-fuel and save the model for the vehicle
  622. vID = Vehicle_Create(ATrailers[TrailerIndex][TrailerModel], x, y + 10.0, z + 5.0, 0.0, random(126), random(126), 600);
  623. // Inform the player about it
  624. format(msg, 128, TXT_PlayerSpawnedVehicle, pName, vID, ATrailers[TrailerIndex][TrailerModel], x, y + 10.0, z + 5.0);
  625. SendClientMessageToAll(0xFFFFFFFF, msg);
  626. // Also, after spawning a vehicle, reset FirstTrailer (so next time, the list starts from the start)
  627. APlayerData[playerid][DialogTrailerFirstTrailer] = 0;
  628. }
  629. }
  630. return 1;
  631. }
  632. // Process the boat dialog
  633. Dialog_Boat(playerid, response, listitem)
  634. {
  635. // Just close the dialog if the player clicked "Cancel"
  636. if(!response) return 1;
  637. // Setup local variables
  638. new Float:x, Float:y, Float:z, Float:rot, CarID, msg[120], vID, pName[24];
  639. new engine,lights,alarm,doors,bonnet,boot,objective;
  640. // Get the player's position and name
  641. GetPlayerPos(playerid, x, y, z);
  642. GetPlayerFacingAngle(playerid, rot);
  643. GetPlayerName(playerid, pName, 24);
  644. // Spawn the boat based on the selection in the list
  645. switch (listitem)
  646. {
  647. case 0: CarID = VehicleCoastguard; // Coastguard
  648. case 1: CarID = VehicleDinghy; // Dinghy
  649. case 2: CarID = VehicleJetmax; // Jetmax
  650. case 3: CarID = VehicleLaunch; // Launch
  651. case 4: CarID = VehicleMarquis; // Marquis
  652. case 5: CarID = VehiclePredator; // Predator
  653. case 6: CarID = VehicleReefer; // Reefer
  654. case 7: CarID = VehicleSpeeder; // Speeder
  655. case 8: CarID = VehicleSquallo; // Squallo
  656. case 9: CarID = VehicleTropic; // Tropic
  657. }
  658. // Spawn the vehicle based on the selection in the list with a random color
  659. // Also set max-fuel and save the model for the vehicle
  660. vID = Vehicle_Create(CarID, x, y, z, rot, random(126), random(126), 600);
  661. // Put the player in the vehicle
  662. PutPlayerInVehicle(playerid, vID, 0);
  663. // Turn on the engine and lights
  664. GetVehicleParamsEx(vID, engine, lights, alarm, doors, bonnet, boot, objective);
  665. SetVehicleParamsEx(vID, 1, 1, alarm, doors, bonnet, boot, objective);
  666. // Store the player's current location and interior-id, otherwise anti-airbreak hack code could kick you
  667. GetPlayerPos(playerid, APlayerData[playerid][PreviousX], APlayerData[playerid][PreviousY], APlayerData[playerid][PreviousZ]);
  668. APlayerData[playerid][PreviousInt] = GetPlayerInterior(playerid);
  669. // Inform all players about it
  670. format(msg, 120, TXT_PlayerSpawnedVehicle, pName, vID, CarID, x, y, z);
  671. SendClientMessageToAll(0xFFFFFFFF, msg);
  672. return 1;
  673. }
  674. // Process the neon dialog
  675. Dialog_Neon(playerid, response, listitem)
  676. {
  677. // Just close the dialog if the player clicked "Cancel"
  678. if(!response) return 1;
  679. // Setup local variables
  680. new vehicleid;
  681. // Get the player's vehicle
  682. vehicleid = GetPlayerVehicleID(playerid);
  683. // Check if the player chose anothet option than "Remove neons"
  684. if (listitem != 7)
  685. {
  686. // Check if the vehicle already has neon lights attached
  687. if (AVehicleData[vehicleid][NeonLeft] != 0)
  688. {
  689. // Delete the current neon-lights and clear the variables
  690. DestroyObject(AVehicleData[vehicleid][NeonLeft]);
  691. DestroyObject(AVehicleData[vehicleid][NeonRight]);
  692. AVehicleData[vehicleid][NeonLeft] = 0;
  693. AVehicleData[vehicleid][NeonRight] = 0;
  694. }
  695. }
  696. // Process the option chosen from the dialog
  697. if (listitem == 0) // Police Light
  698. {
  699. AVehicleData[vehicleid][NeonLeft] = CreateObject(18646,0,0,0,0,0,0);
  700. AVehicleData[vehicleid][NeonRight] = CreateObject(18646,0,0,0,0,0,0);
  701. AttachObjectToVehicle(AVehicleData[vehicleid][NeonLeft], vehicleid, -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  702. AttachObjectToVehicle(AVehicleData[vehicleid][NeonRight], vehicleid, 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  703. GameTextForPlayer(playerid, "~p~Police lights~w~ have been added to your vehicle", 3500, 5);
  704. }
  705. if (listitem == 1) // Red light
  706. {
  707. AVehicleData[vehicleid][NeonLeft] = CreateObject(18647,0,0,0,0,0,0);
  708. AVehicleData[vehicleid][NeonRight] = CreateObject(18647,0,0,0,0,0,0);
  709. AttachObjectToVehicle(AVehicleData[vehicleid][NeonLeft], vehicleid, -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  710. AttachObjectToVehicle(AVehicleData[vehicleid][NeonRight], vehicleid, 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  711. GameTextForPlayer(playerid, "~p~Red lights~w~ have been added to your vehicle", 3500, 5);
  712. }
  713. if (listitem == 2) // Blue light
  714. {
  715. AVehicleData[vehicleid][NeonLeft] = CreateObject(18648,0,0,0,0,0,0);
  716. AVehicleData[vehicleid][NeonRight] = CreateObject(18648,0,0,0,0,0,0);
  717. AttachObjectToVehicle(AVehicleData[vehicleid][NeonLeft], vehicleid, -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  718. AttachObjectToVehicle(AVehicleData[vehicleid][NeonRight], vehicleid, 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  719. GameTextForPlayer(playerid, "~p~Blue lights~w~ have been added to your vehicle", 3500, 5);
  720. }
  721. if (listitem == 3) // Green Light
  722. {
  723. AVehicleData[vehicleid][NeonLeft] = CreateObject(18649,0,0,0,0,0,0);
  724. AVehicleData[vehicleid][NeonRight] = CreateObject(18649,0,0,0,0,0,0);
  725. AttachObjectToVehicle(AVehicleData[vehicleid][NeonLeft], vehicleid, -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  726. AttachObjectToVehicle(AVehicleData[vehicleid][NeonRight], vehicleid, 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  727. GameTextForPlayer(playerid, "~p~Green lights~w~ have been added to your vehicle", 3500, 5);
  728. }
  729. if (listitem == 4) // Yellow Light
  730. {
  731. AVehicleData[vehicleid][NeonLeft] = CreateObject(18650,0,0,0,0,0,0);
  732. AVehicleData[vehicleid][NeonRight] = CreateObject(18650,0,0,0,0,0,0);
  733. AttachObjectToVehicle(AVehicleData[vehicleid][NeonLeft], vehicleid, -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  734. AttachObjectToVehicle(AVehicleData[vehicleid][NeonRight], vehicleid, 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  735. GameTextForPlayer(playerid, "~p~Yellow lights~w~ have been added to your vehicle", 3500, 5);
  736. }
  737. if (listitem == 5) // Pink Light
  738. {
  739. AVehicleData[vehicleid][NeonLeft] = CreateObject(18651,0,0,0,0,0,0);
  740. AVehicleData[vehicleid][NeonRight] = CreateObject(18651,0,0,0,0,0,0);
  741. AttachObjectToVehicle(AVehicleData[vehicleid][NeonLeft], vehicleid, -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  742. AttachObjectToVehicle(AVehicleData[vehicleid][NeonRight], vehicleid, 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  743. GameTextForPlayer(playerid, "~p~Pink lights~w~ have been added to your vehicle", 3500, 5);
  744. }
  745. if (listitem == 6) // White Light
  746. {
  747. AVehicleData[vehicleid][NeonLeft] = CreateObject(18652,0,0,0,0,0,0);
  748. AVehicleData[vehicleid][NeonRight] = CreateObject(18652,0,0,0,0,0,0);
  749. AttachObjectToVehicle(AVehicleData[vehicleid][NeonLeft], vehicleid, -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  750. AttachObjectToVehicle(AVehicleData[vehicleid][NeonRight], vehicleid, 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  751. GameTextForPlayer(playerid, "~p~White lights~w~ have been added to your vehicle", 3500, 5);
  752. }
  753. if (listitem == 7) // Remove neons
  754. {
  755. // Delete the current neon-lights and clear the variables
  756. DestroyObject(AVehicleData[vehicleid][NeonLeft]);
  757. DestroyObject(AVehicleData[vehicleid][NeonRight]);
  758. AVehicleData[vehicleid][NeonLeft] = 0;
  759. AVehicleData[vehicleid][NeonRight] = 0;
  760. GameTextForPlayer(playerid, "Neons have been removed from your vehicle", 3500, 5);
  761. }
  762. return 1;
  763. }
  764. // Process the chosen vehicleclass to show the actual vehicle-list of this vehicleclass
  765. Dialog_RentProcessClass(playerid, response, listitem)
  766. {
  767. // Just close the dialog if the player clicked "Cancel"
  768. if(!response) return 1;
  769. // Setup local variables
  770. new CarList[1000], DialogTitle[128];
  771. // Set the player's chosen vehicle-class based on the listitem he chose (add 1 as the vehicleclass starts at 1)
  772. APlayerData[playerid][DialogRentVClass] = listitem + 1;
  773. // Add all vehicles of the same class to the list
  774. for (new i; i < sizeof(ABuyableVehicles); i++)
  775. {
  776. // Check if the vehicle in the list has the same class as requested
  777. if (ABuyableVehicles[i][VehicleClass] == APlayerData[playerid][DialogRentVClass])
  778. {
  779. // Add the carname to the list and it's price
  780. format(CarList, 1000, "%s%s%s ($%i)", CarList, "\n", ABuyableVehicles[i][CarName], ABuyableVehicles[i][Price] / 10); // Add the name of the next car to the list on the next line
  781. }
  782. }
  783. // Check if the list is empty
  784. if (strlen(CarList) == 0)
  785. {
  786. // Send the player a message that all vehicles have been disabled of the chosen class (no vehicles in the array of this class)
  787. SendClientMessage(playerid, 0xFFFFFFFF, TXT_BuyRentCarEmptyList);
  788. // Exit the function (don't ask to choose a vehicle)
  789. return 1;
  790. }
  791. // Set a title for the dialog based on the requested vehicleclass
  792. switch (APlayerData[playerid][DialogRentVClass])
  793. {
  794. case VClassBike: format(DialogTitle, 128, TXT_RentBike);
  795. case VClassBoat: format(DialogTitle, 128, TXT_RentBoat);
  796. case VClassConvertible: format(DialogTitle, 128, TXT_RentConvertible);
  797. case VClassHelicopter: format(DialogTitle, 128, TXT_RentHelicopter);
  798. case VClassIndustrial: format(DialogTitle, 128, TXT_RentIndustrial);
  799. case VClassLowRider: format(DialogTitle, 128, TXT_RentLowRider);
  800. case VClassOffRoad: format(DialogTitle, 128, TXT_RentOffRoad);
  801. case VClassPlane: format(DialogTitle, 128, TXT_RentPlane);
  802. case VClassPublic: format(DialogTitle, 128, TXT_RentPublicService);
  803. case VClassRCVehicle: format(DialogTitle, 128, TXT_RentRC);
  804. case VClassSaloons: format(DialogTitle, 128, TXT_RentSaloon);
  805. case VClassSportCar: format(DialogTitle, 128, TXT_RentSport);
  806. case VClassStationCar: format(DialogTitle, 128, TXT_RentStationWagon);
  807. case VClassTrailer: format(DialogTitle, 128, TXT_RentTrailer);
  808. case VClassUnique: format(DialogTitle, 128, TXT_RentUnique);
  809. }
  810. // Ask which car the player wants to have by showing the dialog
  811. ShowPlayerDialog(playerid, DialogRentCar, DIALOG_STYLE_LIST, DialogTitle, CarList, TXT_DialogButtonSelect, TXT_DialogButtonCancel);
  812. return 1;
  813. }
  814. // This dialog gives the chosen vehicle to the player (bought or rented)
  815. Dialog_RentCar(playerid, response, listitem)
  816. {
  817. // Just close the dialog if the player clicked "Cancel"
  818. if(!response) return 1;
  819. // Setup local variables
  820. new Counter, Name[24], Float:x, Float:y, Float:z, Msg[128];
  821. // Loop through the entire list of buyable vehicles
  822. for (new i; i < sizeof(ABuyableVehicles); i++)
  823. {
  824. // Check if the vehicle in the list has the same class as requested
  825. if (ABuyableVehicles[i][VehicleClass] == APlayerData[playerid][DialogRentVClass])
  826. {
  827. // Check if this is the vehicle that the player chose
  828. if (Counter == listitem)
  829. {
  830. // Check if the player has enough money to afford renting this vehicle
  831. if (APlayerData[playerid][PlayerMoney] >= (ABuyableVehicles[i][Price] / 10))
  832. {
  833. // Check if the player already has a rented vehicle
  834. if (APlayerData[playerid][RentedVehicleID] != 0)
  835. {
  836. // Clear the data for the already rented vehicle
  837. AVehicleData[APlayerData[playerid][RentedVehicleID]][Model] = 0;
  838. AVehicleData[APlayerData[playerid][RentedVehicleID]][Fuel] = 0;
  839. AVehicleData[APlayerData[playerid][RentedVehicleID]][Owned] = false;
  840. AVehicleData[APlayerData[playerid][RentedVehicleID]][Owner] = 0;
  841. AVehicleData[APlayerData[playerid][RentedVehicleID]][PaintJob] = 0;
  842. for (new j; j < 14; j++)
  843. {
  844. AVehicleData[APlayerData[playerid][RentedVehicleID]][Components][j] = 0;
  845. }
  846. // Destroy the vehicle
  847. DestroyVehicle(APlayerData[playerid][RentedVehicleID]);
  848. // Send the player a message that his previously rented vehicle has been replaced by the new one
  849. SendClientMessage(playerid, 0xFFFFFFFF, TXT_AlreadyRentedVehicle);
  850. }
  851. // Create the vehicle and link it to the player's account
  852. GetPlayerPos(playerid, x, y, z);
  853. APlayerData[playerid][RentedVehicleID] = CreateVehicle(ABuyableVehicles[i][CarModel], x, y, z, 0.0, -1, -1, 600);
  854. // Also set owndership data
  855. AVehicleData[APlayerData[playerid][RentedVehicleID]][Model] = ABuyableVehicles[i][CarModel];
  856. AVehicleData[APlayerData[playerid][RentedVehicleID]][Fuel] = MaxFuel;
  857. AVehicleData[APlayerData[playerid][RentedVehicleID]][Owned] = true;
  858. GetPlayerName(playerid, Name, sizeof(Name));
  859. format(AVehicleData[APlayerData[playerid][RentedVehicleID]][Owner], 24, Name);
  860. // Put the player in the vehicle
  861. PutPlayerInVehicle(playerid, APlayerData[playerid][RentedVehicleID], 0);
  862. // Turn on the engine
  863. new engine,lights,alarm,doors,bonnet,boot,objective;
  864. GetVehicleParamsEx(APlayerData[playerid][RentedVehicleID], engine, lights, alarm, doors, bonnet, boot, objective);
  865. SetVehicleParamsEx(APlayerData[playerid][RentedVehicleID], 1, lights, alarm, doors, bonnet, boot, objective);
  866. // Store the player's current location and interior-id, otherwise anti-airbreak hack code could kick you
  867. GetPlayerPos(playerid, APlayerData[playerid][PreviousX], APlayerData[playerid][PreviousY], APlayerData[playerid][PreviousZ]);
  868. APlayerData[playerid][PreviousInt] = GetPlayerInterior(playerid);
  869. // Let the player pay for renting the vehicle
  870. APlayerData[playerid][PlayerMoney] = APlayerData[playerid][PlayerMoney] - (ABuyableVehicles[i][Price] / 10);
  871. // Let the player know he rented a vehicle
  872. format(Msg, 128, TXT_PlayerRentsVehicle, ABuyableVehicles[i][CarName], (ABuyableVehicles[i][Price] / 10));
  873. SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  874. }
  875. else // The player has not enough money to rent this vehicle
  876. SendClientMessage(playerid, 0xFFFFFFFF, TXT_RentingTooExpensive);
  877. // Stop looking for the vehicle, as it's found and given to the player already
  878. return 1;
  879. }
  880. else // The player chose another vehicle from the same class, keep looking for another one
  881. Counter++;
  882. }
  883. }
  884. return 1;
  885. }
  886. // Process the weather dialog
  887. Dialog_Weather(playerid, response, listitem)
  888. {
  889. // Just close the dialog if the player clicked "Cancel"
  890. if(!response) return 1;
  891. // Setup local variables
  892. new WeatherID;
  893. // Select the weather
  894. switch (listitem)
  895. {
  896. case 0: WeatherID = 0; // Normal
  897. case 1: WeatherID = 8; // Stormy
  898. case 2: WeatherID = 9; // Foggy
  899. case 3: WeatherID = 11; // Scorching hot
  900. case 4: WeatherID = 16; // Dull, cloudy, rainy
  901. case 5: WeatherID = 19; // Sandstorm
  902. case 6: WeatherID = 20; // Green Fog
  903. case 7: WeatherID = 33; // Dark, cloudy, brown
  904. case 8: WeatherID = 39; // Extremely bright
  905. case 9: WeatherID = 43; // Dark toxic clouds
  906. case 10: WeatherID = 44; // Black & white sky
  907. }
  908. // Set the weather
  909. SetWeather(WeatherID);
  910. // Inform the player about it
  911. SendClientMessage(playerid, 0xFFFFFFFF, TXT_ChangedWeather;
  912. return 1;
  913. }
  914. // Process the caroption dialog
  915. Dialog_CarOption(playerid, response, listitem)
  916. {
  917. // Just close the dialog if the player clicked "Cancel"
  918. if(!response) return 1;
  919. // Setup local variables
  920. new vehicleid, engine, lights, bool:alarm, bool:doors, bool:bonnet, bool:boot, bool:objective;
  921. // Get the player's vehicle
  922. vehicleid = GetPlayerVehicleID(playerid);
  923. // Get the current status of the vehicle
  924. GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
  925. // Select the weather
  926. switch (listitem)
  927. {
  928. case 0: SetVehicleParamsEx(vehicleid, 1 - engine, lights, alarm, doors, bonnet, boot, objective);
  929. case 1: SetVehicleParamsEx(vehicleid, engine, 1 - lights, alarm, doors, bonnet, boot, objective);
  930. case 2:
  931. {
  932. if (alarm == true)
  933. SetVehicleParamsEx(vehicleid, engine, lights, false, doors, bonnet, boot, objective);
  934. else
  935. SetVehicleParamsEx(vehicleid, engine, lights, true, doors, bonnet, boot, objective);
  936. }
  937. case 3:
  938. {
  939. if (doors == true)
  940. SetVehicleParamsEx(vehicleid, engine, lights, alarm, false, bonnet, boot, objective);
  941. else
  942. SetVehicleParamsEx(vehicleid, engine, lights, alarm, true, bonnet, boot, objective);
  943. }
  944. case 4:
  945. {
  946. if (bonnet == true)
  947. SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, false, boot, objective);
  948. else
  949. SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, true, boot, objective);
  950. }
  951. case 5:
  952. {
  953. if (boot == true)
  954. SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, false, objective);
  955. else
  956. SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, true, objective);
  957. }
  958. case 6:
  959. {
  960. if (objective == true)
  961. SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, false);
  962. else
  963. SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, true);
  964. }
  965. }
  966. return 1;
  967. }
  968. // This function processes the convoy dialog
  969. Dialog_SelectConvoy(playerid, response, listitem)
  970. {
  971. // Just close the dialog if the player clicked "Cancel"
  972. if(!response) return 1;
  973. // Setup local variables
  974. new Convoy;
  975. // The convoy-id is automatically the listitem
  976. Convoy = listitem;
  977. // Check the status of the selected convoy to determine what to do
  978. switch (AConvoys[Convoy][Status])
  979. {
  980. case CONVOY_EMPTY: // Convoy isn't started yet, this is a free convoy
  981. {
  982. Convoy_Create(playerid, Convoy); // Try to create the convoy
  983. }
  984. case CONVOY_OPEN: // Convoy has been created but still open for new members to join
  985. {
  986. Convoy_Join(playerid, Convoy); // Try to join the convoy
  987. }
  988. case CONVOY_FULL: // Convoy is full (10 members)
  989. {
  990. SendClientMessage(playerid, 0xFFFFFFFF, TXT_ConvoyFull);
  991. }
  992. case CONVOY_CLOSED: // Convoy has started already (the leader already chose a job, causing the convoy to close)
  993. {
  994. SendClientMessage(playerid, 0xFFFFFFFF, TXT_ConvoyEnRoute);
  995. }
  996. }
  997. return 1;
  998. }
  999. // This function processes the housemenu dialog
  1000. Dialog_HouseMenu(playerid, response, listitem)
  1001. {
  1002. // Just close the dialog if the player clicked "Cancel"
  1003. if(!response) return 1;
  1004. // Setup local variables
  1005. new UpgradeList[2000], HouseID, DialogTitle[200], Counter, UpgradePrice, Msg[128], CarSlot, VehicleClassList[1000], VehicleList[500];
  1006. // Get the HouseID of the house where the player is
  1007. HouseID = APlayerData[playerid][CurrentHouse];
  1008. // Select an option based on the selection in the list
  1009. switch(listitem)
  1010. {
  1011. case 0: // Change house name
  1012. {
  1013. // Only the house-owner can use this option
  1014. if (House_PlayerIsOwner(playerid, HouseID) == 1)
  1015. {
  1016. format(DialogTitle, 200, TXT_DialogOldHouseName, AHouseData[HouseID][HouseName]);
  1017. ShowPlayerDialog(playerid, DialogHouseNameChange, DIALOG_STYLE_INPUT, DialogTitle, TXT_DialogEnterNewHouseName, TXT_DialogButtonSelect, TXT_DialogButtonCancel);
  1018. }
  1019. else
  1020. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Only the house-owner can use this option");
  1021. }
  1022. case 1: // Upgrade the house
  1023. {
  1024. // Only the house-owner can use this option
  1025. if (House_PlayerIsOwner(playerid, HouseID) == 1)
  1026. {
  1027. // Check if it's possible to upgrade further
  1028. if (AHouseData[HouseID][HouseLevel] < AHouseData[HouseID][HouseMaxLevel])
  1029. {
  1030. // Add only the upgrades above the current house-level to the upgradelist
  1031. for (new i = AHouseData[HouseID][HouseLevel] + 1; i <= AHouseData[HouseID][HouseMaxLevel]; i++)
  1032. {
  1033. Counter++; // Add 1 to the counter each time an upgrade is added to the upgradelist
  1034. UpgradePrice = ((AHouseData[HouseID][HousePrice] * Counter) / 100) * HouseUpgradePercent;
  1035. // Add the upgrade-info in green if the player can afford it, and in red if he cannot afford it
  1036. if (APlayerData[playerid][PlayerMoney] >= UpgradePrice)
  1037. format(UpgradeList, 2000, "%s{00FF00}%s (level %i)\t\t$%i\n", UpgradeList, AHouseInteriors[i][InteriorName], i, UpgradePrice);
  1038. else
  1039. format(UpgradeList, 2000, "%s{FF0000}%s (level %i)\t\t$%i\n", UpgradeList, AHouseInteriors[i][InteriorName], i, UpgradePrice);
  1040. }
  1041. // Show another dialog to let the player select which upgrade he wants for his house
  1042. ShowPlayerDialog(playerid, DialogUpgradeHouse, DIALOG_STYLE_LIST, TXT_DialogSelectHouseUpgrade, UpgradeList, TXT_DialogButtonSelect, TXT_DialogButtonCancel);
  1043. }
  1044. else
  1045. SendClientMessage(playerid, 0xFFFFFFFF, TXT_HouseReachedMaxLevel);
  1046. }
  1047. else
  1048. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Only the house-owner can use this option");
  1049. }
  1050. case 2: // Buy house-car
  1051. {
  1052. // Only the house-owner can use this option
  1053. if (House_PlayerIsOwner(playerid, HouseID) == 1)
  1054. {
  1055. // Find a free carslot
  1056. CarSlot = House_GetFreeCarSlot(HouseID);
  1057. // Check if the carslot is valid
  1058. if (CarSlot != -1)
  1059. {
  1060. // Let the player choose a vehicle-class
  1061. format(VehicleClassList, 1000, "%s{00FF00}%s{FFFFFF}\n", VehicleClassList, "Bikes");
  1062. format(VehicleClassList, 1000, "%s{40FF00}%s{FFFFFF}\n", VehicleClassList, "Boats");
  1063. format(VehicleClassList, 1000, "%s{80FF00}%s{FFFFFF}\n", VehicleClassList, "Convertibles");
  1064. format(VehicleClassList, 1000, "%s{B0FF00}%s{FFFFFF}\n", VehicleClassList, "Helicopters");
  1065. format(VehicleClassList, 1000, "%s{FFFF00}%s{FFFFFF}\n", VehicleClassList, "Industrial vehicles");
  1066. format(VehicleClassList, 1000, "%s{B0FF40}%s{FFFFFF}\n", VehicleClassList, "Low-riders");
  1067. format(VehicleClassList, 1000, "%s{80FF80}%s{FFFFFF}\n", VehicleClassList, "Off-Road vehicles");
  1068. format(VehicleClassList, 1000, "%s{40FFB0}%s{FFFFFF}\n", VehicleClassList, "Planes");
  1069. format(VehicleClassList, 1000, "%s{00FFFF}%s{FFFFFF}\n", VehicleClassList, "Public Service vehicles");
  1070. format(VehicleClassList, 1000, "%s{00B0FF}%s{FFFFFF}\n", VehicleClassList, "RC vehicles");
  1071. format(VehicleClassList, 1000, "%s{0080FF}%s{FFFFFF}\n", VehicleClassList, "Saloon vehicles");
  1072. format(VehicleClassList, 1000, "%s{0040FF}%s{FFFFFF}\n", VehicleClassList, "Sport vehicles");
  1073. format(VehicleClassList, 1000, "%s{0000FF}%s{FFFFFF}\n", VehicleClassList, "Station wagons");
  1074. format(VehicleClassList, 1000, "%s{4000FF}%s{FFFFFF}\n", VehicleClassList, "Trailers");
  1075. format(VehicleClassList, 1000, "%s{8000FF}%s{FFFFFF}\n", VehicleClassList, "Unique vehicles");
  1076. // Ask which vehicle class the player wants to see to buy a vehicle
  1077. ShowPlayerDialog(playerid, DialogBuyCarClass, DIALOG_STYLE_LIST, TXT_DialogBuyCarSelectClass, VehicleClassList, TXT_DialogButtonSelect, TXT_DialogButtonCancel);
  1078. }
  1079. else
  1080. SendClientMessage(playerid, 0xFFFFFFFF, TXT_HouseHasMaxVehicles);
  1081. }
  1082. else
  1083. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Only the house-owner can use this option");
  1084. }
  1085. case 3: // Buy house-car insurance
  1086. {
  1087. // Only the house-owner can use this option
  1088. if (House_PlayerIsOwner(playerid, HouseID) == 1)
  1089. {
  1090. new MsgInsurance[128];
  1091. // Check if this house doesn't have insurance yet
  1092. if (AHouseData[HouseID][Insurance] == 0)
  1093. {
  1094. // Check if the player can afford the insurance
  1095. if (APlayerData[playerid][PlayerMoney] >= (AHouseData[HouseID][HousePrice] / 10))
  1096. {
  1097. // Construct the message for the dialog, this includes the price for the insurance
  1098. format(MsgInsurance, 128, TXT_DialogBuyInsurance, AHouseData[HouseID][HousePrice] / 10);
  1099. // Ask the player if the wants to buy an insurance for this house's vehicles
  1100. ShowPlayerDialog(playerid, DialogBuyInsurance, DIALOG_STYLE_MSGBOX, TXT_DialogTitleBuyInsurance, MsgInsurance, TXT_DialogButtonYes, TXT_DialogButtonNo);
  1101. }
  1102. else
  1103. SendClientMessage(playerid, 0xFFFFFFFF, TXT_CannotAffordInsurance);
  1104. }
  1105. else
  1106. SendClientMessage(playerid, 0xFFFFFFFF, TXT_HouseAlreadyHasInsurance);
  1107. }
  1108. else
  1109. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Only the house-owner can use this option");
  1110. }
  1111. case 4: // Sell house-car
  1112. {
  1113. // Only the house-owner can use this option
  1114. if (House_PlayerIsOwner(playerid, HouseID) == 1)
  1115. {
  1116. new BuyableCarIndex, bool:HouseHasCars = false;
  1117. // Check if the house has any cars assigned to it
  1118. for (CarSlot = 0; CarSlot < 5; CarSlot++)
  1119. if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
  1120. HouseHasCars = true;
  1121. // Check if the house has any cars assigned to it
  1122. if (HouseHasCars == true)
  1123. {
  1124. // Add all vehicles to the list
  1125. for (CarSlot = 0; CarSlot < 10; CarSlot++)
  1126. {
  1127. if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
  1128. {
  1129. // Get the index where the first vehicle is found in the ABuyableVehicles array
  1130. BuyableCarIndex = VehicleBuyable_GetIndex(GetVehicleModel(AHouseData[HouseID][VehicleIDs][CarSlot]));
  1131. // Add the name of the vehicle to the list
  1132. format(VehicleList, 500, "%s{00FF00}%s: $%i{FFFFFF}\n", VehicleList, ABuyableVehicles[BuyableCarIndex][CarName], ABuyableVehicles[BuyableCarIndex][Price] / 2);
  1133. }
  1134. else
  1135. format(VehicleList, 500, TXT_EmptyCarSlot, VehicleList);
  1136. }
  1137. // Ask which vehicle class the player wants to see to buy a vehicle
  1138. ShowPlayerDialog(playerid, DialogSellCar, DIALOG_STYLE_LIST, TXT_SelectVehicleToSell, VehicleList, TXT_DialogButtonSelect, TXT_DialogButtonCancel);
  1139. }
  1140. else
  1141. SendClientMessage(playerid, 0xFFFFFFFF, TXT_NoHouseVehicles);
  1142. }
  1143. else
  1144. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Only the house-owner can use this option");
  1145. }
  1146. case 5: // Sell house
  1147. {
  1148. // Only the house-owner can use this option
  1149. if (House_PlayerIsOwner(playerid, HouseID) == 1)
  1150. {
  1151. // Setup local variables
  1152. new bool:HouseHasCars = false;
  1153. // Check if the house has any cars assigned to it
  1154. for (CarSlot = 0; CarSlot < 10; CarSlot++)
  1155. if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
  1156. HouseHasCars = true;
  1157. // Check if all house-cars have been sold (all slots are empty)
  1158. if (HouseHasCars == false)
  1159. {
  1160. format(Msg, 128, TXT_SureSellHouse, House_CalcSellPrice(HouseID));
  1161. ShowPlayerDialog(playerid, DialogSellHouse, DIALOG_STYLE_MSGBOX, TXT_AreYouSure, Msg, TXT_DialogButtonYes, TXT_DialogButtonNo);
  1162. }
  1163. else
  1164. SendClientMessage(playerid, 0xFFFFFFFF, TXT_CannotSellHouseWithCars);
  1165. }
  1166. else
  1167. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Only the house-owner can use this option");
  1168. }
  1169. case 6: // Open the house to the public (everyone can enter it)
  1170. {
  1171. // Only the house-owner can use this option
  1172. if (House_PlayerIsOwner(playerid, HouseID) == 1)
  1173. {
  1174. // Open the house to the public
  1175. AHouseData[HouseID][HouseOpened] = true;
  1176. // Let the player know he opened the house to the public
  1177. SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}You've opened the house to the public, anyone can enter it");
  1178. }
  1179. else
  1180. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Only the house-owner can use this option");
  1181. }
  1182. case 7: // Close the house to the public (only the owner can enter it)
  1183. {
  1184. // Only the house-owner can use this option
  1185. if (House_PlayerIsOwner(playerid, HouseID) == 1)
  1186. {
  1187. // Close the house to the public
  1188. AHouseData[HouseID][HouseOpened] = false;
  1189. // Let the player know he closed the house to the public
  1190. SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}You've closed the house to the public, only you can enter it");
  1191. }
  1192. else
  1193. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Only the house-owner can use this option");
  1194. }
  1195. case 8: // Exit the house
  1196. {
  1197. House_Exit(playerid, HouseID);
  1198. }
  1199. }
  1200. return 1;
  1201. }
  1202. // This function processes the house-upgrade menu
  1203. Dialog_UpgradeHouse(playerid, response, listitem)
  1204. {
  1205. // Just close the dialog if the player clicked "Cancel"
  1206. if(!response) return 1;
  1207. // Get the HouseID of the house where the player is
  1208. new HouseID = APlayerData[playerid][CurrentHouse];
  1209. // Calculate the new house-level based on the selection in the list (the first entry is 1 level higher than the current house-level)
  1210. new hLevel = listitem + 1 + AHouseData[HouseID][HouseLevel];
  1211. // Calculate the price for upgrading
  1212. new Payment = ((AHouseData[HouseID][HousePrice] * (listitem + 1)) / 100) * HouseUpgradePercent;
  1213. // Check if the player can afford it
  1214. if (APlayerData[playerid][PlayerMoney] >= Payment)
  1215. {
  1216. // Upgrade the house
  1217. AHouseData[HouseID][HouseLevel] = hLevel;
  1218. // Set the worldid so other players cannot see him anymore
  1219. SetPlayerVirtualWorld(playerid, 1000 + playerid);
  1220. // Set the player inside the new interior of the house
  1221. SetPlayerInterior(playerid, AHouseInteriors[hLevel][InteriorID]);
  1222. // Set the position of the player at the spawn-location of the house's interior
  1223. SetPlayerPos(playerid, AHouseInteriors[hLevel][IntX], AHouseInteriors[hLevel][IntY], AHouseInteriors[hLevel][IntZ]);
  1224. // Let the player pay for the upgrade
  1225. new Msg[128];
  1226. RewardPlayer(playerid, -Payment, 0);
  1227. format(Msg, 128, TXT_PlayerUpgradedHouse, AHouseData[HouseID][HouseLevel], Payment);
  1228. SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  1229. // Also update the 3DText at the entrance of the house
  1230. House_UpdateEntrance(APlayerData[playerid][CurrentHouse]);
  1231. // Save the player-file (and his houses)
  1232. PlayerFile_Save(playerid);
  1233. }
  1234. else
  1235. SendClientMessage(playerid, 0xFFFFFFFF, TXT_CannotAffordUpgrade);
  1236. return 1;
  1237. }
  1238. // Check which house the player chose, and port him to it
  1239. Dialog_GoHome(playerid, response, listitem)
  1240. {
  1241. // Just close the dialog if the player clicked "Cancel"
  1242. if(!response) return 1;
  1243. // Setup local variables
  1244. new HouseIndex, HouseID;
  1245. // The listitem directly indicates the house-index
  1246. HouseIndex = listitem;
  1247. HouseID = APlayerData[playerid][Houses][HouseIndex];
  1248. // Check if this is a valid house (HouseID != 0)
  1249. if (HouseID != 0)
  1250. {
  1251. // Get the coordinates of the house's entrance
  1252. SetPlayerPos(playerid, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]);
  1253. }
  1254. else
  1255. SendClientMessage(playerid, 0xFFFFFFFF, TXT_NoHouseInSlot);
  1256. return 1;
  1257. }
  1258. // Let the player change the name of his house
  1259. Dialog_ChangeHouseName(playerid, response, inputtext[])
  1260. {
  1261. // Just close the dialog if the player clicked "Cancel" or if the player didn't input any text
  1262. if ((!response) || (strlen(inputtext) == 0)) return 1;
  1263. // Change the name of the house
  1264. format(AHouseData[APlayerData[playerid][CurrentHouse]][HouseName], 100, inputtext);
  1265. // Also update the 3DText at the entrance of the house
  1266. House_UpdateEntrance(APlayerData[playerid][CurrentHouse]);
  1267. // Let the player know that the name of his house has been changed
  1268. SendClientMessage(playerid, 0xFFFFFFFF, TXT_ChangedHouseName);
  1269. // Save the player-file (and his houses)
  1270. PlayerFile_Save(playerid);
  1271. return 1;
  1272. }
  1273. // Choose a vehicle class from which to buy a vehicle
  1274. Dialog_BuyCarClass(playerid, response, listitem)
  1275. {
  1276. // Just close the dialog if the player clicked "Cancel"
  1277. if(!response) return 1;
  1278. // Setup local variables
  1279. new CarList[1000], DialogTitle[128];
  1280. // Set the player's chosen vehicle-class based on the listitem he chose (add 1 as the vehicleclass starts at 1)
  1281. APlayerData[playerid][DialogBuyVClass] = listitem + 1;
  1282. // Add all vehicles of the same class to the list
  1283. for (new i; i < sizeof(ABuyableVehicles); i++)
  1284. {
  1285. // Check if the vehicle in the list has the same class as requested
  1286. if (ABuyableVehicles[i][VehicleClass] == APlayerData[playerid][DialogBuyVClass])
  1287. {
  1288. // Add the carname to the list and it's price
  1289. format(CarList, 1000, "%s%s%s ($%i)", CarList, "\n", ABuyableVehicles[i][CarName], ABuyableVehicles[i][Price]); // Add the name of the next car to the list on the next line
  1290. }
  1291. }
  1292. // Check if the list is empty
  1293. if (strlen(CarList) == 0)
  1294. {
  1295. // Send the player a message that all vehicles have been disabled of the chosen class (no vehicles in the array of this class)
  1296. SendClientMessage(playerid, 0xFFFFFFFF, TXT_BuyRentCarEmptyList);
  1297. // Exit the function (don't ask to choose a vehicle)
  1298. return 1;
  1299. }
  1300. // Set a title for the dialog based on the requested vehicleclass
  1301. switch (APlayerData[playerid][DialogBuyVClass])
  1302. {
  1303. case VClassBike: format(DialogTitle, 128, TXT_BuyBike);
  1304. case VClassBoat: format(DialogTitle, 128, TXT_BuyBoat);
  1305. case VClassConvertible: format(DialogTitle, 128, TXT_BuyConvertible);
  1306. case VClassHelicopter: format(DialogTitle, 128, TXT_BuyHelicopter);
  1307. case VClassIndustrial: format(DialogTitle, 128, TXT_BuyIndustrial);
  1308. case VClassLowRider: format(DialogTitle, 128, TXT_BuyLowRider);
  1309. case VClassOffRoad: format(DialogTitle, 128, TXT_BuyOffRoad);
  1310. case VClassPlane: format(DialogTitle, 128, TXT_BuyPlane);
  1311. case VClassPublic: format(DialogTitle, 128, TXT_BuyPublicService);
  1312. case VClassRCVehicle: format(DialogTitle, 128, TXT_BuyRC);
  1313. case VClassSaloons: format(DialogTitle, 128, TXT_BuySaloon);
  1314. case VClassSportCar: format(DialogTitle, 128, TXT_BuySport);
  1315. case VClassStationCar: format(DialogTitle, 128, TXT_BuyStationWagon);
  1316. case VClassTrailer: format(DialogTitle, 128, TXT_BuyTrailer);
  1317. case VClassUnique: format(DialogTitle, 128, TXT_BuyUnique);
  1318. }
  1319. // Ask which car the player wants to have by showing the dialog
  1320. ShowPlayerDialog(playerid, DialogBuyCar, DIALOG_STYLE_LIST, DialogTitle, CarList, TXT_DialogButtonSelect, TXT_DialogButtonCancel);
  1321. return 1;
  1322. }
  1323. // Buy a vehicle and assign it to the house
  1324. Dialog_BuyCar(playerid, response, listitem)
  1325. {
  1326. // Just close the dialog if the player clicked "Cancel"
  1327. if(!response) return 1;
  1328. // Setup local variables
  1329. new Counter, Msg[128], cComponents[14];
  1330. // Get the HouseID
  1331. new HouseID = APlayerData[playerid][CurrentHouse];
  1332. // Loop through the entire list of buyable vehicles
  1333. for (new i; i < sizeof(ABuyableVehicles); i++)
  1334. {
  1335. // Check if the vehicle in the list has the same class as requested
  1336. if (ABuyableVehicles[i][VehicleClass] == APlayerData[playerid][DialogBuyVClass])
  1337. {
  1338. // Check if this is the vehicle that the player chose
  1339. if (Counter == listitem)
  1340. {
  1341. // Check if the player has enough money to afford buying this vehicle
  1342. if (APlayerData[playerid][PlayerMoney] >= (ABuyableVehicles[i][Price]))
  1343. {
  1344. // Add the vehicle to the house (this sets ownership and other data that's needed)
  1345. // The vehicles are by default created inside the hangar of KACC Military Fuels instead of near the EasterBoard Farm
  1346. House_AddVehicle(HouseID, ABuyableVehicles[i][CarModel], 0, cComponents, 2585.0, 2829.0, 10.9, 0.0, -1, -1);
  1347. // Let the player pay for buying the vehicle
  1348. APlayerData[playerid][PlayerMoney] = APlayerData[playerid][PlayerMoney] - ABuyableVehicles[i][Price];
  1349. // Let the player know he bought a vehicle
  1350. format(Msg, 128, TXT_PlayerBoughtVehicle, ABuyableVehicles[i][CarName], ABuyableVehicles[i][Price]);
  1351. SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  1352. SendClientMessage(playerid, 0xFFFFFFFF, TXT_PlayerMustUseGetcarAndPark);
  1353. // Save the player-file (and his houses)
  1354. PlayerFile_Save(playerid);
  1355. }
  1356. else // The player has not enough money to buy this vehicle
  1357. SendClientMessage(playerid, 0xFFFFFFFF, TXT_CannotAffordVehicle);
  1358. // Stop looking for the vehicle, as it's found and given to the player already
  1359. return 1;
  1360. }
  1361. else // The player chose another vehicle from the same class, keep looking for another one
  1362. Counter++;
  1363. }
  1364. }
  1365. return 1;
  1366. }
  1367. // Buy insurance for the house's vehicles
  1368. Dialog_BuyInsurance(playerid, response)
  1369. {
  1370. // Just close the dialog if the player clicked "No"
  1371. if(!response) return 1;
  1372. // Setup local variables
  1373. new Msg[128];
  1374. // Get the HouseID where the player is right now
  1375. new HouseID = APlayerData[playerid][CurrentHouse];
  1376. // Buy an insurance for this house's vehicles (insurance costs 10% of the house's baseprice)
  1377. AHouseData[HouseID][Insurance] = 1;
  1378. RewardPlayer(playerid, -(AHouseData[HouseID][HousePrice] / 10), 0);
  1379. // Let the player know he has bought a vehicle-insurance for this house
  1380. format(Msg, 128, TXT_PlayerBoughtInsurance, AHouseData[HouseID][HousePrice] / 10);
  1381. SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  1382. // Save the player-file (and his houses)
  1383. PlayerFile_Save(playerid);
  1384. // Also save the sold house, otherwise the old ownership-data is still there
  1385. HouseFile_Save(HouseID);
  1386. return 1;
  1387. }
  1388. // Sell the house
  1389. Dialog_SellHouse(playerid, response)
  1390. {
  1391. // Just close the dialog if the player clicked "Cancel"
  1392. if(!response) return 1;
  1393. // Get the HouseID where the player is right now
  1394. new HouseID = APlayerData[playerid][CurrentHouse];
  1395. // Set the player in the normal world again
  1396. SetPlayerVirtualWorld(playerid, 0);
  1397. SetPlayerInterior(playerid, 0);
  1398. // Set the position of the player at the entrance of his house
  1399. SetPlayerPos(playerid, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]);
  1400. // Also clear the tracking-variable to track in which house the player is
  1401. APlayerData[playerid][CurrentHouse] = 0;
  1402. // Clear the owner of the house
  1403. AHouseData[HouseID][Owned] = false;
  1404. AHouseData[HouseID][Owner] = 0;
  1405. // Clear the house-name and house-level
  1406. AHouseData[HouseID][HouseName] = 0;
  1407. AHouseData[HouseID][HouseLevel] = 1;
  1408. // Refund the player 50% of the worth of the house
  1409. RewardPlayer(playerid, House_CalcSellPrice(HouseID), 0);
  1410. SendClientMessage(playerid, 0xFFFFFFFF, TXT_PlayerSoldHouse);
  1411. // Clear the house-id from the player
  1412. for (new i; i < MAX_HOUSESPERPLAYER; i++)
  1413. {
  1414. // If the house-slot if found where the house was added to the player
  1415. if (APlayerData[playerid][Houses][i] == HouseID)
  1416. {
  1417. // Clear the house-id
  1418. APlayerData[playerid][Houses][i] = 0;
  1419. // Stop searching
  1420. break;
  1421. }
  1422. }
  1423. // Update the 3DText near the house's entrance to show other players that it's for sale again
  1424. House_UpdateEntrance(HouseID);
  1425. // Save the player-file (and his houses)
  1426. PlayerFile_Save(playerid);
  1427. // Also save the sold house, otherwise the old ownership-data is still there
  1428. HouseFile_Save(HouseID);
  1429. return 1;
  1430. }
  1431. // Sell the house
  1432. Dialog_SellCar(playerid, response, listitem)
  1433. {
  1434. // Just close the dialog if the player clicked "Cancel"
  1435. if(!response) return 1;
  1436. // Setup local variables
  1437. new HouseID = APlayerData[playerid][CurrentHouse];
  1438. new vid = AHouseData[HouseID][VehicleIDs][listitem];
  1439. // Check if there is a vehicle stored in this carslot
  1440. if (vid != 0)
  1441. {
  1442. new BuyableCarIndex = VehicleBuyable_GetIndex(GetVehicleModel(vid));
  1443. new Msg[128];
  1444. // Destroy the vehicle and remove it from the house
  1445. DestroyVehicle(vid);
  1446. AHouseData[HouseID][VehicleIDs][listitem] = 0;
  1447. // Also clear the data
  1448. AVehicleData[vid][Owned] = false;
  1449. AVehicleData[vid][Owner] = 0;
  1450. AVehicleData[vid][Model] = 0;
  1451. AVehicleData[vid][PaintJob] = 0;
  1452. for (new i; i < 14; i++)
  1453. AVehicleData[vid][Components][i] = 0;
  1454. AVehicleData[vid][SpawnX] = 0.0;
  1455. AVehicleData[vid][SpawnY] = 0.0;
  1456. AVehicleData[vid][SpawnZ] = 0.0;
  1457. AVehicleData[vid][SpawnRot] = 0.0;
  1458. // Refund the player with 50% of the vehicle's buying price
  1459. APlayerData[playerid][PlayerMoney] = APlayerData[playerid][PlayerMoney] + (ABuyableVehicles[BuyableCarIndex][Price] / 2);
  1460. // Let the player know about it
  1461. format(Msg, 128, TXT_PlayerSoldVehicle, ABuyableVehicles[BuyableCarIndex][CarName], ABuyableVehicles[BuyableCarIndex][Price] / 2);
  1462. SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  1463. // Save the player-file (and his houses)
  1464. PlayerFile_Save(playerid);
  1465. }
  1466. else
  1467. SendClientMessage(playerid, 0xFFFFFFFF, TXT_NoVehicleInSlot);
  1468. return 1;
  1469. }
  1470. // This dialog processes the selected house from which to get a vehicle using /getcar
  1471. Dialog_GetCarSelectHouse(playerid, response, listitem)
  1472. {
  1473. // Just close the dialog if the player clicked "Cancel"
  1474. if(!response) return 1;
  1475. // Get the houseid based on the chosen listitem
  1476. new HouseID = APlayerData[playerid][Houses][listitem];
  1477. // Check if it was a valid house
  1478. if (HouseID != 0)
  1479. {
  1480. // Setup local variables
  1481. new BuyableCarIndex, VehicleList[500], bool:HouseHasCars = false, CarSlot;
  1482. // Store the HouseID, otherwise the next dialog won't be able to get a car from the chosen house
  1483. APlayerData[playerid][DialogGetCarHouseID] = HouseID;
  1484. // Check if the house has any cars assigned to it
  1485. for (CarSlot = 0; CarSlot < 10; CarSlot++)
  1486. if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
  1487. HouseHasCars = true;
  1488. // Check if the house has any cars assigned to it
  1489. if (HouseHasCars == true)
  1490. {
  1491. // Add all vehicles to the list
  1492. for (CarSlot = 0; CarSlot < 10; CarSlot++)
  1493. {
  1494. // Check if the carslot has a vehicle in it
  1495. if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
  1496. {
  1497. // Get the index where the first vehicle is found in the ABuyableVehicles array
  1498. BuyableCarIndex = VehicleBuyable_GetIndex(GetVehicleModel(AHouseData[HouseID][VehicleIDs][CarSlot]));
  1499. // Add the name of the vehicle to the list
  1500. if (AVehicleData[AHouseData[HouseID][VehicleIDs][CarSlot]][Clamped] == true)
  1501. format(VehicleList, 500, "%s{00FF00}%s (clamped)\n", VehicleList, ABuyableVehicles[BuyableCarIndex][CarName]);
  1502. else
  1503. format(VehicleList, 500, "%s{00FF00}%s\n", VehicleList, ABuyableVehicles[BuyableCarIndex][CarName]);
  1504. }
  1505. else
  1506. format(VehicleList, 500, TXT_EmptyCarSlot, VehicleList);
  1507. }
  1508. // Ask which vehicle the player wants to teleport to his location
  1509. ShowPlayerDialog(playerid, DialogGetCarSelectCar, DIALOG_STYLE_LIST, TXT_SelectVehicleToGet, VehicleList, TXT_DialogButtonSelect, TXT_DialogButtonCancel);
  1510. }
  1511. else
  1512. SendClientMessage(playerid, 0xFFFFFFFF, TXT_NoHouseVehicles);
  1513. }
  1514. else
  1515. SendClientMessage(playerid, 0xFFFFFFFF, TXT_NoHouseInSlot);
  1516. return 1;
  1517. }
  1518. // This dialog processes the chosen car and spawns it at the player's location
  1519. Dialog_GetCarSelectCar(playerid, response, listitem)
  1520. {
  1521. // Just close the dialog if the player clicked "Cancel"
  1522. if(!response) return 1;
  1523. // Get the HouseID from which to get the car
  1524. new HouseID = APlayerData[playerid][DialogGetCarHouseID];
  1525. // Get the vehicleid from the chosen listitem
  1526. new vid = AHouseData[HouseID][VehicleIDs][listitem];
  1527. // Check if it was a valid vehicleid
  1528. if (vid != 0)
  1529. {
  1530. // Check if the vehicle is clamped
  1531. if (AVehicleData[vid][Clamped] == false)
  1532. {
  1533. // Setup local variables
  1534. new Float:x, Float:y, Float:z, Float:Angle;
  1535. // Get the player's position
  1536. GetPlayerPos(playerid, x, y, z);
  1537. GetPlayerFacingAngle(playerid, Angle);
  1538. // Port the vehicle to the player
  1539. SetVehiclePos(vid, x, y, z);
  1540. // Put the player inside the vehicle and rotate the vehicle to face where the player was facing
  1541. PutPlayerInVehicle(playerid, vid, 0);
  1542. SetVehicleZAngle(vid, Angle);
  1543. // Turn on the engine and lights
  1544. new engine,lights,alarm,doors,bonnet,boot,objective;
  1545. GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
  1546. SetVehicleParamsEx(vid, 1, 1, alarm, doors, bonnet, boot, objective);
  1547. // Store the player's current location and interior-id, otherwise anti-airbreak hack code could kick you
  1548. GetPlayerPos(playerid, APlayerData[playerid][PreviousX], APlayerData[playerid][PreviousY], APlayerData[playerid][PreviousZ]);
  1549. APlayerData[playerid][PreviousInt] = GetPlayerInterior(playerid);
  1550. // Let the player know he should park the vehicle
  1551. SendClientMessage(playerid, 0xFFFFFFFF, TXT_PlayerMustUsePark);
  1552. }
  1553. else // Inform the player that this vehicle is clamped and how he can un-clamp it
  1554. {
  1555. SendClientMessage(playerid, 0xFFFFFFFF, TXT_SpeedometerClampedVehicle);
  1556. SendClientMessage(playerid, 0xFFFFFFFF, TXT_SpeedometerClampedVehicle2);
  1557. }
  1558. }
  1559. else
  1560. SendClientMessage(playerid, 0xFFFFFFFF, TXT_NoVehicleInSlot);
  1561. return 1;
  1562. }
  1563. // This dialog processes the chosen business-type and creates the business
  1564. Dialog_CreateBusSelType(playerid, response, listitem)
  1565. {
  1566. // Just close the dialog if the player clicked "Cancel"
  1567. if(!response) return 1;
  1568. // Setup some local variables
  1569. new BusType, BusID, Float:x, Float:y, Float:z, Msg[128], bool:EmptySlotFound = false;
  1570. // Get the player's position
  1571. GetPlayerPos(playerid, x, y, z);
  1572. // Get the business-type from the option the player chose
  1573. BusType = listitem + 1;
  1574. // Find a free business-id
  1575. for (BusID = 1; BusID < MAX_BUSINESS; BusID++)
  1576. {
  1577. // Check if this business ID is free
  1578. if (ABusinessData[BusID][BusinessType] == 0)
  1579. {
  1580. EmptySlotFound = true;
  1581. break; // Stop processing
  1582. }
  1583. }
  1584. // Check if an empty slot has been found
  1585. if (EmptySlotFound == false)
  1586. {
  1587. // If no empty slot was found, let the player know about it and exit the function
  1588. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Maximum number of businesses reached");
  1589. return 1;
  1590. }
  1591. // Set some default data at the index of NextFreeBusinessID (NextFreeBusinessID will point to the next free business-index)
  1592. ABusinessData[BusID][BusinessX] = x;
  1593. ABusinessData[BusID][BusinessY] = y;
  1594. ABusinessData[BusID][BusinessZ] = z;
  1595. ABusinessData[BusID][BusinessType] = BusType;
  1596. ABusinessData[BusID][BusinessLevel] = 1;
  1597. ABusinessData[BusID][Owned] = false;
  1598. // Add the pickup and 3DText at the location of the business-entrance (where the player is standing when he creates the business)
  1599. Business_CreateEntrance(BusID);
  1600. // Save the business
  1601. BusinessFile_Save(BusID);
  1602. // Inform the player that he created a new house
  1603. format(Msg, 128, "{00FF00}You've succesfully created business {FF00FF}%i{00FF00}", BusID);
  1604. SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  1605. return 1;
  1606. }
  1607. // This function processes the businessmenu dialog
  1608. Dialog_BusinessMenu(playerid, response, listitem)
  1609. {
  1610. // Just close the dialog if the player clicked "Cancel"
  1611. if(!response) return 1;
  1612. // Setup local variables
  1613. new BusID, BusType, Msg[128], DialogTitle[200], UpgradePrice;
  1614. // Get the HouseID of the house where the player is
  1615. BusID = APlayerData[playerid][CurrentBusiness];
  1616. BusType = ABusinessData[BusID][BusinessType];
  1617. // Select an option based on the selection in the list
  1618. switch(listitem)
  1619. {
  1620. case 0: // Change business name
  1621. {
  1622. format(DialogTitle, 200, TXT_DialogOldBusinessName, ABusinessData[BusID][BusinessName]);
  1623. ShowPlayerDialog(playerid, DialogBusinessNameChange, DIALOG_STYLE_INPUT, DialogTitle, TXT_DialogEnterNewBusinessName, TXT_DialogButtonSelect, TXT_DialogButtonCancel);
  1624. }
  1625. case 1: // Upgrade the business
  1626. {
  1627. // Check if it's possible to upgrade further
  1628. if (ABusinessData[BusID][BusinessLevel] < 5)
  1629. {
  1630. // Get the upgrade-price
  1631. UpgradePrice = ABusinessInteriors[BusType][BusPrice];
  1632. // Check if the player can afford the upgrade
  1633. if (APlayerData[playerid][PlayerMoney] >= UpgradePrice)
  1634. {
  1635. // Give the current earnings of the business to the player and update the LastTransaction time
  1636. Business_PayEarnings(playerid, BusID);
  1637. // Upgrade the business 1 level
  1638. ABusinessData[BusID][BusinessLevel]++;
  1639. // Let the player pay for the upgrade
  1640. RewardPlayer(playerid, -UpgradePrice, 0);
  1641. // Update the 3DText near the business's entrance to show what level the business is
  1642. Business_UpdateEntrance(BusID);
  1643. // Let the player know about it
  1644. format(Msg, 128, "{00FF00}You have upgraded your business to level {FFFF00}%i", ABusinessData[BusID][BusinessLevel]);
  1645. SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  1646. }
  1647. else
  1648. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot afford the upgrade");
  1649. }
  1650. else
  1651. SendClientMessage(playerid, 0xFFFFFFFF, TXT_BusinessReachedMaxLevel);
  1652. }
  1653. case 2: // Retrieve business earnings
  1654. {
  1655. // Give the current earnings of the business to the player and update the LastTransaction time
  1656. Business_PayEarnings(playerid, BusID);
  1657. }
  1658. case 3: // Sell business
  1659. {
  1660. format(Msg, 128, TXT_SureSellBusiness, (ABusinessInteriors[BusType][BusPrice] * ABusinessData[BusID][BusinessLevel]) / 2);
  1661. ShowPlayerDialog(playerid, DialogSellBusiness, DIALOG_STYLE_MSGBOX, TXT_AreYouSure, Msg, TXT_DialogButtonYes, TXT_DialogButtonNo);
  1662. }
  1663. case 4: // Exit the business
  1664. {
  1665. Business_Exit(playerid, BusID);
  1666. }
  1667. }
  1668. return 1;
  1669. }
  1670. // This function processes the /gobus dialog
  1671. Dialog_GoBusiness(playerid, response, listitem)
  1672. {
  1673. // Just close the dialog if the player clicked "Cancel"
  1674. if(!response) return 1;
  1675. // Setup local variables
  1676. new BusIndex, BusID;
  1677. // The listitem directly indicates the business-index
  1678. BusIndex = listitem;
  1679. BusID = APlayerData[playerid][Business][BusIndex];
  1680. // Check if this is a valid business (BusID != 0)
  1681. if (BusID != 0)
  1682. {
  1683. // Get the coordinates of the business's entrance
  1684. SetPlayerPos(playerid, ABusinessData[BusID][BusinessX], ABusinessData[BusID][BusinessY], ABusinessData[BusID][BusinessZ]);
  1685. }
  1686. else
  1687. SendClientMessage(playerid, 0xFFFFFFFF, TXT_NoBusinessInSlot);
  1688. return 1;
  1689. }
  1690. // Let the player change the name of his business
  1691. Dialog_ChangeBusinessName(playerid, response, inputtext[])
  1692. {
  1693. // Just close the dialog if the player clicked "Cancel" or if the player didn't input any text
  1694. if ((!response) || (strlen(inputtext) == 0)) return 1;
  1695. // Change the name of the business
  1696. format(ABusinessData[APlayerData[playerid][CurrentBusiness]][BusinessName], 100, inputtext);
  1697. // Also update the 3DText at the entrance of the business
  1698. Business_UpdateEntrance(APlayerData[playerid][CurrentBusiness]);
  1699. // Let the player know that the name of his business has been changed
  1700. SendClientMessage(playerid, 0xFFFFFFFF, TXT_ChangedBusinessName);
  1701. // Save the player-file (and his houses and businesses)
  1702. PlayerFile_Save(playerid);
  1703. return 1;
  1704. }
  1705. // Sell the business
  1706. Dialog_SellBusiness(playerid, response)
  1707. {
  1708. // Just close the dialog if the player clicked "Cancel"
  1709. if(!response) return 1;
  1710. // Get the BusinessID where the player is right now and the business-type
  1711. new BusID = APlayerData[playerid][CurrentBusiness];
  1712. new BusType = ABusinessData[BusID][BusinessType];
  1713. // Set the player in the normal world again
  1714. SetPlayerVirtualWorld(playerid, 0);
  1715. SetPlayerInterior(playerid, 0);
  1716. // Set the position of the player at the entrance of his business
  1717. SetPlayerPos(playerid, ABusinessData[BusID][BusinessX], ABusinessData[BusID][BusinessY], ABusinessData[BusID][BusinessZ]);
  1718. // Also clear the tracking-variable to track in which business the player is
  1719. APlayerData[playerid][CurrentBusiness] = 0;
  1720. // Clear the owner of the business
  1721. ABusinessData[BusID][Owned] = false;
  1722. ABusinessData[BusID][Owner] = 0;
  1723. // Clear the house-name and business-level
  1724. ABusinessData[BusID][BusinessName] = 0;
  1725. ABusinessData[BusID][BusinessLevel] = 1;
  1726. // Refund the player 50% of the worth of the business
  1727. RewardPlayer(playerid, (ABusinessInteriors[BusType][BusPrice] * ABusinessData[BusID][BusinessLevel]) / 2, 0);
  1728. SendClientMessage(playerid, 0xFFFFFFFF, TXT_PlayerSoldBusiness);
  1729. // Clear the house-id from the player
  1730. for (new i; i < MAX_BUSINESSPERPLAYER; i++)
  1731. {
  1732. // If the business-slot if found where the business was added to the player
  1733. if (APlayerData[playerid][Business][i] == BusID)
  1734. {
  1735. // Clear the business-id
  1736. APlayerData[playerid][Business][i] = 0;
  1737. // Stop searching
  1738. break;
  1739. }
  1740. }
  1741. // Update the 3DText near the business's entrance to show other players that it's for sale again
  1742. Business_UpdateEntrance(BusID);
  1743. // Save the player-file (and his houses and businesses)
  1744. PlayerFile_Save(playerid);
  1745. // Also save the sold business, otherwise the old ownership-data is still there
  1746. BusinessFile_Save(BusID);
  1747. return 1;
  1748. }
  1749. // Process the commands dialog
  1750. Dialog_PlayerCommands(playerid, response, listitem)
  1751. {
  1752. // Just close the dialog if the player clicked "Cancel"
  1753. if(!response)
  1754. {
  1755. // Reset the FirstCommand (so the list won't start at an unexpected location in the list, but back at the start of the list)
  1756. APlayerData[playerid][DialogFirstItem] = 0;
  1757. return 1; // Exit the function
  1758. }
  1759. // Process the selected listitem
  1760. switch (listitem)
  1761. {
  1762. case 11: // Player chooses "Next..."
  1763. {
  1764. // Add 5 to the FirstCommand, so the list will start further down the array (will show the next 5 commands)
  1765. APlayerData[playerid][DialogFirstItem] = APlayerData[playerid][DialogFirstItem] + 5;
  1766. // Create a new list of commands and show the dialog
  1767. CommandList_Create(playerid);
  1768. }
  1769. }
  1770. return 1;
  1771. }
  1772. // Process the primary car color dialog
  1773. Dialog_PrimaryCarColor(playerid, response, listitem)
  1774. {
  1775. // Just close the dialog if the player clicked "Cancel"
  1776. if(!response) return 1;
  1777. // Setup local variables
  1778. new vid = GetPlayerVehicleID(playerid);
  1779. // Save the primary car-color and apply the colors
  1780. AVehicleData[vid][Color1] = listitem;
  1781. ChangeVehicleColor(GetPlayerVehicleID(playerid), AVehicleData[vid][Color1], AVehicleData[vid][Color2]);
  1782. // If the primary color is black, remove the paintjob
  1783. if (listitem == 0)
  1784. AVehicleData[vid][PaintJob] = 0;
  1785. // Let the player pay $150 for changing the color
  1786. RewardPlayer(playerid, -150, 0);
  1787. SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}You've changed the color of your vehicle for $150");
  1788. return 1;
  1789. }
  1790. // Process the secundary car color dialog
  1791. Dialog_SedundaryCarColor(playerid, response, listitem)
  1792. {
  1793. // Just close the dialog if the player clicked "Cancel"
  1794. if(!response) return 1;
  1795. // Setup local variables
  1796. new vid = GetPlayerVehicleID(playerid);
  1797. // Save the primary car-color and apply the colors
  1798. AVehicleData[vid][Color2] = listitem;
  1799. ChangeVehicleColor(GetPlayerVehicleID(playerid), AVehicleData[vid][Color1], AVehicleData[vid][Color2]);
  1800. // Let the player pay $150 for changing the color
  1801. RewardPlayer(playerid, -150, 0);
  1802. SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}You've changed the color of your vehicle for $150");
  1803. return 1;
  1804. }
  1805. // Process the unclamp dialog
  1806. Dialog_UnclampVehicles(playerid, response)
  1807. {
  1808. // Just close the dialog if the player clicked "Cancel"
  1809. if(!response) return 1;
  1810. // Setup local variables
  1811. new HouseID, vid, ClampedVehicles, UnclampPrice, Msg[128];
  1812. // Loop through all vehicles owned by this player
  1813. for (new HouseSlot; HouseSlot < MAX_HOUSESPERPLAYER; HouseSlot++)
  1814. {
  1815. // Get the HouseID that exists on this index
  1816. HouseID = APlayerData[playerid][Houses][HouseSlot];
  1817. // Check if this house-slot is used
  1818. if (HouseID != 0)
  1819. {
  1820. // Loop through all vehicles assigned to this house
  1821. for (new CarSlot; CarSlot < 10; CarSlot++)
  1822. {
  1823. // Get the vehicle-id of the vehicle in this carslot
  1824. vid = AHouseData[HouseID][VehicleIDs][CarSlot];
  1825. // Check if this carslot is used
  1826. if (vid != 0)
  1827. {
  1828. // Check if this vehicle is clamped
  1829. if (AVehicleData[vid][Clamped] == true)
  1830. ClampedVehicles++; // Count the clamped vehicles
  1831. }
  1832. }
  1833. }
  1834. }
  1835. // Calculate the price to unclamp all the player's vehicles
  1836. UnclampPrice = ClampedVehicles * UnclampPricePerVehicle;
  1837. // Check if the player has enough cash to unclamp his vehicles
  1838. if (APlayerData[playerid][PlayerMoney] >= UnclampPrice)
  1839. {
  1840. // Loop through all vehicles owned by this player
  1841. for (new HouseSlot; HouseSlot < MAX_HOUSESPERPLAYER; HouseSlot++)
  1842. {
  1843. // Get the HouseID that exists on this index
  1844. HouseID = APlayerData[playerid][Houses][HouseSlot];
  1845. // Check if this house-slot is used
  1846. if (HouseID != 0)
  1847. {
  1848. // Loop through all vehicles assigned to this house
  1849. for (new CarSlot; CarSlot < 10; CarSlot++)
  1850. {
  1851. // Get the vehicle-id of the vehicle in this carslot
  1852. vid = AHouseData[HouseID][VehicleIDs][CarSlot];
  1853. // Check if this carslot is used
  1854. if (vid != 0)
  1855. {
  1856. // Check if this vehicle is clamped
  1857. if (AVehicleData[vid][Clamped] == true)
  1858. AVehicleData[vid][Clamped] = false; // Unclamp the vehicle
  1859. }
  1860. }
  1861. }
  1862. }
  1863. // Remove the money from the player
  1864. RewardPlayer(playerid, -UnclampPrice, 0);
  1865. // Let the player know his vehicles have been unclamped
  1866. format(Msg, 128, "{00FF00}Your vehicles have been unclamped for {FFFF00}$%i", UnclampPrice);
  1867. SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  1868. // Save the player's profile
  1869. PlayerFile_Save(playerid);
  1870. }
  1871. else
  1872. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You don't have enough money to unclamp your vehicles");
  1873. return 1;
  1874. }
  1875. // Process the rules dialog
  1876. Dialog_Rules(playerid, response)
  1877. {
  1878. // Just close the dialog if the player clicked "Cancel"
  1879. if(!response) return 1;
  1880. // Check if the player accepted the rules already
  1881. if (APlayerData[playerid][RulesRead] == false)
  1882. {
  1883. // Reward the player with $5000 for accepting the rules
  1884. RewardPlayer(playerid, 5000, 0);
  1885. // Save that the player has accepted the rules
  1886. APlayerData[playerid][RulesRead] = true;
  1887. // Let the player know he earned some money for accepting the rules
  1888. SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}You have earned {FFFF00}$5000{00FF00} for accepting the rules");
  1889. // Save the player's profile
  1890. PlayerFile_Save(playerid);
  1891. }
  1892. return 1;
  1893. }
  1894. // Process the dialog that displays statistics of another player (accessed through the scoreboard)
  1895. Dialog_StatsOtherPlayer(playerid, response, listitem)
  1896. {
  1897. // Just close the dialog if the player clicked "Cancel"
  1898. if(!response) return 1;
  1899. // Setup local variables
  1900. new Name[24], DialogTitle[128], HouseList[1000], BusinessList[1000], BusID, BusType, Earnings, OtherPlayer, HouseID;
  1901. // Get the ID of the other player
  1902. OtherPlayer = APlayerData[playerid][DialogOtherPlayer];
  1903. // If the player chose the line "Houses: xxx" or "Businesses: xxx", open a new dialog that displays them
  1904. switch (listitem)
  1905. {
  1906. case 20: // Player chose to display the other player's houses
  1907. {
  1908. // Construct the dialog-title
  1909. GetPlayerName(OtherPlayer, Name, sizeof(Name));
  1910. format(DialogTitle, 128, "Houses of player: %s", Name);
  1911. // Add all house-names of the other player to the list
  1912. for (new i; i < MAX_HOUSESPERPLAYER; i++)
  1913. {
  1914. // Get the HouseID
  1915. HouseID = APlayerData[OtherPlayer][Houses][i];
  1916. // Check if this houseindex is occupied
  1917. if (HouseID != 0)
  1918. format(HouseList, 1000, "%s{00FF00}%s{FFFFFF}\n", HouseList, AHouseData[HouseID][HouseName]);
  1919. else
  1920. format(HouseList, 1000, "%s{FFFFFF}%s{FFFFFF}\n", HouseList, "Empty house-slot");
  1921. }
  1922. // Display the dialog (displays all statistics about the house, such as level, bought vehicles, insurance, ...)
  1923. ShowPlayerDialog(playerid, DialogStatsHouse, DIALOG_STYLE_LIST, DialogTitle, HouseList, "Select", "Cancel");
  1924. }
  1925. case 21: // Player chose to display the other player's businesses
  1926. {
  1927. // Construct the dialog-title
  1928. GetPlayerName(OtherPlayer, Name, sizeof(Name));
  1929. format(DialogTitle, 128, "Businesses of player: %s", Name);
  1930. // Ask to which business the player wants to port
  1931. for (new i; i < MAX_BUSINESSPERPLAYER; i++)
  1932. {
  1933. // Get the business-id
  1934. BusID = APlayerData[OtherPlayer][Business][i];
  1935. // Check if this businessindex is occupied
  1936. if (BusID != 0)
  1937. {
  1938. // Get the business-type
  1939. BusType = ABusinessData[BusID][BusinessType];
  1940. Earnings = (BusinessTransactionTime - ABusinessData[BusID][LastTransaction]) * ABusinessInteriors[BusType][BusEarnings] * ABusinessData[BusID][BusinessLevel];
  1941. format(BusinessList, 1000, "%s{00FF00}%s{FFFFFF} (earnings: $%i)\n", BusinessList, ABusinessData[BusID][BusinessName], Earnings);
  1942. }
  1943. else
  1944. format(BusinessList, 1000, "%s{FFFFFF}%s{FFFFFF}\n", BusinessList, "Empty business-slot");
  1945. }
  1946. // Display the dialog (and allow the player to port there)
  1947. ShowPlayerDialog(playerid, DialogStatsGoBusiness, DIALOG_STYLE_LIST, DialogTitle, BusinessList, "Goto", "Cancel");
  1948. }
  1949. }
  1950. return 1;
  1951. }
  1952. // Process the chosen house from another player (displays the statistics of the chosen house)
  1953. Dialog_StatsHouse(playerid, response, listitem)
  1954. {
  1955. // Just close the dialog if the player clicked "Cancel"
  1956. if(!response) return 1;
  1957. // Setup local variables
  1958. new OtherPlayer, HouseID, HouseData[2000], BuyableCarIndex, DialogTitle[128], Name[24];
  1959. // Get the other player and chosen HouseID
  1960. OtherPlayer = APlayerData[playerid][DialogOtherPlayer];
  1961. HouseID = APlayerData[OtherPlayer][Houses][listitem];
  1962. // Construct the dialog-title
  1963. GetPlayerName(OtherPlayer, Name, sizeof(Name));
  1964. format(DialogTitle, 128, "House of player: %s", Name);
  1965. // Check if this is a valid HouseID
  1966. if (HouseID != 0)
  1967. {
  1968. // Add all data about the house to the dialog
  1969. format(HouseData, sizeof(HouseData), "%s{FFFFFF}Name: {00FF00}%s\n", HouseData, AHouseData[HouseID][HouseName]);
  1970. if (AHouseData[HouseID][Insurance] == 1)
  1971. format(HouseData, sizeof(HouseData), "%s{FFFFFF}Insurance: {00FF00}Yes\n", HouseData);
  1972. else
  1973. format(HouseData, sizeof(HouseData), "%s{FFFFFF}Insurance: {00FF00}No\n", HouseData);
  1974. format(HouseData, sizeof(HouseData), "%s{FFFFFF}House-level: {00FF00}%i/%i\n", HouseData, AHouseData[HouseID][HouseLevel], AHouseData[HouseID][HouseMaxLevel]);
  1975. format(HouseData, sizeof(HouseData), "%s{FFFFFF}House-price: {00FF00}%i\n \n", HouseData, AHouseData[HouseID][HousePrice]);
  1976. format(HouseData, sizeof(HouseData), "%s{FFFFFF}Vehicles:\n", HouseData);
  1977. // Add all vehicles to the list
  1978. for (new CarSlot; CarSlot < 10; CarSlot++)
  1979. {
  1980. // Check if the carslot has a vehicle in it
  1981. if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
  1982. {
  1983. // Get the index where the first vehicle is found in the ABuyableVehicles array
  1984. BuyableCarIndex = VehicleBuyable_GetIndex(GetVehicleModel(AHouseData[HouseID][VehicleIDs][CarSlot]));
  1985. // Add the name of the vehicle to the list
  1986. if (AVehicleData[AHouseData[HouseID][VehicleIDs][CarSlot]][Clamped] == true)
  1987. format(HouseData, 500, "%s{00FF00}%s (clamped)\n", HouseData, ABuyableVehicles[BuyableCarIndex][CarName]);
  1988. else
  1989. format(HouseData, 500, "%s{00FF00}%s\n", HouseData, ABuyableVehicles[BuyableCarIndex][CarName]);
  1990. }
  1991. else
  1992. format(HouseData, 500, TXT_EmptyCarSlot, HouseData);
  1993. }
  1994. // Store the HouseID that was chosen of the other player so the other dialogs can display the statistics further
  1995. APlayerData[playerid][DialogOtherPlayerHouse] = HouseID;
  1996. // Display the dialog (and allow the player to port there)
  1997. ShowPlayerDialog(playerid, DialogStatsGoHouse, DIALOG_STYLE_LIST, DialogTitle, HouseData, "Goto", "Cancel");
  1998. }
  1999. else
  2000. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}There is no house in this house-slot");
  2001. return 1;
  2002. }
  2003. // Port to the house that was chosen by the player when viewing stats about a house and choosing "Goto"
  2004. Dialog_StatsGoHouse(playerid, response, listitem)
  2005. {
  2006. // Just close the dialog if the player clicked "Cancel"
  2007. if(!response) return 1;
  2008. // Setup local variables
  2009. new HouseID, CarSlot, Float:x, Float:y, Float:z;
  2010. // Get the HouseID
  2011. HouseID = APlayerData[playerid][DialogOtherPlayerHouse];
  2012. switch (listitem)
  2013. {
  2014. case 6, 7, 8, 9, 10: // One of the cars in the list
  2015. {
  2016. // Calculate the CarSlot
  2017. CarSlot = listitem - 6;
  2018. // Check if the carslot has a car in it
  2019. if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
  2020. {
  2021. // Get the position of the vehicle
  2022. GetVehiclePos(AHouseData[HouseID][VehicleIDs][CarSlot], x, y, z);
  2023. // Port the player to the vehicle
  2024. SetPlayerPos(playerid, x, y, z);
  2025. }
  2026. else
  2027. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}There is no vehicle in this car-slot");
  2028. }
  2029. default: // Any other line
  2030. {
  2031. // Port the player to the house entrance
  2032. SetPlayerPos(playerid, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]);
  2033. }
  2034. }
  2035. return 1;
  2036. }
  2037. // Process the chosen business from another player to port to
  2038. Dialog_StatsGoBusiness(playerid, response, listitem)
  2039. {
  2040. // Just close the dialog if the player clicked "Cancel"
  2041. if(!response) return 1;
  2042. // Setup local variables
  2043. new BusIndex, BusID;
  2044. // The listitem directly indicates the business-index
  2045. BusIndex = listitem;
  2046. BusID = APlayerData[APlayerData[playerid][DialogOtherPlayer]][Business][BusIndex];
  2047. // Check if this is a valid business (BusID != 0)
  2048. if (BusID != 0)
  2049. {
  2050. // Get the coordinates of the business's entrance
  2051. SetPlayerPos(playerid, ABusinessData[BusID][BusinessX], ABusinessData[BusID][BusinessY], ABusinessData[BusID][BusinessZ]);
  2052. }
  2053. else
  2054. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}There is no business in this business-slot");
  2055. return 1;
  2056. }
  2057. // Process the password to register a bank account
  2058. Dialog_BankPasswordRegister(playerid, response, inputtext[])
  2059. {
  2060. // Just close the dialog if the player clicked "Cancel"
  2061. if(!response) return 1;
  2062. // Check if the player entered a valid password
  2063. if ((strlen(inputtext) > 0) && (strlen(inputtext) < 20))
  2064. {
  2065. // Store the password
  2066. format(APlayerData[playerid][BankPassword], 24, inputtext);
  2067. // Save the bank account
  2068. BankFile_Save(playerid);
  2069. // Inform the player that he has succesfully registered a bank account
  2070. SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}You've succesfully registered a bank account");
  2071. }
  2072. else
  2073. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You need to enter a valid password to register a bank account");
  2074. return 1;
  2075. }
  2076. // Process the password to login to your bank account
  2077. Dialog_BankPasswordLogin(playerid, response, inputtext[])
  2078. {
  2079. // Just close the dialog if the player clicked "Cancel"
  2080. if(!response) return 1;
  2081. // Check if the player entered a valid password
  2082. if ((strlen(inputtext) > 0) && (strlen(inputtext) < 20))
  2083. {
  2084. // Check if the player entered the correct password to login to his bank account
  2085. if (strcmp(APlayerData[playerid][BankPassword], inputtext, false) == 0)
  2086. {
  2087. // The player has logged in to his bank account
  2088. APlayerData[playerid][BankLoggedIn] = true;
  2089. // Inform the player that he has succesfully registered a bank account
  2090. SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}You've succesfully logged in to your bank account");
  2091. // Show the bank dialog
  2092. ShowBankMenu(playerid);
  2093. }
  2094. else // The player entered the wrong password
  2095. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You've entered the wrong password for logging in to your bank account");
  2096. }
  2097. else
  2098. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You need to enter the correct password to login to your bank account");
  2099. return 1;
  2100. }
  2101. // Process the options in the bank dialog
  2102. Dialog_BankOptions(playerid, response, listitem)
  2103. {
  2104. // Just close the dialog if the player clicked "Cancel"
  2105. if(!response) return 1;
  2106. // Setup local variables
  2107. new DialogMsg[500];
  2108. // Check what to do based on which option is chosen
  2109. switch (listitem)
  2110. {
  2111. case 0: // Deposit funds in your bank account
  2112. {
  2113. format(DialogMsg, sizeof(DialogMsg), "{FFFFFF}Your money: {00FF00}$%i\n", APlayerData[playerid][PlayerMoney]);
  2114. format(DialogMsg, sizeof(DialogMsg), "%s{FFFFFF}Bank account funds: {00FF00}$%i\n \n", DialogMsg, APlayerData[playerid][BankMoney]);
  2115. format(DialogMsg, sizeof(DialogMsg), "%s{FFFFFF}Please enter the amount of money you want to deposit into your bank account:", DialogMsg);
  2116. ShowPlayerDialog(playerid, DialogBankDeposit, DIALOG_STYLE_INPUT, "Enter amount of money", DialogMsg, TXT_DialogButtonSelect, TXT_DialogButtonCancel);
  2117. }
  2118. case 1: // Withdraw funds from your bank account
  2119. {
  2120. // Check if you have any money in your bank account to withdraw from it
  2121. if (APlayerData[playerid][BankMoney] > 0)
  2122. {
  2123. format(DialogMsg, sizeof(DialogMsg), "{FFFFFF}Your money: {00FF00}$%i\n", APlayerData[playerid][PlayerMoney]);
  2124. format(DialogMsg, sizeof(DialogMsg), "%s{FFFFFF}Bank account funds: {00FF00}$%i\n \n", DialogMsg, APlayerData[playerid][BankMoney]);
  2125. format(DialogMsg, sizeof(DialogMsg), "%s{FFFFFF}Please enter the amount of money you want to withdraw from your bank account:", DialogMsg);
  2126. ShowPlayerDialog(playerid, DialogBankWithdraw, DIALOG_STYLE_INPUT, "Enter amount of money", DialogMsg, TXT_DialogButtonSelect, TXT_DialogButtonCancel);
  2127. }
  2128. else
  2129. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You can't withdraw money from an empty bank account");
  2130. }
  2131. case 2: // Transfer funds from your bank account to another player's bank account
  2132. {
  2133. // Check if you have any money in your bank account to transfer from it
  2134. if (APlayerData[playerid][BankMoney] > 0)
  2135. {
  2136. format(DialogMsg, sizeof(DialogMsg), "{FFFFFF}Your money: {00FF00}$%i\n", APlayerData[playerid][PlayerMoney]);
  2137. format(DialogMsg, sizeof(DialogMsg), "%s{FFFFFF}Bank account funds: {00FF00}$%i\n \n", DialogMsg, APlayerData[playerid][BankMoney]);
  2138. format(DialogMsg, sizeof(DialogMsg), "%s{FFFFFF}Please enter the amount of money you want to transfer to another player's bank account:", DialogMsg);
  2139. ShowPlayerDialog(playerid, DialogBankTransferMoney, DIALOG_STYLE_INPUT, "Enter amount of money", DialogMsg, TXT_DialogButtonSelect, TXT_DialogButtonCancel);
  2140. }
  2141. else
  2142. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You can't transfer money from an empty bank account");
  2143. }
  2144. case 3: // Cancel your bank account
  2145. {
  2146. if (APlayerData[playerid][BankMoney] > 0)
  2147. {
  2148. format(DialogMsg, sizeof(DialogMsg), "{FFFFFF}Your bank account has {00FF00}$%i{FFFFFF} in it\n", APlayerData[playerid][BankMoney]);
  2149. format(DialogMsg, sizeof(DialogMsg), "%s{FFFFFF}Your bank funds will be returned to you when you cancel your bank account\n", DialogMsg, APlayerData[playerid][BankMoney]);
  2150. }
  2151. format(DialogMsg, sizeof(DialogMsg), "%s{FFFFFF}Are you sure you want to cancel your bank account?", DialogMsg);
  2152. // Ask the player if he's sure he wants to cancel his bank account
  2153. ShowPlayerDialog(playerid, DialogBankCancel, DIALOG_STYLE_MSGBOX, TXT_AreYouSure, DialogMsg, TXT_DialogButtonYes, TXT_DialogButtonNo);
  2154. }
  2155. }
  2156. return 1;
  2157. }
  2158. // Process the entered amount of money that needs to be deposited into the player's bank account
  2159. Dialog_BankDeposit(playerid, response, inputtext[])
  2160. {
  2161. // Just close the dialog if the player clicked "Cancel"
  2162. if(!response) return 1;
  2163. // Setup local variables
  2164. new DepositMoney, Msg[128];
  2165. // Convert the entered text into an integer
  2166. DepositMoney = strval(inputtext);
  2167. // Check if the player entered a positive amount of money
  2168. if (DepositMoney > 0)
  2169. {
  2170. // Check if the player has enough money
  2171. if (DepositMoney <= APlayerData[playerid][PlayerMoney])
  2172. {
  2173. // Add the money to your bank account
  2174. APlayerData[playerid][BankMoney] = APlayerData[playerid][BankMoney] + DepositMoney;
  2175. // Take the money away from yourself
  2176. APlayerData[playerid][PlayerMoney] = APlayerData[playerid][PlayerMoney] - DepositMoney;
  2177. // Save the player's account
  2178. PlayerFile_Save(playerid);
  2179. // Save the bank account
  2180. BankFile_Save(playerid);
  2181. // Inform the player that his money has been deposited
  2182. format(Msg, 128, "{00FF00}You have deposited {FFFF00}$%i{00FF00} into your bank account", DepositMoney);
  2183. SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  2184. // Show the bank dialog
  2185. ShowBankMenu(playerid);
  2186. }
  2187. else
  2188. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You don't have that amount of money to deposit into your bank account");
  2189. }
  2190. else
  2191. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You need to enter a positive amount of money to deposit into your bank account");
  2192. return 1;
  2193. }
  2194. // Process the entered amount of money that needs to be withdrawn from the player's bank account
  2195. Dialog_BankWithdraw(playerid, response, inputtext[])
  2196. {
  2197. // Just close the dialog if the player clicked "Cancel"
  2198. if(!response) return 1;
  2199. // Setup local variables
  2200. new WithdrawMoney, Msg[128];
  2201. // Convert the entered text into an integer
  2202. WithdrawMoney = strval(inputtext);
  2203. // Check if the player entered a positive amount of money
  2204. if (WithdrawMoney > 0)
  2205. {
  2206. // Check if the player has enough money in his bank account
  2207. if (WithdrawMoney <= APlayerData[playerid][BankMoney])
  2208. {
  2209. // Withdraw the money from your bank account
  2210. APlayerData[playerid][BankMoney] = APlayerData[playerid][BankMoney] - WithdrawMoney;
  2211. // Give the money to yourself
  2212. APlayerData[playerid][PlayerMoney] = APlayerData[playerid][PlayerMoney] + WithdrawMoney;
  2213. // Save the player's account
  2214. PlayerFile_Save(playerid);
  2215. // Save the bank account
  2216. BankFile_Save(playerid);
  2217. // Inform the player that his money has been withdrawn
  2218. format(Msg, 128, "{00FF00}You have withdrawn {FFFF00}$%i{00FF00} from your bank account", WithdrawMoney);
  2219. SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  2220. // Show the bank dialog
  2221. ShowBankMenu(playerid);
  2222. }
  2223. else
  2224. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You don't have that amount of money in your bank account to withdraw");
  2225. }
  2226. else
  2227. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You need to enter a positive amount of money to withdraw from your bank account");
  2228. return 1;
  2229. }
  2230. // Process the transfer option (player entered the amount of money to transfer to another player)
  2231. Dialog_BankTransferMoney(playerid, response, inputtext[])
  2232. {
  2233. // Just close the dialog if the player clicked "Cancel"
  2234. if(!response) return 1;
  2235. // Setup local variables
  2236. new DialogMsg[500];
  2237. // Check if there is a text entered
  2238. if (strlen(inputtext) == 0)
  2239. {
  2240. // Let the player know he must enter a valid amount of money into the input field
  2241. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You need to enter a valid amount of money");
  2242. return 1;
  2243. }
  2244. // Convert the entered text into an integer and store it
  2245. APlayerData[playerid][UseMoney] = strval(inputtext);
  2246. // Check if the player entered a valid amount of money to be transferred
  2247. if (APlayerData[playerid][UseMoney] > 0)
  2248. {
  2249. // Check if the player has enough money in his bank account to transfer it to another player's account
  2250. if (APlayerData[playerid][UseMoney] <= APlayerData[playerid][BankMoney])
  2251. {
  2252. // Ask the player to which account he wants to transfer the money
  2253. format(DialogMsg, sizeof(DialogMsg), "{FFFFFF}Your money: {00FF00}$%i\n", APlayerData[playerid][PlayerMoney]);
  2254. format(DialogMsg, sizeof(DialogMsg), "%s{FFFFFF}Bank account funds: {00FF00}$%i\n", DialogMsg, APlayerData[playerid][BankMoney]);
  2255. format(DialogMsg, sizeof(DialogMsg), "%s{FFFFFF}Requested transfer amount: {00FF00}$%i\n \n", DialogMsg, APlayerData[playerid][UseMoney]);
  2256. format(DialogMsg, sizeof(DialogMsg), "%s{FFFFFF}Please enter the name of the player who must receive your money-transfer:", DialogMsg);
  2257. ShowPlayerDialog(playerid, DialogBankTransferName, DIALOG_STYLE_INPUT, "Enter player name", DialogMsg, TXT_DialogButtonSelect, TXT_DialogButtonCancel);
  2258. }
  2259. else
  2260. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You don't have that amount of money in your bank account to transfer to another player's account");
  2261. }
  2262. else
  2263. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You need to enter a positive amount of money to transfer money to another player's account");
  2264. return 1;
  2265. }
  2266. // Process the transfer option (player entered the name of the other player who must receive the money)
  2267. Dialog_BankTransferName(playerid, response, inputtext[])
  2268. {
  2269. // Just close the dialog if the player clicked "Cancel"
  2270. if(!response) return 1;
  2271. // Setup local variables
  2272. new file[100], File:BFile, LineForFile[100], ReceiverName[24], SenderName[24], Msg[128];
  2273. new OtherPlayer, Day, Month, Year, Hour, Minute, Second, sDay[3], sMonth[3], sYear[5], sHour[3], sMinute[3];
  2274. // Get the playername of the sender (the player who executes the transfer)
  2275. format(SenderName, sizeof(SenderName), APlayerData[playerid][PlayerName]);
  2276. // Check if there is a text entered
  2277. if (strlen(inputtext) == 0)
  2278. {
  2279. // Let the player know he must enter a playername or playerid into the input field
  2280. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You need to enter a playername OR id");
  2281. return 1;
  2282. }
  2283. // Try to convert the given playername OR playerid to a playerid
  2284. sscanf(inputtext, "u", OtherPlayer);
  2285. // Check if an online player was found by sscanf
  2286. if (OtherPlayer != INVALID_PLAYER_ID)
  2287. {
  2288. // Check if that other player is online (use online bank-transfer)
  2289. if (APlayerData[OtherPlayer][LoggedIn] == true)
  2290. {
  2291. format(ReceiverName, sizeof(ReceiverName), APlayerData[OtherPlayer][PlayerName]); // Get the playername of the receiver
  2292. format(file, sizeof(file), BankFile, ReceiverName); // Construct the complete filename for the receiver's bank-account
  2293. // Check if the receiver has a bank account
  2294. if (fexist(file))
  2295. {
  2296. // Transfer the money from your bank account to the other player's bank account
  2297. APlayerData[OtherPlayer][BankMoney] = APlayerData[OtherPlayer][BankMoney] + APlayerData[playerid][UseMoney];
  2298. // Take the money away from your own bank account
  2299. APlayerData[playerid][BankMoney] = APlayerData[playerid][BankMoney] - APlayerData[playerid][UseMoney];
  2300. // Save both bank accounts
  2301. BankFile_Save(OtherPlayer);
  2302. BankFile_Save(playerid);
  2303. // Inform the receiver that money was transferred to his bank account
  2304. format(Msg, 128, "{00FF00}Your bank account has received a transfer of {FFFF00}$%i{00FF00} from {FFFF00}%s", APlayerData[playerid][UseMoney], SenderName);
  2305. SendClientMessage(OtherPlayer, 0xFFFFFFFF, Msg);
  2306. // Inform the sender that money was transferred from his bank account to the receiver
  2307. format(Msg, 128, "{00FF00}You have transferred {FFFF00}$%i{00FF00} to {FFFF00}%s{00FF00}'s bank account", APlayerData[playerid][UseMoney], ReceiverName);
  2308. SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  2309. // Exit the function (bank transfer was completed), skipping offline transfer
  2310. return 1;
  2311. }
  2312. else // The target player is online, but has no bank account
  2313. {
  2314. format(Msg, 128, "{FF0000}Player {FFFF00}%s{FF0000} is online, but has no bank account, transfer failed", inputtext);
  2315. SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  2316. // Exit the function (bank transfer failed as the target player has no bank account), skipping offline transfer
  2317. return 1;
  2318. }
  2319. }
  2320. else
  2321. {
  2322. // An online player was found here, but he hasn't logged in yet, so treat him as an offline player
  2323. // The rest of the function will be executes to process offline bank transfers
  2324. }
  2325. }
  2326. // The player might be offline or doesn't exist (no player account with that name), so try to use an offline bank-transfer
  2327. // This part of the code is executed because sscanf failed to find an online player with the given name
  2328. // or the player is connected to the server, but hasn't logged in yet (didn't type his password already), this is treated
  2329. // as being offline
  2330. // Construct the complete filename for the receiver's bank-account
  2331. format(file, sizeof(file), BankFile, inputtext);
  2332. // Check if the receiver has a bank account
  2333. if (fexist(file))
  2334. {
  2335. // Open the file
  2336. BFile = fopen(file, io_append); // Open the receiver's bank account for appending data to it
  2337. fwrite(BFile, "[Transfer]\r\n");
  2338. format(LineForFile, 100, "TransferMoney %i\r\n", APlayerData[playerid][UseMoney]); // Construct the line: "TransferMoney <TransferMoney>"
  2339. fwrite(BFile, LineForFile); // And save it to the file
  2340. format(LineForFile, 100, "TransferName %s\r\n", SenderName); // Construct the line: "TransferName <SenderName>"
  2341. fwrite(BFile, LineForFile); // And save it to the file
  2342. // Get the current date and time
  2343. getdate(Year, Month, Day);
  2344. gettime(Hour, Minute, Second);
  2345. // Make sure the Day is 2 characters long
  2346. if (Day < 10) format(sDay, sizeof(sDay), "0%i", Day);
  2347. else format(sDay, sizeof(sDay), "%i", Day);
  2348. // Make sure the Month is 2 characters long
  2349. if (Month < 10) format(sMonth, sizeof(sMonth), "0%i", Month);
  2350. else format(sMonth, sizeof(sMonth), "%i", Month);
  2351. // Convert the Year into a string
  2352. format(sYear, sizeof(sYear), "%i", Year);
  2353. // Make sure the Hour is 2 characters long
  2354. if (Hour < 10) format(sHour, sizeof(sHour), "0%i", Hour);
  2355. else format(sHour, sizeof(sHour), "%i", Hour);
  2356. // Make sure the Minute is 2 characters long
  2357. if (Minute < 10) format(sMinute, sizeof(sMinute), "0%i", Minute);
  2358. else format(sMinute, sizeof(sMinute), "%i", Minute);
  2359. format(LineForFile, 100, "TransferTime %s/%s/%s %s:%s\r\n", sDay, sMonth, sYear, sHour, sMinute); // Construct the line: "TransferTime <TransferTime>"
  2360. fwrite(BFile, LineForFile); // And save it to the file
  2361. fwrite(BFile, "[/Transfer]\r\n"); // Save the transfer-terminator string to the file
  2362. fclose(BFile); // Close the file
  2363. // Take the money away from your own bank account
  2364. APlayerData[playerid][BankMoney] = APlayerData[playerid][BankMoney] - APlayerData[playerid][UseMoney];
  2365. // Save your bank account
  2366. BankFile_Save(playerid);
  2367. // Inform the sender that the transfer was completed
  2368. format(Msg, 128, "{00FF00}Player {FFFF00}%s{00FF00} is offline and has a bank account, transfer of {FFFF00}$%i{00FF00} was succesfull", inputtext, APlayerData[playerid][UseMoney]);
  2369. SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  2370. }
  2371. else
  2372. {
  2373. format(Msg, 128, "{FF0000}Account-name {FFFF00}%s{FF0000} not found, transfer failed", inputtext);
  2374. SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  2375. }
  2376. return 1;
  2377. }
  2378. // Process the Bank Cancel option
  2379. Dialog_BankCancel(playerid, response)
  2380. {
  2381. // Just close the dialog if the player clicked "No"
  2382. if(!response) return 1;
  2383. // Setup local variables
  2384. new file[100], Name[24];
  2385. // Get the playername
  2386. format(Name, sizeof(Name), APlayerData[playerid][PlayerName]);
  2387. // Construct the complete filename for this player's bank-account
  2388. format(file, sizeof(file), BankFile, Name);
  2389. // Check if the player's ban account exists (to be sure it's still there)
  2390. if (fexist(file))
  2391. fremove(file); // Delete the bank account
  2392. // If there is any money left in the account, give the funds back to the player
  2393. RewardPlayer(playerid, APlayerData[playerid][BankMoney], 0);
  2394. // Inform the player about the remaining funds of your bank account
  2395. if (APlayerData[playerid][BankMoney] > 0)
  2396. SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}There was still some money in your bank account, it has been given to your character");
  2397. // Save the player's account
  2398. PlayerFile_Save(playerid);
  2399. // Clear the data from the player's account
  2400. APlayerData[playerid][BankPassword] = 0;
  2401. APlayerData[playerid][BankLoggedIn] = false;
  2402. APlayerData[playerid][BankMoney] = 0;
  2403. // Inform the player about it
  2404. SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Your bank account has been deleted");
  2405. return 1;
  2406. }
  2407. // Process the chosen help-item
  2408. Dialog_HelpItemChosen(playerid, response, listitem)
  2409. {
  2410. // Just close the dialog if the player clicked "Cancel"
  2411. if(!response) return 1;
  2412. // Setup local variables
  2413. new DialogTitle[128];
  2414. // Clear the dialog-message
  2415. format(DialogMsg5000, 5000, "");
  2416. // Set the dialog-title for the help-topic to be shown
  2417. format(DialogTitle, 128, AHelpTopics[listitem]);
  2418. // Select the help-item and create a dialog that displays all text about that item
  2419. for (new i; i < sizeof(AHelpText); i++)
  2420. {
  2421. // Check if this textline belongs to the help-item
  2422. if (AHelpText[i][HelpID] == listitem)
  2423. {
  2424. // Add all help-textlines to the list
  2425. format(DialogMsg5000, 5000, "%s%s\n", DialogMsg5000, AHelpText[i][HelpText]);
  2426. }
  2427. }
  2428. // Show the help-text in a dialog
  2429. ShowPlayerDialog(playerid, DialogHelpItem, DIALOG_STYLE_MSGBOX, DialogTitle, DialogMsg5000, "Back", TXT_DialogButtonCancel);
  2430. return 1;
  2431. }
  2432. // Process the help-item (select "Back" or "Cancel"
  2433. Dialog_HelpItem(playerid, response)
  2434. {
  2435. // Just close the dialog if the player clicked "Cancel"
  2436. if(!response) return 1;
  2437. // If the player chose "Back", re-open the helplist
  2438. HelpList_Create(playerid);
  2439. return 1;
  2440. }
  2441. // Process the old password of the player
  2442. Dialog_OldPassword(playerid, response, inputtext[])
  2443. {
  2444. // Just close the dialog if the player clicked "Cancel"
  2445. if(!response) return 1;
  2446. // Check if the entered password is the same as the password saved in the player's account
  2447. if (strcmp(APlayerData[playerid][PlayerPassword], inputtext, false) == 0)
  2448. {
  2449. // Ask the player to enter a new password
  2450. ShowPlayerDialog(playerid, DialogNewPassword, DIALOG_STYLE_INPUT, "Enter new password:", "Enter your new password here:", "OK", "Cancel");
  2451. }
  2452. else
  2453. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You've entered the wrong password");
  2454. return 1;
  2455. }
  2456. // Process the new password of the player
  2457. Dialog_NewPassword(playerid, response, inputtext[])
  2458. {
  2459. // Just close the dialog if the player clicked "Cancel"
  2460. if(!response) return 1;
  2461. // Setup local variables
  2462. new Msg[256];
  2463. // Check if the entered password is valid (not empty)
  2464. if (strlen(inputtext) > 0)
  2465. {
  2466. // Check if the player didn't enter the same password
  2467. if (strcmp(APlayerData[playerid][PlayerPassword], inputtext, false) != 0)
  2468. {
  2469. // Store the new password
  2470. format(APlayerData[playerid][PlayerNewPassword], 50, inputtext);
  2471. // Construct the content of the dialog, which displays the old and new password
  2472. format(Msg, 256, "{FFFFFF}Your old password: \t{00FF00}%s{FFFFFF}\n", APlayerData[playerid][PlayerPassword]);
  2473. format(Msg, 256, "%sYour new password: \t{00FF00}%s{FFFFFF}\n \n", Msg, APlayerData[playerid][PlayerNewPassword]);
  2474. format(Msg, 256, "%sAre you sure you want to change your password?", Msg);
  2475. // Ask the player if he really wants to change his password
  2476. ShowPlayerDialog(playerid, DialogConfirmPassword, DIALOG_STYLE_MSGBOX, "Are you sure?", Msg, "Yes", "No");
  2477. }
  2478. else
  2479. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Your new password cannot be the same as the old password");
  2480. }
  2481. else
  2482. SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Invalid password");
  2483. return 1;
  2484. }
  2485. // Process the dialog where the player needs to confirm the password-change
  2486. Dialog_ConfirmPassword(playerid, response)
  2487. {
  2488. // Just close the dialog if the player clicked "Cancel"
  2489. if(!response) return 1;
  2490. // Copy the new password to the old one, overwriting the old one
  2491. format(APlayerData[playerid][PlayerPassword], 50, APlayerData[playerid][PlayerNewPassword]);
  2492. // Clear the new password
  2493. format(APlayerData[playerid][PlayerNewPassword], 50, "");
  2494. // Let the player know his password has been changed
  2495. SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Your password has been changed");
  2496. // Save the player's account
  2497. PlayerFile_Save(playerid);
  2498. return 1;
  2499. }