RPFW.0.0a Build 7.pwn 141 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621
  1. // Developers notes
  2. /* # Coding guideline
  3. * Add +1 at the end of array declarations to visually account for null bit.
  4. * Always log first.
  5. * Always notify discord last.
  6. * Always wait for other queries to finish before initiating one: "sql_wait(sqlHandle); // Wait for other queries to finish"
  7. * Delete GVar strings as soon as possible, but at least before the player quits or the gamemode exits, as per: https://forum.sa-mp.com/showthread.php?t=151076
  8. */
  9. /* # Style guide
  10. * GLOBAL_CONSTANT
  11. * local_variable
  12. * someFunction
  13. * SomeClass
  14. * playerid // Variable storing in-game player ID
  15. * player_id // Variable storing database player ID
  16. */
  17. /* # Adding a discord bot to your guild.
  18. https://discordapp.com/oauth2/authorize?client_id=%CLIENT_ID%&scope=bot&permissions=3072
  19. Where %CLEINT_ID% is the client id.
  20. */
  21. /* # To do:
  22. * Add geoiplib, to make connect messages fancier, and add a locate command.
  23. * Show underscores as spaces and convert spaces in changename input to undescores before regex chack.
  24. * Vip limit on characters.
  25. * See why sql_insert_id wont work.
  26. * Add all ADMIN_ECHO_CHANNEL messages to admin chat. (not the real admin chat)
  27. * Check if timestamps work (implemented on temp ban), before implementing it more.
  28. * Normalise database column names.
  29. */
  30. /// Global definitions
  31. // Colours
  32. /*
  33. #define COLOR_GREEN 0x33AA33AA
  34. #define COLOR_YELLOW 0xFFFF00AA
  35. #define COLOR_WHITE 0xFFFFFFAA
  36. #define COLOR_BLUE 0x0000BBAA
  37. #define COLOR_LIGHTBLUE 0x33CCFFAA
  38. #define COLOR_ORANGE 0xFF9900AA
  39. #define COLOR_RED 0xAA3333AA
  40. #define COLOR_LIME 0x10F441AA
  41. #define COLOR_NAVY 0x000080AA
  42. #define COLOR_AQUA 0xF0F8FFAA
  43. #define COLOR_CRIMSON 0xDC143CAA
  44. #define COLOR_BISQUE 0xFFE4C4AA
  45. #define COLOR_BLACK 0x000000AA
  46. #define COLOR_CHARTREUSE 0x7FFF00AA
  47. #define COLOR_BROWN 0XA52A2AAA
  48. #define COLOR_CORAL 0xFF7F50AA
  49. #define COLOR_GOLD 0xB8860BAA
  50. #define COLOR_GREENYELLOW 0xADFF2FAA
  51. #define COLOR_INDIGO 0x4B00B0AA
  52. #define COLOR_IVORY 0xFFFF82AA
  53. #define COLOR_LAWNGREEN 0x7CFC00AA
  54. #define COLOR_SEAGREEN 0x20B2AAAA
  55. #define COLOR_SEAGREEN 0x2E8B57AA
  56. #define COLOR_LIMEGREEN 0x32CD32AA //<--- Dark lime
  57. #define COLOR_MIDNIGHTBLUE 0X191970AA
  58. #define COLOR_MAROON 0x800000AA
  59. #define COLOR_OLIVE 0x808000AA
  60. #define COLOR_ORANGERED 0xFF4500AA
  61. #define COLOR_PINK 0xFFC0CBAA // - Light light pink
  62. #define COLOR_SPRINGGREEN 0x00FF7FAA
  63. #define COLOR_TOMATO 0xFF6347AA // - Tomato >:/ sounds wrong lol... well... :P
  64. #define COLOR_YELLOWGREEN 0x9ACD32AA //- like military green
  65. #define COLOR_MEDIUMAQUA 0x83BFBFAA
  66. #define COLOR_MEDIUMMAGENTA 0x8B008BAA // dark magenta ^^
  67. */
  68. #define COLOR_ACTIVEBORDER 0xB4B4B4FF
  69. #define COLOR_ACTIVECAPTION 0x99B4D1FF
  70. #define COLOR_ACTIVECAPTIONTEXT 0x000000FF
  71. #define COLOR_ALICEBLUE 0xF0F8FFFF
  72. #define COLOR_ANTIQUEWHITE 0xFAEBD7FF
  73. #define COLOR_APPWORKSPACE 0xABABABFF
  74. #define COLOR_AQUA 0x00FFFFFF
  75. #define COLOR_AQUAMARINE 0x7FFFD4FF
  76. #define COLOR_AZURE 0xF0FFFFFF
  77. #define COLOR_BEIGE 0xF5F5DCFF
  78. #define COLOR_BISQUE 0xFFE4C4FF
  79. #define COLOR_BLACK 0x000000FF
  80. #define COLOR_BLANCHEDALMOND 0xFFEBCDFF
  81. #define COLOR_BLUE 0x0000FFFF
  82. #define COLOR_BLUEVIOLET 0x8A2BE2FF
  83. #define COLOR_BROWN 0xA52A2AFF
  84. #define COLOR_BURLYWOOD 0xDEB887FF
  85. #define COLOR_BUTTONFACE 0xF0F0F0FF
  86. #define COLOR_BUTTONHIGHLIGHT 0xFFFFFFFF
  87. #define COLOR_BUTTONSHADOW 0xA0A0A0FF
  88. #define COLOR_CADETBLUE 0x5F9EA0FF
  89. #define COLOR_CHARTREUSE 0x7FFF00FF
  90. #define COLOR_CHOCOLATE 0xD2691EFF
  91. #define COLOR_CONTROL 0xF0F0F0FF
  92. #define COLOR_CONTROLDARK 0xA0A0A0FF
  93. #define COLOR_CONTROLDARKDARK 0x696969FF
  94. #define COLOR_CONTROLLIGHT 0xE3E3E3FF
  95. #define COLOR_CONTROLLIGHTLIGHT 0xFFFFFFFF
  96. #define COLOR_CONTROLTEXT 0x000000FF
  97. #define COLOR_CORAL 0xFF7F50FF
  98. #define COLOR_CORNFLOWERBLUE 0x6495EDFF
  99. #define COLOR_CORNSILK 0xFFF8DCFF
  100. #define COLOR_CRIMSON 0xDC143CFF
  101. #define COLOR_CYAN 0x00FFFFFF
  102. #define COLOR_DARKBLUE 0x00008BFF
  103. #define COLOR_DARKCYAN 0x008B8BFF
  104. #define COLOR_DARKGOLDENROD 0xB8860BFF
  105. #define COLOR_DARKGRAY 0xA9A9A9FF
  106. #define COLOR_DARKGREEN 0x006400FF
  107. #define COLOR_DARKKHAKI 0xBDB76BFF
  108. #define COLOR_DARKMAGENTA 0x8B008BFF
  109. #define COLOR_DARKOLIVEGREEN 0x556B2FFF
  110. #define COLOR_DARKORANGE 0xFF8C00FF
  111. #define COLOR_DARKORCHID 0x9932CCFF
  112. #define COLOR_DARKRED 0x8B0000FF
  113. #define COLOR_DARKSALMON 0xE9967AFF
  114. #define COLOR_DARKSEAGREEN 0x8FBC8BFF
  115. #define COLOR_DARKSLATEBLUE 0x483D8BFF
  116. #define COLOR_DARKSLATEGRAY 0x2F4F4FFF
  117. #define COLOR_DARKTURQUOISE 0x00CED1FF
  118. #define COLOR_DARKVIOLET 0x9400D3FF
  119. #define COLOR_DEEPPINK 0xFF1493FF
  120. #define COLOR_DEEPSKYBLUE 0x00BFFFFF
  121. #define COLOR_DEFAULT_CHAT 0xFFFFFFFF
  122. #define COLOR_DESKTOP 0x000000FF
  123. #define COLOR_DIMGRAY 0x696969FF
  124. #define COLOR_DODGERBLUE 0x1E90FFFF
  125. #define COLOR_FIREBRICK 0xB22222FF
  126. #define COLOR_FLBLUE 0x6495EDAA
  127. #define COLOR_FLORALWHITE 0xFFFAF0FF
  128. #define COLOR_FORESTGREEN 0x228B22FF
  129. #define COLOR_GAINSBORO 0xDCDCDCFF
  130. #define COLOR_GHOSTWHITE 0xF8F8FFFF
  131. #define COLOR_GOLD 0xFFD700FF
  132. #define COLOR_GOLDENROD 0xDAA520FF
  133. #define COLOR_GRADIENTACTIVECAPTION 0xB9D1EAFF
  134. #define COLOR_GRADIENTINACTIVECAPTION 0xD7E4F2FF
  135. #define COLOR_GRAY 0x808080FF
  136. #define COLOR_GRAYTEXT 0x808080FF
  137. #define COLOR_GREEN 0x008000FF
  138. #define COLOR_GREENYELLOW 0xADFF2FFF
  139. #define COLOR_GREY 0xAFAFAFAA
  140. #define COLOR_HIGHLIGHT 0x3399FFFF
  141. #define COLOR_HIGHLIGHTTEXT 0xFFFFFFFF
  142. #define COLOR_HONEYDEW 0xF0FFF0FF
  143. #define COLOR_HOTPINK 0xFF69B4FF
  144. #define COLOR_HOTTRACK 0x0066CCFF
  145. #define COLOR_INACTIVEBORDER 0xF4F7FCFF
  146. #define COLOR_INACTIVECAPTION 0xBFCDDBFF
  147. #define COLOR_INACTIVECAPTIONTEXT 0x434E54FF
  148. #define COLOR_INDIANRED 0xCD5C5CFF
  149. #define COLOR_INDIGO 0x4B0082FF
  150. #define COLOR_INFO 0xFFFFE1FF
  151. #define COLOR_INFOTEXT 0x000000FF
  152. #define COLOR_IVORY 0xFFFFF0FF
  153. #define COLOR_KHAKI 0xF0E68CFF
  154. #define COLOR_LAVENDER 0xE6E6FAFF
  155. #define COLOR_LAVENDERBLUSH 0xFFF0F5FF
  156. #define COLOR_LAWNGREEN 0x7CFC00FF
  157. #define COLOR_LEMONCHIFFON 0xFFFACDFF
  158. #define COLOR_LIGHTBLUE 0xADD8E6FF
  159. #define COLOR_LIGHTCORAL 0xF08080FF
  160. #define COLOR_LIGHTCYAN 0xE0FFFFFF
  161. #define COLOR_LIGHTGOLDENRODYELLOW 0xFAFAD2FF
  162. #define COLOR_LIGHTGRAY 0xD3D3D3FF
  163. #define COLOR_LIGHTGREEN 0x90EE90FF
  164. #define COLOR_LIGHTPINK 0xFFB6C1FF
  165. #define COLOR_LIGHTSALMON 0xFFA07AFF
  166. #define COLOR_LIGHTSEAGREEN 0x20B2AAFF
  167. #define COLOR_LIGHTSKYBLUE 0x87CEFAFF
  168. #define COLOR_LIGHTSLATEGRAY 0x778899FF
  169. #define COLOR_LIGHTSTEELBLUE 0xB0C4DEFF
  170. #define COLOR_LIGHTYELLOW 0xFFFFE0FF
  171. #define COLOR_LIME 0x00FF00FF
  172. #define COLOR_LIMEGREEN 0x32CD32FF
  173. #define COLOR_LINEN 0xFAF0E6FF
  174. #define COLOR_MAGENTA 0xFF00FFFF
  175. #define COLOR_MAROON 0x800000FF
  176. #define COLOR_MEDIUMAQUAMARINE 0x66CDAAFF
  177. #define COLOR_MEDIUMBLUE 0x0000CDFF
  178. #define COLOR_MEDIUMORCHID 0xBA55D3FF
  179. #define COLOR_MEDIUMPURPLE 0x9370DBFF
  180. #define COLOR_MEDIUMSEAGREEN 0x3CB371FF
  181. #define COLOR_MEDIUMSLATEBLUE 0x7B68EEFF
  182. #define COLOR_MEDIUMSPRINGGREEN 0x00FA9AFF
  183. #define COLOR_MEDIUMTURQUOISE 0x48D1CCFF
  184. #define COLOR_MEDIUMVIOLETRED 0xC71585FF
  185. #define COLOR_MENU 0xF0F0F0FF
  186. #define COLOR_MENUBAR 0xF0F0F0FF
  187. #define COLOR_MENUHIGHLIGHT 0x3399FFFF
  188. #define COLOR_MENUTEXT 0x000000FF
  189. #define COLOR_MIDNIGHTBLUE 0x191970FF
  190. #define COLOR_MINTCREAM 0xF5FFFAFF
  191. #define COLOR_MISTYROSE 0xFFE4E1FF
  192. #define COLOR_MOCCASIN 0xFFE4B5FF
  193. #define COLOR_NAVAJOWHITE 0xFFDEADFF
  194. #define COLOR_NAVY 0x000080FF
  195. #define COLOR_OLDLACE 0xFDF5E6FF
  196. #define COLOR_OLIVE 0x808000FF
  197. #define COLOR_OLIVEDRAB 0x6B8E23FF
  198. #define COLOR_ORANGE 0xFFA500FF
  199. #define COLOR_ORANGERED 0xFF4500FF
  200. #define COLOR_ORCHID 0xDA70D6FF
  201. #define COLOR_PALEGOLDENROD 0xEEE8AAFF
  202. #define COLOR_PALEGREEN 0x98FB98FF
  203. #define COLOR_PALETURQUOISE 0xAFEEEEFF
  204. #define COLOR_PALEVIOLETRED 0xDB7093FF
  205. #define COLOR_PAPAYAWHIP 0xFFEFD5FF
  206. #define COLOR_PEACHPUFF 0xFFDAB9FF
  207. #define COLOR_PERU 0xCD853FFF
  208. #define COLOR_PINK 0xFFC0CBFF
  209. #define COLOR_PLUM 0xDDA0DDFF
  210. #define COLOR_POWDERBLUE 0xB0E0E6FF
  211. #define COLOR_PURPLE 0x800080FF
  212. #define COLOR_RED 0xFF0000FF
  213. #define COLOR_ROSYBROWN 0xBC8F8FFF
  214. #define COLOR_ROYALBLUE 0x4169E1FF
  215. #define COLOR_SADDLEBROWN 0x8B4513FF
  216. #define COLOR_SALMON 0xFA8072FF
  217. #define COLOR_SANDYBROWN 0xF4A460FF
  218. #define COLOR_SCROLLBAR 0xC8C8C8FF
  219. #define COLOR_SEAGREEN 0x2E8B57FF
  220. #define COLOR_SEASHELL 0xFFF5EEFF
  221. #define COLOR_SIENNA 0xA0522DFF
  222. #define COLOR_SILVER 0xC0C0C0FF
  223. #define COLOR_SKYBLUE 0x87CEEBFF
  224. #define COLOR_SLATEBLUE 0x6A5ACDFF
  225. #define COLOR_SLATEGRAY 0x708090FF
  226. #define COLOR_SNOW 0xFFFAFAFF
  227. #define COLOR_SPRINGGREEN 0x00FF7FFF
  228. #define COLOR_STEELBLUE 0x4682B4FF
  229. #define COLOR_TAN 0xD2B48CFF
  230. #define COLOR_TEAL 0x008080FF
  231. #define COLOR_THISTLE 0xD8BFD8FF
  232. #define COLOR_TOMATO 0xFF6347FF
  233. #define COLOR_TRANSPARENT 0xFFFFFF00
  234. #define COLOR_TURQUOISE 0x40E0D0FF
  235. #define COLOR_VIOLET 0xEE82EEFF
  236. #define COLOR_WHEAT 0xF5DEB3FF
  237. #define COLOR_WHITE 0xFFFFFFFF
  238. #define COLOR_WHITESMOKE 0xF5F5F5FF
  239. #define COLOR_WINDOW 0xFFFFFFFF
  240. #define COLOR_WINDOWFRAME 0x646464FF
  241. #define COLOR_WINDOWTEXT 0x000000FF
  242. #define COLOR_YELLOW 0xFFFF00FF
  243. #define COLOR_YELLOWGREEN 0x9ACD32FF
  244. #define COLOR_STEALTH_ORANGE 0xFF880000
  245. #define COLOR_STEALTH_OLIVE 0x66660000
  246. #define COLOR_STEALTH_GREEN 0x33DD1100
  247. #define COLOR_STEALTH_PINK 0xFF22EE00
  248. #define COLOR_STEALTH_BLUE 0x0077BB00
  249. // Color groups
  250. #define COLOR_COMMAND_OUTPUT 0xFFFFFFFF // White
  251. #define COLOR_NOTICE 0xAFAFAFAA // Grey
  252. #define COLOR_WARNING_MESSAGE 0xFFA500FF // Orange? (Looks more yellow to me)
  253. #define COLOR_ERROR_MESSAGE 0xFF0000FF // Red
  254. #define COLOR_GLOBAL_CHAT 0xFFFFFFFF // White
  255. #define COLOR_PM_CHAT 0xFFFF00FF // Yellow
  256. #define COLOR_VIP_CHAT 0x800080FF // Purple
  257. #define COLOR_CREW_CHAT 0xFF9900AA // Orange
  258. #define COLOR_ADMIN_CHAT 0xB8860BAA // Gold
  259. #define EMBED_COLOR_GREY "{AFAFAF}"
  260. #define EMBED_COLOR_RED "{FF0000}"
  261. #define EMBED_COLOR_WHITE "{FFFFFF}"
  262. // SQL datatypes
  263. #define MAX_SQL_INTEGER 10
  264. #define MAX_SQL_TIMESTAMP 19 // 1999-01-08 04:05:06 [5 + 4 + 2 + 2 +2 + 2 + 2]
  265. #define MAX_SQL_FLOAT 16
  266. #define MAX_SQL_HASH 128
  267. #define MAX_SQL_IP 45
  268. #define MAX_SQL_REASON 121
  269. // Log levels
  270. #define LOGLEVEL_CHAT -2
  271. #define LOGLEVEL_COMMAND -1
  272. #define LOGLEVEL_DEBUG 0
  273. #define LOGLEVEL_INFO 1
  274. #define LOGLEVEL_NOTICE 2
  275. #define LOGLEVEL_WARNING 3
  276. #define LOGLEVEL_ERROR 4
  277. #define LOGLEVEL_CRITICAL 5
  278. #define LOGLEVEL_PANIC 6
  279. // Userlevels
  280. enum{ // Noted values as comments, for database reference.
  281. UNREGISTERED_PLAYER, // 0
  282. REGISTERED_PLAYER, // 1
  283. REGULAR_PLAYER, // 2 Spent many hours in and around the comunity.
  284. VIP_PLAYER, // 3 Donated.
  285. MODERATOR_CREW, // 4
  286. VETERAN_CREW, // 5 Inactive admins and management that are allowed to keep their rights.
  287. ADMIN_CREW, // 6
  288. UNDERCOVER_ADMIN_CREW, // 7
  289. MANAGEMENT_CREW, // 8
  290. UNDRECOVER_MANAGEMENT_CREW, // 9
  291. FOUNDER_PLAYER, // 10
  292. UNDERCOVER_FOUNDER_PLAYER // 11
  293. }
  294. // Discord channels
  295. enum{
  296. ECHO_CHANNEL,
  297. MAIN_CHANNEL,
  298. ADMIN_ECHO_CHANNEL,
  299. ADMIN_CHANNEL,
  300. MANAGEMENT_CHANNEL
  301. }
  302. // Chats
  303. enum{
  304. CHAT_LOCAL, // Has to be 0, else a gVar would have to be created OnJoin, this conserves memory when no chatmode is set (which will be the case most likely)
  305. CHAT_WHISPER,
  306. CHAT_LOW,
  307. CHAT_ACTION,
  308. CHAT_SHOUT,
  309. CHAT_OC,
  310. CHAT_GLOBAL,
  311. CHAT_CALL,
  312. CHAT_SMS,
  313. CHAT_RADIO,
  314. CHAT_PM,
  315. CHAT_GANG,
  316. CHAT_GANG_OC,
  317. CHAT_FACTION,
  318. CHAT_FACTION_OC,
  319. CHAT_VIP,
  320. CHAT_CREW,
  321. CHAT_ADMIN,
  322. CHAT_MANAGEMENT,
  323. CHAT_UNDERCOVER
  324. }
  325. // Dialogs
  326. enum{
  327. DIALOG_CHANGENAME,
  328. DIALOG_REGISTER,
  329. DIALOG_ACCOUNT_CREATED,
  330. DIALOG_LOGIN,
  331. DIALOG_CHANGE_USERNAME,
  332. DIALOG_CHARACTERS,
  333. DIALOG_LOGIN_FAILED,
  334. DIALOG_DELETE_CHARACTER,
  335. DIALOG_GOTO,
  336. DIALOG_GOTO_INTERIOR,
  337. DIALOG_GOTO_247,
  338. DIALOG_GOTO_AVIATION,
  339. DIALOG_GOTO_AMMUNATION,
  340. DIALOG_GOTO_BURGLARY,
  341. DIALOG_GOTO_MISSION,
  342. DIALOG_GOTO_MISSIONEXT,
  343. DIALOG_GOTO_MISSIONHOUSE,
  344. DIALOG_GOTO_MODDING,
  345. DIALOG_GOTO_POLICE,
  346. DIALOG_GOTO_HOUSE,
  347. DIALOG_GOTO_SHOP,
  348. DIALOG_GOTO_STADIA,
  349. DIALOG_CREATE_PICKUP,
  350. DIALOG_CREATE_FACTION_PICKUP,
  351. DIALOG_DUTY_PD,
  352. DIALOG_POLICE_SKIN
  353. }
  354. // Pickups
  355. enum{
  356. PICKUP_PORTAL,
  357. PICKUP_FACTION_PD,
  358. }
  359. // Location categories
  360. enum{
  361. GOTO_CATEGORY_INTERIOR
  362. }
  363. enum{
  364. INTERIOR_CATEGORY_247,
  365. INTERIOR_CATEGORY_AVIATION,
  366. INTERIOR_CATEGORY_AMMUNATION,
  367. INTERIOR_CATEGORY_BUGRLARY,
  368. INTERIOR_CATEGORY_MISSION,
  369. INTERIOR_CATEGORY_MISSIONEXT,
  370. INTERIOR_CATEGORY_MISSIONHOUSE,
  371. INTERIOR_CATEGORY_MODSHOP,
  372. INTERIOR_CATEGORY_POLICE,
  373. INTERIOR_CATEGORY_HOUSES,
  374. INTERIOR_CATEGORY_SHOPS,
  375. INTERIOR_CATEGORY_STADIA
  376. }
  377. enum{INTERIOR_247_LSHAPED, INTERIOR_247_OBLONG, INTERIOR_247_MEDIUM, INTERIOR_247_MEDIUM_NOEXIT, INTERIOR_247_LONG, INTERIOR_247_SQAURE}
  378. enum{
  379. INTERIOR_AVIATION_TICKET,
  380. INTERIOR_AVIATION_BAGGAGE,
  381. INTERIOR_AVIATION_SHAMAL,
  382. INTERIOR_AVIATION_ANDROMADA,
  383. INTERIOR_AVIATION_LSAIRPORT
  384. }
  385. enum{INTERIOR_AMMU_OCEAN, INTERIOR_AMMU_PALOMINO, INTERIOR_AMMU_ANGEL, INTERIOR_AMMU_QUEBRADOS, INTERIOR_AMMU_2STORIES, INTERIOR_AMMU_BOOTH, INTERIOR_AMMU_RANGE}
  386. enum{
  387. INTERIOR_BURGRLARY_LARGE,
  388. INTERIOR_BURGRLARY_MEDIUM,
  389. INTERIOR_BURGRLARY_SMALL,
  390. INTERIOR_BURGRLARY_VERYLARGE,
  391. INTERIOR_BURGRLARY_5,
  392. INTERIOR_BURGRLARY_6,
  393. INTERIOR_BURGRLARY_NOBATH,
  394. }
  395. enum{
  396. INTERIOR_MISSION_ATRIUM,
  397. INTERIOR_MISSION_BIGSMOKE,
  398. INTERIOR_MISSION_JEFFERSON,
  399. INTERIOR_MISSION_JIZZY,
  400. INTERIOR_MISSION_RC,
  401. INTERIOR_MISSION_WUZI,
  402. }
  403. enum{
  404. INTERIOR_MISSIONEXT_GAS,
  405. INTERIOR_MISSIONEXT_LIBERTY,
  406. INTERIOR_MISSIONEXT_SFGARAGE,
  407. }
  408. enum{
  409. INTERIOR_MISSIONHOUSE_DESIRE,
  410. INTERIOR_MISSIONHOUSE_COLONEL,
  411. INTERIOR_MISSIONHOUSE_RYDER,
  412. INTERIOR_MISSIONHOUSE_SWEET,
  413. INTERIOR_MISSIONHOUSE_CRACK,
  414. }
  415. enum{INTERIOR_MOD_LOCO, INTERIOR_MOD_WHEEL, INTERIOR_MOD_TRANSFENDER}
  416. enum{INTERIOR_PD_LV, INTERIOR_PD_LS, INTERIOR_PD_SF, INTERIOR_PD_BARBARA}
  417. enum{
  418. INTERIOR_HOUSE_GOLDEN,
  419. INTERIOR_HOUSE_HASHBURY,
  420. INTERIOR_HOUSE_JOHNSON,
  421. INTERIOR_HOUSE_MADDDOGG,
  422. INTERIOR_HOUSE_RED,
  423. INTERIOR_HOUSE_VERDANT,
  424. INTERIOR_HOUSE_UNUSED
  425. }
  426. enum{
  427. INTERIOR_SHOP_TATTOO,
  428. INTERIOR_SHOP_BURGER,
  429. INTERIOR_SHOP_PIZZA,
  430. INTERIOR_SHOP_CLUCKIN,
  431. INTERIOR_SHOP_CALIGULAS,
  432. INTERIOR_SHOP_CASINO,
  433. INTERIOR_SHOP_4DRAGONS,
  434. INTERIOR_SHOP_DONUTS,
  435. INTERIOR_SHOP_RC,
  436. INTERIOR_SHOP_PUMP
  437. }
  438. enum{
  439. INTERIOR_STADIUM_BLOODBOWL,
  440. INTERIOR_STADIUM_KICKSTART,
  441. INTERIOR_STADIUM_8TRACK,
  442. INTERIOR_STADIUM_DIRTBIKE,
  443. }
  444. // Factions
  445. enum{
  446. FACTION_POLICE,
  447. }
  448. // Environment settings TODO: THESE SHOULD ALL BE READ FROM A CONFIG FILE!
  449. static bool:scriptDebug = true; // Debug setting
  450. #define MODE_NAME "0.0a Build 7"
  451. #define SERVER_NAME "Bone County RPG"
  452. #define PG_HOST "127.0.0.1"
  453. #define PG_ROLE "rpfw-dev"
  454. #define PG_PASS "nJd&1k$0fs"
  455. #define PG_DB "rpfw-dev"
  456. #define PG_PORT 5432
  457. #define DISCORD_HOME_GUILD_ID "666077037470941184" // Emerald City Roleplay
  458. #define DISCORD_ECHO_CHANNEL_ID "677855051166777344" // #bcrp-echo
  459. //#define DISCORD_ECHO_CHANNEL_ID "666078187079598080" // #ecrp-echo
  460. #define DISCORD_MAIN_CHANNEL_ID "677855315898793984" // #bcrp
  461. //#define DISCORD_MAIN_CHANNEL_ID "667396220402270228" // #development
  462. #define DISCORD_ADMIN_ECHO_CHANNEL_ID "672841892169383936" // #admin-echo
  463. #define DISCORD_ADMIN_CHANNEL_ID "667396026058932236" // #admins
  464. #define DISCORD_MANAGEMENT_CHANNEL_ID "666091376240361492" // #management
  465. // Game-mode limits
  466. #define MAX_CHARACTERS_PER_USER 20 // Maximum of MAX_CHARACTERS_PER_USER_DIGITS digits (Due to SQL query string length)
  467. #define MAX_CHARACTERS_PER_USER_DIGITS 3
  468. // SQL plugin
  469. new SQL:sqlHandle;
  470. // discord-connector
  471. //static DCC_Guild:homeGuild; // Discord guild controlled by game community.
  472. static DCC_Channel:echoChannel; // Public echo channel.
  473. static DCC_Channel:mainChannel; // Channel for communirty notifications.
  474. static DCC_Channel:adminEchoChannel; // Admin echo channel.
  475. static DCC_Channel:adminChannel; // Channel for admin notifications.
  476. static DCC_Channel:managementChannel; // Channel for management notifications.
  477. DiscordEcho(const message[], messageLevel){ // Write to echo channels.
  478. switch(messageLevel) // Output facilities.
  479. {
  480. case ECHO_CHANNEL: { // Public echo message
  481. DiscordSendChannelMessage(echoChannel, message);
  482. DiscordSendChannelMessage(adminEchoChannel, message); // Also send to admin echo channel, so admin can see everything in one channel without needing to constantly switch. Also handy as log on conflicts/complaints.
  483. }
  484. case MAIN_CHANNEL: {DiscordSendChannelMessage(mainChannel, message);} // Public notification
  485. case ADMIN_ECHO_CHANNEL: {DiscordSendChannelMessage(adminEchoChannel, message);} // Admin echo message
  486. case ADMIN_CHANNEL: {DiscordSendChannelMessage(adminChannel, message);} // Admin notification
  487. case MANAGEMENT_CHANNEL: {DiscordSendChannelMessage(managementChannel, message);} // Management notification
  488. }
  489. return 0;
  490. }
  491. // Natives
  492. native WP_Hash(buffer[], len, const str[]); // https://forum.sa-mp.com/showthread.php?t=570945
  493. //native Float:loadavg(); // https://forum.sa-mp.com/showthread.php?t=260206 LINUX ONLY
  494. // Includes
  495. #include <a_samp> // https://sa-mp.com
  496. #include <sql> // https://github.com/udan11/samp-plugin-sql (Fastest player in town and only one supporting postgreSQL) | Examples: https://pastebin.com/67y2nq2n https://github.com/udan11/samp-plugin-sql/issues/10
  497. #include <sscanf2> // Newest version: https://github.com/maddinat0r/sscanf/releases | Better readme: https://github.com/Y-Less/sscanf
  498. #include <strlib> // https://github.com/oscar-broman/strlib
  499. #include <Pawn.Regex> // https://github.com/urShadow/Pawn.Regex
  500. #include <Pawn.CMD> // https://github.com/urShadow/Pawn.CMD (Fastest player in town)
  501. #include <gvar> // https://github.com/samp-incognito/samp-gvar-plugin
  502. #include <discord-connector> // https://github.com/maddinat0r/samp-discord-connector (Only player in town)
  503. #include <streamer> // https://github.com/samp-incognisto/samp-streamer-plugin
  504. /// Middle-ware
  505. // Logging
  506. logger(const log_level, const message[]){ // Write to logging facility
  507. // Do not log commands or debug when script debugging is turned off.
  508. if(scriptDebug == false){ // Debug is off
  509. if(log_level == LOGLEVEL_COMMAND || log_level == LOGLEVEL_DEBUG){ // Command or debug message
  510. return 0; // Stop and do not log
  511. }
  512. }
  513. // Messagelevel tag
  514. new human_readable_log_level[8 + 1];
  515. switch(log_level){ // Assign log level.
  516. case LOGLEVEL_CHAT: human_readable_log_level = "chat";
  517. case LOGLEVEL_COMMAND: human_readable_log_level = "command";
  518. case LOGLEVEL_DEBUG: human_readable_log_level = "debug";
  519. case LOGLEVEL_INFO: human_readable_log_level = "info";
  520. case LOGLEVEL_NOTICE: human_readable_log_level = "notice";
  521. case LOGLEVEL_WARNING: human_readable_log_level = "warning";
  522. case LOGLEVEL_ERROR: human_readable_log_level = "error";
  523. case LOGLEVEL_CRITICAL: human_readable_log_level = "critical";
  524. case LOGLEVEL_PANIC: human_readable_log_level = "panic";
  525. }
  526. printf("[%s] %s", human_readable_log_level, message); // Print to STDOUT.
  527. return 0;
  528. }
  529. /*// SQL plugin (BROKEN, look at it again after I have more then a week of experience)
  530. //forward sqlQuery(SQL:handle, query[]);
  531. //public sqlQuery(SQL:handle, query[]){
  532. sqlQuery(SQL:handle, query[]){
  533. //sql_wait(handle); // Wait for all queries to finish.
  534. new Result:result = sql_query(handle, query);
  535. if(sql_error(result)){printf("SQL error");} // Did not work during a test with a faulty statement.
  536. return result;
  537. }*/
  538. // discord-connector
  539. DiscordSendChannelMessage(DCC_Channel:channel, const message[]){
  540. if(scriptDebug){ // Log middle-ware event in debugging mode only
  541. new channel_name[100 + 1]; // Default value from tutorial
  542. DCC_GetChannelName(channel, channel_name);
  543. new logMessage[26 + 100 + 2000 + 1]; // Discord max message length = 2000
  544. format(logMessage, sizeof(logMessage), "Send to discord channel %s: %s", channel_name, message);
  545. logger(LOGLEVEL_DEBUG, logMessage); // Actually log the message
  546. }
  547. DCC_SendChannelMessage(channel, message); // Call discord-connector DISABLE THIS TO STOP ALL OUTGOING DISCORD MESSAGES
  548. }
  549. /// Game-mode
  550. // Account functions
  551. forward changeName(playerid, const name[]);
  552. public changeName(playerid, const name[]){ // Check if name is valid and force change if needed.
  553. // Prevent regex error when comparing against null
  554. if(isempty(name)){ // No name entered
  555. ShowPlayerDialog(playerid, DIALOG_CHANGENAME, DIALOG_STYLE_INPUT, "Character name", "You must enter a name.\n\nExamples:\n Jo_Bo\n Dingle_P._J._Berry\n Jackson_DeForest_Kelley\n MaryJo_Ann_LaFluer", "Change", ""); // Force RP name.
  556. return 0;
  557. }
  558. // Check name
  559. new Regex:r = Regex_New("^[A-Z][a-z]{1,}([A-Z][a-z]{1,})?(_([A-Z][a-z]{1,}([A-Z][a-z]{1,})?|[A-Z]\\.(_[A-Z]\\.)?))?_[A-Z][a-z]{1,}([A-Z][a-z]{1,})?$"); // Regex name filter
  560. new isValidName = Regex_Check(name, r); // Validate name to filter
  561. Regex_Delete(r);
  562. if(!isValidName){ // Invalid role-play name
  563. ShowPlayerDialog(playerid, DIALOG_CHANGENAME, DIALOG_STYLE_INPUT, "Character name", "Please pick a realistic name, separate first and last name with an underscore.\n\nExamples:\n Jo_Bo\n Dingle_P._J._Berry\n Jackson_DeForest_Kelley\n MaryJo_Ann_LaFluer", "Change", ""); // Force RP name.
  564. }
  565. else { // Valid role-play name
  566. // Check for name in use
  567. /*new escaped_name[MAX_PLAYER_NAME + 1]; // TODO should be more, to account for escape characters.
  568. sql_escape_string(sqlHandle, name, escaped_name, sizeof(escaped_name)); // Escape player name BROKEN argument type mismatch on argument 2, but name is a sting...*/
  569. new character_query[40 + MAX_PLAYER_NAME + 1], Result:character_result = sql_query(sqlHandle, character_query);
  570. format(character_query, sizeof(character_query), "SELECT id FROM character WHERE name = '%s'", name);
  571. if(sql_num_rows(character_result) > 0){ // Name taken
  572. ShowPlayerDialog(playerid, DIALOG_CHANGENAME, DIALOG_STYLE_INPUT, "Character name", "Name already taken. Please pick an original name.", "Change", ""); // Force RP name.
  573. }
  574. else{ // Name free
  575. // Notify all players
  576. new message[11 + 4 + MAX_PLAYER_NAME + 1];
  577. format(message, sizeof(message), "* [%i] %s joined.", playerid, getCharacterName(playerid));
  578. SendClientMessageToAll(COLOR_NOTICE, message); // Notify all players
  579. DiscordEcho(message, ECHO_CHANNEL); // Notify discord public echo
  580. new client_connect_username[MAX_PLAYER_NAME + 1], admin_message[38 + 4 + MAX_PLAYER_NAME + MAX_PLAYER_NAME + 1];
  581. GetGVarString("client_connect_username", client_connect_username, sizeof(client_connect_username), playerid); // Get client connect name
  582. if(GetPlayerState(playerid) == PLAYER_STATE_NONE){ // Not spawned: character creation (Creating a character without registering)
  583. // Notify admins
  584. format(admin_message, sizeof(admin_message), "* [%i] %s temporary charcter, created by: %s", playerid, getCharacterName(playerid), client_connect_username);
  585. sendToAdmins(COLOR_NOTICE, admin_message);
  586. DiscordEcho(admin_message, ADMIN_ECHO_CHANNEL);
  587. // Do nothing let continue to spawn, after spawn character will be saved to database.
  588. }
  589. else{ // Spawnedplayer: Creating permanent or renaming an existing permanent character
  590. // Notify admins
  591. format(admin_message, sizeof(admin_message), "* [%i] %s created by: %s", playerid, getCharacterName(playerid), client_connect_username);
  592. sendToAdmins(COLOR_NOTICE, admin_message);
  593. DiscordEcho(admin_message, ADMIN_ECHO_CHANNEL);
  594. // Send to skin selection
  595. ForceClassSelection(playerid);
  596. TogglePlayerSpectating(playerid, true);
  597. TogglePlayerSpectating(playerid, false);
  598. }
  599. // Change name (No way yet to change name ingame)
  600. /*if(GetGVarInt("userlevel", playerid) > 1){ // Registered player.
  601. // Get username
  602. new username[MAX_PLAYER_NAME + 1], message[75 + MAX_PLAYER_NAME + 1];
  603. GetGVarString("username", username, sizeof(username), playerid);
  604. // Update or create character name in database
  605. new callback[1];
  606. new Result:result;
  607. new query[51 + MAX_PLAYER_NAME + MAX_PLAYER_NAME + 1];
  608. format(query, sizeof(query), "UPDATE \"user\"(name) VALUES('%s') WHERE username == '%s'", name, username);
  609. sql_wait(sqlHandle); // Wait for other queries to finish
  610. result = sql_query(sqlHandle, query, callback = "", "r");
  611. // Inform user
  612. format(message, sizeof(message), "SERVER: Your username remains unchanged, next time connect as: %s", client_connect_username);
  613. SendClientMessage(playerid, COLOR_WHITE, message);
  614. }*/
  615. SetPlayerName(playerid, name); // Change name in-game
  616. }
  617. }
  618. return 0;
  619. }
  620. forward register(playerid);
  621. public register(playerid){ // Register player in database
  622. if(GetPlayerState(playerid) == PLAYER_STATE_NONE){ // Not spawned
  623. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "ERROR: You need to have spawned to register.");
  624. }
  625. else{ // Spawned player
  626. if(GetGVarInt("userlevel", playerid) != UNREGISTERED_PLAYER){ // Registered player.
  627. new message[35 + MAX_PLAYER_NAME + 1];
  628. format(message, sizeof(message), "ERROR: You are already registered"); //, %s.",
  629. SendClientMessage(playerid, COLOR_WHITE, message);
  630. }
  631. else{ // Unregistered player.
  632. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Password", "Please pick a strong and safe password, that you are able to remember.", "Continue", "Cancel"); // Password prompt
  633. }
  634. }
  635. }
  636. forward createCharacterRecord(playerid, id);
  637. public createCharacterRecord(playerid, id){
  638. new character_query[94 + MAX_SQL_INTEGER + MAX_PLAYER_NAME + 3 + 1];
  639. format(character_query, sizeof(character_query), "INSERT INTO character(user_id, name, skin_id) VALUES(%i, '%s', %i)", id, getPlayerName(playerid), GetPlayerSkin(playerid));
  640. sql_query(sqlHandle, character_query);
  641. }
  642. forward authenticate(playerid);
  643. public authenticate(playerid){
  644. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Sign in", "Enter your password to log on", "Log in", "Cancel"); // Show password confirmation dialog
  645. }
  646. forward characterSelection(playerid);
  647. public characterSelection(playerid){
  648. if(GetGVarInt("userlevel", playerid) < REGISTERED_PLAYER){ // Unregistered player (Or worse?)
  649. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "SERVER: Register first with: /my account register");
  650. }
  651. else{ // Registered player
  652. print("Character selection registered player.");
  653. // If spawned, save current character
  654. if(GetPlayerState(playerid) != PLAYER_STATE_NONE){
  655. savePlayerState(playerid);
  656. }
  657. new id = getUserID(playerid);
  658. new character_query[75 + MAX_SQL_INTEGER + MAX_CHARACTERS_PER_USER_DIGITS + 1];
  659. format(character_query, sizeof(character_query), "SELECT id, name FROM character WHERE user_id = %i LIMIT %i", id, MAX_CHARACTERS_PER_USER);
  660. new Result:character_result = sql_query(sqlHandle, character_query);
  661. new character_string[1024 + 1], character_array[MAX_CHARACTERS_PER_USER];
  662. for(new i = 0; i < sql_num_rows(character_result); i++){
  663. new name[MAX_PLAYER_NAME + 1];
  664. sql_get_field_assoc_ex(character_result, i, "name", name, sizeof(name));
  665. format(character_string, sizeof(character_string), "%s%s\n", character_string, name);
  666. character_array[i] = sql_get_field_assoc_int_ex(character_result, i, "id");
  667. }
  668. print(character_string);
  669. new character_array_string[MAX_CHARACTERS_PER_USER * MAX_SQL_INTEGER + 1];
  670. strfrombin(character_array_string, character_array); // Convert array to string for use with GVar
  671. SetGVarString("character_array_string", character_array_string, playerid);
  672. print("About to show dialog");
  673. ShowPlayerDialog(playerid, DIALOG_CHARACTERS, DIALOG_STYLE_LIST, "Characters", character_string, "Spawn", "New");
  674. }
  675. }
  676. forward savePlayerState(playerid);
  677. public savePlayerState(playerid){
  678. new escaped_playername[MAX_PLAYER_NAME + 1], character_query[183 + MAX_SQL_INTEGER + 3 + 3 + 1 + MAX_SQL_FLOAT + MAX_SQL_FLOAT + MAX_SQL_FLOAT + MAX_SQL_FLOAT + MAX_PLAYER_NAME + 1]; // Should be longer to allow for escaped characters
  679. sql_escape_string(sqlHandle, getPlayerName(playerid), escaped_playername, sizeof(escaped_playername)); // Escape player name
  680. new Float:health, Float:armour, Float:x, Float:y, Float:z, Float:Angle;
  681. // Unrealiable TODO change to gvars
  682. GetPlayerHealth(playerid, health);
  683. GetPlayerArmour(playerid, armour);
  684. GetPlayerPos(playerid, x, y, z);
  685. GetPlayerFacingAngle(playerid, Angle);
  686. format(character_query, sizeof(character_query), "UPDATE character SET (cash, health, armour, jailed, pos_x, pos_y, pos_z, rotation) = (%i, '%f', '%f', %i, '%f', '%f', '%f', '%f') WHERE name = '%s'", GetPlayerMoney(playerid), health, armour, 0, x, y, z, Angle, escaped_playername);
  687. sql_query(sqlHandle, character_query);
  688. }
  689. forward kickPlayerDelay(playerid);
  690. public kickPlayerDelay(playerid){
  691. Kick(playerid);
  692. }
  693. forward kickPlayer(playerid, kickerid, const reason[], banned);
  694. public kickPlayer(playerid, kickerid, const reason[], banned){ // Kick a player
  695. // Issuer of kick
  696. new kickername[MAX_PLAYER_NAME + 1], kicker_id[MAX_SQL_INTEGER + 1];
  697. if(kickerid == -1){ // Not kicked by in-game player
  698. kickername = "SERVER";
  699. kicker_id = "NULL";
  700. }
  701. else{ // Kicked by in-game player
  702. kickername = getPlayerName(playerid);
  703. kicker_id = "%s", getUserID(kickerid);
  704. }
  705. strreplace(kickername, "_", " ");
  706. // Action
  707. new action[16 + MAX_SQL_INTEGER + 1];
  708. if(banned){
  709. if(banned < 1){ // Permanent ban
  710. action = "banned permanently";
  711. }
  712. else{ // Temporary ban
  713. format(action, sizeof(action), "banned for %i days", banned);
  714. }
  715. }
  716. else{
  717. action = "kicked";
  718. }
  719. // Notify all players
  720. new playername[MAX_PLAYER_NAME + 1], message[16 + 4 + MAX_PLAYER_NAME + MAX_PLAYER_NAME + 16 + MAX_SQL_REASON + 1], admin_message[23 + 4 + MAX_PLAYER_NAME + 16 + MAX_PLAYER_NAME + MAX_SQL_REASON + 1]; // Max samp chat message length 128 - 8 for "/kick ? ".
  721. GetPlayerName(playerid, playername, sizeof(playername));
  722. format(message, sizeof(message), "* [%i] %s %s, reason: %s", playerid, getCharacterName(playerid), action, reason);
  723. format(admin_message, sizeof(admin_message), "* [%i] %s kicked %s, reason: %s", kickerid, kickername, getCharacterName(playerid), action, reason);
  724. logger(LOGLEVEL_INFO, message); // Log event
  725. SendClientMessageToAll(COLOR_NOTICE, message);
  726. DiscordEcho(message, ECHO_CHANNEL);
  727. sendToAdmins(COLOR_NOTICE, admin_message);
  728. DiscordEcho(admin_message, ADMIN_ECHO_CHANNEL);
  729. // Inform player (Redundant, but some people are blind or stupid)
  730. new player_message[30 + 6 + MAX_PLAYER_NAME + MAX_SQL_REASON + 1]; // Max samp chat message length 128 - 8 for "/kick ? ".
  731. format(player_message, sizeof(player_message), "SERVER: You have been %s, reason: %s", action, reason);
  732. SendClientMessage(playerid, COLOR_ERROR_MESSAGE, player_message); // Notify player
  733. if(banned){
  734. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "You may appeal this ban via the forum or Discord.");
  735. }
  736. new ip_id = getIPID(playerid);
  737. // Crearte IP kick record
  738. new ip_query[61 + 4 + MAX_SQL_REASON + 4 + 1];
  739. format(ip_query, sizeof(ip_query), "INSERT INTO ip_kick(ip_id, reason, kicker_id) VALUES(%i, '%s', %s)", ip_id, reason, kicker_id);
  740. sql_query(sqlHandle, ip_query);
  741. // Get IP kick record
  742. new ip_id_query[64 + 4 + MAX_SQL_REASON + 4 + 1];
  743. format(ip_id_query, sizeof(ip_id_query), "SELECT id FROM ip_kick WHERE ip_id = %i ORDER BY id DESC LIMIT 1", ip_id);
  744. new Result:ip_id_result = sql_query(sqlHandle, ip_id_query);
  745. new ip_kick_id = sql_get_field_assoc_int(Result:ip_id_result, "id");
  746. // User kick record
  747. printf("Userlevel: %i", GetGVarInt("userlevel", playerid));
  748. if(GetGVarInt("userlevel", playerid) > UNREGISTERED_PLAYER){ // Not logged in to a user account
  749. new user_query[79 + 4 + MAX_SQL_REASON + 4 + 1];
  750. format(user_query, sizeof(user_query), "INSERT INTO user_kick(user_id, reason, kicker_id, ip_kick_id) VALUES(%i, '%s', %s, %i)", getUserID(playerid), reason, kicker_id, ip_kick_id);
  751. sql_query(sqlHandle, user_query);
  752. }
  753. SetTimerEx("kickPlayerDelay", 50, false, "i", playerid); // Give the message 50 milliseconds to reach the player before kicking.
  754. }
  755. banExpiration(days);
  756. banExpiration(days){
  757. if(days < 1){ // Permanent ban
  758. new foo[MAX_SQL_TIMESTAMP + 1] = "0";
  759. return foo;
  760. }
  761. else{ // Temporary ban
  762. new year, month, day, hour, minute, second, expires[MAX_SQL_TIMESTAMP + 1];
  763. getdate(year, month, day);
  764. gettime(hour, minute, second);
  765. day = day + days;
  766. format(expires, sizeof(expires), "%i-%i-%i %i:%i:%i", year, month, day, hour, minute, second);
  767. return expires;
  768. //return year, month, day, hour, minute, second;
  769. //return 0;
  770. }
  771. }
  772. forward banPlayer(playerid, bannerid, const reason[], days);
  773. public banPlayer(playerid, bannerid, const reason[], days){ // Ban & kick a player
  774. new ip_id = getIPID(playerid);
  775. // Create IP ban record
  776. new banner_id, ip_query[72 + MAX_SQL_INTEGER + MAX_SQL_TIMESTAMP + MAX_SQL_REASON + MAX_SQL_INTEGER + 1];
  777. if(bannerid < 0){ // Not banned by in-game player
  778. format(ip_query, sizeof(ip_query), "INSERT INTO ip_ban(ip_id, expires, reason) VALUES(%i, '%s', '%s')", ip_id, banExpiration(days), reason);
  779. }
  780. else{ // Banned by in-game player
  781. banner_id = getUserID(bannerid);
  782. format(ip_query, sizeof(ip_query), "INSERT INTO ip_ban(ip_id, expires, reason, banner_id) VALUES(%i, '%s', '%s', %i)", ip_id, banExpiration(days), reason, banner_id);
  783. }
  784. sql_query(sqlHandle, ip_query);
  785. // Get IP ban record ID
  786. new ban_id_query[61 + MAX_PLAYER_NAME + 1];
  787. format(ban_id_query, sizeof(ban_id_query), "SELECT id FROM ip_ban WHERE ip_id = %i ORDER BY id DESC LIMIT 1", ip_id);
  788. new Result:ban_id_result = sql_query(sqlHandle, ban_id_query);
  789. new ip_ban_id = sql_get_field_assoc_int(ban_id_result, "id");
  790. // User ban record (As banned players get only kicked, noneed to check for active ban)
  791. if(GetGVarInt("userlevel", playerid) > 1){ // Registered player
  792. new user_query[97 + MAX_SQL_INTEGER + MAX_SQL_TIMESTAMP + MAX_SQL_REASON + MAX_SQL_INTEGER + MAX_SQL_INTEGER + 1];
  793. format(user_query, sizeof(user_query), "INSERT INTO user_ban(user_id, expires, reason, banner_id, ip_ban_id) VALUES(%i, %s, %s, %i, %i) WHERE id = %i", ip_id, banExpiration(days), reason, banner_id, ip_ban_id);
  794. sql_query(sqlHandle, user_query);
  795. }
  796. // Kick player
  797. kickPlayer(playerid, bannerid, reason, days);
  798. }
  799. // Database functions
  800. forward getIPID(playerid);
  801. public getIPID(playerid){
  802. new player_ip[MAX_SQL_IP + 1], query[37 + MAX_SQL_IP + 1]; // Create varaibles
  803. GetPlayerIp(playerid, player_ip, sizeof(player_ip)); // Polulate player_ip variable
  804. format(query, sizeof(query), "SELECT id FROM ip WHERE address = '%s'", player_ip); // Format query string
  805. new Result:result = sql_query(sqlHandle, query); // Execute query
  806. return sql_get_field_assoc_int(result, "id"); // Get id from result
  807. }
  808. forward getUserID(playerid);
  809. public getUserID(playerid){
  810. // SQL escape username
  811. new client_connect_username[MAX_PLAYER_NAME + 1], escaped_username[MAX_PLAYER_NAME + 1]; // TODO escaped_username should be longer to account for escape characters (Also increate database column size!)
  812. GetGVarString("client_connect_username", client_connect_username, sizeof(client_connect_username), playerid); // Get client connect name
  813. sql_escape_string(sqlHandle, client_connect_username, escaped_username, sizeof(escaped_username)); // Escape player name
  814. // Get user ID
  815. new userid_query[47 + MAX_PLAYER_NAME + 1];
  816. format(userid_query, sizeof(userid_query), "SELECT id FROM \"user\" WHERE name = '%s'", escaped_username);
  817. new Result:result = sql_query(sqlHandle, userid_query);
  818. return sql_get_field_assoc_int(result, "id");
  819. }
  820. // Player functions
  821. forward deleteAllGVars(playerid);
  822. public deleteAllGVars(playerid){ // Delete GVars as per https://forum.sa-mp.com/showthread.php?t=151076
  823. DeleteGVar("client_connect_username", playerid); // From OnPlayerConnect()
  824. DeleteGVar("userlevel", playerid); // From OnPlayerConnect()
  825. DeleteGVar("hash", playerid); // From DIALOG_REGISTER
  826. DeleteGVar("character_array_string", playerid); // From OnDialogResponse()
  827. DeleteGVar("authentication_count", playerid); // From DIALOG_LOGIN
  828. DeleteGVar("chatmode", playerid); // From cmd:my
  829. DeleteGVar("disable_pickups", playerid); // From OnPlayerPickUpDynamicPickup()
  830. DeleteGVar("goto_target", playerid); // From cmd:my & cmd:p
  831. }
  832. getPlayerName(playerid);
  833. getPlayerName(playerid){
  834. // new playername[MAX_PLAYER_NAME + 1];
  835. new const playername[MAX_PLAYER_NAME + 1];
  836. GetPlayerName(playerid, playername, sizeof(playername));
  837. // new output[MAX_PLAYER_NAME + 1];
  838. // strfromliteral(output, playername);
  839. return playername;
  840. }
  841. forward teleportPlayer(playerid, Float:x, Float:y, Float:z, world, interior, Float:angle, const name[]);
  842. public teleportPlayer(playerid, Float:x, Float:y, Float:z, world, interior, Float:angle, const name[]){
  843. SetPlayerPos(playerid, x, y, z);
  844. SetPlayerVirtualWorld(playerid, world);
  845. SetPlayerInterior(playerid, interior);
  846. SetPlayerFacingAngle(playerid, angle);
  847. // Inform admins
  848. new admin_message[21 + 4 + MAX_PLAYER_NAME + 5 + 4 + MAX_PLAYER_NAME + 1 + 1]; // 5 + 4 + MAX_PLAYER_NAME + 1 = name
  849. format(admin_message, sizeof(admin_message), "* [%i] %s teleported to: %s", playerid, getCharacterName(playerid), name);
  850. sendToAdmins(COLOR_NOTICE, admin_message);
  851. DiscordEcho(admin_message, ADMIN_ECHO_CHANNEL);
  852. }
  853. // Chat functions
  854. getCharacterName(playerid);
  855. getCharacterName(playerid){ // Convert name from player name
  856. new playername[MAX_PLAYER_NAME + 1], output[MAX_PLAYER_NAME + 1];
  857. GetPlayerName(playerid, playername, sizeof(playername));
  858. strfromliteral(output, playername);
  859. strreplace(output, "_", " ");
  860. return output;
  861. }
  862. forward sendToChat(playerid, target, text[], receiver_id);
  863. public sendToChat(playerid, target, text[], receiver_id){
  864. strtrim(text); // Trim edge whitespaces
  865. if(isempty(text)){
  866. return 0; // Fail if text is empty
  867. }
  868. new playername[MAX_PLAYER_NAME + 1];
  869. playername = getPlayerName(playerid);
  870. new chat_format, chat_color, chat_range, chat_userlevel, chat_character[1 + 1], chat_name[13 + 1], discord_channel;
  871. switch(target){
  872. case CHAT_WHISPER:{
  873. chat_format = 2;
  874. chat_range = 3;
  875. chat_name = "whispers";
  876. chat_color = COLOR_COMMAND_OUTPUT;
  877. discord_channel = ADMIN_ECHO_CHANNEL;
  878. }
  879. case CHAT_LOW:{
  880. chat_format = 2;
  881. chat_range = 10;
  882. chat_name = "speaks softly";
  883. chat_color = COLOR_COMMAND_OUTPUT;
  884. discord_channel = ADMIN_ECHO_CHANNEL;
  885. }
  886. case CHAT_LOCAL:{
  887. chat_format = 1;
  888. chat_range = 20;
  889. chat_color = COLOR_COMMAND_OUTPUT;
  890. discord_channel = ADMIN_ECHO_CHANNEL;
  891. }
  892. case CHAT_SHOUT:{
  893. chat_format = 2;
  894. chat_range = 50;
  895. chat_name = "shouts";
  896. chat_color = COLOR_COMMAND_OUTPUT;
  897. discord_channel = ADMIN_ECHO_CHANNEL;
  898. }
  899. case CHAT_ACTION:{
  900. chat_format = 0;
  901. chat_range = 20;
  902. chat_color = COLOR_COMMAND_OUTPUT;
  903. discord_channel = ADMIN_ECHO_CHANNEL;
  904. }
  905. case CHAT_OC:{
  906. chat_format = 3;
  907. chat_range = 20;
  908. chat_character = "'";
  909. chat_name = "OOC";
  910. chat_color = COLOR_COMMAND_OUTPUT;
  911. discord_channel = ADMIN_ECHO_CHANNEL;
  912. }
  913. case CHAT_GLOBAL:{
  914. chat_format = 3;
  915. chat_character = "`";
  916. chat_name = "Global";
  917. chat_color = COLOR_COMMAND_OUTPUT;
  918. discord_channel = ECHO_CHANNEL;
  919. }
  920. case CHAT_GANG:{
  921. chat_format = 3;
  922. chat_character = "~";
  923. chat_name = "Gang";
  924. chat_color = COLOR_CREW_CHAT;
  925. // TODO: Output to gang Discord channel
  926. discord_channel = ADMIN_ECHO_CHANNEL;
  927. }
  928. case CHAT_GANG_OC:{
  929. chat_format = 3;
  930. chat_character = "$";
  931. chat_name = "Gang OC";
  932. chat_color = COLOR_CREW_CHAT;
  933. // TODO: Output to gang Discord channel
  934. discord_channel = ADMIN_ECHO_CHANNEL;
  935. }
  936. case CHAT_FACTION:{
  937. chat_format = 3;
  938. chat_character = "!";
  939. chat_name = "Faction";
  940. chat_color = COLOR_CREW_CHAT;
  941. // TODO: Output to faction Discord channel
  942. discord_channel = ADMIN_ECHO_CHANNEL;
  943. }
  944. case CHAT_FACTION_OC:{
  945. chat_format = 3;
  946. chat_character = "%";
  947. chat_name = "Faction OC";
  948. chat_color = COLOR_CREW_CHAT;
  949. // TODO: Output to faction Discord channel
  950. discord_channel = ADMIN_ECHO_CHANNEL;
  951. }
  952. case CHAT_CREW:{
  953. chat_format = 3;
  954. chat_character = "@";
  955. chat_name = "Crew";
  956. chat_color = COLOR_CREW_CHAT;
  957. chat_userlevel = MODERATOR_CREW;
  958. discord_channel = ADMIN_ECHO_CHANNEL;
  959. }
  960. case CHAT_ADMIN:{
  961. chat_format = 3;
  962. chat_character = "#";
  963. chat_name = "Admin";
  964. chat_color = COLOR_ADMIN_CHAT;
  965. chat_userlevel = ADMIN_CREW;
  966. discord_channel = ADMIN_ECHO_CHANNEL;
  967. }
  968. case CHAT_MANAGEMENT:{
  969. chat_format = 3;
  970. chat_character = "&";
  971. chat_name = "Management";
  972. chat_color = COLOR_ADMIN_CHAT;
  973. chat_userlevel = MANAGEMENT_CREW;
  974. discord_channel = MANAGEMENT_CHANNEL;
  975. }
  976. case CHAT_VIP:{
  977. chat_format = 3;
  978. chat_character = "^";
  979. chat_name = "VIP";
  980. chat_color = COLOR_VIP_CHAT;
  981. chat_userlevel = VIP_PLAYER;
  982. discord_channel = ADMIN_ECHO_CHANNEL;
  983. //TODO: Add VIP discord channel.
  984. }
  985. case CHAT_UNDERCOVER:{
  986. chat_format = -1;
  987. chat_character = "*";
  988. chat_color = COLOR_COMMAND_OUTPUT;
  989. chat_userlevel = ADMIN_CREW;
  990. discord_channel = ECHO_CHANNEL;
  991. }
  992. case CHAT_PM:{
  993. chat_format = 3;
  994. chat_character = ">";
  995. chat_name = "PM";
  996. chat_color = COLOR_PM_CHAT;
  997. discord_channel = ADMIN_ECHO_CHANNEL;
  998. }
  999. case CHAT_CALL:{
  1000. chat_format = 3;
  1001. chat_character = "+";
  1002. chat_name = "Call";
  1003. chat_color = COLOR_PM_CHAT;
  1004. discord_channel = ADMIN_ECHO_CHANNEL;
  1005. }
  1006. case CHAT_SMS:{
  1007. chat_format = 3;
  1008. chat_character = "-";
  1009. chat_name = "SMS";
  1010. chat_color = COLOR_PM_CHAT;
  1011. discord_channel = ADMIN_ECHO_CHANNEL;
  1012. }
  1013. case CHAT_RADIO:{
  1014. chat_format = 3;
  1015. chat_character = "=";
  1016. chat_name = "Radio";
  1017. chat_color = COLOR_PM_CHAT;
  1018. discord_channel = ADMIN_ECHO_CHANNEL;
  1019. }
  1020. }
  1021. // Format chat message
  1022. new message[9 + (6 * 8) + 1 + sizeof(chat_name) + 4 + MAX_PLAYER_NAME + 128 + 1];
  1023. switch(chat_format){
  1024. case -1: format(message, sizeof(message), "%s %s", chat_character, text);
  1025. case 0: format(message, sizeof(message), EMBED_COLOR_GREY"["EMBED_COLOR_WHITE"%i"EMBED_COLOR_GREY"]{%06x} %s %s", playerid, getCharacterName(playerid), chat_color >>> 8, text);
  1026. case 1: format(message, sizeof(message), EMBED_COLOR_GREY"["EMBED_COLOR_WHITE"%i"EMBED_COLOR_GREY"]"EMBED_COLOR_WHITE" %s"EMBED_COLOR_GREY":{%06x} %s", playerid, getCharacterName(playerid), chat_color >>> 8, text);
  1027. case 2: format(message, sizeof(message), EMBED_COLOR_GREY"["EMBED_COLOR_WHITE"%i"EMBED_COLOR_GREY"]"EMBED_COLOR_WHITE" %s %s"EMBED_COLOR_GREY":{%06x} %s", playerid, getCharacterName(playerid), chat_name, chat_color >>> 8, text);
  1028. case 3: format(message, sizeof(message), "%s "EMBED_COLOR_GREY"(%s) ["EMBED_COLOR_WHITE"%i"EMBED_COLOR_GREY"]"EMBED_COLOR_WHITE" %s"EMBED_COLOR_GREY":{%06x} %s", chat_character, chat_name, playerid, getCharacterName(playerid), chat_color >>> 8, text);
  1029. }
  1030. // Authorisation
  1031. if(chat_userlevel && chat_userlevel > GetGVarInt("userlevel", playerid)){ // User not privilged to read chat
  1032. if(target == CHAT_CREW){ // Show the user the message was sent to crew chat.
  1033. SendClientMessage(playerid, chat_color, message);
  1034. }
  1035. else{
  1036. SendClientMessage(playerid, COLOR_CREW_CHAT, "ERROR: You are not authorized to speak in this chat.");
  1037. return 0; // Fail to send the message
  1038. }
  1039. }
  1040. // Send TODO: Add checks for muted.
  1041. if(chat_range){ // Ranged chats
  1042. logger(LOGLEVEL_CHAT, message); // Log event
  1043. // Show message to players in range
  1044. new Float:x, Float:y, Float:z;
  1045. GetPlayerPos(playerid, x, y, z);
  1046. for(new recipient_id, a = GetMaxPlayers(); recipient_id < a; recipient_id++){
  1047. if(IsPlayerConnected(receiver_id)){
  1048. new Float:distance = GetPlayerDistanceFromPoint(recipient_id, x, y, z);
  1049. if(distance <= chat_range){ // Player nearby
  1050. SendClientMessage(recipient_id, chat_color, message);
  1051. }
  1052. }
  1053. }
  1054. DiscordEcho(message, discord_channel);
  1055. }
  1056. else{ // Global chats
  1057. if(target == CHAT_GLOBAL){ // Public chat
  1058. logger(LOGLEVEL_CHAT, message); // Log event
  1059. SendClientMessageToAll(chat_color, message);
  1060. DiscordEcho(message, discord_channel);
  1061. }
  1062. else if(target == CHAT_GANG || target == CHAT_GANG_OC || target == CHAT_FACTION || target == CHAT_FACTION_OC || target == CHAT_CALL || target == CHAT_SMS || target == CHAT_RADIO ){
  1063. // TODO
  1064. // TODO sendToAdmins();
  1065. // TODO send to specific discord channel
  1066. SendClientMessage(playerid, chat_color, "You are not a member of the required entity.");
  1067. }
  1068. else if(target == CHAT_PM){
  1069. new output[sizeof(message)];
  1070. strdel(message, 0, 1);
  1071. format(output, sizeof(output), "<%s", message);
  1072. SendClientMessage(receiver_id, chat_color, output);
  1073. new receipt[12 + 1 + sizeof(chat_name) + 4 + MAX_PLAYER_NAME + 128 + 1];
  1074. format(receipt, sizeof(receipt), "%s (%s) to [%i] %s: %s", chat_character, chat_name, receiver_id, getCharacterName(playerid), text);
  1075. SendClientMessage(playerid, chat_color, receipt);
  1076. new admin_message[15 + 1 + sizeof(chat_name) + 4 + MAX_PLAYER_NAME + 4 + 128 + 1];
  1077. format(admin_message, sizeof(admin_message), "%s (%s) [%i] to %s [%i]: %s", chat_character, chat_name, playerid, getCharacterName(playerid), receiver_id, text);
  1078. logger(LOGLEVEL_CHAT, admin_message); // Log event
  1079. sendToAdmins(chat_color, admin_message);
  1080. DiscordEcho(message, discord_channel);
  1081. }
  1082. else{ // Chat with select users
  1083. for(new recipient_id, a = GetMaxPlayers(); recipient_id < a; recipient_id++){
  1084. if(IsPlayerConnected(recipient_id)){
  1085. if(GetGVarInt("userlevel", recipient_id) >= chat_userlevel){ // Privileged
  1086. logger(LOGLEVEL_CHAT, message); // Log event
  1087. SendClientMessage(recipient_id, chat_color, message);
  1088. DiscordEcho(message, discord_channel);
  1089. }
  1090. }
  1091. }
  1092. }
  1093. }
  1094. return 1;
  1095. }
  1096. forward sendToAdmins(chat_color, const message[]);
  1097. public sendToAdmins(chat_color, const message[]){
  1098. for(new recipient_id, a = GetMaxPlayers(); recipient_id < a; recipient_id++){
  1099. if(IsPlayerConnected(recipient_id)){
  1100. if(GetGVarInt("userlevel", recipient_id) >= ADMIN_CREW){ // Privileged
  1101. SendClientMessage(recipient_id, chat_color, message);
  1102. }
  1103. }
  1104. }
  1105. }
  1106. forward sendPM(playerid, text[], recipient_id);
  1107. public sendPM(playerid, text[], recipient_id){
  1108. if (recipient_id == INVALID_PLAYER_ID){
  1109. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "ERROR: Player not found.");
  1110. }
  1111. else{
  1112. sendToChat(playerid, CHAT_PM, text, recipient_id);
  1113. }
  1114. }
  1115. // Pickup functions
  1116. forward createDynamicPickup(object, Float:x, Float:y, Float:z, world, interior, pickup_type);
  1117. public createDynamicPickup(object, Float:x, Float:y, Float:z, world, interior, pickup_type){
  1118. // Object position corrections
  1119. if(object == 19902){
  1120. z = z - 0.5;
  1121. }
  1122. else if(object == 19607){
  1123. z = z - 0.5;
  1124. }
  1125. // Pickup types
  1126. new type;
  1127. switch(pickup_type){
  1128. case PICKUP_PORTAL: type = 1;
  1129. case PICKUP_FACTION_PD: type = 1;
  1130. }
  1131. new pickupid = CreateDynamicPickup(object, type, x, y, z, world, interior);
  1132. SetGVarInt("pickup_type", pickup_type, pickupid);
  1133. return pickupid;
  1134. }
  1135. forward spawnPortal(id, object, Float:pos_x, Float:pos_y, Float:pos_z, world, interior, exit_object, Float:exit_pos_x, Float:exit_pos_y, Float:exit_pos_z, exit_world, exit_interior);
  1136. public spawnPortal(id, object, Float:pos_x, Float:pos_y, Float:pos_z, world, interior, exit_object, Float:exit_pos_x, Float:exit_pos_y, Float:exit_pos_z, exit_world, exit_interior){
  1137. new pickup_id = createDynamicPickup(object, pos_x, pos_y, pos_z, world, interior, PICKUP_PORTAL);
  1138. SetGVarFloat("pickup_x", exit_pos_x, pickup_id);
  1139. SetGVarFloat("pickup_y", exit_pos_y, pickup_id);
  1140. SetGVarFloat("pickup_z", exit_pos_z, pickup_id);
  1141. SetGVarInt("pickup_world", exit_world, pickup_id);
  1142. SetGVarInt("pickup_interior", exit_interior, pickup_id);
  1143. new exit_pickup_id = createDynamicPickup(exit_object, exit_pos_x, exit_pos_y, exit_pos_z, exit_world, exit_interior, PICKUP_PORTAL);
  1144. SetGVarFloat("pickup_x", pos_x, exit_pickup_id);
  1145. SetGVarFloat("pickup_y", pos_y, exit_pickup_id);
  1146. SetGVarFloat("pickup_z", pos_z, exit_pickup_id);
  1147. SetGVarInt("pickup_world", world, exit_pickup_id);
  1148. SetGVarInt("pickup_interior", interior, exit_pickup_id);
  1149. new portal_query[64 + MAX_SQL_INTEGER + MAX_SQL_INTEGER + MAX_SQL_INTEGER + 1];
  1150. format(portal_query, sizeof(portal_query), "UPDATE portal SET (pickup_id, exit_pickup_id) = (%i, %i) WHERE id = %i", pickup_id, exit_pickup_id, id);
  1151. sql_query(sqlHandle, portal_query);
  1152. }
  1153. forward destroyPortal(id);
  1154. public destroyPortal(id){
  1155. DestroyDynamicPickup(id);
  1156. DeleteGVar("pickup_type", id);
  1157. DeleteGVar("pickup_x", id);
  1158. DeleteGVar("pickup_y", id);
  1159. DeleteGVar("pickup_z", id);
  1160. DeleteGVar("pickup_world", id);
  1161. DeleteGVar("pickup_interior", id);
  1162. }
  1163. // Command functions
  1164. public OnPlayerCommandPerformed(playerid, cmd[], params[], result, flags){
  1165. if(result == -1){
  1166. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "SERVER: Unknown command.");
  1167. return 0;
  1168. }
  1169. return 1;
  1170. }
  1171. public OnPlayerCommandReceived(playerid, cmd[], params[], flags){
  1172. new userlevel = GetGVarInt("userlevel", playerid);
  1173. if(flags){
  1174. printf("Flags: %i", flags);
  1175. if(flags > userlevel){
  1176. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "SERVER: Access denied.");
  1177. printf("player %d doesn�t have access to command '%s'", playerid, cmd); // TODO decide to send this to a chat or not.
  1178. return 0;
  1179. }
  1180. }
  1181. //if (!(flags & userlevel)){} // From sa-mp
  1182. return 1;
  1183. }
  1184. public PC_OnInit(){ // TODO
  1185. return 1; // Remove this once stuff is in place.
  1186. }
  1187. flags:test(ADMIN_CREW);
  1188. cmd:test(playerid, params[]){
  1189. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Executed");
  1190. return 1;
  1191. }
  1192. // Command commands
  1193. cmd:help(playerid, params[]){
  1194. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "SERVER: Ask questions in the chat, on Discord or the forum.\nTo list all commands: /cmds");
  1195. return 1;
  1196. }
  1197. alias:help("h");
  1198. cmd:cmds(playerid, params[]){
  1199. SendClientMessage(playerid, COLOR_NOTICE, "Command help syntax: \"/\" = start of cmd, \"()\" = cmd aliasses, \"|\" = or, \"<>\" = required parameter, \"[]\" = optional parameter, \",\" = next item.");
  1200. SendClientMessage(playerid, COLOR_NOTICE, "Command help syntax example: /command (/alias | /other_alias) <parameter> [optional_parameter], /next_command");
  1201. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "General commands: /help (/h), /cmds (/cmd | /commands), /my (/myself | /mine), /v (/vehivle | /veh), /p (/player)");
  1202. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Chat commands: /me (/emote | /action), /w (/whisper), /low (/soft), /l (/local), /s (/shout | /scream), /o (' | /oc | /ooc)");
  1203. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Chat commands: /g (` | /global | /public), /gc (~) /fc (!), /vc (&), /cc (@), /my chatmode <value>");
  1204. if(GetGVarInt("userlevel", playerid) >= ADMIN_CREW){
  1205. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Admin commands: /property");
  1206. }
  1207. return 0;
  1208. }
  1209. alias:cmds("commands", "cmd");
  1210. // User commands
  1211. cmd:register(playerid, params[]){
  1212. register(playerid);
  1213. }
  1214. cmd:my(playerid, params[]){
  1215. // No option specified
  1216. if(strlen(params) < 1){
  1217. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Usage: /my <option> <value>");
  1218. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Options: account chatmode");
  1219. if(GetGVarInt("userlevel", playerid) >= ADMIN_CREW){
  1220. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Admin options: goto");
  1221. }
  1222. return 0;
  1223. }
  1224. // Options
  1225. if(!strcmp(params, "account", true, 7)){ // /my account
  1226. strdel(params, 0, 8); // Remove first 8 characters, "account ", from the string.
  1227. // Values
  1228. if (isequal(params, "register", .ignorecase = true)){ // /my account register
  1229. register(playerid); // Call public register function
  1230. }
  1231. else if (isequal(params, "characters", .ignorecase = true)){ // /my account characters
  1232. characterSelection(playerid);
  1233. }
  1234. else if (isequal(params, "deletecharacter", .ignorecase = true)){ // /my account characters
  1235. ShowPlayerDialog(playerid, DIALOG_DELETE_CHARACTER, DIALOG_STYLE_MSGBOX, "Charater deletion", "You are about to permanently delete this charater and all it's assets.\n This can NOT be undone.", "Destroy", "Abort");
  1236. }
  1237. else{ // Invalid value
  1238. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Usage: /my account <value>");
  1239. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Values: register characters deletecharacter");
  1240. }
  1241. }
  1242. else if(!strcmp(params, "chatmode", true, 8)){ // /my chatmode
  1243. strdel(params, 0, 9); // Remove first 9 characters, "account ", from the string.
  1244. // Values
  1245. if (isequal(params, "whisper", .ignorecase = true)){
  1246. SetGVarInt("chatmode", CHAT_WHISPER, playerid);
  1247. }
  1248. else if (isequal(params, "low", .ignorecase = true)){
  1249. SetGVarInt("chatmode", CHAT_LOW, playerid);
  1250. }
  1251. else if (isequal(params, "local", .ignorecase = true)){
  1252. SetGVarInt("chatmode", CHAT_LOCAL, playerid);
  1253. }
  1254. else if (isequal(params, "shout", .ignorecase = true)){
  1255. SetGVarInt("chatmode", CHAT_SHOUT, playerid);
  1256. }
  1257. else if (isequal(params, "oc", .ignorecase = true)){
  1258. SetGVarInt("chatmode", CHAT_OC, playerid);
  1259. }
  1260. else if (isequal(params, "global", .ignorecase = true)){
  1261. SetGVarInt("chatmode", CHAT_GLOBAL, playerid);
  1262. }
  1263. else if (isequal(params, "gang", .ignorecase = true)){
  1264. SetGVarInt("chatmode", CHAT_GANG, playerid);
  1265. }
  1266. else if (isequal(params, "faction", .ignorecase = true)){
  1267. SetGVarInt("chatmode", CHAT_FACTION, playerid);
  1268. }
  1269. else if (isequal(params, "vip", .ignorecase = true)){
  1270. SetGVarInt("chatmode", CHAT_VIP, playerid);
  1271. }
  1272. else if (isequal(params, "crew", .ignorecase = true)){
  1273. SetGVarInt("chatmode", CHAT_CREW, playerid);
  1274. }
  1275. else if (isequal(params, "admin", .ignorecase = true)){
  1276. SetGVarInt("chatmode", CHAT_ADMIN, playerid);
  1277. }
  1278. else if (isequal(params, "management", .ignorecase = true)){
  1279. SetGVarInt("chatmode", CHAT_MANAGEMENT, playerid);
  1280. }
  1281. else{ // Invalid value
  1282. printf("else isequals register");
  1283. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Usage: /my chatmode <value>");
  1284. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Values: whisper low local shout oc global gang faction vip crew admin management");
  1285. }
  1286. }
  1287. else if(!strcmp(params, "goto", true, 4) || !strcmp(params, "sendto", true, 6) || !strcmp(params, "teleport", true, 8)){
  1288. if(GetGVarInt("userlevel", playerid) < ADMIN_CREW){
  1289. return SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "SERVER: Access denied.");
  1290. }
  1291. SetGVarInt("goto_target", playerid, playerid);
  1292. ShowPlayerDialog(playerid, DIALOG_GOTO, DIALOG_STYLE_LIST, "Categories", "Interiors", "Select", "Cancel");
  1293. }
  1294. else{ // Invalid option
  1295. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "/my options: account chatmode");
  1296. if(GetGVarInt("userlevel", playerid) >= ADMIN_CREW){
  1297. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Admin options: goto");
  1298. }
  1299. }
  1300. return 0;
  1301. }
  1302. alias:my("myself", "mine");
  1303. // Chat commands
  1304. cmd:w(playerid, params[]){
  1305. sendToChat(playerid, CHAT_WHISPER, params, 0);
  1306. return 1;
  1307. }
  1308. alias:w("whisper");
  1309. cmd:low(playerid, params[]){
  1310. sendToChat(playerid, CHAT_LOW, params, 0);
  1311. return 1;
  1312. }
  1313. alias:low("soft");
  1314. cmd:l(playerid, params[]){
  1315. sendToChat(playerid, CHAT_LOCAL, params, 0);
  1316. return 1;
  1317. }
  1318. alias:l("local");
  1319. cmd:me(playerid, params[]){
  1320. sendToChat(playerid, CHAT_ACTION, params, 0);
  1321. return 1;
  1322. }
  1323. alias:me("emote", "action");
  1324. cmd:s(playerid, params[]){
  1325. sendToChat(playerid, CHAT_SHOUT, params, 0);
  1326. return 1;
  1327. }
  1328. alias:s("shout", "scream");
  1329. cmd:o(playerid, params[]){
  1330. sendToChat(playerid, CHAT_OC, params, 0);
  1331. return 1;
  1332. }
  1333. alias:o("oc", "ooc");
  1334. cmd:g(playerid, params[]){
  1335. sendToChat(playerid, CHAT_GLOBAL, params, 0);
  1336. return 1;
  1337. }
  1338. alias:g("global", "public");
  1339. cmd:gc(playerid, params[]){
  1340. sendToChat(playerid, CHAT_GANG, params, 0);
  1341. return 1;
  1342. }
  1343. cmd:fc(playerid, params[]){
  1344. sendToChat(playerid, CHAT_FACTION, params, 0);
  1345. return 1;
  1346. }
  1347. cmd:vc(playerid, params[]){
  1348. sendToChat(playerid, CHAT_VIP, params, 0);
  1349. return 1;
  1350. }
  1351. cmd:cc(playerid, params[]){
  1352. sendToChat(playerid, CHAT_CREW, params, 0);
  1353. return 1;
  1354. }
  1355. cmd:pm(playerid, params[]){
  1356. new recipient_id, message[123 + 1];
  1357. if (sscanf(params, "u s", recipient_id, message)){
  1358. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Usage: /pm <playerid> <message>");
  1359. }
  1360. else{
  1361. sendPM(playerid, message, recipient_id);
  1362. }
  1363. return 1;
  1364. }
  1365. alias:pm("msg", "dm");
  1366. // Vehicle commands
  1367. cmd:v(playerid, params[]){
  1368. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "health/armor [AMOUNT]");
  1369. return 1;
  1370. }
  1371. alias:v("vehicle", "veh");
  1372. // Player commands
  1373. cmd:p(playerid, params[]){
  1374. // No parameters
  1375. if(strlen(params) < 1){
  1376. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Usage: /p <ID> option");
  1377. return SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "/p options: admin, goto");
  1378. }
  1379. new player_id, option[123 + 1];
  1380. if(sscanf(params, "i s", player_id, option)){
  1381. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Usage: /p <ID> <option>");
  1382. return SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "/p options: admin, goto");
  1383. }
  1384. if(!strcmp(option, "admin", true, 5)){
  1385. SetGVarInt("userlevel", ADMIN_CREW, player_id);
  1386. // TODO take admin if already admin
  1387. // TODO notify admins
  1388. }
  1389. else if(!strcmp(option, "goto", true, 4) || !strcmp(option, "sendto", true, 6 || !strcmp(option, "teleport", true, 8)) ){
  1390. if(GetGVarInt("userlevel", playerid) < ADMIN_CREW){
  1391. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "SERVER: Access denied.");
  1392. SetGVarInt("goto_target", player_id);
  1393. }
  1394. }
  1395. else{
  1396. return SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "/p <ID> options: admin, goto");
  1397. }
  1398. return 1;
  1399. }
  1400. alias:p("player");
  1401. // Admin commands
  1402. flags:property(ADMIN_CREW);
  1403. cmd:property(playerid, params[]){
  1404. // No option specified
  1405. if(strlen(params) < 1){
  1406. return SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "/property options: pickup, portal");
  1407. }
  1408. // Options
  1409. if(!strcmp(params, "pickup", true, 6)){ // /property pickup
  1410. strdel(params, 0, 7); // Remove first 7 characters, "pickup ", from the string.
  1411. // Values
  1412. new pickup_id, option[110 + 1];
  1413. if(!strcmp(params, "create", true)){ // /property pickup create
  1414. ShowPlayerDialog(playerid, DIALOG_CREATE_PICKUP, DIALOG_STYLE_LIST, "Pickup caterogy", "Faction", "Select", "Cancel");
  1415. }
  1416. else if (!sscanf(params, "i s", pickup_id, option)){
  1417. new pickup_query[166 + MAX_SQL_INTEGER + 1];
  1418. format(pickup_query, sizeof(pickup_query), "SELECT object_id, pox_x, pos_y, pos_z, world_id, interior_id, type_id, pickup_id FROM pickup WHERE id = %i", pickup_id);
  1419. new Result:pickup_result = sql_query(sqlHandle, pickup_query);
  1420. if(sql_num_rows(pickup_result) < 1){ // Invalid pickup ID
  1421. return SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Invalid portal ID");
  1422. }
  1423. new pickupid = sql_get_field_assoc_int(pickup_result, "pickup_id");
  1424. if(!strcmp(params, "move", true)){
  1425. // Destroy old pickup
  1426. DestroyDynamicPickup(pickupid);
  1427. // Create new pickup
  1428. new object_id = sql_get_field_assoc_int(Result:pickup_result, "object_id");
  1429. new pos_x = sql_get_field_assoc_int(Result:pickup_result, "pos_x");
  1430. new pos_y = sql_get_field_assoc_int(Result:pickup_result, "pos_y");
  1431. new pos_z = sql_get_field_assoc_int(Result:pickup_result, "pos_z");
  1432. new world_id = sql_get_field_assoc_int(Result:pickup_result, "world_id");
  1433. new interior_id = sql_get_field_assoc_int(Result:pickup_result, "interior_id");
  1434. new type_id = sql_get_field_assoc_int(Result:pickup_result, "type_id");
  1435. new new_pickupid = createDynamicPickup(object_id, pos_x, pos_y, pos_z, world_id, interior_id, type_id);
  1436. // Update pickup record
  1437. new update_query[109 + MAX_SQL_FLOAT + MAX_SQL_FLOAT + MAX_SQL_FLOAT + MAX_SQL_INTEGER + MAX_SQL_INTEGER + MAX_SQL_INTEGER + 1];
  1438. format(update_query, sizeof(update_query), "UPDATE pickup SET pos_x = '%f', pos_y = '%f', pos_z = '%f', world_id = %i, interior_id = %i, pickup_id = %i WHERE id = %i", pos_x, pos_y, pos_z, world_id, interior_id, new_pickupid, pickup_id);
  1439. sql_query(sqlHandle, update_query);
  1440. // Inform admins
  1441. new admin_message[39 + 4 + MAX_PLAYER_NAME + MAX_SQL_INTEGER + 1];
  1442. format(admin_message, sizeof(admin_message), "* [%i] %s modified the location of pickup: %i", playerid, getPlayerName(playerid), pickup_id);
  1443. sendToAdmins(COLOR_NOTICE, admin_message);
  1444. DiscordEcho(admin_message, ADMIN_ECHO_CHANNEL);
  1445. }
  1446. else if(!strcmp(params, "delete", true)){
  1447. // Destroy pickup
  1448. DestroyDynamicPickup(pickupid);
  1449. // Delete pickup record
  1450. new update_query[95 + MAX_SQL_FLOAT + MAX_SQL_FLOAT + MAX_SQL_FLOAT + MAX_SQL_INTEGER + MAX_SQL_INTEGER + MAX_SQL_INTEGER + 1];
  1451. format(update_query, sizeof(update_query), "DELETE FROM pickup WHERE id = %i", pickupid);
  1452. sql_query(sqlHandle, update_query);
  1453. // Inform admins
  1454. new admin_message[39 + 4 + MAX_PLAYER_NAME + MAX_SQL_INTEGER + 1];
  1455. format(admin_message, sizeof(admin_message), "* [%i] %s deleted pickup: %i", playerid, getPlayerName(playerid), pickupid);
  1456. sendToAdmins(COLOR_NOTICE, admin_message);
  1457. DiscordEcho(admin_message, ADMIN_ECHO_CHANNEL);
  1458. }
  1459. else{ // Invalid option.
  1460. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "/property pickup <ID> usage: move, delete");
  1461. }
  1462. }
  1463. else{ // Invalid value
  1464. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "/property pickup usage: create, <ID> <move | delete>");
  1465. }
  1466. }
  1467. else if(!strcmp(params, "portal", true, 6)){ // /property portal
  1468. strdel(params, 0, 7); // Remove first 7 characters, "portal ", from the string.
  1469. // Values
  1470. if (!strcmp(params, "create", true, 6)){ // /property portal create
  1471. strdel(params, 0, 7); // Remove first 7 characters, "create ", from the string.
  1472. // Worlds
  1473. new world[105 + 1], world_id;
  1474. if (sscanf(params, "s", world)){
  1475. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "For a portal that works in all worlds use: /property portal create all");
  1476. }
  1477. if(!strcmp(world, "all", true)){
  1478. world_id = -1;
  1479. }
  1480. else{
  1481. world_id = GetPlayerVirtualWorld(playerid);
  1482. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Invalid world option, creating default portal.");
  1483. }
  1484. new Float:x, Float:y, Float:z;
  1485. GetPlayerPos(playerid, x, y, z);
  1486. new interior = GetPlayerInterior(playerid);
  1487. new pickup_id = createDynamicPickup(19902, x, y, z, world_id, interior, PICKUP_PORTAL);
  1488. // Create portal database record
  1489. new portal_query[111 + MAX_SQL_FLOAT + MAX_SQL_FLOAT + MAX_SQL_FLOAT + MAX_SQL_INTEGER + 1];
  1490. format(portal_query, sizeof(portal_query), "INSERT INTO portal(object, pos_x, pos_y, pos_z, world, pickup_id, interior_id) VALUES (19902, '%f', '%f', '%f', %i, %i, %i)", x, y, z, world_id, pickup_id, interior);
  1491. sql_query(sqlHandle, portal_query);
  1492. // Inform user(s)
  1493. new portal_id_query[91 + MAX_SQL_FLOAT + MAX_SQL_FLOAT + MAX_SQL_FLOAT + MAX_SQL_INTEGER + 1];
  1494. format(portal_id_query, sizeof(portal_id_query), "SELECT id FROM portal WHERE pos_x = '%f' AND pos_y = '%f' AND pos_z = '%f' AND world = %i AND interior_id = %i", x, y, z, world_id, interior);
  1495. new Result:portal_id_result = sql_query(sqlHandle, portal_id_query);
  1496. new portal_id = sql_get_field_assoc_int(Result:portal_id_result, "id");
  1497. new message[69 + MAX_SQL_INTEGER + MAX_SQL_INTEGER + 1], admin_message[21 + 4 + MAX_PLAYER_NAME + MAX_SQL_INTEGER + 1];
  1498. format(message, sizeof(message), "Portal %i created. Create the other side with: /property portal exit %i", portal_id, portal_id);
  1499. format(admin_message, sizeof(admin_message), "* [%i] %s created portal: %i", playerid, getPlayerName(playerid), portal_id);
  1500. sendToAdmins(COLOR_NOTICE , admin_message);
  1501. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, message);
  1502. DiscordEcho(admin_message, ADMIN_ECHO_CHANNEL);
  1503. }
  1504. else if (!strcmp(params, "exit", true, 4)){
  1505. strdel(params, 0, 5); // Remove first 5 characters from the string.
  1506. new portal_id;
  1507. if (sscanf(params, "i", portal_id)){
  1508. return SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Usage: /property portal exit <Portal ID>");
  1509. }
  1510. // Get portal record
  1511. new portal_query[97 + MAX_SQL_INTEGER + 1];
  1512. format(portal_query, sizeof(portal_query), "SELECT pos_x, pos_y, pos_z, world, interior_id, pickup_id, exit_pickup_id FROM portal WHERE id = %i", portal_id);
  1513. new Result:portal_result = sql_query(sqlHandle, portal_query);
  1514. new Float:pos_x = sql_get_field_assoc_float(portal_result, "pos_x");
  1515. new Float:pos_y = sql_get_field_assoc_float(portal_result, "pos_y");
  1516. new Float:pos_z = sql_get_field_assoc_float(portal_result, "pos_z");
  1517. new world_id = sql_get_field_assoc_int(portal_result, "world");
  1518. new interior_id = sql_get_field_assoc_int(portal_result, "interior_id");
  1519. new session_id = sql_get_field_assoc_int(portal_result, "pickup_id");
  1520. new exit_pickup_id = sql_get_field_assoc_int(portal_result, "exit_pickup_id");
  1521. if(sql_num_rows(portal_result) < 1){ // Invalid portal ID
  1522. return SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Invalid portal ID");
  1523. }
  1524. // World
  1525. new world;
  1526. if(world_id != -1){ // Not an all-world portal
  1527. world = GetPlayerVirtualWorld(playerid);
  1528. }
  1529. else{
  1530. world = world_id;
  1531. }
  1532. // Location
  1533. new Float:x, Float:y, Float:z;
  1534. GetPlayerPos(playerid, x, y, z);
  1535. new interior = GetPlayerInterior(playerid);
  1536. // Delete old exit if exists
  1537. if(exit_pickup_id){
  1538. destroyPortal(exit_pickup_id);
  1539. }
  1540. new pickup_id = createDynamicPickup(19607, x, y, z, world, interior, PICKUP_PORTAL);
  1541. SetGVarFloat("pickup_x", pos_x, pickup_id);
  1542. SetGVarFloat("pickup_y", pos_y, pickup_id);
  1543. SetGVarFloat("pickup_z", pos_z, pickup_id);
  1544. SetGVarInt("pickup_world", world_id, pickup_id);
  1545. SetGVarInt("pickup_interior", interior_id, pickup_id);
  1546. SetGVarFloat("pickup_x", x, session_id);
  1547. SetGVarFloat("pickup_y", y, session_id);
  1548. SetGVarFloat("pickup_z", z, session_id);
  1549. SetGVarInt("pickup_world", world, session_id);
  1550. SetGVarInt("pickup_interior", interior, session_id);
  1551. // Update portal record
  1552. new update_query[155 + MAX_SQL_FLOAT + MAX_SQL_FLOAT + MAX_SQL_FLOAT + MAX_SQL_INTEGER + MAX_SQL_INTEGER + MAX_SQL_INTEGER + 1];
  1553. format(update_query, sizeof(update_query), "UPDATE portal SET exit_object = 19607, exit_pos_x = '%f', exit_pos_y = '%f', exit_pos_z = '%f', exit_world = %i, exit_interior_id = %i, exit_pickup_id = %i WHERE id = %i", x, y, z, world, interior, pickup_id, portal_id);
  1554. sql_query(sqlHandle, update_query);
  1555. // Inform admins and Discord
  1556. new admin_message[61 + 4 + MAX_PLAYER_NAME + MAX_SQL_INTEGER + 1];
  1557. format(admin_message, sizeof(admin_message), "* [%i] %s modified the exit location of portal: %i", playerid, getPlayerName(playerid), portal_id);
  1558. sendToAdmins(COLOR_NOTICE , admin_message);
  1559. DiscordEcho(admin_message, ADMIN_ECHO_CHANNEL);
  1560. }
  1561. else if(!strcmp(params, "object", true, 6)){
  1562. strdel(params, 0, 7); // Remove first 7 characters from the string.
  1563. new portal_id, object, exit_object;
  1564. if (sscanf(params, "i i i", portal_id, object, exit_object)){
  1565. return SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Usage: /property portal object <Portal ID> <Object ID> <Object ID>");
  1566. }
  1567. // Get portal record
  1568. new portal_query[163 + MAX_SQL_INTEGER + 1];
  1569. format(portal_query, sizeof(portal_query), "SELECT pos_x, pos_y, pos_z, world, interior_id, pickup_id, exit_pos_x, exit_pos_y, exit_pos_z, exit_world, exit_interior_id, exit_pickup_id FROM portal WHERE id = %i", portal_id);
  1570. new Result:portal_result = sql_query(sqlHandle, portal_query);
  1571. // Invalid portal ID
  1572. if(sql_num_rows(portal_result) < 1){
  1573. return SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Invalid portal ID");
  1574. }
  1575. new Float:pos_x = sql_get_field_assoc_float(portal_result, "pos_x");
  1576. new Float:pos_y = sql_get_field_assoc_float(portal_result, "pos_y");
  1577. new Float:pos_z = sql_get_field_assoc_float(portal_result, "pos_z");
  1578. new world_id = sql_get_field_assoc_int(portal_result, "world");
  1579. new interior_id = sql_get_field_assoc_int(portal_result, "interior_id");
  1580. new pickup_id = sql_get_field_assoc_int(portal_result, "pickup_id");
  1581. new Float:exit_pos_x = sql_get_field_assoc_float(portal_result, "exit_pos_x");
  1582. new Float:exit_pos_y = sql_get_field_assoc_float(portal_result, "exit_pos_y");
  1583. new Float:exit_pos_z = sql_get_field_assoc_float(portal_result, "exit_pos_z");
  1584. new exit_world_id = sql_get_field_assoc_int(portal_result, "exit_world");
  1585. new exit_interior_id = sql_get_field_assoc_int(portal_result, "exit_interior_id");
  1586. new exit_pickup_id = sql_get_field_assoc_int(portal_result, "exit_pickup_id");
  1587. destroyPortal(exit_pickup_id);
  1588. destroyPortal(pickup_id);
  1589. spawnPortal(portal_id, object, pos_x, pos_y, pos_z, world_id, interior_id, exit_object, exit_pos_x, exit_pos_y, exit_pos_z, exit_world_id, exit_interior_id);
  1590. new update_query[57 + MAX_SQL_INTEGER + MAX_SQL_INTEGER + MAX_SQL_INTEGER + 1];
  1591. format(update_query, sizeof(update_query), "UPDATE portal SET (object, exit_object) = (%i, %i) WHERE id = %i", object, exit_object, portal_id);
  1592. sql_query(sqlHandle, portal_query);
  1593. }
  1594. else if(!strcmp(params, "delete", true, 6)){
  1595. strdel(params, 0, 7); // Remove first 7 characters from the string.
  1596. new portal_id;
  1597. if (sscanf(params, "i", portal_id)){
  1598. return SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Usage: /property portal delete <Portal ID>");
  1599. }
  1600. // Get portal record
  1601. new portal_query[98 + MAX_SQL_INTEGER + 1];
  1602. format(portal_query, sizeof(portal_query), "SELECT pickup_id, exit_pickup_id FROM portal WHERE id = %i", portal_id);
  1603. new Result:portal_result = sql_query(sqlHandle, portal_query);
  1604. // Invalid portal ID
  1605. printf("sql rows: %i", sql_num_rows(portal_result));
  1606. if(sql_num_rows(portal_result) < 1){
  1607. return SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Invalid portal ID");
  1608. }
  1609. print("Still executing anyway");
  1610. new pickup_id = sql_get_field_assoc_int(portal_result, "pickup_id");
  1611. new exit_pickup_id = sql_get_field_assoc_int(portal_result, "exit_pickup_id");
  1612. // TODO: Confirmation, by spectating the pickup or having to be near.
  1613. destroyPortal(exit_pickup_id);
  1614. destroyPortal(pickup_id);
  1615. // Delete portal record
  1616. new delete_query[31 + MAX_SQL_INTEGER + 1];
  1617. format(delete_query, sizeof(delete_query), "DELETE FROM portal WHERE id = %i", portal_id);
  1618. sql_query(sqlHandle, delete_query);
  1619. }
  1620. else if(!strcmp(params, "entrance", true, 8)){
  1621. strdel(params, 0, 9); // Remove first 9 characters from the string.
  1622. new portal_id;
  1623. if (sscanf(params, "i", portal_id)){
  1624. return SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Usage: /property portal entrance <Portal ID>");
  1625. }
  1626. // Get portal record
  1627. new portal_query[212 + MAX_SQL_INTEGER + 1];
  1628. format(portal_query, sizeof(portal_query), "SELECT object, pos_x, pos_y, pos_z, world, pickup_id, exit_pos_x, exit_pos_y, exit_pos_x, exit_world, exit_interior FROM portal WHERE id = %i", portal_id);
  1629. new Result:portal_result = sql_query(sqlHandle, portal_query);
  1630. new object = sql_get_field_assoc_int(portal_result, "object");
  1631. //new Float:x = sql_get_field_assoc_float(portal_result, "pos_x");
  1632. //new Float:y = sql_get_field_assoc_float(portal_result, "pos_y");
  1633. //new Float:z = sql_get_field_assoc_float(portal_result, "pos_z"); todo shorten qeury
  1634. new world = sql_get_field_assoc_int(portal_result, "world");
  1635. new pickup_id = sql_get_field_assoc_int(portal_result, "pickup_id");
  1636. new Float:pos_x = sql_get_field_assoc_float(portal_result, "exit_pos_x");
  1637. new Float:pos_y = sql_get_field_assoc_float(portal_result, "exit_pos_y");
  1638. new Float:pos_z = sql_get_field_assoc_float(portal_result, "exit_pos_z");
  1639. new world_id = sql_get_field_assoc_int(portal_result, "exit_world");
  1640. new interior_id = sql_get_field_assoc_int(portal_result, "exit_interior");
  1641. if(sql_num_rows(portal_result) < 1){ // Invalid portal ID
  1642. return SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Invalid portal ID");
  1643. }
  1644. // World
  1645. if(world_id != -1){ // Not an all-world portal
  1646. world = GetPlayerVirtualWorld(playerid);
  1647. }
  1648. else{
  1649. world = world_id;
  1650. }
  1651. // Location
  1652. new Float:x, Float:y, Float:z;
  1653. GetPlayerPos(playerid, x, y, z);
  1654. new interior = GetPlayerInterior(playerid);
  1655. destroyPortal(pickup_id); // Despawn old pickups and remove GVars
  1656. new pickupid = createDynamicPickup(object, x, y, z, world, interior, PICKUP_PORTAL);
  1657. SetGVarFloat("pickup_x", pos_x, pickupid);
  1658. SetGVarFloat("pickup_y", pos_y, pickupid);
  1659. SetGVarFloat("pickup_z", pos_z, pickupid);
  1660. SetGVarInt("pickup_world", world_id, pickupid);
  1661. SetGVarInt("pickup_interior", interior_id, pickupid);
  1662. // Inform admins and Discord
  1663. new admin_message[65 + 4 + MAX_PLAYER_NAME + MAX_SQL_INTEGER + 1];
  1664. format(admin_message, sizeof(admin_message), "* [%i] %s modified the entrance location of portal: %i", playerid, getPlayerName(playerid), portal_id);
  1665. sendToAdmins(COLOR_NOTICE, admin_message);
  1666. DiscordEcho(admin_message, ADMIN_ECHO_CHANNEL);
  1667. }
  1668. else{ // Invalid value
  1669. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "/property portal options: create, exit, entrance, object, delete");
  1670. }
  1671. }
  1672. else{ // Invalid option
  1673. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "/property options: portal");
  1674. }
  1675. return 1;
  1676. }
  1677. // Dialog functions
  1678. forward dialogGotoInterior(playerid);
  1679. public dialogGotoInterior(playerid){
  1680. ShowPlayerDialog(playerid, DIALOG_GOTO_INTERIOR, DIALOG_STYLE_LIST, "Categories", "24/7's\nAvaition\nAmmunation's\nBurglary houses\nMissions\nMission exteriors\nMission houses\nModding shops\nPolice departments\nSafe houses\nShops & casino's\nStadia", "Select", "Back");
  1681. }
  1682. // a_samp events
  1683. public OnGameModeInit(){
  1684. new message[36 + 22 + 1];
  1685. format(message, sizeof(message), "* Global game-mode initialization: v%s", MODE_NAME);
  1686. logger(LOGLEVEL_NOTICE, "* Global game-mode initialization."); // Log event.
  1687. // Player radar blip markers only visible to nearby players.
  1688. ShowPlayerMarkers(PLAYER_MARKERS_MODE_STREAMED);
  1689. LimitPlayerMarkerRadius(15);
  1690. // Set mode name
  1691. SetGameModeText(MODE_NAME);
  1692. // SQL log level
  1693. if(scriptDebug){
  1694. sql_debug(LOG_ALL, LOG_ALL); // Log everything everywhere.
  1695. }
  1696. else{
  1697. sql_debug(LOG_INFO, LOG_WARNING); // Loglevel info for file and worning for console.
  1698. }
  1699. // Connect to database
  1700. sqlHandle = SQL:sql_connect(SQL_HANDLER_POSTGRESQL, PG_HOST, PG_ROLE, PG_PASS, PG_DB, PG_PORT);
  1701. printf("sqlconnection = %d", _:sqlHandle);
  1702. if(!sql_ping(sqlHandle)){
  1703. print( " + Database connection" );
  1704. }
  1705. else{
  1706. print( "Database connection failed" );
  1707. }
  1708. // Initialize Discord
  1709. //homeGuild = DCC_GetGuildId(DISCORD_HOME_GUILD_ID); // Set home guild ID. NOT NEEDED FOR NOW AND BROKEN
  1710. echoChannel = DCC_FindChannelById(DISCORD_ECHO_CHANNEL_ID); // Set main echo channel ID.
  1711. mainChannel = DCC_FindChannelById(DISCORD_MAIN_CHANNEL_ID); // Set main notification channel ID.
  1712. adminEchoChannel = DCC_FindChannelById(DISCORD_ADMIN_ECHO_CHANNEL_ID); // Set admin echo channel ID.
  1713. adminChannel = DCC_FindChannelById(DISCORD_ADMIN_CHANNEL_ID); // Set admin notification channel ID.
  1714. managementChannel = DCC_FindChannelById(DISCORD_MANAGEMENT_CHANNEL_ID); // Set management notification channel ID.
  1715. DiscordEcho(message, ECHO_CHANNEL); // Notify Discord
  1716. //DiscordEcho(message, MAIN_CHANNEL); // TODO Enable after we are stable
  1717. // Portals
  1718. new Result:portal_result = sql_query(sqlHandle, "SELECT id, object, pos_x, pos_y, pos_z, world, interior_id, exit_object, exit_pos_x, exit_pos_y, exit_pos_z, exit_world, exit_interior_id FROM portal");
  1719. for(new i = 0; i < sql_num_rows(portal_result); i++){
  1720. new id = sql_get_field_assoc_int(portal_result, "id");
  1721. new object = sql_get_field_assoc_int(portal_result, "object");
  1722. new Float:pos_x = sql_get_field_assoc_float(portal_result, "pos_x");
  1723. new Float:pos_y = sql_get_field_assoc_float(portal_result, "pos_y");
  1724. new Float:pos_z = sql_get_field_assoc_float(portal_result, "pos_z");
  1725. new world = sql_get_field_assoc_int(portal_result, "world");
  1726. new interior = sql_get_field_assoc_int(portal_result, "interior_id");
  1727. new exit_object = sql_get_field_assoc_int(portal_result, "exit_object");
  1728. new Float:exit_pos_x = sql_get_field_assoc_float(portal_result, "exit_pos_x");
  1729. new Float:exit_pos_y = sql_get_field_assoc_float(portal_result, "exit_pos_y");
  1730. new Float:exit_pos_z = sql_get_field_assoc_float(portal_result, "exit_pos_z");
  1731. new exit_world = sql_get_field_assoc_int(portal_result, "exit_world");
  1732. new exit_interior = sql_get_field_assoc_int(portal_result, "exit_interior_id");
  1733. spawnPortal(id, object, pos_x, pos_y, pos_z, world, interior, exit_object, exit_pos_x, exit_pos_y, exit_pos_z, exit_world, exit_interior);
  1734. }
  1735. // Pickups
  1736. new Result:pickup_result = sql_query(sqlHandle, "SELECT id, object_id, pos_x, pos_y, pos_z, world_id, interior_id, type_id FROM pickup");
  1737. for(new i = 0; i < sql_num_rows(pickup_result); i++){
  1738. new id = sql_get_field_assoc_int(portal_result, "id");
  1739. new object_id = sql_get_field_assoc_int(portal_result, "object_id");
  1740. new Float:pos_x = sql_get_field_assoc_float(portal_result, "pos_x");
  1741. new Float:pos_y = sql_get_field_assoc_float(portal_result, "pos_y");
  1742. new Float:pos_z = sql_get_field_assoc_float(portal_result, "pos_z");
  1743. new world_id = sql_get_field_assoc_int(portal_result, "world_id");
  1744. new interior_id = sql_get_field_assoc_int(portal_result, "interior_id");
  1745. new type_id = sql_get_field_assoc_int(portal_result, "type_id");
  1746. new pickupid = createDynamicPickup(object_id, pos_x, pos_y, pos_z, world_id, interior_id, type_id);
  1747. // Update pickup record
  1748. new pickup_query[44 + MAX_SQL_INTEGER + MAX_SQL_INTEGER + 1];
  1749. format(pickup_query, sizeof(pickup_query), "UPDATE pickup SET pickup_id = %i WHERE id = %i", pickupid, id);
  1750. sql_query(sqlHandle, pickup_query);
  1751. }
  1752. // Hobo's with a cane (0 ammo value makes them lose the cane as soon as they switch weapon)
  1753. // Only homeless skins, as players should slowly class up in society.
  1754. AddPlayerClass(134, -184.7607, 950.5010, 16.7740, 358.3032, 15, 0, 0, 0, 0, false); // Fort Carson West boulevard right curb.
  1755. AddPlayerClass(10, -184.7607, 950.5010, 16.7740, 358.3032, 15, 0, 0, 0, 0, false); // Fort Carson West boulevard right curb.
  1756. AddPlayerClass(78, 111.0115, 1189.2029, 18.1627, 89.0095, 15, 0, 0, 0, 0, false); // Fort Carson South boulevard left curb.
  1757. AddPlayerClass(129, 111.0115, 1189.2029, 18.1627, 89.0095, 15, 0, 0, 0, 0, false); // Fort Carson South boulevard left curb.
  1758. AddPlayerClass(162, -109.4227, 1242.4860, 16.8223, 183.5798, 15, 0, 0, 0, 0, false); // Fort Carson East boulevard left curb.
  1759. AddPlayerClass(77, -109.4227, 1242.4860, 16.8223, 183.5798, 15, 0, 0, 0, 0, false); // Fort Carson East boulevard left curb.
  1760. AddPlayerClass(79, -201.5379, 948.1683, 15.9131, 359.9720, 15, 0, 0, 0, 0, false); // Fort Carson West boulevard left curb.
  1761. AddPlayerClass(196, -201.5379, 948.1683, 15.9131, 359.9720, 15, 0, 0, 0, 0, false); // Fort Carson West boulevard left curb.
  1762. AddPlayerClass(239, 62.4694, 1205.0531, 18.8153, 89.9380, 15, 0, 0, 0, 0, false); // Fort Carson South boulevard right curb.
  1763. AddPlayerClass(89, 62.4694, 1205.0531, 18.8153, 89.9380, 15, 0, 0, 0, 0, false); // Fort Carson South boulevard right curb.
  1764. AddPlayerClass(135, -126.0831, 1242.5745, 18.6138, 183.2986, 15, 0, 0, 0, 0, false); // Fort Carson East boulevard right curb.
  1765. AddPlayerClass(197, -126.0831, 1242.5745, 18.6138, 183.2986, 15, 0, 0, 0, 0, false); // Fort Carson East boulevard right curb.
  1766. return 1;
  1767. }
  1768. public OnGameModeExit(){
  1769. // Cycle every player
  1770. for(new playerid, a = GetMaxPlayers(); playerid < a; playerid++){
  1771. if(IsPlayerConnected(playerid))
  1772. {
  1773. // Set name back to username
  1774. new client_connect_username[MAX_PLAYER_NAME + 1];
  1775. GetGVarString("client_connect_username", client_connect_username, sizeof(client_connect_username), playerid);
  1776. SetPlayerName(playerid, client_connect_username); // Change name in-game back to username, for login after restart PROBLEM: Crashses the server on GMX.
  1777. //deleteAllGVars(playerid); // Delete GVars as per https://forum.sa-mp.com/showthread.php?t=151076
  1778. // TODO think of somthing for the usernames, kickign every player, or accapting character names as usersnames.
  1779. }
  1780. }
  1781. logger(LOGLEVEL_NOTICE, "* Global game-mode termination."); // Log event
  1782. sql_wait(sqlHandle); // Wait for queries to finish.
  1783. sql_disconnect(sqlHandle); // Disconnect from database.
  1784. DiscordEcho("* Global game-mode termination.", ECHO_CHANNEL); // Notify discord
  1785. //DiscordEcho("* Global game-mode termination.", MAIN_CHANNEL); // Enable when stable
  1786. return 1;
  1787. }
  1788. public OnPlayerRequestClass(playerid, classid){ // Skin selection before spawn.
  1789. if(scriptDebug){
  1790. new message[23 + 4 + MAX_PLAYER_NAME + 1];
  1791. format(message, sizeof(message), "* [%i] %s Class selection.", playerid, getCharacterName(playerid));
  1792. logger(LOGLEVEL_DEBUG, message); // Log event.
  1793. }
  1794. SetPlayerPos(playerid, -185.5514, 944.2042, 15.9337); // In front of Fort Carson city limits sign.
  1795. SetPlayerFacingAngle(playerid, 182.7345); // Charater looks toward the camera.
  1796. SetPlayerCameraPos(playerid, -185.5514, 939.0957, 15.6594); // Further in front of the Fort Carson city limits sign.
  1797. SetPlayerCameraLookAt(playerid, -185.5514, 944.2042, 15.9337); // In front of Fort Carson city limits sign.
  1798. return 1; // Must return one, or skin selection breaks
  1799. }
  1800. public OnPlayerConnect(playerid){
  1801. SetPlayerColor(playerid, COLOR_BLACK);
  1802. // Create & populate variables
  1803. new playername[MAX_PLAYER_NAME + 1], playerip[MAX_SQL_IP + 1];
  1804. playername = getPlayerName(playerid);
  1805. GetPlayerIp(playerid, playerip, sizeof(playerip));
  1806. // Global connection notification
  1807. new admin_message[23 + MAX_PLAYER_NAME + MAX_SQL_IP + 1];
  1808. format(admin_message, sizeof(admin_message), "* [%d] %s (IP: %s) connected.", playerid, getCharacterName(playerid), playerip);
  1809. logger(LOGLEVEL_INFO, admin_message); // Log event
  1810. sendToAdmins(COLOR_NOTICE, admin_message); // Notify all admins.
  1811. DiscordEcho(admin_message, ADMIN_ECHO_CHANNEL); // Notify Discord admin echo.
  1812. // Create IP record or update connection attempts
  1813. new ip_query[109 + MAX_SQL_IP + 1];
  1814. format(ip_query, sizeof(ip_query), "INSERT INTO ip(address) VALUES('%s') ON CONFLICT (address) DO UPDATE SET connections = ip.connections+1", playerip);
  1815. sql_query(sqlHandle, ip_query);
  1816. // Check if IP is banned
  1817. new ip_id = getIPID(playerid);
  1818. new ban_query[75 + MAX_SQL_INTEGER + 1];
  1819. format(ban_query, sizeof(ban_query), "SELECT id, reason FROM ip_ban WHERE ip_id = %i AND expires > NOW()::timestamp", ip_id);
  1820. new Result:ban_result = sql_query(sqlHandle, ban_query);
  1821. if(sql_num_rows(ban_result) > 0){ // Banned
  1822. new kick_message[8 + MAX_SQL_REASON + 1];
  1823. format(kick_message, sizeof(kick_message), "Banned: %s", sql_get_field_assoc_int(ban_result, "reason"));
  1824. kickPlayer(playerid, -1, kick_message, 1);
  1825. }
  1826. // Get user record
  1827. new escaped_username[MAX_PLAYER_NAME + 1], user_query[47 + MAX_PLAYER_NAME + 1]; // Should be longer to allow for escaped characters
  1828. sql_escape_string(sqlHandle, playername, escaped_username, sizeof(escaped_username)); // Escape player name
  1829. format(user_query, sizeof(user_query), "SELECT id FROM \"user\" WHERE name = '%s'", escaped_username);
  1830. //new Result:result = sqlQuery(sqlHandle, user_query); // Middleware broken.
  1831. new Result:result = sql_query(sqlHandle, user_query);
  1832. SetGVarString("client_connect_username", playername, playerid); // Used by register, DIALOG_LOGIN, getUserID & OnGameModeExit
  1833. if(sql_num_rows(result) == 0){ // Unkown user
  1834. SetGVarInt("userlevel", UNREGISTERED_PLAYER, playerid); // Set userlevel unregistered
  1835. changeName(playerid, playername); // Check, force and set role-play name
  1836. }
  1837. else{ // Known user
  1838. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Sign in", "Enter your password to log on", "Log in", "Cancel"); // Show password confirmation dialog
  1839. }
  1840. //return 1;
  1841. }
  1842. public OnPlayerDisconnect(playerid, reason){
  1843. if(GetPlayerState(playerid) != PLAYER_STATE_NONE){ // Only save character if spawned
  1844. savePlayerState(playerid); // Save character
  1845. }
  1846. deleteAllGVars(playerid); // Delete GVars as per https://forum.sa-mp.com/showthread.php?t=151076
  1847. new playername[MAX_PLAYER_NAME + 1], message[40 + 4 + MAX_PLAYER_NAME + 1];
  1848. playername = getPlayerName(playerid);
  1849. switch(reason){
  1850. case 0: format(message, sizeof(message), "* [%i] %s disconnected. (Lost Connection)", playerid, getCharacterName(playerid));
  1851. case 1: format(message, sizeof(message), "* [%i] %s disconnected. (Leaving)", playerid, getCharacterName(playerid));
  1852. case 2: format(message, sizeof(message), "* [%i] %s disconnected. (Kicked)", playerid, getCharacterName(playerid)); // Leave this in place for RCON kicks.
  1853. }
  1854. logger(LOGLEVEL_INFO, message); // Log event
  1855. SendClientMessageToAll(COLOR_NOTICE, message); // Notify all players.
  1856. DiscordEcho(message, ECHO_CHANNEL); // Notify discord.
  1857. return 1;
  1858. }
  1859. public OnPlayerSpawn(playerid){
  1860. if(scriptDebug){ // Log event in case of debugging.
  1861. new message[MAX_PLAYER_NAME + 14 + 1];
  1862. format(message, sizeof(message), "* [%i] %s spawned.", playerid, getCharacterName(playerid));
  1863. logger(LOGLEVEL_DEBUG, message); // Log event.
  1864. }
  1865. if(GetGVarInt("userlevel", playerid) == UNREGISTERED_PLAYER){ // Unregistered player.
  1866. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "SERVER: To reserve your name, save your character, statistics and money, type: /register");
  1867. }
  1868. return 1;
  1869. }
  1870. public OnPlayerDeath(playerid, killerid, reason){
  1871. new message[15 + MAX_PLAYER_NAME + 1];
  1872. format(message, sizeof(message), "* [%d] %s died.", playerid, getCharacterName(playerid)); // TODO Add killerid & reason.
  1873. logger(LOGLEVEL_DEBUG, message); // Log event
  1874. DiscordEcho(message, ADMIN_ECHO_CHANNEL); // Notify Discord admin echo.
  1875. //ResetPlayerMoney(playerid); TODO test if required
  1876. //SpawnPlayer(playerid);
  1877. return 1;
  1878. }
  1879. public OnVehicleSpawn(vehicleid) // TODO for 0.0a
  1880. {
  1881. return 1;
  1882. }
  1883. public OnVehicleDeath(vehicleid, killerid) // TODO for 0.0a
  1884. {
  1885. return 1;
  1886. }
  1887. public OnPlayerText(playerid, text[]){
  1888. new shortcut_message[128 + 1];
  1889. strfromliteral(shortcut_message, text);
  1890. strdel(shortcut_message, 0, 1); // Remove chat character from text
  1891. switch(strgetfirstc(text)){
  1892. case '`': {
  1893. if(GetGVarInt("chatmode", playerid) == CHAT_LOCAL){
  1894. sendToChat(playerid, CHAT_GLOBAL, shortcut_message, 0);
  1895. }
  1896. else if (GetGVarInt("chatmode", playerid) == CHAT_GLOBAL){
  1897. sendToChat(playerid, CHAT_LOCAL, shortcut_message, 0);
  1898. }
  1899. else{
  1900. sendToChat(playerid, CHAT_GLOBAL, shortcut_message, 0);
  1901. }
  1902. }
  1903. case '~': {sendToChat(playerid, CHAT_GANG, shortcut_message, 0);}
  1904. case '!': {sendToChat(playerid, CHAT_FACTION, shortcut_message, 0);}
  1905. case '@': {sendToChat(playerid, CHAT_CREW, shortcut_message, 0);}
  1906. case '#': {sendToChat(playerid, CHAT_ADMIN, shortcut_message, 0);}
  1907. case '$': {sendToChat(playerid, CHAT_GANG_OC, shortcut_message, 0);}
  1908. case '%': {sendToChat(playerid, CHAT_FACTION_OC, shortcut_message, 0);}
  1909. case '^': {sendToChat(playerid, CHAT_MANAGEMENT, shortcut_message, 0);}
  1910. //case '$': {sendToChat(playerid, CHAT_MANAGEMENT, shortcut_message[]);}
  1911. case '&': {sendToChat(playerid, CHAT_VIP, shortcut_message, 0);}
  1912. case '*': {sendToChat(playerid, CHAT_UNDERCOVER, shortcut_message, 0);}
  1913. case '+': {sendToChat(playerid, CHAT_CALL, shortcut_message, 0);}
  1914. case '-': {sendToChat(playerid, CHAT_SMS, shortcut_message, 0);}
  1915. case '=': {sendToChat(playerid, CHAT_RADIO, shortcut_message, 0);}
  1916. case '>': {
  1917. new recipient_id, message[125 + 1];
  1918. if (sscanf(shortcut_message, "u s", recipient_id, message)){
  1919. SendClientMessage(playerid, COLOR_COMMAND_OUTPUT, "Usage: > <playerid> <message>");
  1920. }
  1921. else{
  1922. sendPM(playerid, message, recipient_id);
  1923. }
  1924. }
  1925. default:{
  1926. new chatmode = GetGVarInt("chatmode", playerid);
  1927. if(!chatmode){ // Default is local chat
  1928. sendToChat(playerid, CHAT_LOCAL, text, 0);
  1929. }
  1930. else{ // Send to preferred chat
  1931. printf("chatmode: %i", chatmode);
  1932. sendToChat(playerid, chatmode, text, 0);
  1933. }
  1934. }
  1935. }
  1936. return 0; // Return 1 for default behavior, return 0 to disable default output.
  1937. }
  1938. public OnPlayerCommandText(playerid, cmdtext[]){
  1939. if(scriptDebug){ // Log event in case of debugging.
  1940. new message[5 + 4 + MAX_PLAYER_NAME + 128 + 1]; // 128 = samp text input limit.
  1941. format(message, sizeof(message), "[%d] %s: %s", playerid, getCharacterName(playerid), cmdtext);
  1942. logger(LOGLEVEL_COMMAND, message); // Log event
  1943. }
  1944. return 0;
  1945. }
  1946. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) // TODO for 0.0a
  1947. {
  1948. return 1;
  1949. }
  1950. public OnPlayerExitVehicle(playerid, vehicleid) // TODO for 0.0a
  1951. {
  1952. return 1;
  1953. }
  1954. public OnPlayerStateChange(playerid, newstate, oldstate) // TODO for 0.0a
  1955. {
  1956. return 1;
  1957. }
  1958. public OnPlayerEnterCheckpoint(playerid) // TODO for 0.0a
  1959. {
  1960. return 1;
  1961. }
  1962. public OnPlayerLeaveCheckpoint(playerid) // TODO for 0.0a
  1963. {
  1964. return 1;
  1965. }
  1966. public OnPlayerEnterRaceCheckpoint(playerid) // TODO for 0.0a
  1967. {
  1968. return 1;
  1969. }
  1970. public OnPlayerLeaveRaceCheckpoint(playerid) // TODO for 0.0a
  1971. {
  1972. return 1;
  1973. }
  1974. public OnRconCommand(cmd[]){ // The website and some cronjobs do RCON commands. TODO create filter not to show some commands to preven spam
  1975. new message[8 + 128 + 1]; // Max samp message legnth = 128.
  1976. format(message, sizeof(message), "* RCON: %s", cmd);
  1977. logger(LOGLEVEL_NOTICE, message); // Log event
  1978. DiscordEcho(message, MANAGEMENT_CHANNEL);
  1979. return 1;
  1980. }
  1981. public OnPlayerRequestSpawn(playerid){ // After picking a skin in class selection.
  1982. SetPlayerColor(playerid, COLOR_WHITE);
  1983. new playername[MAX_PLAYER_NAME + 1], message[14 + MAX_PLAYER_NAME + 1];
  1984. playername = getPlayerName(playerid);
  1985. if(scriptDebug){ // Only log spawns when debuggins script.
  1986. format(message, sizeof(message), "* [%d] %s Chose a character.", playerid, getCharacterName(playerid));
  1987. logger(LOGLEVEL_DEBUG, message); // Log event
  1988. }
  1989. if(GetGVarInt("userlevel", playerid) > UNREGISTERED_PLAYER){ // Registered player
  1990. createCharacterRecord(playerid, getUserID(playerid)); // Save character
  1991. new client_connect_username[MAX_PLAYER_NAME + 1], admin_message[25 + 4 + MAX_PLAYER_NAME + MAX_PLAYER_NAME + 1];
  1992. GetGVarString("client_connect_username", client_connect_username, sizeof(client_connect_username), playerid); // Get client connect name
  1993. format(admin_message, sizeof(admin_message), "[%i] %s has been created by %s.", playerid, getCharacterName(playerid), client_connect_username);
  1994. DiscordEcho(admin_message, ADMIN_ECHO_CHANNEL);
  1995. }
  1996. return 1;
  1997. }
  1998. public OnObjectMoved(objectid) // TODO for 0.0a
  1999. {
  2000. return 1;
  2001. }
  2002. public OnPlayerObjectMoved(playerid, objectid) // TODO for 0.0a
  2003. {
  2004. return 1;
  2005. }
  2006. //public OnPlayerPickUpPickup(playerid, pickupid){} // Replaced byOnPlayerPickUpDynamicPickup() streamer.inc
  2007. public OnPlayerPickUpDynamicPickup(playerid, pickupid){ // Requires streamer
  2008. new type = GetGVarInt("pickup_type", pickupid);
  2009. switch(type){
  2010. case PICKUP_PORTAL: {
  2011. // Do nothing if the player just used a pickup
  2012. if(GetGVarInt("disable_pickups", playerid)){
  2013. return 0;
  2014. }
  2015. new Float:x = GetGVarFloat("pickup_x", pickupid);
  2016. new Float:y = GetGVarFloat("pickup_y", pickupid);
  2017. new Float:z = GetGVarFloat("pickup_z", pickupid);
  2018. new world = GetGVarInt("pickup_world", pickupid);
  2019. new interior = GetGVarInt("pickup_interior", pickupid);
  2020. // Don't releport when the exit is not set
  2021. if(x == 0 && y == 0 && z == 0){
  2022. return 0;
  2023. }
  2024. // Create dynamic area and temporarily disable pickups for player
  2025. new area = CreateDynamicCircle(x, y, 1, world, -1, playerid);
  2026. SetGVarInt("disable_pickups", area, playerid);
  2027. // Teleport player
  2028. SetPlayerPos(playerid, x, y, z);
  2029. SetPlayerVirtualWorld(playerid, world);
  2030. SetPlayerInterior(playerid, interior);
  2031. }
  2032. case PICKUP_FACTION_PD: {
  2033. // Do nothing if the player just used a pickup
  2034. if(GetGVarInt("disable_pickups", playerid)){
  2035. return 0;
  2036. }
  2037. // Create dynamic area and temporarily disable pickups for player
  2038. new Float:x, Float:y, Float:z;
  2039. GetPlayerPos(playerid, x, y, z);
  2040. new area = CreateDynamicCircle(x, y, 1, GetPlayerVirtualWorld(playerid), -1, playerid);
  2041. SetGVarInt("disable_pickups", area, playerid);
  2042. ShowPlayerDialog(playerid, DIALOG_DUTY_PD, DIALOG_STYLE_MSGBOX, "Active police duty", "Go on police duty as a rookie cop?", "Yes", "Cancel");
  2043. }
  2044. }
  2045. return 1;
  2046. }
  2047. public OnPlayerLeaveDynamicArea(playerid, areaid){ // Requires streamer
  2048. // Reactivate pickup after player leaves it
  2049. new area = GetGVarInt("disable_pickups", playerid);
  2050. if(area == 0 && areaid != 0){ // Stop if player had not had this area disabled (With the exception of areaid 0 as GetVarInt() returns 0 on null)
  2051. return;
  2052. }
  2053. else if(area == 0){ // Player has not had picks disabled
  2054. return;
  2055. }
  2056. if(area == areaid){ // Player had this pickup disabled
  2057. DestroyDynamicArea(GetGVarInt("disable_pickups", playerid));
  2058. DeleteGVar("disable_pickups", playerid);
  2059. }
  2060. }
  2061. public OnVehicleMod(playerid, vehicleid, componentid) // TODO for 0.0a
  2062. {
  2063. return 1;
  2064. }
  2065. public OnVehiclePaintjob(playerid, vehicleid, paintjobid) // TODO for 0.0a
  2066. {
  2067. return 1;
  2068. }
  2069. public OnVehicleRespray(playerid, vehicleid, color1, color2) // TODO for 0.0a
  2070. {
  2071. return 1;
  2072. }
  2073. public OnPlayerSelectedMenuRow(playerid, row) // TODO for 0.0a
  2074. {
  2075. return 1;
  2076. }
  2077. public OnPlayerExitedMenu(playerid) // TODO for 0.0a
  2078. {
  2079. return 1;
  2080. }
  2081. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid) // TODO for 0.0a
  2082. {
  2083. return 1;
  2084. }
  2085. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) // TODO for 0.0a
  2086. {
  2087. return 1;
  2088. }
  2089. public OnRconLoginAttempt(ip[], password[], success){
  2090. new message[30 + MAX_SQL_IP + 1];
  2091. if(success){
  2092. format(message, sizeof(message), "* [%s] authenticated via RCON.", ip);
  2093. }
  2094. else{
  2095. format(message, sizeof(message), "* [%s] invalid RCON authentication.", ip);
  2096. }
  2097. logger(LOGLEVEL_NOTICE, message); // Log event
  2098. DiscordEcho(message, MANAGEMENT_CHANNEL); // Notify Discord management.
  2099. return 1;
  2100. }
  2101. public OnPlayerUpdate(playerid) // Don't use for now.
  2102. {
  2103. return 1;
  2104. }
  2105. public OnPlayerStreamIn(playerid, forplayerid){
  2106. return 1;
  2107. }
  2108. public OnPlayerStreamOut(playerid, forplayerid) // TODO for 0.0a
  2109. {
  2110. return 1;
  2111. }
  2112. public OnVehicleStreamIn(vehicleid, forplayerid) // TODO for 0.0a
  2113. {
  2114. return 1;
  2115. }
  2116. public OnVehicleStreamOut(vehicleid, forplayerid) // TODO for 0.0a
  2117. {
  2118. return 1;
  2119. }
  2120. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
  2121. switch(dialogid){
  2122. case DIALOG_CHANGENAME:{
  2123. if(GetGVarInt("userlevel", playerid) > UNREGISTERED_PLAYER){ // Registered player
  2124. if(!response){ // User aborted
  2125. return 0; // Allow escaping dialogm without forcing to continue
  2126. }
  2127. }
  2128. changeName(playerid, inputtext); // Forced name check and change
  2129. }
  2130. case DIALOG_REGISTER:{
  2131. if(response){ // If they clicked 'Yes' or pressed enter
  2132. // Check password complexity
  2133. new Regex:r = Regex_New("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[0-9!@#\\$%\\^&\\*\\(\\)\\-\\_=+[{\\]}\\\\|;:'\",<.>\\/?]).{8,}$"); // Regex password filter
  2134. new isSecurePassword = Regex_Check(inputtext, r); // Validate name to filter
  2135. Regex_Delete(r);
  2136. if(!isSecurePassword){ // Insecure password
  2137. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Insecure password", "Enter a secure password, containg at least:\n\n * A lowercase letter (a-z)\n * A capiral letter (A-Z)\n * A number (0-9).\n * A character that is not a letter (0-9!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?).\n * 8 characters.", "Register", "Cancel"); // Show password requirements.
  2138. }
  2139. else { // Secure password
  2140. // Hash password
  2141. new buffer[MAX_SQL_HASH + 1], hash[MAX_SQL_HASH + 1];
  2142. WP_Hash(buffer, sizeof(buffer), inputtext);
  2143. GetGVarString("hash", hash, sizeof(hash), playerid);
  2144. if(isempty(hash)){ // First password dialog
  2145. SetGVarString("hash", buffer, playerid); // Save password has a GVar
  2146. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Password confirmation", "Repeat your password to confirm.", "Register", "Cancel"); // Show password confirmation dialog
  2147. }
  2148. else{ // Password confirmation
  2149. if(!isequal(hash, buffer)){ // Password does not match confirmation
  2150. DeleteGVar("hash", playerid);
  2151. SendClientMessage(playerid, COLOR_RED, "ERROR: Password does not match password confirmation.");
  2152. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Password", "Enter the same password twice.", "Continue", "Cancel"); // Password prompt
  2153. }
  2154. else{ // Password matches confirmation
  2155. DeleteGVar("hash", playerid);
  2156. new client_connect_username[MAX_PLAYER_NAME + 1], playerIP[MAX_SQL_IP + 1], escaped_username[MAX_PLAYER_NAME + 1];
  2157. GetGVarString("client_connect_username", client_connect_username, sizeof(client_connect_username), playerid);
  2158. GetPlayerIp(playerid, playerIP, sizeof(playerIP));
  2159. sql_escape_string(sqlHandle, client_connect_username, escaped_username, sizeof(escaped_username));
  2160. // Create user record
  2161. new user_query[61 + MAX_PLAYER_NAME + MAX_SQL_HASH + 1 + MAX_SQL_IP + 1];
  2162. format(user_query, sizeof(user_query), "INSERT INTO \"user\"(name, password) VALUES('%s', '%s')", escaped_username, hash);
  2163. /*new Result:user_result = sql_query(sqlHandle, user_query);
  2164. //new id = sql_insert_id(user_result); // Broken, always returns 0.
  2165. // sql_insert_id workaround*/
  2166. sql_query(sqlHandle, user_query);
  2167. new id = getUserID(playerid); // Get ID user user record
  2168. SetGVarInt("userlevel", REGISTERED_PLAYER, playerid);
  2169. // Create user_ip relation table record
  2170. new user_ip_query[50 + MAX_SQL_INTEGER + MAX_SQL_INTEGER + 1 ];
  2171. format(user_ip_query, sizeof(user_ip_query), "INSERT INTO user_ip(id, id) VALUES(%i, %i)", getIPID(playerid), id);
  2172. sql_query(sqlHandle, user_ip_query);
  2173. createCharacterRecord(playerid, id); // Save character
  2174. // Inform user
  2175. new dialogMessage[135 + MAX_PLAYER_NAME + 1], message[31 + MAX_PLAYER_NAME + 1];
  2176. format(dialogMessage, sizeof(dialogMessage), "To login as any of your characters, connect as: \nRemember your username carefully, as you have to use it to connect with SA-MP client!", client_connect_username);
  2177. ShowPlayerDialog(playerid, DIALOG_ACCOUNT_CREATED, DIALOG_STYLE_MSGBOX, "Account created", dialogMessage, "Play", "");
  2178. format(message, sizeof(message), "SERVER: Remember your username, %s!", client_connect_username);
  2179. SendClientMessage(playerid, COLOR_WARNING_MESSAGE, message);
  2180. // send discord admin echo
  2181. new admin_message[30 + 4 + MAX_PLAYER_NAME + 1];
  2182. format(admin_message, sizeof(admin_message), "[%i] %s has registered an account.", playerid, client_connect_username);
  2183. DiscordEcho(admin_message, ADMIN_ECHO_CHANNEL);
  2184. }
  2185. }
  2186. }
  2187. }
  2188. else{ // Pressed ESC or clicked cancel
  2189. DeleteGVar("hash", playerid);
  2190. }
  2191. }
  2192. case DIALOG_LOGIN:{
  2193. if(response){ // If they clicked 'Yes' or pressed enter
  2194. // Escape username
  2195. new client_connect_username[MAX_PLAYER_NAME + 1], escaped_username[MAX_PLAYER_NAME + 1];
  2196. GetGVarString("client_connect_username", client_connect_username, sizeof(client_connect_username), playerid);
  2197. sql_escape_string(sqlHandle, client_connect_username, escaped_username, sizeof(escaped_username));
  2198. // Get account
  2199. new user_query[82 + MAX_PLAYER_NAME + 1], hash[MAX_SQL_HASH + 1];
  2200. format(user_query, sizeof(user_query), "SELECT id, password, level FROM \"user\" WHERE name = '%s'", escaped_username);
  2201. new Result:user_result = sql_query(sqlHandle, user_query);
  2202. sql_get_field_assoc_ex(user_result, 0, "password", hash, sizeof(hash));
  2203. // Compare hashes
  2204. new buffer[MAX_SQL_HASH + 1];
  2205. WP_Hash(buffer, sizeof(buffer), inputtext);
  2206. if (!isequal(buffer, hash)){ // Hashes don't match
  2207. // Brute-force protection
  2208. new authentication_count = GetGVarInt("authentication_count", playerid);
  2209. authentication_count++;
  2210. SetGVarInt("authentication_count", authentication_count, playerid);
  2211. ShowPlayerDialog(playerid, DIALOG_LOGIN_FAILED, DIALOG_STYLE_MSGBOX, "Authenticaion failed", "Invalid password.", "Wait", "");
  2212. switch(authentication_count){
  2213. case 0: SetTimerEx("authenticate", 3000, false, "i", playerid); // Return to authentication workflow in 3 second.
  2214. case 1: SetTimerEx("authenticate", 5000, false, "i", playerid); // Return to authentication workflow in 5 seconds.
  2215. case 2: SetTimerEx("authenticate", 7000, false, "i", playerid); // Return to authentication workflow in 7 seconds.
  2216. default: ShowPlayerDialog(playerid, DIALOG_CHANGE_USERNAME, DIALOG_STYLE_INPUT, "Username", "Pick an unregistered username.", "Change", ""); // After 4 failed authentication attempts
  2217. }
  2218. }
  2219. else{ // Hashes match
  2220. // Set userlevel (This has to be done before banning, else the user ban record won't save)
  2221. new userlevel = sql_get_field_assoc_int(user_result, "level");
  2222. printf("Setting userlevel: %i", userlevel);
  2223. SetGVarInt("userlevel", userlevel, playerid);
  2224. // Check bans
  2225. new ban_query[76 + MAX_SQL_INTEGER + 1];
  2226. format(ban_query, sizeof(ban_query), "SELECT user_id FROM user_ban WHERE user_id = %i AND expires > NOW()::timestamp", getUserID(playerid));
  2227. new Result:ban_result = sql_query(sqlHandle, ban_query);
  2228. if(sql_num_rows(ban_result) > 0){ // Banned
  2229. new reason[121 + 1];
  2230. format(reason, sizeof(reason), "Logged in with banned account: %i", sql_get_field_assoc_int(ban_result, "user_id"));
  2231. banPlayer(playerid, -1, reason, 10);
  2232. }
  2233. // Get character names
  2234. characterSelection(playerid);
  2235. }
  2236. }
  2237. else{ // Pressed ESC or clicked cancel
  2238. ShowPlayerDialog(playerid, DIALOG_CHANGE_USERNAME, DIALOG_STYLE_INPUT, "Username", "Pick an unregistered username.", "Change", "");
  2239. }
  2240. }
  2241. case DIALOG_CHANGE_USERNAME:{
  2242. if(response){ // If they clicked 'Yes' or pressed enter
  2243. new Regex:r = Regex_New("^[0-9a-zA-Z\\[\\]\\(\\)\\$@._=]{1,}$"); // Regex name filter
  2244. new isValidName = Regex_Check(inputtext, r);
  2245. Regex_Delete(r);
  2246. if(isValidName){ // Valid name
  2247. // Get user record
  2248. new escaped_username[MAX_PLAYER_NAME + 1], user_query[36 + MAX_PLAYER_NAME + 1];
  2249. sql_escape_string(sqlHandle, inputtext, escaped_username, sizeof(escaped_username)); // Escape player name
  2250. format(user_query, sizeof(user_query), "SELECT id FROM \"user\" WHERE name = '%s'", escaped_username);
  2251. //new Result:result = sqlQuery(sqlHandle, user_query); // Middleware broken.
  2252. new Result:result = sql_query(sqlHandle, user_query);
  2253. if(sql_num_rows(result) > 0){ // Username taken
  2254. ShowPlayerDialog(playerid, DIALOG_CHANGE_USERNAME, DIALOG_STYLE_INPUT, "Username", "Pick an unregistered username.", "Change", "");
  2255. }
  2256. else{ // Username free
  2257. SetGVarString("client_connect_username", inputtext, playerid); // Used by register and DIALOG_LOGIN
  2258. SetPlayerName(playerid, inputtext); // Change name in-game
  2259. return 1; // Do nothing to let player continue class selection
  2260. }
  2261. }
  2262. else{ // Invalid name
  2263. ShowPlayerDialog(playerid, DIALOG_CHANGE_USERNAME, DIALOG_STYLE_INPUT, "Username", "Invalid name. Names may only contain numbers (0-9), letters (a-z) & (A-Z) and special characters ([]()$@._=)", "Change", "");
  2264. }
  2265. }
  2266. else{ // Pick another username
  2267. ShowPlayerDialog(playerid, DIALOG_CHANGE_USERNAME, DIALOG_STYLE_INPUT, "Username", "Pick an unregistered username.", "Change", "");
  2268. }
  2269. }
  2270. case DIALOG_CHARACTERS:{
  2271. if(response){ // Spawn as character
  2272. new character_array_string[MAX_CHARACTERS_PER_USER * MAX_SQL_INTEGER + 1], character_array[MAX_CHARACTERS_PER_USER];
  2273. GetGVarString("character_array_string", character_array_string, sizeof(character_array_string), playerid);
  2274. DeleteGVar("character_array_string");
  2275. strtobin(character_array, character_array_string);
  2276. new character_query[100 + MAX_PLAYER_NAME + 1], name[24 + 1];
  2277. format(character_query, sizeof(character_query), "SELECT name, skin_id, cash, armour, health, pos_x, pos_y, pos_z, rotation FROM character WHERE id = %i", character_array[listitem]);
  2278. new Result:character_result = sql_query(sqlHandle, character_query);
  2279. sql_get_field_assoc(character_result, "name", name, sizeof(name));
  2280. new skin_id = sql_get_field_assoc_int(character_result, "skin_id");
  2281. new cash = sql_get_field_assoc_int(character_result, "cash");
  2282. new Float:armour = sql_get_field_assoc_int(character_result, "armour");
  2283. new Float:health = sql_get_field_assoc_int(character_result, "health");
  2284. new Float:pos_x = sql_get_field_assoc_int(character_result, "pos_x");
  2285. new Float:pos_y = sql_get_field_assoc_int(character_result, "pos_y");
  2286. new Float:pos_z = sql_get_field_assoc_int(character_result, "pos_z");
  2287. new Float:rotation = sql_get_field_assoc_int(character_result, "rotation");
  2288. // Temporary bug workaround TODO find cause
  2289. if(pos_x == 0 && pos_y == 0 && pos_z == 0){ // Sometimes this happens. Due to unreliable OnPlayerDisconnect() & OnGamemodeExit(), due to character creation, or due to (forgot the other possiblity, but had a strong hunch)?
  2290. pos_x = -144.0328;
  2291. pos_y = 1225.0564;
  2292. pos_z = 19.8992;
  2293. rotation = 175.5507;
  2294. }
  2295. SetSpawnInfo(playerid, 0, skin_id, pos_x, pos_y, pos_z, rotation, 0, 0, 0, 0, 0, 0);
  2296. //SetSpawnInfo(playerid, 0, skin_id, -144.0328, 1225.0564, 19.8992, 175.5507, 0, 0, 0, 0, 0, 0 );
  2297. SetPlayerName(playerid, name); // Change name in-game
  2298. SetPlayerColor(playerid, COLOR_WHITE);
  2299. SpawnPlayer(playerid);
  2300. ResetPlayerMoney(playerid);
  2301. GivePlayerMoney(playerid, cash);
  2302. SetPlayerHealth(playerid, health);
  2303. SetPlayerArmour(playerid, armour);
  2304. // Notify all players
  2305. new message[16 + 4 + MAX_PLAYER_NAME + 1];
  2306. format(message, sizeof(message), "* [%i] %s joined.", playerid, getCharacterName(playerid));
  2307. SendClientMessageToAll(COLOR_NOTICE, message); // Notify all players.
  2308. DiscordEcho(message, ECHO_CHANNEL); // Notify discord public echo
  2309. }
  2310. else{ // New character
  2311. // character cap
  2312. new id = getUserID(playerid);
  2313. new character_query[60 + MAX_SQL_INTEGER + 1];
  2314. format(character_query, sizeof(character_query), "SELECT id FROM character WHERE character_id = %i", id);
  2315. new Result:character_result = sql_query(sqlHandle, character_query);
  2316. printf("%i", sql_num_rows(character_result));
  2317. if(sql_num_rows(character_result) >= MAX_CHARACTERS_PER_USER){ // At or over character limit
  2318. SendClientMessage(playerid, COLOR_WARNING_MESSAGE, "SERVER: Maximum characters reached, can not create another.");
  2319. characterSelection(playerid);
  2320. }
  2321. else{
  2322. ShowPlayerDialog(playerid, DIALOG_CHANGENAME, DIALOG_STYLE_INPUT, "Character name", "Pick a name.\n\nExamples:\n Jo_Bo\n Dingle_P._J._Berry\n Jackson_DeForest_Kelley\n MaryJo_Ann_LaFluer", "Change", ""); // Force RP name.
  2323. // changeName(playerid, ""); // Pick name and save character ANNOYING this forces new character creation, no way out.
  2324. }
  2325. }
  2326. }
  2327. case DIALOG_LOGIN_FAILED:{
  2328. ShowPlayerDialog(playerid, DIALOG_LOGIN_FAILED, DIALOG_STYLE_MSGBOX, "Authenticaion failed", "Take some time to think about your password...", "Wait", "Longer");
  2329. }
  2330. case DIALOG_DELETE_CHARACTER:{
  2331. if(response){ // Delete character
  2332. new playername[MAX_PLAYER_NAME + 1];
  2333. playername = getPlayerName(playerid);
  2334. // Checkcharacter amount
  2335. new id = getUserID(playerid), character_query[75 + MAX_SQL_INTEGER + MAX_CHARACTERS_PER_USER_DIGITS + 1];
  2336. format(character_query, sizeof(character_query), "SELECT id, name FROM character WHERE user_id = %i LIMIT %i", id, MAX_CHARACTERS_PER_USER);
  2337. new Result:character_result = sql_query(sqlHandle, character_query);
  2338. if(sql_num_rows(character_result) < 2){ // 1 character or less
  2339. SendClientMessage(playerid, COLOR_WARNING_MESSAGE, "SERVER: You can not have less then one character.\nCreate another character,before deleting this one.");
  2340. }
  2341. else{ // More then 1 character
  2342. // delete character record
  2343. new delete_query[50 + MAX_PLAYER_NAME + MAX_SQL_INTEGER + 1];
  2344. format(delete_query, sizeof(delete_query), "DELETE FROM character WHERE name = '%s' AND user_id = %i", playername, getUserID(playerid));
  2345. sql_query(sqlHandle, delete_query);
  2346. // infordm admin echo
  2347. new client_connect_username[MAX_PLAYER_NAME + 1], message[28 + 4 + MAX_PLAYER_NAME + MAX_PLAYER_NAME + 1];
  2348. GetGVarString("client_connect_username", client_connect_username, sizeof(client_connect_username), playerid); // Get client connect name
  2349. format(message, sizeof(message), "* [%i] %s has been deleted by it's user: %s", playerid, getCharacterName(playerid), client_connect_username);
  2350. DiscordEcho(message, ADMIN_ECHO_CHANNEL);
  2351. sendToAdmins(COLOR_COMMAND_OUTPUT, message);
  2352. // Player must not be spawned or will be able to esacpe the character menu and continue with character without dartabase record
  2353. ForceClassSelection(playerid);
  2354. TogglePlayerSpectating(playerid, true);
  2355. TogglePlayerSpectating(playerid, false);
  2356. characterSelection(playerid);
  2357. }
  2358. }
  2359. }
  2360. case DIALOG_GOTO:{
  2361. if(response){
  2362. switch(listitem){
  2363. case GOTO_CATEGORY_INTERIOR:{
  2364. dialogGotoInterior(playerid);
  2365. }
  2366. }
  2367. }
  2368. }
  2369. case DIALOG_GOTO_INTERIOR:{
  2370. if(response){
  2371. switch(listitem){
  2372. case INTERIOR_CATEGORY_247:{
  2373. ShowPlayerDialog(playerid, DIALOG_GOTO_247, DIALOG_STYLE_TABLIST, "24/7's", "L-shaped\tBig\tNO EXIT\nOblong\tBig\tNO EXIT\nSquare\tMedium\tCreek, LV\nSquare\tMedium\tNO EXIT\nLong\tSmall\tMulholland\nSquare\tSmall\tWhetstone", "Goto", "Cancel");
  2374. }
  2375. case INTERIOR_CATEGORY_AVIATION:{
  2376. ShowPlayerDialog(playerid, DIALOG_GOTO_AVIATION, DIALOG_STYLE_TABLIST, "Aviation interiors", "Francis Intn'l Airport - Ticket sales\tStarting Cutscene\nFrancis Intn'l Airport - Baggage claim\tStarting Cutscene\nShamal cabin\tMission \"Free Fall\"\nAndromada cargo hold\tMission \"Stowaway\"\nLS Airport, Baggage Reclaim\tCutscene in \"Opening Mission\"", "Goto", "Cancel");
  2377. }
  2378. case INTERIOR_CATEGORY_AMMUNATION:{
  2379. ShowPlayerDialog(playerid, DIALOG_GOTO_AMMUNATION, DIALOG_STYLE_TABLIST, "Ammunation's", "Ocean Flats\tSF\nPalomino Creek\tLV\nAngel Pine\tSF\nEl Quebrados\tLV\n2 Stories/t with Booth and Range\n Booth\n Range", "Goto", "Cancel");
  2380. }
  2381. case INTERIOR_CATEGORY_BUGRLARY:{
  2382. ShowPlayerDialog(playerid, DIALOG_GOTO_BURGLARY, DIALOG_STYLE_TABLIST, "Burglary houses", "Large\t2 story\t3 bedroom clone of house 9\t\nMedium\t1 story\t1 bedroom\tEast LS\nSmall\t1 story\t1 bedroom\tCalton Heights, SF\nVery large\t2 story\t4 bedrooms\nSmall\t1 story\t2 bedrooms\tJefferson LS\nSmall\t1 story\t2 bedrooms\tEast LS\nSmall\t1 story\t 1 bedroom (NO BATHROOM!)", "Goto", "Cancel");
  2383. }
  2384. case INTERIOR_CATEGORY_MISSION:{
  2385. ShowPlayerDialog(playerid, DIALOG_GOTO_MISSION, DIALOG_STYLE_TABLIST, "Mission interiors", "Atrium\tMission \"Just Business\"\tLS\nBig Smoke's Crack Palace\tMission \"End of the Line\"\nJefferson Motel\tMission \"Reuniting the Families\"\tLS\nPleasure Domes/Jizzy's\tMission \"Ice Cold Killa\"\tSF\nRC Battlefield\tMission \"New Model Army\"\nWoozies Apartment/Wu-Zi Mu's\t\tSF\n", "Goto", "Cancel");
  2386. }
  2387. case INTERIOR_CATEGORY_MISSIONEXT:{
  2388. ShowPlayerDialog(playerid, DIALOG_GOTO_MISSIONEXT, DIALOG_STYLE_TABLIST, "Mission exteriors", "Dillimore Gas Station\tMission \"Tanker Commander\"\nLiberty City\tMission \"Saint Marks Bistro\"\nSan Fierro Garage\tDoherty (Locked Camera Position}", "Goto", "Cancel");
  2389. }
  2390. case INTERIOR_CATEGORY_MISSIONHOUSE:{
  2391. ShowPlayerDialog(playerid, DIALOG_GOTO_MISSIONHOUSE, DIALOG_STYLE_TABLIST, "Mission houses", "Burning Desire house\t\tEast LS\nColonel Furhberger's\tMission \"Home Invasion\"\t Los Flores, LS\nRyder's house\nSweet's house\tCutscene in \"First Date\"\nCrack Den\tMission \"Cleaning The Hood\"", "Goto", "Cancel");
  2392. }
  2393. case INTERIOR_CATEGORY_MODSHOP:{
  2394. ShowPlayerDialog(playerid, DIALOG_GOTO_MODDING, DIALOG_STYLE_TABLIST, "Modding shops", "Loco Low Co\tLos Santos\nWheel Arch Angels\tSan Fierro\nTransfender", "Goto", "Cancel");
  2395. }
  2396. case INTERIOR_CATEGORY_POLICE:{
  2397. ShowPlayerDialog(playerid, DIALOG_GOTO_POLICE, DIALOG_STYLE_LIST, "Police departments", "Las Venturas\nLos Santos\nSan Fierro\nBarbara's love nest", "Goto", "Cancel");
  2398. }
  2399. case INTERIOR_CATEGORY_HOUSES:{
  2400. ShowPlayerDialog(playerid, DIALOG_GOTO_HOUSE, DIALOG_STYLE_TABLIST, "Safe houses", "Golden Bed motel room\t\t\nHashbury house\tHashburry\tSF\nThe Johnson house\tGanton\tLS\nMadd Doggs mansion\tMulholland\tLS\nRed Bed motel Room\nVerdant Bluffs safehouse\tVerdant Bluffs\t LV\nUnused safehouse\tLarge modern safehouse", "Goto", "Cancel");
  2401. }
  2402. case INTERIOR_CATEGORY_SHOPS:{
  2403. ShowPlayerDialog(playerid, DIALOG_GOTO_SHOP, DIALOG_STYLE_TABLIST, "Shops & casino's", "Tattoos\tIdlewood\tLS\nBurger Shot\tWhitewood Estates\nWell Stacked Pizza\tBlueberry\nCluckin' Bell\nCaligulas casino\tThe Strip\tLV\nCasino (Redsands West)\tThe Strip\tLV\n4 Dragons casino\tThe Strip\tLV\nRusty Brown's donuts\tMission \"Burning Desire\"\nZero's RC shop\tGarcia\tSF\nThe Welcome Pump", "Goto", "Cancel");
  2404. }
  2405. case INTERIOR_CATEGORY_STADIA:{
  2406. ShowPlayerDialog(playerid, DIALOG_GOTO_STADIA, DIALOG_STYLE_TABLIST, "Stadia", "Bloodbowl stadium\nKickstart stadium\n8 Track stadium\nDirtbike stadium\n", "Goto", "Cancel");
  2407. }
  2408. }
  2409. }
  2410. else{
  2411. ShowPlayerDialog(playerid, DIALOG_GOTO, DIALOG_STYLE_LIST, "Categories", "Interiors", "Select", "Cancel");
  2412. }
  2413. }
  2414. case DIALOG_GOTO_247:{
  2415. if(response){
  2416. new Float:x, Float:y, Float:z, world, interior, Float:angle, name[25 + 1];
  2417. switch(listitem){
  2418. case INTERIOR_247_LSHAPED:{
  2419. x = -25.7220;
  2420. y = -187.8216;
  2421. z = 1003.5469;
  2422. world = GetPlayerVirtualWorld(playerid);
  2423. interior = 17;
  2424. angle = 5.0760;
  2425. name = "L-shaped ammunation";
  2426. }
  2427. case INTERIOR_247_OBLONG:{
  2428. x = 6.0856;
  2429. y = -28.8966;
  2430. z = 1003.5494;
  2431. world = GetPlayerVirtualWorld(playerid);
  2432. interior = 10;
  2433. angle = 5.0365;
  2434. name = "Oblong ammunation";
  2435. }
  2436. case INTERIOR_247_MEDIUM:{
  2437. x = -30.9875;
  2438. y = -89.6806;
  2439. z = 1003.5469;
  2440. world = GetPlayerVirtualWorld(playerid);
  2441. interior = 18;
  2442. angle = 359.8401;
  2443. name = "Medium ammunation";
  2444. }
  2445. case INTERIOR_247_MEDIUM_NOEXIT:{
  2446. x = -26.1856;
  2447. y = -140.9164;
  2448. z = 1003.5469;
  2449. world = GetPlayerVirtualWorld(playerid);
  2450. interior = 16;
  2451. angle = 2.9087;
  2452. name = "Medium no exit ammunation";
  2453. }
  2454. case INTERIOR_247_LONG:{
  2455. x = -27.844;
  2456. y = 26.6737;
  2457. z = 1003.5573;
  2458. world = GetPlayerVirtualWorld(playerid);
  2459. interior = 4;
  2460. angle = 184.3118;
  2461. name = "Small long ammunation";
  2462. }
  2463. case INTERIOR_247_SQAURE:{
  2464. x = -26.8339,
  2465. y = -55.5846,
  2466. z = 1003.5469,
  2467. world = GetPlayerVirtualWorld(playerid),
  2468. interior = 6,
  2469. angle = 3.9528;
  2470. name = "Small square ammunation";
  2471. }
  2472. }
  2473. new target_player = GetGVarInt("goto_target", playerid);
  2474. DeleteGVar("goto_target", playerid);
  2475. teleportPlayer(target_player, x, y, z, world, interior, angle, name);
  2476. }
  2477. else{dialogGotoInterior(playerid);}
  2478. }
  2479. case DIALOG_GOTO_AVIATION:{
  2480. if(response){
  2481. new Float:x, Float:y, Float:z, world, interior, Float:angle, name[39 + 1];
  2482. switch(listitem){
  2483. case INTERIOR_AVIATION_TICKET:{
  2484. x = -1827.147338;
  2485. y = 7.207418;
  2486. z = 1061.143554;
  2487. world = GetPlayerVirtualWorld(playerid);
  2488. interior = 14;
  2489. angle = 335.3199;
  2490. name = "Francis Intn'l Airport - Ticket sales";
  2491. }
  2492. case INTERIOR_AVIATION_BAGGAGE:{
  2493. x = -1855.568725;
  2494. y = 41.263156;
  2495. z = 1061.143554;
  2496. world = GetPlayerVirtualWorld(playerid);
  2497. interior = 14;
  2498. angle = 335.3199;
  2499. name = "Francis Intn'l Airport - Baggage claim";
  2500. }
  2501. case INTERIOR_AVIATION_SHAMAL:{
  2502. x = 2.384830;
  2503. y = 33.103397;
  2504. z = 1199.849976 ;
  2505. world = GetPlayerVirtualWorld(playerid);
  2506. interior = 1;
  2507. angle = 359.8401;
  2508. name = "Shamal cabin";
  2509. }
  2510. case INTERIOR_AVIATION_ANDROMADA:{
  2511. x = 315.856170;
  2512. y = 1024.496459;
  2513. z = 1949.797363;
  2514. world = GetPlayerVirtualWorld(playerid);
  2515. interior = 9;
  2516. angle = 359.6368;
  2517. name = "Andromada cargo hold";
  2518. }
  2519. case INTERIOR_AVIATION_LSAIRPORT:{
  2520. x = -1870.80;
  2521. y = 59.81;
  2522. z = 1056.25;
  2523. world = GetPlayerVirtualWorld(playerid);
  2524. interior = 14;
  2525. angle = 85.8541;
  2526. name = "LS Airport, Baggage Reclaim";
  2527. }
  2528. }
  2529. new target_player = GetGVarInt("goto_target", playerid);
  2530. DeleteGVar("goto_target", playerid);
  2531. teleportPlayer(target_player, x, y, z, world, interior, angle, name);
  2532. }
  2533. else{dialogGotoInterior(playerid);}
  2534. }
  2535. case DIALOG_GOTO_AMMUNATION:{ // TODO there are more ammunations that deserve a booth and range teleport
  2536. if(response){
  2537. new Float:x, Float:y, Float:z, world, interior, Float:angle, name[31 + 1];
  2538. switch(listitem){
  2539. case INTERIOR_AMMU_OCEAN:{
  2540. x = 286.148987;
  2541. y = -40.644398 ;
  2542. z = 1001.569946;
  2543. world = GetPlayerVirtualWorld(playerid);
  2544. interior = 1;
  2545. angle = 0.7529;
  2546. name = "Ocean Flats, SF";
  2547. }
  2548. case INTERIOR_AMMU_PALOMINO:{
  2549. x = 286.800995;
  2550. y = -82.547600;
  2551. z = 1001.539978;
  2552. world = GetPlayerVirtualWorld(playerid);
  2553. interior = 4;
  2554. angle = 290.2195;
  2555. name = "Palomino Creek, LV";
  2556. }
  2557. case INTERIOR_AMMU_ANGEL:{
  2558. x = 296.919983;
  2559. y = -108.071999;
  2560. z = 1001.569946;
  2561. world = GetPlayerVirtualWorld(playerid);
  2562. interior = 6;
  2563. angle = 290.2195;
  2564. name = "Angel Pine, SF";
  2565. }
  2566. case INTERIOR_AMMU_QUEBRADOS:{
  2567. x = 316.524994;
  2568. y = -167.706985;
  2569. z = 999.661987;
  2570. world = GetPlayerVirtualWorld(playerid);
  2571. interior = 6;
  2572. angle = 10.3031;
  2573. name = "El Quebrados, LV";
  2574. }
  2575. case INTERIOR_AMMU_2STORIES:{
  2576. x = 314.820984;
  2577. y = -141.431992;
  2578. z = 999.661987;
  2579. world = GetPlayerVirtualWorld(playerid);
  2580. interior = 7;
  2581. angle = 20.2254;
  2582. name = "2 Stories, with booth and range";
  2583. }
  2584. case INTERIOR_AMMU_BOOTH:{
  2585. x = 302.292877;
  2586. y = -143.139099;
  2587. z = 1004.062500;
  2588. world = GetPlayerVirtualWorld(playerid);
  2589. interior = 7;
  2590. angle = 20.2254;
  2591. name = "Booth";
  2592. }
  2593. case INTERIOR_AMMU_RANGE:{
  2594. x = 280.795104;
  2595. y = -135.203353;
  2596. z = 1004.062500;
  2597. world = GetPlayerVirtualWorld(playerid);
  2598. interior = 7;
  2599. angle = 20.2254;
  2600. name = "Range";
  2601. }
  2602. }
  2603. new target_player = GetGVarInt("goto_target", playerid);
  2604. DeleteGVar("goto_target", playerid);
  2605. teleportPlayer(target_player, x, y, z, world, interior, angle, name);
  2606. }
  2607. else{dialogGotoInterior(playerid);}
  2608. }
  2609. case DIALOG_GOTO_BURGLARY:{
  2610. if(response){
  2611. new Float:x, Float:y, Float:z, world, interior, Float:angle, name[45 + 1];
  2612. switch(listitem){
  2613. case INTERIOR_BURGRLARY_LARGE:{
  2614. x = 235.508994;
  2615. y = 1189.169897;
  2616. z = 1080.339966;
  2617. world = GetPlayerVirtualWorld(playerid);
  2618. interior = 3;
  2619. angle = 349.4844;
  2620. name = "Large: 2 story, 3 bedroom clone of house 9";
  2621. }
  2622. case INTERIOR_BURGRLARY_MEDIUM:{
  2623. x = 225.756989;
  2624. y = 1240.000000;
  2625. z = 1082.149902;
  2626. world = GetPlayerVirtualWorld(playerid);
  2627. interior = 2;
  2628. angle = 96.2852;
  2629. name = "Medium: 1 story, 1 bedroom";
  2630. }
  2631. case INTERIOR_BURGRLARY_SMALL:{
  2632. x = 223.043991;
  2633. y = 1289.259888;
  2634. z = 1082.199951;
  2635. world = GetPlayerVirtualWorld(playerid);
  2636. interior = 1;
  2637. angle = 359.868;
  2638. name = "Small: 1 story, 1 bedroom";
  2639. }
  2640. case INTERIOR_BURGRLARY_VERYLARGE:{
  2641. x = 225.630997;
  2642. y = 1022.479980;
  2643. z = 1084.069946;
  2644. world = GetPlayerVirtualWorld(playerid);
  2645. interior = 7;
  2646. angle = 270.2654;
  2647. name = "VERY Large: 2 story, 4 bedrooms";
  2648. }
  2649. case INTERIOR_BURGRLARY_5:{
  2650. x = 295.138977;
  2651. y = 1474.469971;
  2652. z = 1080.519897;
  2653. world = GetPlayerVirtualWorld(playerid);
  2654. interior = 15;
  2655. angle = 0;
  2656. name = "Small: 1 story, 2 bedrooms";
  2657. }
  2658. case INTERIOR_BURGRLARY_6:{
  2659. x = 328.493988;
  2660. y = 1480.589966;
  2661. z = 1084.449951;
  2662. world = GetPlayerVirtualWorld(playerid);
  2663. interior = 15;
  2664. angle = 0;
  2665. name = "Small: 1 story, 2 bedrooms";
  2666. }
  2667. case INTERIOR_BURGRLARY_NOBATH:{
  2668. x = 385.803986;
  2669. y = 1471.769897;
  2670. z = 1080.209961;
  2671. world = GetPlayerVirtualWorld(playerid);
  2672. interior = 15;
  2673. angle = 0;
  2674. name = "Small: 1 story, 1 bedroom (NO BATHROOM!)";
  2675. }
  2676. }
  2677. new target_player = GetGVarInt("goto_target", playerid);
  2678. DeleteGVar("goto_target", playerid);
  2679. teleportPlayer(target_player, x, y, z, world, interior, angle, name);
  2680. }
  2681. else{dialogGotoInterior(playerid);}
  2682. }
  2683. case DIALOG_GOTO_MISSION:{
  2684. if(response){
  2685. new Float:x, Float:y, Float:z, world, interior, Float:angle, name[30 + 1];
  2686. switch(listitem){
  2687. case INTERIOR_MISSION_ATRIUM:{
  2688. x = 1726.18;
  2689. y = -1641.00;
  2690. z = 20.23;
  2691. world = GetPlayerVirtualWorld(playerid);
  2692. interior = 18;
  2693. angle = 172.4193;
  2694. name = "Atrium";
  2695. }
  2696. case INTERIOR_MISSION_BIGSMOKE:{
  2697. x = 2567.52;
  2698. y = -1294.59;
  2699. z = 1063.25 ;
  2700. world = GetPlayerVirtualWorld(playerid);
  2701. interior = 2;
  2702. angle = 254.9548;
  2703. name = "Big Smoke's Crack Palace";
  2704. }
  2705. case INTERIOR_MISSION_JEFFERSON:{
  2706. x = 2220.26;
  2707. y = -1148.01;
  2708. z = 1025.80;
  2709. world = GetPlayerVirtualWorld(playerid);
  2710. interior = 15;
  2711. angle = 273.7328;
  2712. name = "Jefferson Motel";
  2713. }
  2714. case INTERIOR_MISSION_JIZZY:{
  2715. x = -2637.69;
  2716. y = 1404.24;
  2717. z = 906.46;
  2718. world = GetPlayerVirtualWorld(playerid);
  2719. interior = 3;
  2720. angle = 94.6794;
  2721. name = "Pleasure Domes/Jizzy's";
  2722. }
  2723. case INTERIOR_MISSION_RC:{
  2724. x = -1079.99;
  2725. y = 1061.58;
  2726. z = 1343.04;
  2727. world = GetPlayerVirtualWorld(playerid);
  2728. interior = 10;
  2729. angle = 274.5268;
  2730. name = "RC Battlefield";
  2731. }
  2732. case INTERIOR_MISSION_WUZI:{
  2733. x = -2158.72;
  2734. y = 641.29;
  2735. z = 1052.38;
  2736. world = GetPlayerVirtualWorld(playerid);
  2737. interior = 1;
  2738. angle = 86.5402;
  2739. name = "Woozies Apartment/Wu-Zi Mu's";
  2740. }
  2741. }
  2742. new target_player = GetGVarInt("goto_target", playerid);
  2743. DeleteGVar("goto_target", playerid);
  2744. teleportPlayer(target_player, x, y, z, world, interior, angle, name);
  2745. }
  2746. else{dialogGotoInterior(playerid);}
  2747. }
  2748. case DIALOG_GOTO_MISSIONEXT:{
  2749. if(response){
  2750. new Float:x, Float:y, Float:z, world, interior, Float:angle, name[30 + 1];
  2751. switch(listitem){
  2752. case INTERIOR_MISSIONEXT_GAS:{
  2753. x = 664.19;
  2754. y = -570.73;
  2755. z = 16.34;
  2756. world = GetPlayerVirtualWorld(playerid);
  2757. interior = 0;
  2758. angle = 264.9829;
  2759. name = "Dillimore Gas Station";
  2760. }
  2761. case INTERIOR_MISSIONEXT_LIBERTY:{ // TODO Create extra interior inside the shop
  2762. x = -750.80;
  2763. y = 491.00;
  2764. z = 1371.70;
  2765. world = GetPlayerVirtualWorld(playerid);
  2766. interior = 1;
  2767. angle = 71.7782;
  2768. name = "Liberty City";
  2769. }
  2770. case INTERIOR_MISSIONEXT_SFGARAGE:{ // TODO Create extra interior of area that does not capture the camera & see about the camera camera capturing (Use it for broadcast? & In other world or interior place more usable?)
  2771. x = -2042.42;
  2772. y = 178.59;
  2773. z = 28.84;
  2774. world = GetPlayerVirtualWorld(playerid);
  2775. interior = 1;
  2776. angle = 156.2153;
  2777. name = "San Fierro Garage Interior";
  2778. }
  2779. }
  2780. new target_player = GetGVarInt("goto_target", playerid);
  2781. DeleteGVar("goto_target", playerid);
  2782. teleportPlayer(target_player, x, y, z, world, interior, angle, name);
  2783. }
  2784. else{dialogGotoInterior(playerid);}
  2785. }
  2786. case DIALOG_GOTO_MISSIONHOUSE:{
  2787. if(response){
  2788. new Float:x, Float:y, Float:z, world, interior, Float:angle, name[30 + 1];
  2789. switch(listitem){
  2790. case INTERIOR_MISSIONHOUSE_DESIRE:{
  2791. x = 2338.32;
  2792. y = -1180.61;
  2793. z = 1027.98;
  2794. world = GetPlayerVirtualWorld(playerid);
  2795. interior = 5;
  2796. angle = 99.1864;
  2797. name = "Burning Desire House";
  2798. }
  2799. case INTERIOR_MISSIONHOUSE_COLONEL:{
  2800. x = 2807.63;
  2801. y = -1170.15;
  2802. z = 1025.57;
  2803. world = GetPlayerVirtualWorld(playerid);
  2804. interior = 8;
  2805. angle = 193.7117;
  2806. name = "Colonel Furhberger's";
  2807. }
  2808. case INTERIOR_MISSIONHOUSE_RYDER:{
  2809. x = 2451.77;
  2810. y = -1699.80;
  2811. z = 1013.51;
  2812. world = GetPlayerVirtualWorld(playerid);
  2813. interior = 2;
  2814. angle = 314.5253;
  2815. name = "Ryder's House";
  2816. }
  2817. case INTERIOR_MISSIONHOUSE_SWEET:{
  2818. x = 2535.83;
  2819. y = -1674.32;
  2820. z = 1015.50;
  2821. world = GetPlayerVirtualWorld(playerid);
  2822. interior = 1;
  2823. angle = 260.9709;
  2824. name = "Sweet's House";
  2825. }
  2826. case INTERIOR_MISSIONHOUSE_CRACK:{
  2827. x = 318.565;
  2828. y = 1115.210;
  2829. z = 1082.98;
  2830. world = GetPlayerVirtualWorld(playerid);
  2831. interior = 5;
  2832. angle = 267.459;
  2833. name = "Crack den";
  2834. }
  2835. }
  2836. new target_player = GetGVarInt("goto_target", playerid);
  2837. DeleteGVar("goto_target", playerid);
  2838. teleportPlayer(target_player, x, y, z, world, interior, angle, name);
  2839. }
  2840. else{dialogGotoInterior(playerid);}
  2841. }
  2842. case DIALOG_GOTO_MODDING:{
  2843. if(response){
  2844. new Float:x, Float:y, Float:z, world, interior, Float:angle, name[25 + 1];
  2845. switch(listitem){
  2846. case INTERIOR_MOD_LOCO:{
  2847. x = 616.7820;
  2848. y = -74.8151;
  2849. z = 997.6350;
  2850. world = GetPlayerVirtualWorld(playerid);
  2851. interior = 2;
  2852. angle = 320.9263;
  2853. name = "Loco Low Co";
  2854. }
  2855. case INTERIOR_MOD_WHEEL:{
  2856. x = 615.2851;
  2857. y = -124.2390;
  2858. z = 997.6350;
  2859. world = GetPlayerVirtualWorld(playerid);
  2860. interior = 3;
  2861. angle = 266.5704;
  2862. name = "Wheel Arch Angels";
  2863. }
  2864. case INTERIOR_MOD_TRANSFENDER:{
  2865. x = 617.5380;
  2866. y = -1.9900;
  2867. z = 1000.6829;
  2868. world = GetPlayerVirtualWorld(playerid);
  2869. interior = 1;
  2870. angle = 15.6789;
  2871. name = "Transfender";
  2872. }
  2873. }
  2874. new target_player = GetGVarInt("goto_target", playerid);
  2875. DeleteGVar("goto_target", playerid);
  2876. teleportPlayer(target_player, x, y, z, world, interior, angle, name);
  2877. }
  2878. else{dialogGotoInterior(playerid);}
  2879. }
  2880. case DIALOG_GOTO_POLICE:{
  2881. if(response){
  2882. new Float:x, Float:y, Float:z, world, interior, Float:angle, name[30 + 1];
  2883. switch(listitem){
  2884. case INTERIOR_PD_LV:{
  2885. x = 288.4723;
  2886. y = 170.0647;
  2887. z = 1007.1794;
  2888. world = GetPlayerVirtualWorld(playerid);
  2889. interior = 3;
  2890. angle = 22.0477;
  2891. name = "Las Venturas police deparment";
  2892. }
  2893. case INTERIOR_PD_LS:{
  2894. x = 246.6695;
  2895. y = 65.8039;
  2896. z = 1003.6406;
  2897. world = GetPlayerVirtualWorld(playerid);
  2898. interior = 6;
  2899. angle = 7.9562;
  2900. name = "Los Santos police deparment";
  2901. }
  2902. case INTERIOR_PD_SF:{
  2903. x = 246.0688;
  2904. y = 108.9703;
  2905. z = 1003.2188;
  2906. world = GetPlayerVirtualWorld(playerid);
  2907. interior = 10;
  2908. angle = 0.2922;
  2909. name = "San Fierro police deparment";
  2910. }
  2911. case INTERIOR_PD_BARBARA:{
  2912. x = 322.5014;
  2913. y = 303.6906;
  2914. z = 999.1484;
  2915. world = GetPlayerVirtualWorld(playerid);
  2916. interior = 5;
  2917. angle = 8.1747;
  2918. name = "Barbara's Love nest";
  2919. }
  2920. }
  2921. new target_player = GetGVarInt("goto_target", playerid);
  2922. DeleteGVar("goto_target", playerid);
  2923. teleportPlayer(target_player, x, y, z, world, interior, angle, name);
  2924. }
  2925. else{dialogGotoInterior(playerid);}
  2926. }
  2927. case DIALOG_GOTO_HOUSE:{
  2928. if(response){
  2929. new Float:x, Float:y, Float:z, world, interior, Float:angle, name[25 + 1];
  2930. switch(listitem){
  2931. case INTERIOR_HOUSE_GOLDEN:{
  2932. x = 2251.85;
  2933. y = -1138.16;
  2934. z = 1050.63;
  2935. world = GetPlayerVirtualWorld(playerid);
  2936. interior = 9;
  2937. angle = 167.3959;
  2938. name = "Golden Bed motel room";
  2939. }
  2940. case INTERIOR_HOUSE_HASHBURY:{
  2941. x = 2260.76;
  2942. y = -1210.45;
  2943. z = 1049.02;
  2944. world = GetPlayerVirtualWorld(playerid);
  2945. interior = 10;
  2946. angle = 266.88;
  2947. name = "Hashbury house";
  2948. }
  2949. case INTERIOR_HOUSE_JOHNSON:{
  2950. x = 2496.65;
  2951. y = -1696.55;
  2952. z = 1014.74;
  2953. world = GetPlayerVirtualWorld(playerid);
  2954. interior = 3;
  2955. angle = 179.2174;
  2956. name = "The Johnson house";
  2957. }
  2958. case INTERIOR_HOUSE_MADDDOGG:{
  2959. x = 1299.14;
  2960. y = -794.77;
  2961. z = 1084.00;
  2962. world = GetPlayerVirtualWorld(playerid);
  2963. interior = 5;
  2964. angle = 231.3418;
  2965. name = "Madd Doggs mansion";
  2966. }
  2967. case INTERIOR_HOUSE_RED:{
  2968. x = 2262.83;
  2969. y = -1137.71;
  2970. z = 1050.63;
  2971. world = GetPlayerVirtualWorld(playerid);
  2972. interior = 10;
  2973. angle = 266.88;
  2974. name = "Red Bed motel room";
  2975. }
  2976. case INTERIOR_HOUSE_VERDANT:{
  2977. x = 2365.42;
  2978. y = -1131.85;
  2979. z = 1050.88;
  2980. world = GetPlayerVirtualWorld(playerid);
  2981. interior = 8;
  2982. angle = 177.3947;
  2983. name = "Verdant Bluffs safehouse";
  2984. }
  2985. case INTERIOR_HOUSE_UNUSED:{
  2986. x = 2324.33;
  2987. y = -1144.79;
  2988. z = 1050.71;
  2989. world = GetPlayerVirtualWorld(playerid);
  2990. interior = 12;
  2991. angle = 269.0954;
  2992. name = "Unused safe house";
  2993. }
  2994. }
  2995. new target_player = GetGVarInt("goto_target", playerid);
  2996. DeleteGVar("goto_target", playerid);
  2997. teleportPlayer(target_player, x, y, z, world, interior, angle, name);
  2998. }
  2999. else{dialogGotoInterior(playerid);}
  3000. }
  3001. case DIALOG_GOTO_SHOP:{
  3002. if(response){
  3003. new Float:x, Float:y, Float:z, world, interior, Float:angle, name[25 + 1];
  3004. switch(listitem){
  3005. case INTERIOR_SHOP_TATTOO:{
  3006. x = -203.0764;
  3007. y = -24.1658;
  3008. z = 1002.2734;
  3009. world = GetPlayerVirtualWorld(playerid);
  3010. interior = 16;
  3011. angle = 252.8154;
  3012. name = "Tattoos";
  3013. }
  3014. case INTERIOR_SHOP_BURGER:{
  3015. x = 366.0248;
  3016. y = -73.3478;
  3017. z = 1001.5078;
  3018. world = GetPlayerVirtualWorld(playerid);
  3019. interior = 10;
  3020. angle = 292.0084;
  3021. name = "Burger Shot";
  3022. }
  3023. case INTERIOR_SHOP_PIZZA:{
  3024. x = 372.3520;
  3025. y = -131.6510;
  3026. z = 1001.4922;
  3027. world = GetPlayerVirtualWorld(playerid);
  3028. interior = 5;
  3029. angle = 354.2285;
  3030. name = "Well Stacked Pizza";
  3031. }
  3032. case INTERIOR_SHOP_CLUCKIN:{
  3033. x = 365.7158;
  3034. y = -9.8873;
  3035. z = 1001.8516;
  3036. world = GetPlayerVirtualWorld(playerid);
  3037. interior = 9;
  3038. angle = 160.528;
  3039. name = "Cluckin' Bell";
  3040. }
  3041. case INTERIOR_SHOP_CALIGULAS:{
  3042. x = 2233.8032;
  3043. y = 1712.2303;
  3044. z = 1011.7632;
  3045. world = GetPlayerVirtualWorld(playerid);
  3046. interior = 1;
  3047. angle = 184.3891;
  3048. name = "Caligulas Casino";
  3049. }
  3050. case INTERIOR_SHOP_CASINO:{
  3051. x = 1118.8878;
  3052. y = -10.2737;
  3053. z = 1002.0859;
  3054. world = GetPlayerVirtualWorld(playerid);
  3055. interior = 12;
  3056. angle = 165.8482;
  3057. name = "Casino (Redsands West)";
  3058. }
  3059. case INTERIOR_SHOP_4DRAGONS:{
  3060. x = 2016.2699;
  3061. y = 1017.7790;
  3062. z = 996.8750;
  3063. world = GetPlayerVirtualWorld(playerid);
  3064. interior = 10;
  3065. angle = 88.0055;
  3066. name = "4 Dragons Casino";
  3067. }
  3068. case INTERIOR_SHOP_DONUTS:{
  3069. x = 376.99;
  3070. y = -191.21;
  3071. z = 1000.63;
  3072. world = GetPlayerVirtualWorld(playerid);
  3073. interior = 17;
  3074. angle = 141.0245;
  3075. name = "Rusty Brown's donuts";
  3076. }
  3077. case INTERIOR_SHOP_RC:{
  3078. x = -2240.00;
  3079. y = 131.00;
  3080. z = 1035.40;
  3081. world = GetPlayerVirtualWorld(playerid);
  3082. interior = 6;
  3083. angle = 269.0954;
  3084. name = "Zero's RC shop";
  3085. }
  3086. case INTERIOR_SHOP_PUMP:{
  3087. x = 681.66;
  3088. y = -453.32;
  3089. z = -25.61;
  3090. world = GetPlayerVirtualWorld(playerid);
  3091. interior = 1;
  3092. angle = 166.166;
  3093. name = "The Welcome Pump";
  3094. }
  3095. }
  3096. new target_player = GetGVarInt("goto_target", playerid);
  3097. DeleteGVar("goto_target", playerid);
  3098. teleportPlayer(target_player, x, y, z, world, interior, angle, name);
  3099. }
  3100. else{dialogGotoInterior(playerid);}
  3101. }
  3102. case DIALOG_GOTO_STADIA:{
  3103. if(response){
  3104. new Float:x, Float:y, Float:z, world, interior, Float:angle, name[25 + 1];
  3105. switch(listitem){
  3106. case INTERIOR_STADIUM_BLOODBOWL:{
  3107. x = -1394.20;
  3108. y = 987.62;
  3109. z = 1023.96;
  3110. world = GetPlayerVirtualWorld(playerid);
  3111. interior = 15;
  3112. angle = 0.7013;
  3113. name = "Bloodbowl Stadium";
  3114. }
  3115. case INTERIOR_STADIUM_KICKSTART:{
  3116. x = -1410.72;
  3117. y = 1591.16;
  3118. z = 1052.53;
  3119. world = GetPlayerVirtualWorld(playerid);
  3120. interior = 14;
  3121. angle = 159.1255;
  3122. name = "Kickstart Stadium";
  3123. }
  3124. case INTERIOR_STADIUM_8TRACK:{
  3125. x = -1395.958;
  3126. y = -208.197;
  3127. z = 1051.170;
  3128. world = GetPlayerVirtualWorld(playerid);
  3129. interior = 7;
  3130. angle = 355.8576;
  3131. name = "8 Track Stadium";
  3132. }
  3133. case INTERIOR_STADIUM_DIRTBIKE:{
  3134. x = -1424.9319;
  3135. y = -664.5869;
  3136. z = 1059.8585;
  3137. world = GetPlayerVirtualWorld(playerid);
  3138. interior = 4;
  3139. angle = 170.9341;
  3140. name = "Dirtbike Stadium";
  3141. }
  3142. }
  3143. new target_player = GetGVarInt("goto_target", playerid);
  3144. DeleteGVar("goto_target", playerid);
  3145. teleportPlayer(target_player, x, y, z, world, interior, angle, name);
  3146. }
  3147. else{dialogGotoInterior(playerid);}
  3148. }
  3149. case DIALOG_CREATE_PICKUP:{
  3150. if(response){
  3151. switch(listitem){
  3152. case PICKUP_FACTION_PD:{
  3153. ShowPlayerDialog(playerid, DIALOG_CREATE_FACTION_PICKUP, DIALOG_STYLE_LIST, "Faction types", "Police", "Select", "Cancel");
  3154. }
  3155. }
  3156. }
  3157. }
  3158. case DIALOG_CREATE_FACTION_PICKUP:{
  3159. if(response){
  3160. switch(listitem){
  3161. case FACTION_POLICE:{
  3162. new Float:x, Float:y, Float:z;
  3163. GetPlayerPos(playerid, x, y, z);
  3164. new world = GetPlayerVirtualWorld(playerid);
  3165. new interior = GetPlayerInterior(playerid);
  3166. new pickupid = createDynamicPickup(1210, x, y, z, world, interior, PICKUP_FACTION_PD);
  3167. // Create pickup record
  3168. new pickup_query[127 + MAX_SQL_FLOAT + MAX_SQL_FLOAT + MAX_SQL_FLOAT + MAX_SQL_INTEGER + MAX_SQL_INTEGER + MAX_SQL_INTEGER + MAX_SQL_INTEGER + 1];
  3169. format(pickup_query, sizeof(pickup_query), "INSERT INTO pickup(object_id, pos_x, pos_y, pos_z, world_id, interior_id, type_id, pickup_id) VALUES (1210, '%f', '%f', '%f', %i, %i, %i, %i)", x, y, z, world, interior, PICKUP_FACTION_PD, pickupid);
  3170. sql_query(sqlHandle, pickup_query);
  3171. // Get pickup record ID
  3172. new id_query[44 + 1];
  3173. format(id_query, sizeof(id_query), "SELECT id FROM pickup WHERE pickup_id = %i", pickupid);
  3174. new Result:id_result = sql_query(sqlHandle, id_query);
  3175. new pickup_id = sql_get_field_assoc_int(id_result, "pickup_id");
  3176. // Inform admins
  3177. new admin_message[21 + 4 + MAX_PLAYER_NAME + MAX_SQL_INTEGER + 1];
  3178. format(admin_message, sizeof(admin_message), "* [%i] %s created police faction pickup: %i", playerid, getPlayerName(playerid), pickup_id);
  3179. sendToAdmins(COLOR_NOTICE, admin_message);
  3180. DiscordEcho(admin_message, ADMIN_ECHO_CHANNEL);
  3181. }
  3182. }
  3183. }
  3184. }
  3185. case DIALOG_DUTY_PD:{
  3186. if(response){
  3187. // TODO: Check if has passport
  3188. // TODO: Check for crimes, warrents, etc
  3189. ShowPlayerDialog(playerid, DIALOG_POLICE_SKIN, DIALOG_STYLE_LIST, "Police skins", "Police", "Los Santos Police Officer\nSan Fierro Police Officer\nLSPD Motorbike Cop\nLos Santos Police Officer (Without gun holster)\nSan Fierro Police Officer (Without gun holster)\nLos Santos Police Officer\nSan Fierro Police Officer", "Cancel");
  3190. }
  3191. }
  3192. case DIALOG_POLICE_SKIN:{
  3193. if(response){
  3194. // TODO: Set job gvar + Set color + Set skin
  3195. SetPlayerColor(playerid, 0xFF0000FF);
  3196. }
  3197. }
  3198. }
  3199. return 0; // MUST return 0 here, just like OnPlayerCommandText.
  3200. }
  3201. public OnPlayerClickPlayer(playerid, clickedplayerid, source) // TODO for 0.0a
  3202. {
  3203. return 1;
  3204. }
  3205. public OnEnterExitModShop(playerid, enterexit, interiorid) // TODO for 0.0a
  3206. {
  3207. return 1;
  3208. }
  3209. public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid) // TODO for 0.0a
  3210. {
  3211. return 1;
  3212. }
  3213. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid) // TODO for 0.0a
  3214. {
  3215. return 1;
  3216. }
  3217. // discord-connector events
  3218. public DCC_OnMessageCreate(DCC_Message:message){
  3219. // Originating Discord channel
  3220. new DCC_Channel:channel;
  3221. DCC_GetMessageChannel(message, channel);
  3222. // Originating Discord user
  3223. new DCC_User:author;
  3224. DCC_GetMessageAuthor(message, author);
  3225. // Message content
  3226. new str[256];
  3227. new command[32], params[128];
  3228. DCC_GetMessageContent(message, str);
  3229. sscanf(str, "s[32]s[128]", command, params); // This string is to small some times, and throws an error BROKEN TODO
  3230. // Ignore bots
  3231. new bool:isBot;
  3232. DCC_IsUserBot(author, isBot);
  3233. if(isBot){
  3234. return 1;
  3235. }
  3236. /*// Beyond this point, don't respond to commands on foreign guilds.
  3237. if(guild != homeGuild){
  3238. return 1;
  3239. }*/
  3240. // Beyond this point, only respond to privilaged channels.
  3241. if(channel != adminEchoChannel && channel != adminChannel && channel != managementChannel){
  3242. return 1;
  3243. }
  3244. // Test command.
  3245. if(!strcmp(command, "!test", true)){
  3246. DiscordSendChannelMessage(channel, "Works.");
  3247. print("Some said !test in the echo channel.");
  3248. }
  3249. return 1;
  3250. }
  3251. // Entrypoint
  3252. main(){
  3253. // Credits
  3254. print("\n*----------------------------------*");
  3255. print(" RPFW by tBKwtWS.");
  3256. new message[21 + 20 + 1];
  3257. format(message, sizeof(message), " Role-play framework v%s", MODE_NAME);
  3258. print(message);
  3259. //printf("System load average: %f",loadavg()); // Linux only TODO: test
  3260. print("*----------------------------------*\n");
  3261. }