atcommand.c 305 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include <math.h>
  8. #include "../common/socket.h"
  9. #include "../common/timer.h"
  10. #include "../common/nullpo.h"
  11. #include "../common/mmo.h"
  12. #include "../common/core.h"
  13. #include "../common/showmsg.h"
  14. #include "log.h"
  15. #include "clif.h"
  16. #include "chrif.h"
  17. #include "intif.h"
  18. #include "itemdb.h"
  19. #include "map.h"
  20. #include "pc.h"
  21. #include "status.h"
  22. #include "skill.h"
  23. #include "mob.h"
  24. #include "pet.h"
  25. #include "battle.h"
  26. #include "party.h"
  27. #include "guild.h"
  28. #include "atcommand.h"
  29. #include "script.h"
  30. #include "npc.h"
  31. #include "trade.h"
  32. #ifndef TXT_ONLY
  33. #include "mail.h"
  34. #endif
  35. static char command_symbol = '@'; // first char of the commands (by [Yor])
  36. char *msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  37. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  38. ACMD_FUNC(broadcast);
  39. ACMD_FUNC(localbroadcast);
  40. ACMD_FUNC(rura);
  41. ACMD_FUNC(where);
  42. ACMD_FUNC(jumpto);
  43. ACMD_FUNC(jump);
  44. ACMD_FUNC(who);
  45. ACMD_FUNC(who2);
  46. ACMD_FUNC(who3);
  47. ACMD_FUNC(whomap);
  48. ACMD_FUNC(whomap2);
  49. ACMD_FUNC(whomap3);
  50. ACMD_FUNC(whogm); // by Yor
  51. ACMD_FUNC(whozeny); // [Valaris]
  52. ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
  53. ACMD_FUNC(save);
  54. ACMD_FUNC(load);
  55. ACMD_FUNC(speed);
  56. ACMD_FUNC(storage);
  57. ACMD_FUNC(guildstorage);
  58. ACMD_FUNC(option);
  59. ACMD_FUNC(hide);
  60. ACMD_FUNC(jobchange);
  61. ACMD_FUNC(die);
  62. ACMD_FUNC(kill);
  63. ACMD_FUNC(alive);
  64. ACMD_FUNC(kami);
  65. ACMD_FUNC(heal);
  66. ACMD_FUNC(item);
  67. ACMD_FUNC(item2);
  68. ACMD_FUNC(itemreset);
  69. ACMD_FUNC(itemcheck);
  70. ACMD_FUNC(baselevelup);
  71. ACMD_FUNC(joblevelup);
  72. ACMD_FUNC(help);
  73. ACMD_FUNC(help2);
  74. ACMD_FUNC(gm);
  75. ACMD_FUNC(pvpoff);
  76. ACMD_FUNC(pvpon);
  77. ACMD_FUNC(gvgoff);
  78. ACMD_FUNC(gvgon);
  79. ACMD_FUNC(model);
  80. ACMD_FUNC(go);
  81. ACMD_FUNC(monster);
  82. ACMD_FUNC(monstersmall);
  83. ACMD_FUNC(monsterbig);
  84. ACMD_FUNC(spawn);
  85. ACMD_FUNC(killmonster);
  86. ACMD_FUNC(killmonster2);
  87. ACMD_FUNC(refine);
  88. ACMD_FUNC(produce);
  89. ACMD_FUNC(memo);
  90. ACMD_FUNC(gat);
  91. ACMD_FUNC(packet);
  92. ACMD_FUNC(waterlevel);
  93. ACMD_FUNC(statuspoint);
  94. ACMD_FUNC(skillpoint);
  95. ACMD_FUNC(zeny);
  96. ACMD_FUNC(param);
  97. ACMD_FUNC(guildlevelup);
  98. ACMD_FUNC(makeegg);
  99. ACMD_FUNC(hatch);
  100. ACMD_FUNC(petfriendly);
  101. ACMD_FUNC(pethungry);
  102. ACMD_FUNC(petrename);
  103. ACMD_FUNC(recall);
  104. ACMD_FUNC(recallall);
  105. ACMD_FUNC(revive);
  106. ACMD_FUNC(night);
  107. ACMD_FUNC(day);
  108. ACMD_FUNC(doom);
  109. ACMD_FUNC(doommap);
  110. ACMD_FUNC(raise);
  111. ACMD_FUNC(raisemap);
  112. ACMD_FUNC(kick);
  113. ACMD_FUNC(kickall);
  114. ACMD_FUNC(allskill);
  115. ACMD_FUNC(questskill);
  116. ACMD_FUNC(lostskill);
  117. ACMD_FUNC(spiritball);
  118. ACMD_FUNC(party);
  119. ACMD_FUNC(guild);
  120. ACMD_FUNC(agitstart);
  121. ACMD_FUNC(agitend);
  122. ACMD_FUNC(reloaditemdb);
  123. ACMD_FUNC(reloadmobdb);
  124. ACMD_FUNC(reloadskilldb);
  125. ACMD_FUNC(reloadscript);
  126. ACMD_FUNC(reloadgmdb); // by Yor
  127. ACMD_FUNC(reloadatcommand);
  128. ACMD_FUNC(reloadbattleconf);
  129. ACMD_FUNC(reloadstatusdb);
  130. ACMD_FUNC(reloadpcdb);
  131. ACMD_FUNC(reloadmotd); // [Valaris]
  132. ACMD_FUNC(mapexit);
  133. ACMD_FUNC(idsearch);
  134. ACMD_FUNC(mapinfo);
  135. ACMD_FUNC(dye); //** by fritz
  136. ACMD_FUNC(hair_style); //** by fritz
  137. ACMD_FUNC(hair_color); //** by fritz
  138. ACMD_FUNC(stat_all); //** by fritz
  139. ACMD_FUNC(char_block); // by Yor
  140. ACMD_FUNC(char_ban); // by Yor
  141. ACMD_FUNC(char_unblock); // by Yor
  142. ACMD_FUNC(char_unban); // by Yor
  143. ACMD_FUNC(mount_peco); // by Valaris
  144. ACMD_FUNC(char_mount_peco); // by Yor
  145. ACMD_FUNC(guildspy); // [Syrus22]
  146. ACMD_FUNC(partyspy); // [Syrus22]
  147. ACMD_FUNC(repairall); // [Valaris]
  148. ACMD_FUNC(guildrecall); // by Yor
  149. ACMD_FUNC(partyrecall); // by Yor
  150. ACMD_FUNC(nuke); // [Valaris]
  151. ACMD_FUNC(shownpc);
  152. ACMD_FUNC(hidenpc);
  153. ACMD_FUNC(loadnpc);
  154. ACMD_FUNC(unloadnpc);
  155. ACMD_FUNC(servertime); // by Yor
  156. ACMD_FUNC(chardelitem); // by Yor
  157. ACMD_FUNC(jail); // by Yor
  158. ACMD_FUNC(unjail); // by Yor
  159. ACMD_FUNC(disguise); // [Valaris]
  160. ACMD_FUNC(undisguise); // by Yor
  161. ACMD_FUNC(chardisguise); // Kalaspuff
  162. ACMD_FUNC(charundisguise); // Kalaspuff
  163. ACMD_FUNC(email); // by Yor
  164. ACMD_FUNC(effect);//by Apple
  165. ACMD_FUNC(character_cart_list); // by Yor
  166. ACMD_FUNC(addwarp); // by MouseJstr
  167. ACMD_FUNC(follow); // by MouseJstr
  168. ACMD_FUNC(skillon); // by MouseJstr
  169. ACMD_FUNC(skilloff); // by MouseJstr
  170. ACMD_FUNC(killer); // by MouseJstr
  171. ACMD_FUNC(npcmove); // by MouseJstr
  172. ACMD_FUNC(killable); // by MouseJstr
  173. ACMD_FUNC(charkillable); // by MouseJstr
  174. ACMD_FUNC(dropall); // by MouseJstr
  175. ACMD_FUNC(chardropall); // by MouseJstr
  176. ACMD_FUNC(storeall); // by MouseJstr
  177. ACMD_FUNC(charstoreall); // by MouseJstr
  178. ACMD_FUNC(skillid); // by MouseJstr
  179. ACMD_FUNC(useskill); // by MouseJstr
  180. ACMD_FUNC(summon);
  181. ACMD_FUNC(rain);
  182. ACMD_FUNC(snow);
  183. ACMD_FUNC(sakura);
  184. ACMD_FUNC(clouds);
  185. ACMD_FUNC(clouds2); // [Valaris]
  186. ACMD_FUNC(fog);
  187. ACMD_FUNC(fireworks);
  188. ACMD_FUNC(leaves);
  189. ACMD_FUNC(adjgmlvl); // by MouseJstr
  190. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  191. ACMD_FUNC(trade); // by MouseJstr
  192. ACMD_FUNC(send); // by davidsiaw
  193. ACMD_FUNC(setbattleflag); // by MouseJstr
  194. ACMD_FUNC(unmute); // [Valaris]
  195. ACMD_FUNC(clearweather); // Dexity
  196. ACMD_FUNC(uptime); // by MC Cameri
  197. ACMD_FUNC(changesex); // by MC Cameri
  198. ACMD_FUNC(mute); // celest
  199. ACMD_FUNC(refresh); // by MC Cameri
  200. ACMD_FUNC(petid); // by MC Cameri
  201. ACMD_FUNC(identify); // by MC Cameri
  202. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  203. ACMD_FUNC(misceffect); // by MC Cameri
  204. ACMD_FUNC(mobsearch);
  205. ACMD_FUNC(cleanmap);
  206. ACMD_FUNC(npctalk);
  207. ACMD_FUNC(pettalk);
  208. ACMD_FUNC(users);
  209. ACMD_FUNC(autoloot); // Improved version imported from Freya.
  210. #ifndef TXT_ONLY
  211. ACMD_FUNC(checkmail); // [Valaris]
  212. ACMD_FUNC(listmail); // [Valaris]
  213. ACMD_FUNC(listnewmail); // [Valaris]
  214. ACMD_FUNC(readmail); // [Valaris]
  215. ACMD_FUNC(sendmail); // [Valaris]
  216. ACMD_FUNC(sendprioritymail); // [Valaris]
  217. ACMD_FUNC(deletemail); // [Valaris]
  218. ACMD_FUNC(refreshonline); // [Valaris]
  219. #endif /* TXT_ONLY */
  220. ACMD_FUNC(skilltree); // by MouseJstr
  221. ACMD_FUNC(marry); // by MouseJstr
  222. ACMD_FUNC(divorce); // by MouseJstr
  223. ACMD_FUNC(grind); // by MouseJstr
  224. ACMD_FUNC(grind2); // by MouseJstr
  225. #ifdef DMALLOC
  226. ACMD_FUNC(dmstart); // by MouseJstr
  227. ACMD_FUNC(dmtick); // by MouseJstr
  228. #endif
  229. ACMD_FUNC(jumptoid); // by Dino9021
  230. ACMD_FUNC(jumptoid2); // by Dino9021
  231. ACMD_FUNC(recallid); // by Dino9021
  232. ACMD_FUNC(recallid2); // by Dino9021
  233. ACMD_FUNC(kickid); // by Dino9021
  234. ACMD_FUNC(kickid2); // by Dino9021
  235. ACMD_FUNC(reviveid); // by Dino9021
  236. ACMD_FUNC(reviveid2); // by Dino9021
  237. ACMD_FUNC(killid); // by Dino9021
  238. ACMD_FUNC(killid2); // by Dino9021
  239. ACMD_FUNC(charkillableid); // by Dino9021
  240. ACMD_FUNC(charkillableid2); // by Dino9021
  241. ACMD_FUNC(sound);
  242. ACMD_FUNC(undisguiseall);
  243. ACMD_FUNC(disguiseall);
  244. ACMD_FUNC(changelook);
  245. ACMD_FUNC(mobinfo); //by Lupus
  246. ACMD_FUNC(exp); // by Skotlex
  247. ACMD_FUNC(adopt); // by Veider
  248. ACMD_FUNC(version); // by Ancyker
  249. ACMD_FUNC(mutearea); // by MouseJstr
  250. ACMD_FUNC(shuffle); // by MouseJstr
  251. ACMD_FUNC(rates); // by MouseJstr
  252. ACMD_FUNC(iteminfo); // Lupus
  253. ACMD_FUNC(mapflag); // Lupus
  254. ACMD_FUNC(me); //added by massdriller, code by lordalfa
  255. ACMD_FUNC(monsterignore); // [Valaris]
  256. ACMD_FUNC(fakename); //[Valaris]
  257. ACMD_FUNC(size); //[Valaris]
  258. ACMD_FUNC(showexp); //moved from charcommand [Kevin]
  259. ACMD_FUNC(showzeny);
  260. ACMD_FUNC(showdelay); //moved from charcommand [Kevin]
  261. ACMD_FUNC(autotrade);// durf
  262. ACMD_FUNC(changeleader);// [Skotlex]
  263. ACMD_FUNC(changegm);// durf
  264. // Duel [LuzZza]
  265. ACMD_FUNC(invite);
  266. ACMD_FUNC(duel);
  267. ACMD_FUNC(leave);
  268. ACMD_FUNC(accept);
  269. ACMD_FUNC(reject);
  270. ACMD_FUNC(away); // LuzZza
  271. ACMD_FUNC(main); // LuzZza
  272. ACMD_FUNC(clone); // [Valaris]
  273. /*==========================================
  274. *AtCommandInfo atcommand_info[]構造体の定義
  275. *------------------------------------------
  276. */
  277. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  278. // to set default level, read atcommand_athena.conf first please.
  279. static AtCommandInfo atcommand_info[] = {
  280. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  281. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  282. { AtCommand_Where, "@where", 1, atcommand_where },
  283. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  284. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  285. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  286. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  287. { AtCommand_Who, "@who", 20, atcommand_who },
  288. { AtCommand_Who, "@whois", 20, atcommand_who },
  289. { AtCommand_Who, "@w", 20, atcommand_who },
  290. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  291. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  292. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  293. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  294. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  295. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  296. { AtCommand_Save, "@save", 40, atcommand_save },
  297. { AtCommand_Load, "@return", 40, atcommand_load },
  298. { AtCommand_Load, "@load", 40, atcommand_load },
  299. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  300. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  301. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  302. { AtCommand_Option, "@option", 40, atcommand_option },
  303. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  304. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  305. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  306. { AtCommand_Die, "@die", 1, atcommand_die },
  307. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  308. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  309. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  310. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  311. { AtCommand_KamiC, "@kamic", 40, atcommand_kami }, //[LuzZza]
  312. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  313. { AtCommand_Item, "@item", 60, atcommand_item },
  314. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  315. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  316. { AtCommand_ItemCheck, "@itemcheck", 60, atcommand_itemcheck },
  317. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  318. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  319. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  320. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  321. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  322. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  323. { AtCommand_H, "@h", 20, atcommand_help },
  324. { AtCommand_Help, "@help", 20, atcommand_help },
  325. { AtCommand_H2, "@h2", 20, atcommand_help2 },
  326. { AtCommand_Help2, "@help2", 20, atcommand_help2 },
  327. { AtCommand_GM, "@gm", 100,atcommand_gm },
  328. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  329. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  330. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  331. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  332. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  333. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  334. { AtCommand_Model, "@model", 20, atcommand_model },
  335. { AtCommand_Go, "@go", 10, atcommand_go },
  336. { AtCommand_Spawn, "@monster", 50, atcommand_monster },
  337. { AtCommand_Spawn, "@spawn", 50, atcommand_monster },
  338. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  339. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  340. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  341. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  342. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  343. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  344. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  345. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  346. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  347. { AtCommand_Packet, "@packetmode", 99, atcommand_packet }, // debug function
  348. { AtCommand_WaterLevel, "@waterlevel", 99, atcommand_waterlevel }, // debug function
  349. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  350. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  351. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  352. { AtCommand_Strength, "@str", 60, atcommand_param },
  353. { AtCommand_Agility, "@agi", 60, atcommand_param },
  354. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  355. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  356. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  357. { AtCommand_Luck, "@luk", 60, atcommand_param },
  358. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  359. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  360. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  361. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  362. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  363. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  364. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  365. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  366. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  367. { AtCommand_Night, "@night", 80, atcommand_night },
  368. { AtCommand_Day, "@day", 80, atcommand_day },
  369. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  370. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  371. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  372. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  373. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  374. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  375. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  376. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  377. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  378. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  379. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  380. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  381. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  382. { AtCommand_Party, "@party", 1, atcommand_party },
  383. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  384. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  385. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  386. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  387. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  388. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  389. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  390. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  391. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  392. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  393. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  394. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  395. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  396. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  397. { AtCommand_ReloadAtcommand, "@reloadatcommand", 99, atcommand_reloadatcommand },
  398. { AtCommand_ReloadBattleConf, "@reloadbattleconf", 99, atcommand_reloadbattleconf },
  399. { AtCommand_ReloadStatusDB, "@reloadstatusdb", 99, atcommand_reloadstatusdb },
  400. { AtCommand_ReloadPcDB, "@reloadpcdb", 99, atcommand_reloadpcdb },
  401. { AtCommand_ReloadMOTD, "@reloadmotd", 99, atcommand_reloadmotd }, // [Valaris]
  402. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  403. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  404. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  405. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  406. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  407. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  408. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  409. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  410. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  411. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  412. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  413. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  414. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  415. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  416. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  417. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  418. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  419. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  420. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  421. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  422. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  423. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  424. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  425. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  426. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  427. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  428. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  429. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  430. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  431. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  432. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  433. { AtCommand_Shownpc, "@shownpc", 80, atcommand_shownpc }, // []
  434. { AtCommand_Hidenpc, "@hidenpc", 80, atcommand_hidenpc }, // []
  435. { AtCommand_Loadnpc, "@loadnpc", 80, atcommand_loadnpc }, // []
  436. { AtCommand_Unloadnpc, "@unloadnpc", 80, atcommand_unloadnpc }, // []
  437. { AtCommand_ServerTime, "@time", 1, atcommand_servertime }, // by Yor
  438. { AtCommand_ServerTime, "@date", 1, atcommand_servertime }, // by Yor
  439. { AtCommand_ServerTime, "@server_date", 1, atcommand_servertime }, // by Yor
  440. { AtCommand_ServerTime, "@serverdate", 1, atcommand_servertime }, // by Yor
  441. { AtCommand_ServerTime, "@server_time", 1, atcommand_servertime }, // by Yor
  442. { AtCommand_ServerTime, "@servertime", 1, atcommand_servertime }, // by Yor
  443. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  444. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  445. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  446. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  447. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  448. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  449. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  450. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  451. { AtCommand_EMail, "@email", 1, atcommand_email }, // by Yor
  452. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  453. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  454. { AtCommand_Follow, "@follow", 20, atcommand_follow }, // by MouseJstr
  455. { AtCommand_AddWarp, "@addwarp", 60, atcommand_addwarp }, // by MouseJstr
  456. { AtCommand_SkillOn, "@skillon", 80, atcommand_skillon }, // by MouseJstr
  457. { AtCommand_SkillOff, "@skilloff", 80, atcommand_skilloff }, // by MouseJstr
  458. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  459. { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
  460. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  461. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  462. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  463. { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
  464. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  465. { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
  466. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  467. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  468. { AtCommand_Rain, "@rain", 99, atcommand_rain },
  469. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  470. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  471. { AtCommand_Clouds, "@clouds", 99, atcommand_clouds },
  472. { AtCommand_Clouds2, "@clouds2", 99, atcommand_clouds2 },
  473. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  474. { AtCommand_Fireworks, "@fireworks", 99, atcommand_fireworks },
  475. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  476. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  477. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  478. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  479. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  480. { AtCommand_Send, "@send", 60, atcommand_send },
  481. { AtCommand_SetBattleFlag, "@setbattleflag", 99, atcommand_setbattleflag },
  482. { AtCommand_UnMute, "@unmute", 60, atcommand_unmute }, // [Valaris]
  483. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  484. { AtCommand_UpTime, "@uptime", 1, atcommand_uptime }, // by MC Cameri
  485. // { AtCommand_ChangeSex, "@changesex", 1, atcommand_changesex }, // by MC Cameri <- do we still need this? [Foruken]
  486. { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
  487. { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
  488. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  489. { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy", 40, atcommand_happyhappyjoyjoy }, // [Valaris]
  490. { AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
  491. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  492. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  493. { AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  494. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  495. { AtCommand_MobSearch, "@mobsearch", 10, atcommand_mobsearch },
  496. { AtCommand_CleanMap, "@cleanmap", 40, atcommand_cleanmap },
  497. { AtCommand_NpcTalk, "@npctalk", 20, atcommand_npctalk },
  498. { AtCommand_PetTalk, "@pettalk", 10, atcommand_pettalk },
  499. { AtCommand_Users, "@users", 40, atcommand_users },
  500. { AtCommand_ResetState, "/reset", 40, NULL },
  501. #ifndef TXT_ONLY // sql-only commands
  502. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  503. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  504. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  505. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  506. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  507. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  508. { AtCommand_SendPriorityMail, "@sendprioritymail", 80, atcommand_sendmail }, // [Valaris]
  509. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  510. #endif /* TXT_ONLY */
  511. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  512. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  513. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  514. { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
  515. { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
  516. #ifdef DMALLOC
  517. { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
  518. { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
  519. #endif
  520. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  521. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  522. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  523. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  524. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  525. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  526. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  527. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  528. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  529. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  530. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  531. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  532. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  533. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  534. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  535. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  536. { AtCommand_Sound, "@sound", 40, atcommand_sound },
  537. { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
  538. { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
  539. { AtCommand_ChangeLook, "@changelook", 99, atcommand_changelook },
  540. { AtCommand_AutoLoot, "@autoloot", 10, atcommand_autoloot }, // Upa-Kun
  541. { AtCommand_MobInfo, "@mobinfo", 1, atcommand_mobinfo }, // [Lupus]
  542. { AtCommand_MobInfo, "@monsterinfo", 1, atcommand_mobinfo }, // [Lupus]
  543. { AtCommand_MobInfo, "@mi", 1, atcommand_mobinfo }, // [Lupus]
  544. { AtCommand_Exp, "@exp", 0, atcommand_exp }, // [Skotlex]
  545. { AtCommand_Adopt, "@adopt", 40, atcommand_adopt }, // [Veider]
  546. { AtCommand_Version, "@version", 1, atcommand_version },
  547. { AtCommand_MuteArea, "@mutearea", 99, atcommand_mutearea }, // MouseJstr
  548. { AtCommand_MuteArea, "@stfu", 99, atcommand_mutearea }, // MouseJstr
  549. { AtCommand_Shuffle, "@shuffle", 40, atcommand_shuffle }, // MouseJstr
  550. { AtCommand_Rates, "@rates", 1, atcommand_rates }, // MouseJstr
  551. { AtCommand_ItemInfo, "@iteminfo", 1, atcommand_iteminfo }, // [Lupus]
  552. { AtCommand_ItemInfo, "@ii", 1, atcommand_iteminfo }, // [Lupus]
  553. { AtCommand_MapFlag, "@mapflag", 99, atcommand_mapflag }, // [Lupus]
  554. { AtCommand_Me, "@me", 20, atcommand_me }, //added by massdriller, code by lordalfa
  555. { AtCommand_MonsterIgnore, "@monsterignore", 99, atcommand_monsterignore }, // [Valaris]
  556. { AtCommand_FakeName, "@fakename", 20, atcommand_fakename }, // [Valaris]
  557. { AtCommand_Size, "@size", 20, atcommand_size },
  558. { AtCommand_ShowExp, "@showexp", 10, atcommand_showexp},
  559. { AtCommand_ShowZeny, "@showzeny", 10, atcommand_showzeny},
  560. { AtCommand_ShowDelay, "@showdelay", 1, atcommand_showdelay},
  561. { AtCommand_AutoTrade, "@autotrade", 10, atcommand_autotrade }, // durf
  562. { AtCommand_AutoTrade, "@at", 10, atcommand_autotrade },
  563. { AtCommand_ChangeGM, "@changegm", 10, atcommand_changegm }, // durf
  564. { AtCommand_ChangeLeader, "@changeleader", 10, atcommand_changeleader }, // durf
  565. { AtCommand_Invite, "@invite", 1, atcommand_invite }, // By LuzZza
  566. { AtCommand_Duel, "@duel", 1, atcommand_duel }, // By LuzZza
  567. { AtCommand_Leave, "@leave", 1, atcommand_leave }, // By LuzZza
  568. { AtCommand_Accept, "@accept", 1, atcommand_accept }, // By LuzZza
  569. { AtCommand_Reject, "@reject", 1, atcommand_reject }, // By LuzZza
  570. { AtCommand_Away, "@away", 1, atcommand_away }, // [LuzZza]
  571. { AtCommand_Away, "@aw", 1, atcommand_away }, // [LuzZza]
  572. { AtCommand_Main, "@main", 1, atcommand_main }, // [LuzZza]
  573. { AtCommand_Clone, "@clone", 50, atcommand_clone },
  574. { AtCommand_Clone, "@slaveclone", 50, atcommand_clone },
  575. { AtCommand_Clone, "@evilclone", 50, atcommand_clone }, // [Valaris]
  576. // add new commands before this line
  577. { AtCommand_Unknown, NULL, 1, NULL }
  578. };
  579. /*=========================================
  580. * Generic variables
  581. *-----------------------------------------
  582. */
  583. char atcmd_output[200];
  584. char atcmd_player_name[100];
  585. char atcmd_temp[100];
  586. /*==========================================
  587. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  588. *------------------------------------------
  589. */
  590. char *estr_lower(char *str)
  591. {
  592. int i;
  593. for (i=0; str[i]; i++)
  594. if ((str[i] >= 65) && (str[i] <= 90))
  595. str[i] += 32;
  596. return str;
  597. }
  598. // compare function for sorting high to lowest
  599. int hightolow_compare (const void * a, const void * b)
  600. {
  601. return ( *(int*)b - *(int*)a );
  602. }
  603. // compare function for sorting lowest to highest
  604. int lowtohigh_compare (const void * a, const void * b)
  605. {
  606. return ( *(int*)a - *(int*)b );
  607. }
  608. //-----------------------------------------------------------
  609. // Return the message string of the specified number by [Yor]
  610. //-----------------------------------------------------------
  611. char * msg_txt(int msg_number) {
  612. if (msg_number >= 0 && msg_number < MAX_MSG &&
  613. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  614. return msg_table[msg_number];
  615. return "??";
  616. }
  617. //-----------------------------------------------------------
  618. // Returns Players title (from msg_athena.conf) [Lupus]
  619. //-----------------------------------------------------------
  620. char * player_title_txt(int level) {
  621. if (level < battle_config.title_lvl1)
  622. return ""; //w/o any titles
  623. if (level >= battle_config.title_lvl8)
  624. sprintf(atcmd_temp, msg_table[332], level);
  625. else
  626. if (level >= battle_config.title_lvl7)
  627. sprintf(atcmd_temp, msg_table[331], level);
  628. else
  629. if (level >= battle_config.title_lvl6)
  630. sprintf(atcmd_temp, msg_table[330], level);
  631. else
  632. if (level >= battle_config.title_lvl5)
  633. sprintf(atcmd_temp, msg_table[329], level);
  634. else
  635. if (level >= battle_config.title_lvl4)
  636. sprintf(atcmd_temp, msg_table[328], level);
  637. else
  638. if (level >= battle_config.title_lvl3)
  639. sprintf(atcmd_temp, msg_table[327], level);
  640. else
  641. if (level >= battle_config.title_lvl2)
  642. sprintf(atcmd_temp, msg_table[326], level);
  643. else
  644. sprintf(atcmd_temp, msg_table[325], level); //lvl1
  645. return atcmd_temp;
  646. }
  647. //------------------------------------------------------------
  648. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  649. //------------------------------------------------------------
  650. int e_mail_check(char *email) {
  651. char ch;
  652. char* last_arobas;
  653. // athena limits
  654. if (strlen(email) < 3 || strlen(email) > 39)
  655. return 0;
  656. // part of RFC limits (official reference of e-mail description)
  657. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  658. return 0;
  659. if (email[strlen(email)-1] == '.')
  660. return 0;
  661. last_arobas = strrchr(email, '@');
  662. if (strstr(last_arobas, "@.") != NULL ||
  663. strstr(last_arobas, "..") != NULL)
  664. return 0;
  665. for(ch = 1; ch < 32; ch++) {
  666. if (strchr(last_arobas, ch) != NULL) {
  667. return 0;
  668. break;
  669. }
  670. }
  671. if (strchr(last_arobas, ' ') != NULL ||
  672. strchr(last_arobas, ';') != NULL)
  673. return 0;
  674. // all correct
  675. return 1;
  676. }
  677. /*==========================================
  678. * get_atcommand_level @コマンドの必要レベルを取得
  679. *------------------------------------------
  680. */
  681. int get_atcommand_level(const AtCommandType type) {
  682. int i;
  683. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  684. if (atcommand_info[i].type == type)
  685. return atcommand_info[i].level;
  686. return 100; // 100: command can not be used
  687. }
  688. /*==========================================
  689. *is_atcommand @コマンドに存在するかどうか確認する
  690. *------------------------------------------
  691. */
  692. AtCommandType
  693. is_atcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
  694. const char* str = message;
  695. int s_flag = 0;
  696. AtCommandInfo info;
  697. AtCommandType type;
  698. nullpo_retr(AtCommand_None, sd);
  699. if (!battle_config.allow_atcommand_when_mute &&
  700. sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1) {
  701. return AtCommand_Unknown;
  702. }
  703. if (!message || !*message)
  704. return AtCommand_None;
  705. memset(&info, 0, sizeof(info));
  706. str += strlen(sd->status.name);
  707. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  708. if (*str == ':')
  709. s_flag = 1;
  710. str++;
  711. }
  712. if (!*str)
  713. return AtCommand_None;
  714. type = atcommand(sd, gmlvl > 0 ? gmlvl : pc_isGM(sd), str, &info);
  715. if (type != AtCommand_None) {
  716. char command[100];
  717. const char* p = str;
  718. memset(command, '\0', sizeof(command));
  719. memset(atcmd_output, '\0', sizeof(atcmd_output));
  720. while (*p && !isspace(*p))
  721. p++;
  722. if (p - str >= sizeof(command)) // too long
  723. return AtCommand_Unknown;
  724. strncpy(command, str, p - str);
  725. while (isspace(*p))
  726. p++;
  727. if (type == AtCommand_Unknown || info.proc == NULL) {
  728. sprintf(atcmd_output, msg_table[153], command); // %s is Unknown Command.
  729. clif_displaymessage(fd, atcmd_output);
  730. } else {
  731. if (info.proc(fd, sd, command, p) != 0) {
  732. // Command can not be executed
  733. sprintf(atcmd_output, msg_table[154], command); // %s failed.
  734. clif_displaymessage(fd, atcmd_output);
  735. }
  736. }
  737. return info.type;
  738. }
  739. return AtCommand_None;
  740. }
  741. /*==========================================
  742. *
  743. *------------------------------------------
  744. */
  745. AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info) {
  746. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  747. if (!info)
  748. return AtCommand_None;
  749. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  750. return AtCommand_None;
  751. if (!p || !*p) {
  752. ShowError("at command message is empty\n");
  753. return AtCommand_None;
  754. }
  755. if (*p == command_symbol) { // check first char.
  756. char command[101];
  757. int i = 0;
  758. memset(info, 0, sizeof(AtCommandInfo));
  759. sscanf(p, "%100s", command);
  760. command[sizeof(command)-1] = '\0';
  761. while (atcommand_info[i].type != AtCommand_Unknown) {
  762. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  763. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  764. break;
  765. }
  766. i++;
  767. }
  768. if (atcommand_info[i].type == AtCommand_Unknown) {
  769. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  770. if (level == 0)
  771. return AtCommand_None;
  772. else
  773. return AtCommand_Unknown;
  774. } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
  775. log_atcommand(sd, message);
  776. }
  777. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  778. } else {
  779. return AtCommand_None;
  780. }
  781. return info->type;
  782. }
  783. /*==========================================
  784. * Read Message Data
  785. *------------------------------------------
  786. */
  787. int msg_config_read(const char *cfgName) {
  788. int msg_number;
  789. char line[1024], w1[1024], w2[1024];
  790. FILE *fp;
  791. static int called = 1;
  792. if ((fp = fopen(cfgName, "r")) == NULL) {
  793. ShowError("Messages file not found: %s\n", cfgName);
  794. return 1;
  795. }
  796. if ((--called) == 0)
  797. memset(&msg_table[0], 0, sizeof(msg_table[0]) * MAX_MSG);
  798. while(fgets(line, sizeof(line)-1, fp)) {
  799. if (line[0] == '/' && line[1] == '/')
  800. continue;
  801. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  802. if (strcmpi(w1, "import") == 0) {
  803. msg_config_read(w2);
  804. } else {
  805. msg_number = atoi(w1);
  806. if (msg_number >= 0 && msg_number < MAX_MSG) {
  807. if (msg_table[msg_number] != NULL)
  808. aFree(msg_table[msg_number]);
  809. msg_table[msg_number] = (char *)aCalloc(strlen(w2) + 1, sizeof (char));
  810. strcpy(msg_table[msg_number],w2);
  811. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  812. }
  813. }
  814. }
  815. }
  816. fclose(fp);
  817. return 0;
  818. }
  819. /*==========================================
  820. * Cleanup Message Data
  821. *------------------------------------------
  822. */
  823. void do_final_msg (void) {
  824. int i;
  825. for (i = 0; i < MAX_MSG; i++)
  826. aFree(msg_table[i]);
  827. return;
  828. }
  829. /*==========================================
  830. *
  831. *------------------------------------------
  832. */
  833. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  834. int i;
  835. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  836. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  837. return &atcommand_info[i];
  838. return NULL;
  839. }
  840. /*==========================================
  841. *
  842. *------------------------------------------
  843. */
  844. int atcommand_config_read(const char *cfgName) {
  845. char line[1024], w1[1024], w2[1024];
  846. AtCommandInfo* p;
  847. FILE* fp;
  848. if ((fp = fopen(cfgName, "r")) == NULL) {
  849. ShowError("At commands configuration file not found: %s\n", cfgName);
  850. return 1;
  851. }
  852. while (fgets(line, sizeof(line)-1, fp)) {
  853. if (line[0] == '/' && line[1] == '/')
  854. continue;
  855. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  856. continue;
  857. p = get_atcommandinfo_byname(w1);
  858. if (p != NULL) {
  859. p->level = atoi(w2);
  860. if (p->level > 100)
  861. p->level = 100;
  862. else if (p->level < 0)
  863. p->level = 0;
  864. }
  865. if (strcmpi(w1, "import") == 0)
  866. atcommand_config_read(w2);
  867. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  868. w2[0] != '/' && // symbol of standard ragnarok GM commands
  869. w2[0] != '%' && // symbol of party chat speaking
  870. w2[0] != '$' && // symbol of guild chat
  871. w2[0] != '#') // symbol of charcommand
  872. command_symbol = w2[0];
  873. }
  874. fclose(fp);
  875. return 0;
  876. }
  877. /*==========================================
  878. * Duel organizing functions [LuzZza]
  879. *------------------------------------------
  880. */
  881. void duel_msg_foreach_sameduel_wos(
  882. const unsigned int did, struct map_session_data* sd, char *output)
  883. {
  884. int i;
  885. struct map_session_data* msg_sd;
  886. for(i=0; i<fd_max; i++)
  887. if(session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  888. && msg_sd->state.auth && msg_sd->duel_group == did && msg_sd != sd)
  889. clif_disp_onlyself(msg_sd, output, strlen(output));
  890. return;
  891. }
  892. void duel_savetime(struct map_session_data* sd) {
  893. time_t timer;
  894. struct tm *t;
  895. time(&timer);
  896. t = localtime(&timer);
  897. pc_setglobalreg(sd, "PC_LAST_DUEL_TIME",
  898. t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min);
  899. return;
  900. }
  901. int duel_checktime(struct map_session_data* sd) {
  902. int diff;
  903. time_t timer;
  904. struct tm *t;
  905. time(&timer);
  906. t = localtime(&timer);
  907. diff = t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min -
  908. pc_readglobalreg(sd, "PC_LAST_DUEL_TIME");
  909. return !(diff >= 0 && diff < battle_config.duel_time_interval);
  910. }
  911. int duel_showinfo(
  912. const unsigned int did, struct map_session_data* sd)
  913. {
  914. int i, p=0;
  915. char output[256];
  916. struct map_session_data* msg_sd;
  917. if(duel_list[did].max_players_limit > 0)
  918. sprintf(output, msg_txt(370), //" -- Duels: %d/%d, Members: %d/%d, Max players: %d --"
  919. did, duel_count,
  920. duel_list[did].members_count,
  921. duel_list[did].members_count + duel_list[did].invites_count,
  922. duel_list[did].max_players_limit);
  923. else
  924. sprintf(output, msg_txt(371), //" -- Duels: %d/%d, Members: %d/%d --"
  925. did, duel_count,
  926. duel_list[did].members_count,
  927. duel_list[did].members_count + duel_list[did].invites_count);
  928. clif_disp_onlyself(sd, output, strlen(output));
  929. for(i=0; i<fd_max; i++)
  930. if (session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  931. && msg_sd->state.auth && msg_sd->duel_group == did) {
  932. sprintf(output, " %d. %s", ++p, (unsigned char *) msg_sd->status.name);
  933. clif_disp_onlyself(sd, output, strlen(output));
  934. }
  935. return 0;
  936. }
  937. int duel_create(
  938. struct map_session_data* sd, const unsigned int maxpl)
  939. {
  940. int i=1;
  941. char output[256];
  942. while(duel_list[i].members_count > 0 && i < MAX_DUEL) i++;
  943. if(i == MAX_DUEL) return 0;
  944. duel_count++;
  945. sd->duel_group = i;
  946. duel_list[i].members_count++;
  947. duel_list[i].invites_count = 0;
  948. duel_list[i].max_players_limit = maxpl;
  949. strcpy(output, msg_txt(372)); // " -- Duel has been created (@invite/@leave) --"
  950. clif_disp_onlyself(sd, output, strlen(output));
  951. clif_set0199(sd->fd, 1);
  952. //clif_misceffect2(&sd->bl, 159);
  953. return i;
  954. }
  955. int duel_invite(
  956. const unsigned int did, struct map_session_data* sd,
  957. struct map_session_data* target_sd)
  958. {
  959. char output[256];
  960. sprintf(output, msg_txt(373), // " -- Player %s invites %s to duel --"
  961. (unsigned char *)sd->status.name, (unsigned char *)target_sd->status.name);
  962. duel_msg_foreach_sameduel_wos(did, sd, output);
  963. target_sd->duel_invite = did;
  964. duel_list[did].invites_count++;
  965. // "Blue -- Player %s invites you to PVP duel (@accept/@reject) --"
  966. sprintf(output, msg_txt(374), (unsigned char *)sd->status.name);
  967. clif_GMmessage((struct block_list *)target_sd, output, strlen(output)+1, 3);
  968. return 0;
  969. }
  970. int duel_leave(
  971. const unsigned int did, struct map_session_data* sd)
  972. {
  973. int i;
  974. char output[256];
  975. struct map_session_data* msg_sd;
  976. // " <- Player %s has left duel --"
  977. sprintf(output, msg_txt(375), (unsigned char *)sd->status.name);
  978. duel_msg_foreach_sameduel_wos(did, sd, output);
  979. duel_list[did].members_count--;
  980. if(duel_list[did].members_count == 0) {
  981. for (i=0; i<fd_max; i++)
  982. if (session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  983. && msg_sd->state.auth && msg_sd->duel_invite == did && msg_sd != sd) {
  984. msg_sd->duel_invite = 0;
  985. }
  986. duel_count--;
  987. }
  988. sd->duel_group = 0;
  989. duel_savetime(sd);
  990. clif_set0199(sd->fd, 0);
  991. return 0;
  992. }
  993. int duel_accept(
  994. const unsigned int did, struct map_session_data* sd)
  995. {
  996. char output[256];
  997. // " -> Player %s has accepted duel --"
  998. sprintf(output, msg_txt(376), (unsigned char *)sd->status.name);
  999. duel_msg_foreach_sameduel_wos(did, sd, output);
  1000. duel_list[did].members_count++;
  1001. sd->duel_group = sd->duel_invite;
  1002. duel_list[did].invites_count--;
  1003. sd->duel_invite = 0;
  1004. clif_set0199(sd->fd, 1);
  1005. //clif_misceffect2(&sd->bl, 159);
  1006. return 0;
  1007. }
  1008. int duel_reject(
  1009. const unsigned int did, struct map_session_data* sd)
  1010. {
  1011. char output[256];
  1012. // " -- Player %s has rejected duel --"
  1013. sprintf(output, msg_txt(377), (unsigned char *)sd->status.name);
  1014. duel_msg_foreach_sameduel_wos(did, sd, output);
  1015. duel_list[did].invites_count--;
  1016. sd->duel_invite = 0;
  1017. return 0;
  1018. }
  1019. /*==========================================
  1020. // @ command processing functions
  1021. *------------------------------------------
  1022. */
  1023. /*==========================================
  1024. * @send (used for testing packet sends from the client)
  1025. *------------------------------------------
  1026. */
  1027. int atcommand_send(
  1028. const int fd, struct map_session_data* sd,
  1029. const char* command, const char* message)
  1030. {
  1031. int i,type=0;
  1032. int info[20];
  1033. if (!message || !*message || sscanf(message, "%x %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", &type, &info[1], &info[2], &info[3], &info[4], &info[5], &info[6], &info[7], &info[8], &info[9], &info[10], &info[11], &info[12], &info[13], &info[14], &info[15], &info[16], &info[17], &info[18], &info[19], &info[20]) < 1) {
  1034. clif_displaymessage(fd, "Please enter a packet number, and - if required - up to 20 additional values.");
  1035. return -1;
  1036. }
  1037. if (type > 0 && type < MAX_PACKET_DB) {
  1038. switch (type)
  1039. {
  1040. case 0x209: {
  1041. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1042. WFIFOW(fd,0) = 0x209;
  1043. WFIFOW(fd,2) = 2;
  1044. memcpy(WFIFOP(fd, 12), sd->status.name, NAME_LENGTH);
  1045. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1046. break;
  1047. }
  1048. case 0x1b1:
  1049. case 0x1c2:
  1050. //case xxx:
  1051. // add others here
  1052. // break;
  1053. default: {
  1054. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1055. WFIFOW(fd,0) = type;
  1056. for(i=1;i<=sizeof(info);i++)
  1057. if(info[i])
  1058. WFIFOW(fd,i) = info[i];
  1059. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1060. break;
  1061. }
  1062. }
  1063. sprintf (atcmd_output, msg_table[258], type, type);
  1064. clif_displaymessage(fd, atcmd_output);
  1065. } else {
  1066. clif_displaymessage(fd, msg_table[259]);
  1067. }
  1068. return 0;
  1069. }
  1070. // @rura
  1071. /*==========================================
  1072. *
  1073. *------------------------------------------
  1074. */
  1075. int atcommand_rura(
  1076. const int fd, struct map_session_data* sd,
  1077. const char* command, const char* message)
  1078. {
  1079. char map_name[MAP_NAME_LENGTH];
  1080. unsigned short mapindex;
  1081. int x = 0, y = 0;
  1082. int m = -1;
  1083. nullpo_retr(-1, sd);
  1084. memset(map_name, '\0', sizeof(map_name));
  1085. if (!message || !*message || sscanf(message, "%15s %d %d", map_name, &x, &y) < 1) {
  1086. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  1087. return -1;
  1088. }
  1089. if (x <= 0)
  1090. x = rand() % 399 + 1;
  1091. if (y <= 0)
  1092. y = rand() % 399 + 1;
  1093. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1094. strcat(map_name, ".gat");
  1095. mapindex = mapindex_name2id(map_name);
  1096. if (mapindex)
  1097. m = map_mapindex2mapid(mapindex);
  1098. if (!mapindex || m < 0) {
  1099. clif_displaymessage(fd, msg_table[1]); // Map not found.
  1100. return -1;
  1101. }
  1102. if (x > 0 && x < 400 && y > 0 && y < 400) {
  1103. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1104. clif_displaymessage(fd, msg_table[247]);
  1105. return -1;
  1106. }
  1107. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1108. clif_displaymessage(fd, msg_table[248]);
  1109. return -1;
  1110. }
  1111. if (pc_setpos(sd, mapindex, x, y, 3) == 0)
  1112. clif_displaymessage(fd, msg_table[0]); // Warped.
  1113. else {
  1114. clif_displaymessage(fd, msg_table[1]); // Map not found.
  1115. return -1;
  1116. }
  1117. } else {
  1118. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  1119. return -1;
  1120. }
  1121. return 0;
  1122. }
  1123. /*==========================================
  1124. * Displays where a character is. Corrected version by Silent. [Skotlex]
  1125. *------------------------------------------
  1126. */
  1127. int atcommand_where(
  1128. const int fd, struct map_session_data* sd,
  1129. const char* command, const char* message)
  1130. {
  1131. struct map_session_data *pl_sd = NULL;
  1132. int GM_level, pl_GM_level;
  1133. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1134. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  1135. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  1136. return -1;
  1137. }
  1138. pl_sd = map_nick2sd(atcmd_player_name);
  1139. nullpo_retr(-1, sd);
  1140. if (pl_sd == NULL)
  1141. return -1;
  1142. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
  1143. return -1;
  1144. GM_level = pc_isGM(sd);//also hide gms depending on settings in battle_athena.conf, show if they are aid [Kevin]
  1145. pl_GM_level = pc_isGM(pl_sd);
  1146. if (battle_config.hide_GM_session) {
  1147. if(!(GM_level >= pl_GM_level)) {
  1148. if (!(battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid)) {
  1149. return -1;
  1150. }
  1151. }
  1152. }
  1153. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d",
  1154. atcmd_player_name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1155. clif_displaymessage(fd, atcmd_output);
  1156. return 0;
  1157. }
  1158. /*==========================================
  1159. *
  1160. *------------------------------------------
  1161. */
  1162. int atcommand_jumpto(
  1163. const int fd, struct map_session_data* sd,
  1164. const char* command, const char* message)
  1165. {
  1166. struct map_session_data *pl_sd = NULL;
  1167. nullpo_retr(-1, sd);
  1168. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  1169. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1170. return -1;
  1171. }
  1172. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1173. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  1174. return -1;
  1175. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) //Yourself mate? Tsk tsk tsk.
  1176. return -1;
  1177. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  1178. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1179. clif_displaymessage(fd, msg_table[247]);
  1180. return -1;
  1181. }
  1182. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1183. clif_displaymessage(fd, msg_table[248]);
  1184. return -1;
  1185. }
  1186. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  1187. sprintf(atcmd_output, msg_table[4], atcmd_player_name); // Jump to %s
  1188. clif_displaymessage(fd, atcmd_output);
  1189. } else {
  1190. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1191. return -1;
  1192. }
  1193. return 0;
  1194. }
  1195. /*==========================================
  1196. *
  1197. *------------------------------------------
  1198. */
  1199. int atcommand_jump(
  1200. const int fd, struct map_session_data* sd,
  1201. const char* command, const char* message)
  1202. {
  1203. int x = 0, y = 0;
  1204. nullpo_retr(-1, sd);
  1205. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1206. sscanf(message, "%d %d", &x, &y);
  1207. if (x <= 0) //If coordinates are 'wrong', random jump.
  1208. x = -1;
  1209. if (y <= 0)
  1210. y = -1;
  1211. if (sd->bl.m >= 0 && (map[sd->bl.m].flag.nowarp || map[sd->bl.m].flag.nowarpto) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1212. clif_displaymessage(fd, msg_table[248]);
  1213. return -1;
  1214. }
  1215. pc_setpos(sd, sd->mapindex, x, y, 3);
  1216. sprintf(atcmd_output, msg_table[5], sd->bl.x, sd->bl.y); // Jump to %d %d
  1217. clif_displaymessage(fd, atcmd_output);
  1218. return 0;
  1219. }
  1220. /*==========================================
  1221. * @who3 = Player name, his location
  1222. *------------------------------------------
  1223. */
  1224. int atcommand_who3(
  1225. const int fd, struct map_session_data* sd,
  1226. const char* command, const char* message)
  1227. {
  1228. char temp0[100];
  1229. struct map_session_data *pl_sd, **pl_allsd;
  1230. int i, j, count, users;
  1231. int pl_GM_level, GM_level;
  1232. char match_text[100];
  1233. char player_name[NAME_LENGTH];
  1234. nullpo_retr(-1, sd);
  1235. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1236. memset(match_text, '\0', sizeof(match_text));
  1237. memset(player_name, '\0', sizeof(player_name));
  1238. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1239. strcpy(match_text, "");
  1240. for (j = 0; match_text[j]; j++)
  1241. match_text[j] = tolower(match_text[j]);
  1242. count = 0;
  1243. GM_level = pc_isGM(sd);
  1244. pl_allsd = map_getallusers(&users);
  1245. for (i = 0; i < users; i++) {
  1246. if ((pl_sd = pl_allsd[i])) {
  1247. pl_GM_level = pc_isGM(pl_sd);
  1248. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1249. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1250. for (j = 0; player_name[j]; j++)
  1251. player_name[j] = tolower(player_name[j]);
  1252. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1253. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  1254. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  1255. } else {
  1256. atcmd_output[0]=0;
  1257. }
  1258. //Player name
  1259. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  1260. strcat(atcmd_output,temp0);
  1261. //Player title, if exists
  1262. if (pl_GM_level > 0) {
  1263. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1264. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1265. strcat(atcmd_output,temp0);
  1266. }
  1267. //Players Location: map x y
  1268. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1269. strcat(atcmd_output,temp0);
  1270. clif_displaymessage(fd, atcmd_output);
  1271. count++;
  1272. }
  1273. }
  1274. }
  1275. }
  1276. if (count == 0)
  1277. clif_displaymessage(fd, msg_table[28]); // No player found.
  1278. else if (count == 1)
  1279. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1280. else {
  1281. sprintf(atcmd_output, msg_table[30], count); // %d players found.
  1282. clif_displaymessage(fd, atcmd_output);
  1283. }
  1284. return 0;
  1285. }
  1286. /*==========================================
  1287. * Player name, BLevel, Job,
  1288. *------------------------------------------
  1289. */
  1290. int atcommand_who2(
  1291. const int fd, struct map_session_data* sd,
  1292. const char* command, const char* message)
  1293. {
  1294. char temp0[100];
  1295. struct map_session_data *pl_sd, **pl_allsd;
  1296. int i, j, count, users;
  1297. int pl_GM_level, GM_level;
  1298. char match_text[100];
  1299. char player_name[NAME_LENGTH];
  1300. nullpo_retr(-1, sd);
  1301. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1302. memset(match_text, '\0', sizeof(match_text));
  1303. memset(player_name, '\0', sizeof(player_name));
  1304. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1305. strcpy(match_text, "");
  1306. for (j = 0; match_text[j]; j++)
  1307. match_text[j] = tolower(match_text[j]);
  1308. count = 0;
  1309. GM_level = pc_isGM(sd);
  1310. pl_allsd = map_getallusers(&users);
  1311. for (i = 0; i < users; i++) {
  1312. if ((pl_sd = pl_allsd[i])) {
  1313. pl_GM_level = pc_isGM(pl_sd);
  1314. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1315. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1316. for (j = 0; player_name[j]; j++)
  1317. player_name[j] = tolower(player_name[j]);
  1318. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1319. //Players Name
  1320. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1321. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1322. //Player title, if exists
  1323. if (pl_GM_level > 0) {
  1324. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1325. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1326. strcat(atcmd_output,temp0);
  1327. }
  1328. //Players Base Level / Job name
  1329. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1330. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1331. strcat(atcmd_output,temp0);
  1332. clif_displaymessage(fd, atcmd_output);
  1333. count++;
  1334. }
  1335. }
  1336. }
  1337. }
  1338. if (count == 0)
  1339. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1340. else if (count == 1)
  1341. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1342. else {
  1343. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1344. clif_displaymessage(fd, atcmd_output);
  1345. }
  1346. return 0;
  1347. }
  1348. /*==========================================
  1349. * Player name, Playrs Party / Guild name
  1350. *------------------------------------------
  1351. */
  1352. int atcommand_who(
  1353. const int fd, struct map_session_data* sd,
  1354. const char* command, const char* message)
  1355. {
  1356. char temp0[100];
  1357. struct map_session_data *pl_sd, **pl_allsd;
  1358. int i, j, count, users;
  1359. int pl_GM_level, GM_level;
  1360. char match_text[100];
  1361. char player_name[NAME_LENGTH];
  1362. struct guild *g;
  1363. struct party *p;
  1364. nullpo_retr(-1, sd);
  1365. memset(temp0, '\0', sizeof(temp0));
  1366. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1367. memset(match_text, '\0', sizeof(match_text));
  1368. memset(player_name, '\0', sizeof(player_name));
  1369. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1370. strcpy(match_text, "");
  1371. for (j = 0; match_text[j]; j++)
  1372. match_text[j] = tolower(match_text[j]);
  1373. count = 0;
  1374. GM_level = pc_isGM(sd);
  1375. pl_allsd = map_getallusers(&users);
  1376. for (i = 0; i < users; i++) {
  1377. if ((pl_sd = pl_allsd[i])) {
  1378. pl_GM_level = pc_isGM(pl_sd);
  1379. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1380. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1381. for (j = 0; player_name[j]; j++)
  1382. player_name[j] = tolower(player_name[j]);
  1383. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1384. g = guild_search(pl_sd->status.guild_id);
  1385. p = party_search(pl_sd->status.party_id);
  1386. //Players Name
  1387. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1388. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1389. //Player title, if exists
  1390. if (pl_GM_level > 0) {
  1391. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1392. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1393. strcat(atcmd_output,temp0);
  1394. }
  1395. //Players Party if exists
  1396. if (p != NULL) {
  1397. //sprintf(temp0," | Party: '%s'", p->name);
  1398. sprintf(temp0, msg_txt(335), p->name);
  1399. strcat(atcmd_output,temp0);
  1400. }
  1401. //Players Guild if exists
  1402. if (g != NULL) {
  1403. //sprintf(temp0," | Guild: '%s'", g->name);
  1404. sprintf(temp0, msg_txt(336), g->name);
  1405. strcat(atcmd_output,temp0);
  1406. }
  1407. clif_displaymessage(fd, atcmd_output);
  1408. count++;
  1409. }
  1410. }
  1411. }
  1412. }
  1413. if (count == 0)
  1414. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1415. else if (count == 1)
  1416. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1417. else {
  1418. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1419. clif_displaymessage(fd, atcmd_output);
  1420. }
  1421. return 0;
  1422. }
  1423. /*==========================================
  1424. *
  1425. *------------------------------------------
  1426. */
  1427. int atcommand_whomap3(
  1428. const int fd, struct map_session_data* sd,
  1429. const char* command, const char* message)
  1430. {
  1431. struct map_session_data *pl_sd, **pl_allsd;
  1432. int i, count, users;
  1433. int pl_GM_level, GM_level;
  1434. int map_id;
  1435. char map_name[MAP_NAME_LENGTH];
  1436. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1437. memset(map_name, '\0', sizeof(map_name));
  1438. if (!message || !*message)
  1439. map_id = sd->bl.m;
  1440. else {
  1441. sscanf(message, "%15s", map_name);
  1442. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1443. strcat(map_name, ".gat");
  1444. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1445. map_id = sd->bl.m;
  1446. }
  1447. count = 0;
  1448. GM_level = pc_isGM(sd);
  1449. pl_allsd = map_getallusers(&users);
  1450. for (i = 0; i < users; i++) {
  1451. if ((pl_sd = pl_allsd[i])) {
  1452. pl_GM_level = pc_isGM(pl_sd);
  1453. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1454. if (pl_sd->bl.m == map_id) {
  1455. if (pl_GM_level > 0)
  1456. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1457. else
  1458. sprintf(atcmd_output, "Name: %s | Location: %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1459. clif_displaymessage(fd, atcmd_output);
  1460. count++;
  1461. }
  1462. }
  1463. }
  1464. }
  1465. if (count == 0)
  1466. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1467. else if (count == 1)
  1468. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1469. else {
  1470. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1471. }
  1472. clif_displaymessage(fd, atcmd_output);
  1473. return 0;
  1474. }
  1475. /*==========================================
  1476. *
  1477. *------------------------------------------
  1478. */
  1479. int atcommand_whomap2(
  1480. const int fd, struct map_session_data* sd,
  1481. const char* command, const char* message)
  1482. {
  1483. struct map_session_data *pl_sd, **pl_allsd;
  1484. int i, count, users;
  1485. int pl_GM_level, GM_level;
  1486. int map_id = 0;
  1487. char map_name[MAP_NAME_LENGTH];
  1488. nullpo_retr(-1, sd);
  1489. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1490. memset(map_name, '\0', sizeof(map_name));
  1491. if (!message || !*message)
  1492. map_id = sd->bl.m;
  1493. else {
  1494. sscanf(message, "%15s", map_name);
  1495. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1496. strcat(map_name, ".gat");
  1497. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1498. map_id = sd->bl.m;
  1499. }
  1500. count = 0;
  1501. GM_level = pc_isGM(sd);
  1502. pl_allsd = map_getallusers(&users);
  1503. for (i = 0; i < users; i++) {
  1504. if ((pl_sd = pl_allsd[i])) {
  1505. pl_GM_level = pc_isGM(pl_sd);
  1506. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1507. if (pl_sd->bl.m == map_id) {
  1508. if (pl_GM_level > 0)
  1509. sprintf(atcmd_output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1510. else
  1511. sprintf(atcmd_output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1512. clif_displaymessage(fd, atcmd_output);
  1513. count++;
  1514. }
  1515. }
  1516. }
  1517. }
  1518. if (count == 0)
  1519. sprintf(atcmd_output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1520. else if (count == 1)
  1521. sprintf(atcmd_output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1522. else {
  1523. sprintf(atcmd_output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1524. }
  1525. clif_displaymessage(fd, atcmd_output);
  1526. return 0;
  1527. }
  1528. /*==========================================
  1529. *
  1530. *------------------------------------------
  1531. */
  1532. int atcommand_whomap(
  1533. const int fd, struct map_session_data* sd,
  1534. const char* command, const char* message)
  1535. {
  1536. char temp0[100];
  1537. char temp1[100];
  1538. struct map_session_data *pl_sd, **pl_allsd;
  1539. int i, count, users;
  1540. int pl_GM_level, GM_level;
  1541. int map_id = 0;
  1542. char map_name[MAP_NAME_LENGTH];
  1543. struct guild *g;
  1544. struct party *p;
  1545. nullpo_retr(-1, sd);
  1546. memset(temp0, '\0', sizeof(temp0));
  1547. memset(temp1, '\0', sizeof(temp1));
  1548. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1549. memset(map_name, '\0', sizeof(map_name));
  1550. if (!message || !*message)
  1551. map_id = sd->bl.m;
  1552. else {
  1553. sscanf(message, "%15s", map_name);
  1554. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1555. strcat(map_name, ".gat");
  1556. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1557. map_id = sd->bl.m;
  1558. }
  1559. count = 0;
  1560. GM_level = pc_isGM(sd);
  1561. pl_allsd = map_getallusers(&users);
  1562. for (i = 0; i < users; i++) {
  1563. if ((pl_sd = pl_allsd[i])) {
  1564. pl_GM_level = pc_isGM(pl_sd);
  1565. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1566. if (pl_sd->bl.m == map_id) {
  1567. g = guild_search(pl_sd->status.guild_id);
  1568. if (g == NULL)
  1569. sprintf(temp1, "None");
  1570. else
  1571. sprintf(temp1, "%s", g->name);
  1572. p = party_search(pl_sd->status.party_id);
  1573. if (p == NULL)
  1574. sprintf(temp0, "None");
  1575. else
  1576. sprintf(temp0, "%s", p->name);
  1577. if (pl_GM_level > 0)
  1578. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1579. else
  1580. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1581. clif_displaymessage(fd, atcmd_output);
  1582. count++;
  1583. }
  1584. }
  1585. }
  1586. }
  1587. if (count == 0)
  1588. sprintf(atcmd_output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1589. else if (count == 1)
  1590. sprintf(atcmd_output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1591. else {
  1592. sprintf(atcmd_output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1593. }
  1594. clif_displaymessage(fd, atcmd_output);
  1595. return 0;
  1596. }
  1597. /*==========================================
  1598. *
  1599. *------------------------------------------
  1600. */
  1601. int atcommand_whogm(
  1602. const int fd, struct map_session_data* sd,
  1603. const char* command, const char* message)
  1604. {
  1605. char temp0[100];
  1606. char temp1[100];
  1607. struct map_session_data *pl_sd, **pl_allsd;
  1608. int i, j, count, users;
  1609. int pl_GM_level, GM_level;
  1610. char match_text[100];
  1611. char player_name[NAME_LENGTH];
  1612. struct guild *g;
  1613. struct party *p;
  1614. nullpo_retr(-1, sd);
  1615. memset(temp0, '\0', sizeof(temp0));
  1616. memset(temp1, '\0', sizeof(temp1));
  1617. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1618. memset(match_text, '\0', sizeof(match_text));
  1619. memset(player_name, '\0', sizeof(player_name));
  1620. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1621. strcpy(match_text, "");
  1622. for (j = 0; match_text[j]; j++)
  1623. match_text[j] = tolower(match_text[j]);
  1624. count = 0;
  1625. GM_level = pc_isGM(sd);
  1626. pl_allsd = map_getallusers(&users);
  1627. for (i = 0; i < users; i++) {
  1628. if ((pl_sd = pl_allsd[i])) {
  1629. pl_GM_level = pc_isGM(pl_sd);
  1630. if (pl_GM_level > 0) {
  1631. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1632. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1633. for (j = 0; player_name[j]; j++)
  1634. player_name[j] = tolower(player_name[j]);
  1635. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1636. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1637. clif_displaymessage(fd, atcmd_output);
  1638. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1639. clif_displaymessage(fd, atcmd_output);
  1640. g = guild_search(pl_sd->status.guild_id);
  1641. if (g == NULL)
  1642. sprintf(temp1, "None");
  1643. else
  1644. sprintf(temp1, "%s", g->name);
  1645. p = party_search(pl_sd->status.party_id);
  1646. if (p == NULL)
  1647. sprintf(temp0, "None");
  1648. else
  1649. sprintf(temp0, "%s", p->name);
  1650. sprintf(atcmd_output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1651. clif_displaymessage(fd, atcmd_output);
  1652. count++;
  1653. }
  1654. }
  1655. }
  1656. }
  1657. }
  1658. if (count == 0)
  1659. clif_displaymessage(fd, msg_table[150]); // No GM found.
  1660. else if (count == 1)
  1661. clif_displaymessage(fd, msg_table[151]); // 1 GM found.
  1662. else {
  1663. sprintf(atcmd_output, msg_table[152], count); // %d GMs found.
  1664. clif_displaymessage(fd, atcmd_output);
  1665. }
  1666. return 0;
  1667. }
  1668. int atcommand_whozeny(
  1669. const int fd, struct map_session_data* sd,
  1670. const char* command, const char* message)
  1671. {
  1672. struct map_session_data *pl_sd, **pl_allsd;
  1673. int i, j, count,c, users;
  1674. char match_text[100];
  1675. char player_name[NAME_LENGTH];
  1676. int *zeny;
  1677. int *counted;
  1678. nullpo_retr(-1, sd);
  1679. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1680. memset(match_text, '\0', sizeof(match_text));
  1681. memset(player_name, '\0', sizeof(player_name));
  1682. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1683. strcpy(match_text, "");
  1684. for (j = 0; match_text[j]; j++)
  1685. match_text[j] = tolower(match_text[j]);
  1686. count = 0;
  1687. pl_allsd = map_getallusers(&users);
  1688. if (users < 1)
  1689. {
  1690. clif_displaymessage(fd, msg_table[28]); // No player found.
  1691. return 0;
  1692. }
  1693. zeny = (int *)aCallocA(users, sizeof(int));
  1694. counted = (int *)aCallocA(users, sizeof(int));
  1695. for (i = 0; i < users; i++) {
  1696. if ((pl_sd = pl_allsd[i])) {
  1697. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1698. for (j = 0; player_name[j]; j++)
  1699. player_name[j] = tolower(player_name[j]);
  1700. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1701. zeny[count]=pl_sd->status.zeny;
  1702. counted[i]=0;
  1703. count++;
  1704. }
  1705. }
  1706. }
  1707. qsort(zeny, count, sizeof(int), hightolow_compare);
  1708. for (c = 0; c < count && c < 50; c++) {
  1709. if(!zeny[c])
  1710. continue;
  1711. for (i = 0; i < users; i++) {
  1712. if(!zeny[c])
  1713. continue;
  1714. if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
  1715. if(pl_sd->status.zeny==zeny[c]) {
  1716. sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1717. clif_displaymessage(fd, atcmd_output);
  1718. zeny[c]=0;
  1719. counted[i]=1;
  1720. }
  1721. }
  1722. }
  1723. }
  1724. if (count == 0)
  1725. clif_displaymessage(fd, msg_table[28]); // No player found.
  1726. else if (count == 1)
  1727. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1728. else {
  1729. sprintf(atcmd_output, msg_table[30], count); // %d players found.
  1730. clif_displaymessage(fd, atcmd_output);
  1731. }
  1732. aFree(zeny);
  1733. aFree(counted);
  1734. return 0;
  1735. }
  1736. // cause random emote on all online players [Valaris]
  1737. int atcommand_happyhappyjoyjoy(
  1738. const int fd, struct map_session_data* sd,
  1739. const char* command, const char* message)
  1740. {
  1741. struct map_session_data *pl_sd, **pl_allsd;
  1742. int i,e, users;
  1743. nullpo_retr(-1, sd);
  1744. pl_allsd = map_getallusers(&users);
  1745. for (i = 0; i < users; i++) {
  1746. if ((pl_sd = pl_allsd[i])) {
  1747. e=rand()%40;
  1748. if(e==34)
  1749. e = 0;
  1750. clif_emotion(&pl_sd->bl,e);
  1751. }
  1752. }
  1753. return 0;
  1754. }
  1755. /*==========================================
  1756. *
  1757. *------------------------------------------
  1758. */
  1759. int atcommand_save(
  1760. const int fd, struct map_session_data* sd,
  1761. const char* command, const char* message)
  1762. {
  1763. nullpo_retr(-1, sd);
  1764. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  1765. if (sd->status.pet_id > 0 && sd->pd)
  1766. intif_save_petdata(sd->status.account_id, &sd->pet);
  1767. chrif_save(sd,0);
  1768. clif_displaymessage(fd, msg_table[6]); // Character data respawn point saved.
  1769. return 0;
  1770. }
  1771. /*==========================================
  1772. *
  1773. *------------------------------------------
  1774. */
  1775. int atcommand_load(
  1776. const int fd, struct map_session_data* sd,
  1777. const char* command, const char* message)
  1778. {
  1779. int m;
  1780. nullpo_retr(-1, sd);
  1781. m = map_mapindex2mapid(sd->status.save_point.map);
  1782. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1783. clif_displaymessage(fd, msg_table[249]);
  1784. return -1;
  1785. }
  1786. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1787. clif_displaymessage(fd, msg_table[248]);
  1788. return -1;
  1789. }
  1790. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1791. clif_displaymessage(fd, msg_table[7]); // Warping to respawn point.
  1792. return 0;
  1793. }
  1794. /*==========================================
  1795. *
  1796. *------------------------------------------
  1797. */
  1798. int atcommand_speed(
  1799. const int fd, struct map_session_data* sd,
  1800. const char* command, const char* message)
  1801. {
  1802. int speed;
  1803. nullpo_retr(-1, sd);
  1804. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1805. if (!message || !*message) {
  1806. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1807. clif_displaymessage(fd, atcmd_output);
  1808. return -1;
  1809. }
  1810. speed = atoi(message);
  1811. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1812. sd->speed = speed;
  1813. //sd->walktimer = x;
  1814. //この文を追加 by れ�
  1815. clif_updatestatus(sd, SP_SPEED);
  1816. clif_displaymessage(fd, msg_table[8]); // Speed changed.
  1817. } else {
  1818. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1819. clif_displaymessage(fd, atcmd_output);
  1820. return -1;
  1821. }
  1822. return 0;
  1823. }
  1824. /*==========================================
  1825. *
  1826. *------------------------------------------
  1827. */
  1828. int atcommand_storage(
  1829. const int fd, struct map_session_data* sd,
  1830. const char* command, const char* message)
  1831. {
  1832. struct storage *stor; //changes from Freya/Yor
  1833. nullpo_retr(-1, sd);
  1834. if (sd->state.storage_flag) {
  1835. clif_displaymessage(fd, msg_table[250]);
  1836. return -1;
  1837. }
  1838. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1839. clif_displaymessage(fd, msg_table[250]);
  1840. return -1;
  1841. }
  1842. storage_storageopen(sd);
  1843. return 0;
  1844. }
  1845. /*==========================================
  1846. *
  1847. *------------------------------------------
  1848. */
  1849. int atcommand_guildstorage(
  1850. const int fd, struct map_session_data* sd,
  1851. const char* command, const char* message)
  1852. {
  1853. struct storage *stor; //changes from Freya/Yor
  1854. nullpo_retr(-1, sd);
  1855. if (sd->status.guild_id > 0) {
  1856. if (sd->state.storage_flag) {
  1857. clif_displaymessage(fd, msg_table[251]);
  1858. return -1;
  1859. }
  1860. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1861. clif_displaymessage(fd, msg_table[251]);
  1862. return -1;
  1863. }
  1864. storage_guild_storageopen(sd);
  1865. } else {
  1866. clif_displaymessage(fd, msg_table[252]);
  1867. return -1;
  1868. }
  1869. return 0;
  1870. }
  1871. /*==========================================
  1872. *
  1873. *------------------------------------------
  1874. */
  1875. int atcommand_option(
  1876. const int fd, struct map_session_data* sd,
  1877. const char* command, const char* message)
  1878. {
  1879. int param1 = 0, param2 = 0, param3 = 0;
  1880. nullpo_retr(-1, sd);
  1881. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1882. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1883. return -1;
  1884. }
  1885. sd->sc.opt1 = param1;
  1886. sd->sc.opt2 = param2;
  1887. if (!(sd->sc.option & CART_MASK) && param3 & CART_MASK) {
  1888. if (sd->status.class_ == JOB_BABY_MERCHANT)
  1889. clif_cart_itemlist(sd);
  1890. clif_cart_equiplist(sd);
  1891. clif_updatestatus(sd, SP_CARTINFO);
  1892. }
  1893. pc_setoption(sd, param3);
  1894. clif_displaymessage(fd, msg_table[9]); // Options changed.
  1895. return 0;
  1896. }
  1897. /*==========================================
  1898. *
  1899. *------------------------------------------
  1900. */
  1901. int atcommand_hide(
  1902. const int fd, struct map_session_data* sd,
  1903. const char* command, const char* message)
  1904. {
  1905. nullpo_retr(-1, sd);
  1906. if (sd->sc.option & OPTION_INVISIBLE) {
  1907. sd->sc.option &= ~OPTION_INVISIBLE;
  1908. clif_displaymessage(fd, msg_table[10]); // Invisible: Off
  1909. } else {
  1910. sd->sc.option |= OPTION_INVISIBLE;
  1911. clif_displaymessage(fd, msg_table[11]); // Invisible: On
  1912. }
  1913. clif_changeoption(&sd->bl);
  1914. return 0;
  1915. }
  1916. /*==========================================
  1917. * 転職する upperを指定すると転生や養子にもなれる
  1918. *------------------------------------------
  1919. */
  1920. int atcommand_jobchange(
  1921. const int fd, struct map_session_data* sd,
  1922. const char* command, const char* message)
  1923. {
  1924. int job = 0, upper = 0;
  1925. nullpo_retr(-1, sd);
  1926. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  1927. int i, found = 0;
  1928. const struct { char name[16]; int id; } jobs[] = {
  1929. { "novice", 0 },
  1930. { "swordsman", 1 },
  1931. { "mage", 2 },
  1932. { "archer", 3 },
  1933. { "acolyte", 4 },
  1934. { "merchant", 5 },
  1935. { "thief", 6 },
  1936. { "knight", 7 },
  1937. { "priest", 8 },
  1938. { "priestess", 8 },
  1939. { "wizard", 9 },
  1940. { "blacksmith", 10 },
  1941. { "hunter", 11 },
  1942. { "assassin", 12 },
  1943. { "crusader", 14 },
  1944. { "monk", 15 },
  1945. { "sage", 16 },
  1946. { "rogue", 17 },
  1947. { "alchemist", 18 },
  1948. { "bard", 19 },
  1949. { "dancer", 20 },
  1950. { "super novice", 23 },
  1951. { "supernovice", 23 },
  1952. { "high novice", 4001 },
  1953. { "swordsman high", 4002 },
  1954. { "mage high", 4003 },
  1955. { "archer high", 4004 },
  1956. { "acolyte high", 4005 },
  1957. { "merchant high", 4006 },
  1958. { "thief high", 4007 },
  1959. { "lord knight", 4008 },
  1960. { "high priest", 4009 },
  1961. { "high priestess", 4009 },
  1962. { "high wizard", 4010 },
  1963. { "whitesmith", 4011 },
  1964. { "sniper", 4012 },
  1965. { "assassin cross", 4013 },
  1966. { "paladin", 4015 },
  1967. { "champion", 4016 },
  1968. { "professor", 4017 },
  1969. { "stalker", 4018 },
  1970. { "creator", 4019 },
  1971. { "clown", 4020 },
  1972. { "gypsy", 4021 },
  1973. { "baby novice", 4023 },
  1974. { "baby swordsman", 4024 },
  1975. { "baby mage", 4025 },
  1976. { "baby archer", 4026 },
  1977. { "baby acolyte", 4027 },
  1978. { "baby merchant", 4028 },
  1979. { "baby thief", 4029 },
  1980. { "baby knight", 4030 },
  1981. { "baby priest", 4031 },
  1982. { "baby priestess", 4031 },
  1983. { "baby wizard", 4032 },
  1984. { "baby blacksmith",4033 },
  1985. { "baby hunter", 4034 },
  1986. { "baby assassin", 4035 },
  1987. { "baby crusader", 4037 },
  1988. { "baby monk", 4038 },
  1989. { "baby sage", 4039 },
  1990. { "baby rogue", 4040 },
  1991. { "baby alchemist", 4041 },
  1992. { "baby bard", 4042 },
  1993. { "baby dancer", 4043 },
  1994. { "super baby", 4045 },
  1995. { "taekwon", 4046 },
  1996. { "taekwon boy", 4046 },
  1997. { "taekwon girl", 4046 },
  1998. { "star gladiator", 4047 },
  1999. { "soul linker", 4049 },
  2000. };
  2001. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  2002. if (strncmpi(message, jobs[i].name, 16) == 0) {
  2003. job = jobs[i].id;
  2004. upper = 0;
  2005. found = 1;
  2006. break;
  2007. }
  2008. }
  2009. if (!found) {
  2010. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  2011. return -1;
  2012. }
  2013. }
  2014. if (job == 37 ||job == 45)
  2015. return 0;
  2016. if ((job >= 0 && job < MAX_PC_CLASS))
  2017. {
  2018. int j;
  2019. for (j=0; j < MAX_INVENTORY; j++) {
  2020. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  2021. pc_unequipitem(sd, j, 3);
  2022. }
  2023. if (pc_jobchange(sd, job, upper) == 0)
  2024. clif_displaymessage(fd, msg_table[12]); // Your job has been changed.
  2025. else {
  2026. clif_displaymessage(fd, msg_table[155]); // Impossible to change your job.
  2027. return -1;
  2028. }
  2029. } else {
  2030. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  2031. return -1;
  2032. }
  2033. return 0;
  2034. }
  2035. /*==========================================
  2036. *
  2037. *------------------------------------------
  2038. */
  2039. int atcommand_die(
  2040. const int fd, struct map_session_data* sd,
  2041. const char* command, const char* message)
  2042. {
  2043. nullpo_retr(-1, sd);
  2044. clif_specialeffect(&sd->bl,450,1);
  2045. pc_damage(NULL, sd, sd->status.hp);
  2046. clif_displaymessage(fd, msg_table[13]); // A pity! You've died.
  2047. return 0;
  2048. }
  2049. /*==========================================
  2050. *
  2051. *------------------------------------------
  2052. */
  2053. int atcommand_kill(
  2054. const int fd, struct map_session_data* sd,
  2055. const char* command, const char* message)
  2056. {
  2057. struct map_session_data *pl_sd;
  2058. nullpo_retr(-1, sd);
  2059. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2060. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2061. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  2062. return -1;
  2063. }
  2064. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  2065. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  2066. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  2067. clif_displaymessage(fd, msg_table[14]); // Character killed.
  2068. } else {
  2069. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  2070. return -1;
  2071. }
  2072. } else {
  2073. clif_displaymessage(fd, msg_table[3]); // Character not found.
  2074. return -1;
  2075. }
  2076. return 0;
  2077. }
  2078. /*==========================================
  2079. *
  2080. *------------------------------------------
  2081. */
  2082. int atcommand_alive(
  2083. const int fd, struct map_session_data* sd,
  2084. const char* command, const char* message)
  2085. {
  2086. nullpo_retr(-1, sd);
  2087. if (pc_isdead(sd)) {
  2088. sd->status.hp = sd->status.max_hp;
  2089. sd->status.sp = sd->status.max_sp;
  2090. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2091. pc_setstand(sd);
  2092. if (battle_config.pc_invincible_time > 0)
  2093. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  2094. clif_updatestatus(sd, SP_HP);
  2095. clif_updatestatus(sd, SP_SP);
  2096. clif_resurrection(&sd->bl, 1);
  2097. clif_displaymessage(fd, msg_table[16]); // You've been revived! It's a miracle!
  2098. return 0;
  2099. }
  2100. return -1;
  2101. }
  2102. /*==========================================
  2103. * +kamic [LuzZza]
  2104. *------------------------------------------
  2105. */
  2106. int atcommand_kami(
  2107. const int fd, struct map_session_data* sd,
  2108. const char* command, const char* message)
  2109. {
  2110. unsigned long color=0;
  2111. nullpo_retr(-1, sd);
  2112. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2113. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  2114. if (!message || !*message) {
  2115. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  2116. return -1;
  2117. }
  2118. sscanf(message, "%199[^\n]", atcmd_output);
  2119. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  2120. } else {
  2121. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  2122. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  2123. return -1;
  2124. }
  2125. if(color < 0 || color > 0xFFFFFF) {
  2126. clif_displaymessage(fd, "Invalid color.");
  2127. return -1;
  2128. }
  2129. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  2130. }
  2131. return 0;
  2132. }
  2133. /*==========================================
  2134. *
  2135. *------------------------------------------
  2136. */
  2137. int atcommand_heal(
  2138. const int fd, struct map_session_data* sd,
  2139. const char* command, const char* message)
  2140. {
  2141. int hp = 0, sp = 0; // [Valaris] thanks to fov
  2142. nullpo_retr(-1, sd);
  2143. sscanf(message, "%d %d", &hp, &sp);
  2144. if (hp == 0 && sp == 0) {
  2145. hp = sd->status.max_hp - sd->status.hp;
  2146. sp = sd->status.max_sp - sd->status.sp;
  2147. } else {
  2148. if (hp > 0 && (hp > sd->status.max_hp || hp > (sd->status.max_hp - sd->status.hp))) // fix positiv overflow
  2149. hp = sd->status.max_hp - sd->status.hp;
  2150. else if (hp < 0 && (hp < -sd->status.max_hp || hp < (1 - sd->status.hp))) // fix negativ overflow
  2151. hp = 1 - sd->status.hp;
  2152. if (sp > 0 && (sp > sd->status.max_sp || sp > (sd->status.max_sp - sd->status.sp))) // fix positiv overflow
  2153. sp = sd->status.max_sp - sd->status.sp;
  2154. else if (sp < 0 && (sp < -sd->status.max_sp || sp < (1 - sd->status.sp))) // fix negativ overflow
  2155. sp = 1 - sd->status.sp;
  2156. }
  2157. if (hp > 0) // display like heal
  2158. clif_heal(fd, SP_HP, hp);
  2159. else if (hp < 0) // display like damage
  2160. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2161. if (sp > 0) // no display when we lost SP
  2162. clif_heal(fd, SP_SP, sp);
  2163. if (hp != 0 || sp != 0) {
  2164. pc_heal(sd, hp, sp);
  2165. if (hp >= 0 && sp >= 0)
  2166. clif_displaymessage(fd, msg_table[17]); // HP, SP recovered.
  2167. else
  2168. clif_displaymessage(fd, msg_table[156]); // HP or/and SP modified.
  2169. } else {
  2170. clif_displaymessage(fd, msg_table[157]); // HP and SP are already with the good value.
  2171. return -1;
  2172. }
  2173. return 0;
  2174. }
  2175. /*==========================================
  2176. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2177. *------------------------------------------
  2178. */
  2179. int atcommand_item(
  2180. const int fd, struct map_session_data* sd,
  2181. const char* command, const char* message)
  2182. {
  2183. char item_name[100];
  2184. int number = 0, item_id, flag;
  2185. struct item item_tmp;
  2186. struct item_data *item_data;
  2187. int get_count, i, pet_id;
  2188. nullpo_retr(-1, sd);
  2189. memset(item_name, '\0', sizeof(item_name));
  2190. if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
  2191. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2192. return -1;
  2193. }
  2194. if (number <= 0)
  2195. number = 1;
  2196. item_id = 0;
  2197. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2198. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2199. item_id = item_data->nameid;
  2200. if (item_id >= 500) {
  2201. get_count = number;
  2202. // check pet egg
  2203. pet_id = search_petDB_index(item_id, PET_EGG);
  2204. if (item_data->type == 4 || item_data->type == 5 ||
  2205. item_data->type == 7 || item_data->type == 8) {
  2206. get_count = 1;
  2207. }
  2208. for (i = 0; i < number; i += get_count) {
  2209. // if pet egg
  2210. if (pet_id >= 0) {
  2211. sd->catch_target_class = pet_db[pet_id].class_;
  2212. intif_create_pet(sd->status.account_id, sd->status.char_id,
  2213. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2214. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2215. 100, 0, 1, pet_db[pet_id].jname);
  2216. // if not pet egg
  2217. } else {
  2218. memset(&item_tmp, 0, sizeof(item_tmp));
  2219. item_tmp.nameid = item_id;
  2220. item_tmp.identify = 1;
  2221. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, get_count)))
  2222. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  2223. }
  2224. }
  2225. //Logs (A)dmins items [Lupus]
  2226. if(log_config.pick > 0 ) {
  2227. log_pick(sd, "A", 0, item_id, number, NULL);
  2228. }
  2229. //Logs
  2230. clif_displaymessage(fd, msg_table[18]); // Item created.
  2231. } else {
  2232. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2233. return -1;
  2234. }
  2235. return 0;
  2236. }
  2237. /*==========================================
  2238. *
  2239. *------------------------------------------
  2240. */
  2241. int atcommand_item2(
  2242. const int fd, struct map_session_data* sd,
  2243. const char* command, const char* message)
  2244. {
  2245. struct item item_tmp;
  2246. struct item_data *item_data;
  2247. char item_name[100];
  2248. int item_id, number = 0;
  2249. int identify = 0, refine = 0, attr = 0;
  2250. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2251. int flag;
  2252. int loop, get_count, i;
  2253. nullpo_retr(-1, sd);
  2254. memset(item_name, '\0', sizeof(item_name));
  2255. if (!message || !*message || sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9) {
  2256. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2257. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2258. return -1;
  2259. }
  2260. if (number <= 0)
  2261. number = 1;
  2262. item_id = 0;
  2263. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2264. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2265. item_id = item_data->nameid;
  2266. if (item_id > 500) {
  2267. loop = 1;
  2268. get_count = number;
  2269. if (item_data->type == 4 || item_data->type == 5 ||
  2270. item_data->type == 7 || item_data->type == 8) {
  2271. loop = number;
  2272. get_count = 1;
  2273. if (item_data->type == 7) {
  2274. identify = 1;
  2275. refine = 0;
  2276. }
  2277. if (item_data->type == 8)
  2278. refine = 0;
  2279. if (refine > 10)
  2280. refine = 10;
  2281. } else {
  2282. identify = 1;
  2283. refine = attr = 0;
  2284. }
  2285. for (i = 0; i < loop; i++) {
  2286. memset(&item_tmp, 0, sizeof(item_tmp));
  2287. item_tmp.nameid = item_id;
  2288. item_tmp.identify = identify;
  2289. item_tmp.refine = refine;
  2290. item_tmp.attribute = attr;
  2291. item_tmp.card[0] = c1;
  2292. item_tmp.card[1] = c2;
  2293. item_tmp.card[2] = c3;
  2294. item_tmp.card[3] = c4;
  2295. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2296. clif_additem(sd, 0, 0, flag);
  2297. }
  2298. //Logs (A)dmins items [Lupus]
  2299. if(log_config.pick > 0 ) {
  2300. log_pick(sd, "A", 0, item_tmp.nameid, number, &item_tmp);
  2301. }
  2302. //Logs
  2303. clif_displaymessage(fd, msg_table[18]); // Item created.
  2304. } else {
  2305. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2306. return -1;
  2307. }
  2308. return 0;
  2309. }
  2310. /*==========================================
  2311. *
  2312. *------------------------------------------
  2313. */
  2314. int atcommand_itemreset(
  2315. const int fd, struct map_session_data* sd,
  2316. const char* command, const char* message)
  2317. {
  2318. int i;
  2319. nullpo_retr(-1, sd);
  2320. for (i = 0; i < MAX_INVENTORY; i++) {
  2321. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  2322. //Logs (A)dmins items [Lupus]
  2323. if(log_config.pick > 0 ) {
  2324. log_pick(sd, "A", 0, sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  2325. }
  2326. //Logs
  2327. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2328. }
  2329. }
  2330. clif_displaymessage(fd, msg_table[20]); // All of your items have been removed.
  2331. return 0;
  2332. }
  2333. /*==========================================
  2334. *
  2335. *------------------------------------------
  2336. */
  2337. int atcommand_itemcheck(
  2338. const int fd, struct map_session_data* sd,
  2339. const char* command, const char* message)
  2340. {
  2341. nullpo_retr(-1, sd);
  2342. pc_checkitem(sd);
  2343. return 0;
  2344. }
  2345. /*==========================================
  2346. * Atcommand @lvlup
  2347. *------------------------------------------
  2348. */
  2349. int atcommand_baselevelup(
  2350. const int fd, struct map_session_data* sd,
  2351. const char* command, const char* message)
  2352. {
  2353. int level=0, i=0;
  2354. nullpo_retr(-1, sd);
  2355. level = atoi(message);
  2356. if (!message || !*message || !level) {
  2357. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2358. return -1;
  2359. }
  2360. if (level > 0) {
  2361. if (sd->status.base_level == pc_maxbaselv(sd)) { /* check for max level by Valaris */
  2362. clif_displaymessage(fd, msg_table[47]); /* Base level can't go any higher. */
  2363. return -1;
  2364. } /* End Addition */
  2365. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  2366. level = pc_maxbaselv(sd) - sd->status.base_level;
  2367. for (i = 1; i <= level; i++)
  2368. sd->status.status_point += (sd->status.base_level + i + 14) / 5;
  2369. sd->status.base_level += (unsigned int)level;
  2370. clif_updatestatus(sd, SP_BASELEVEL);
  2371. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2372. clif_updatestatus(sd, SP_STATUSPOINT);
  2373. status_calc_pc(sd, 0);
  2374. pc_heal(sd, sd->status.max_hp, sd->status.max_sp);
  2375. clif_misceffect(&sd->bl, 0);
  2376. clif_displaymessage(fd, msg_table[21]); /* Base level raised. */
  2377. } else {
  2378. if (sd->status.base_level == 1) {
  2379. clif_displaymessage(fd, msg_table[158]); /* Base level can't go any lower. */
  2380. return -1;
  2381. }
  2382. level*=-1;
  2383. if ((unsigned int)level >= sd->status.base_level)
  2384. level = sd->status.base_level-1;
  2385. if (sd->status.status_point > 0) {
  2386. for (i = 0; i > -level; i--)
  2387. sd->status.status_point -= (sd->status.base_level + i + 14) / 5;
  2388. if (sd->status.status_point < 0)
  2389. sd->status.status_point = 0;
  2390. clif_updatestatus(sd, SP_STATUSPOINT);
  2391. } /* to add: remove status points from stats */
  2392. sd->status.base_level -= (unsigned int)level;
  2393. clif_updatestatus(sd, SP_BASELEVEL);
  2394. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2395. status_calc_pc(sd, 0);
  2396. clif_displaymessage(fd, msg_table[22]); /* Base level lowered. */
  2397. }
  2398. return 0;
  2399. }
  2400. /*==========================================
  2401. *
  2402. *------------------------------------------
  2403. */
  2404. int atcommand_joblevelup(
  2405. const int fd, struct map_session_data* sd,
  2406. const char* command, const char* message)
  2407. {
  2408. int level=0;
  2409. nullpo_retr(-1, sd);
  2410. level = atoi(message);
  2411. if (!message || !*message || !level) {
  2412. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2413. return -1;
  2414. }
  2415. if (level > 0) {
  2416. if (sd->status.job_level == pc_maxjoblv(sd)) {
  2417. clif_displaymessage(fd, msg_table[23]); // Job level can't go any higher.
  2418. return -1;
  2419. }
  2420. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  2421. level = pc_maxjoblv(sd) - sd->status.job_level;
  2422. sd->status.job_level += (unsigned int)level;
  2423. clif_updatestatus(sd, SP_JOBLEVEL);
  2424. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2425. sd->status.skill_point += level;
  2426. clif_updatestatus(sd, SP_SKILLPOINT);
  2427. status_calc_pc(sd, 0);
  2428. clif_misceffect(&sd->bl, 1);
  2429. clif_displaymessage(fd, msg_table[24]); // Job level raised.
  2430. } else {
  2431. if (sd->status.job_level == 1) {
  2432. clif_displaymessage(fd, msg_table[159]); // Job level can't go any lower.
  2433. return -1;
  2434. }
  2435. level *=-1;
  2436. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  2437. level = sd->status.job_level-1;
  2438. sd->status.job_level -= (unsigned int)level;
  2439. clif_updatestatus(sd, SP_JOBLEVEL);
  2440. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2441. if (sd->status.skill_point < level)
  2442. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  2443. sd->status.skill_point -= level;
  2444. if (sd->status.skill_point < 0)
  2445. sd->status.skill_point = 0;
  2446. clif_updatestatus(sd, SP_SKILLPOINT);
  2447. status_calc_pc(sd, 0);
  2448. clif_displaymessage(fd, msg_table[25]); // Job level lowered.
  2449. }
  2450. return 0;
  2451. }
  2452. /*==========================================
  2453. * @help
  2454. *------------------------------------------
  2455. */
  2456. int atcommand_help(
  2457. const int fd, struct map_session_data* sd,
  2458. const char* command, const char* message)
  2459. {
  2460. char buf[2048], w1[2048], w2[2048];
  2461. int i, gm_level;
  2462. FILE* fp;
  2463. nullpo_retr(-1, sd);
  2464. memset(buf, '\0', sizeof(buf));
  2465. if ((fp = fopen(help_txt, "r")) != NULL) {
  2466. clif_displaymessage(fd, msg_table[26]); /* Help commands: */
  2467. gm_level = pc_isGM(sd);
  2468. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2469. if (buf[0] == '/' && buf[1] == '/')
  2470. continue;
  2471. for (i = 0; buf[i] != '\0'; i++) {
  2472. if (buf[i] == '\r' || buf[i] == '\n') {
  2473. buf[i] = '\0';
  2474. break;
  2475. }
  2476. }
  2477. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2478. clif_displaymessage(fd, buf);
  2479. else if (gm_level >= atoi(w1))
  2480. clif_displaymessage(fd, w2);
  2481. }
  2482. fclose(fp);
  2483. } else {
  2484. clif_displaymessage(fd, msg_table[27]); /* File help.txt not found. */
  2485. return -1;
  2486. }
  2487. return 0;
  2488. }
  2489. /*==========================================
  2490. * @help2 - Char commands [Kayla]
  2491. *------------------------------------------
  2492. */
  2493. int atcommand_help2(
  2494. const int fd, struct map_session_data* sd,
  2495. const char* command, const char* message)
  2496. {
  2497. char buf[2048], w1[2048], w2[2048];
  2498. int i, gm_level;
  2499. FILE* fp;
  2500. nullpo_retr(-1, sd);
  2501. memset(buf, '\0', sizeof(buf));
  2502. if ((fp = fopen(help2_txt, "r")) != NULL) {
  2503. clif_displaymessage(fd, msg_table[26]); /* Help commands: */
  2504. gm_level = pc_isGM(sd);
  2505. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2506. if (buf[0] == '/' && buf[1] == '/')
  2507. continue;
  2508. for (i = 0; buf[i] != '\0'; i++) {
  2509. if (buf[i] == '\r' || buf[i] == '\n') {
  2510. buf[i] = '\0';
  2511. break;
  2512. }
  2513. }
  2514. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2515. clif_displaymessage(fd, buf);
  2516. else if (gm_level >= atoi(w1))
  2517. clif_displaymessage(fd, w2);
  2518. }
  2519. fclose(fp);
  2520. } else {
  2521. clif_displaymessage(fd, msg_table[27]); /* File help.txt not found. */
  2522. return -1;
  2523. }
  2524. return 0;
  2525. }
  2526. /*==========================================
  2527. * @gm
  2528. *------------------------------------------
  2529. */
  2530. int atcommand_gm(
  2531. const int fd, struct map_session_data* sd,
  2532. const char* command, const char* message)
  2533. {
  2534. char password[100];
  2535. nullpo_retr(-1, sd);
  2536. memset(password, '\0', sizeof(password));
  2537. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2538. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2539. return -1;
  2540. }
  2541. if (pc_isGM(sd)) { /* a GM can not use this function. only a normal player (become gm is not for gm!) */
  2542. clif_displaymessage(fd, msg_table[50]); /* You already have some GM powers. */
  2543. return -1;
  2544. } else
  2545. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2546. return 0;
  2547. }
  2548. /*==========================================
  2549. *
  2550. *------------------------------------------
  2551. */
  2552. int atcommand_pvpoff(
  2553. const int fd, struct map_session_data* sd,
  2554. const char* command, const char* message)
  2555. {
  2556. struct map_session_data *pl_sd, **pl_allsd;
  2557. int i, users;
  2558. nullpo_retr(-1, sd);
  2559. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2560. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2561. return -1;
  2562. }
  2563. if (map[sd->bl.m].flag.pvp) {
  2564. map[sd->bl.m].flag.pvp = 0;
  2565. clif_send0199(sd->bl.m, 0);
  2566. pl_allsd = map_getallusers(&users);
  2567. for (i = 0; i < users; i++) { //人数分ループ
  2568. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m) {
  2569. clif_pvpset(pl_sd, 0, 0, 2);
  2570. if (pl_sd->pvp_timer != -1) {
  2571. delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
  2572. pl_sd->pvp_timer = -1;
  2573. }
  2574. }
  2575. }
  2576. clif_displaymessage(fd, msg_table[31]); // PvP: Off.
  2577. } else {
  2578. clif_displaymessage(fd, msg_table[160]); // PvP is already Off.
  2579. return -1;
  2580. }
  2581. return 0;
  2582. }
  2583. /*==========================================
  2584. *
  2585. *------------------------------------------
  2586. */
  2587. int atcommand_pvpon(
  2588. const int fd, struct map_session_data* sd,
  2589. const char* command, const char* message)
  2590. {
  2591. struct map_session_data *pl_sd, **pl_allsd;
  2592. int i, users;
  2593. nullpo_retr(-1, sd);
  2594. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2595. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2596. return -1;
  2597. }
  2598. if (!map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.nopvp) {
  2599. map[sd->bl.m].flag.pvp = 1;
  2600. clif_send0199(sd->bl.m, 1);
  2601. pl_allsd = map_getallusers(&users);
  2602. for (i = 0; i < users; i++) {
  2603. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2604. pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2605. pl_sd->pvp_rank = 0;
  2606. pl_sd->pvp_lastusers = 0;
  2607. pl_sd->pvp_point = 5;
  2608. pl_sd->pvp_won = 0;
  2609. pl_sd->pvp_lost = 0;
  2610. }
  2611. }
  2612. clif_displaymessage(fd, msg_table[32]); // PvP: On.
  2613. } else {
  2614. clif_displaymessage(fd, msg_table[161]); // PvP is already On.
  2615. return -1;
  2616. }
  2617. return 0;
  2618. }
  2619. /*==========================================
  2620. *
  2621. *------------------------------------------
  2622. */
  2623. int atcommand_gvgoff(
  2624. const int fd, struct map_session_data* sd,
  2625. const char* command, const char* message)
  2626. {
  2627. nullpo_retr(-1, sd);
  2628. if (map[sd->bl.m].flag.gvg) {
  2629. map[sd->bl.m].flag.gvg = 0;
  2630. clif_send0199(sd->bl.m, 0);
  2631. clif_displaymessage(fd, msg_table[33]); // GvG: Off.
  2632. } else {
  2633. clif_displaymessage(fd, msg_table[162]); // GvG is already Off.
  2634. return -1;
  2635. }
  2636. return 0;
  2637. }
  2638. /*==========================================
  2639. *
  2640. *------------------------------------------
  2641. */
  2642. int atcommand_gvgon(
  2643. const int fd, struct map_session_data* sd,
  2644. const char* command, const char* message)
  2645. {
  2646. nullpo_retr(-1, sd);
  2647. if (!map[sd->bl.m].flag.gvg) {
  2648. map[sd->bl.m].flag.gvg = 1;
  2649. clif_send0199(sd->bl.m, 3);
  2650. clif_displaymessage(fd, msg_table[34]); // GvG: On.
  2651. } else {
  2652. clif_displaymessage(fd, msg_table[163]); // GvG is already On.
  2653. return -1;
  2654. }
  2655. return 0;
  2656. }
  2657. /*==========================================
  2658. *
  2659. *------------------------------------------
  2660. */
  2661. int atcommand_model(
  2662. const int fd, struct map_session_data* sd,
  2663. const char* command, const char* message)
  2664. {
  2665. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2666. nullpo_retr(-1, sd);
  2667. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2668. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2669. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2670. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2671. clif_displaymessage(fd, atcmd_output);
  2672. return -1;
  2673. }
  2674. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2675. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2676. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2677. /* Removed because this check is TOO strange. [Skotlex]
  2678. //秒フ色変更
  2679. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2680. //The hell? Why Rogue/Assassins can't... change their option if they have clothes colors and are males? o.O [Skotlex]
  2681. //秒フ色未実装職の判定
  2682. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2683. return -1;
  2684. } else {
  2685. */
  2686. pc_changelook(sd, LOOK_HAIR, hair_style);
  2687. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2688. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2689. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2690. // }
  2691. } else {
  2692. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2693. return -1;
  2694. }
  2695. return 0;
  2696. }
  2697. /*==========================================
  2698. * @dye && @ccolor
  2699. *------------------------------------------
  2700. */
  2701. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2702. {
  2703. int cloth_color = 0;
  2704. nullpo_retr(-1, sd);
  2705. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2706. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2707. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2708. clif_displaymessage(fd, atcmd_output);
  2709. return -1;
  2710. }
  2711. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2712. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2713. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2714. } else {
  2715. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2716. return -1;
  2717. }
  2718. return 0;
  2719. }
  2720. /*==========================================
  2721. * @hairstyle && @hstyle
  2722. *------------------------------------------
  2723. */
  2724. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2725. {
  2726. int hair_style = 0;
  2727. nullpo_retr(-1, sd);
  2728. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2729. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2730. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2731. clif_displaymessage(fd, atcmd_output);
  2732. return -1;
  2733. }
  2734. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2735. /* Removed because this check is TOO strange. [Skotlex]
  2736. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) { //???
  2737. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2738. return -1;
  2739. } else {
  2740. */
  2741. pc_changelook(sd, LOOK_HAIR, hair_style);
  2742. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2743. // }
  2744. } else {
  2745. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2746. return -1;
  2747. }
  2748. return 0;
  2749. }
  2750. /*==========================================
  2751. * @charhairstyle by [MouseJstr]
  2752. *------------------------------------------
  2753. */
  2754. int
  2755. atcommand_charhairstyle(const int fd, struct map_session_data* sd,
  2756. const char* command, const char* message)
  2757. {
  2758. nullpo_retr(-1, sd);
  2759. return 0;
  2760. }
  2761. /*==========================================
  2762. * @haircolor && @hcolor
  2763. *------------------------------------------
  2764. */
  2765. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2766. {
  2767. int hair_color = 0;
  2768. nullpo_retr(-1, sd);
  2769. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2770. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2771. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2772. clif_displaymessage(fd, atcmd_output);
  2773. return -1;
  2774. }
  2775. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2776. /* Removed for being such a strange check. [Skotlex]
  2777. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2778. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2779. return -1;
  2780. } else {
  2781. */
  2782. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2783. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2784. // }
  2785. } else {
  2786. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2787. return -1;
  2788. }
  2789. return 0;
  2790. }
  2791. /*==========================================
  2792. * @go [city_number or city_name] - Updated by Harbin
  2793. *------------------------------------------
  2794. */
  2795. int atcommand_go(
  2796. const int fd, struct map_session_data* sd,
  2797. const char* command, const char* message)
  2798. {
  2799. int i;
  2800. int town;
  2801. char map_name[MAP_NAME_LENGTH];
  2802. int m;
  2803. const struct { char map[MAP_NAME_LENGTH]; int x, y; } data[] = {
  2804. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  2805. { MAP_MORROC, 156, 93 }, // 1=Morroc
  2806. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  2807. { MAP_PAYON, 162, 233 }, // 3=Payon
  2808. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  2809. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  2810. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  2811. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  2812. { MAP_COMODO, 209, 143 }, // 8=Comodo
  2813. { MAP_YUNO, 157, 51 }, // 9=Yuno
  2814. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  2815. { MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun
  2816. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  2817. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  2818. { MAP_LOUYANG, 217, 40 }, // 14=Lou Yang
  2819. { "new_1-1.gat", 53, 111 }, // 15=Training Grounds
  2820. { MAP_JAIL, 23, 61 }, // 16=Prison
  2821. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  2822. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  2823. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  2824. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  2825. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  2826. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  2827. };
  2828. nullpo_retr(-1, sd);
  2829. if(map[sd->bl.m].flag.nogo) {
  2830. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2831. return 0;
  2832. }
  2833. memset(map_name, '\0', sizeof(map_name));
  2834. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2835. // get the number
  2836. town = atoi(message);
  2837. // if no value, display all value
  2838. if (!message || !*message || sscanf(message, "%15s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2839. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2840. clif_displaymessage(fd, msg_table[82]); // Please, use one of this number/name:
  2841. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2842. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2843. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2844. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun");
  2845. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang");
  2846. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2847. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2848. clif_displaymessage(fd, " 21=Einbech 22=Hugel");
  2849. return -1;
  2850. } else {
  2851. // get possible name of the city and add .gat if not in the name
  2852. map_name[MAP_NAME_LENGTH-1] = '\0';
  2853. for (i = 0; map_name[i]; i++)
  2854. map_name[i] = tolower(map_name[i]);
  2855. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  2856. strcat(map_name, ".gat");
  2857. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2858. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2859. town = 0;
  2860. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2861. town = 1;
  2862. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2863. town = 2;
  2864. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2865. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2866. town = 3;
  2867. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2868. town = 4;
  2869. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2870. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2871. town = 5;
  2872. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2873. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2874. town = 6;
  2875. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2876. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2877. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2878. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2879. town = 7;
  2880. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2881. town = 8;
  2882. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2883. town = 9;
  2884. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2885. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2886. town = 10;
  2887. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2888. town = 11;
  2889. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2890. town = 12;
  2891. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2892. town = 13;
  2893. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2894. town = 14;
  2895. } else if (strncmp(map_name, "new_1-1.gat", 3) == 0 || // 3 first characters (or "newbies")
  2896. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2897. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2898. town = 15;
  2899. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2900. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2901. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2902. town = 16;
  2903. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  2904. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  2905. town = 17;
  2906. } else if (strncmp(map_name, "ayothaya.gat", 2) == 0 || // 2 first characters
  2907. strncmp(map_name, "ayotaya.gat", 2) == 0) { // writing error (2 first characters)
  2908. town = 18;
  2909. } else if (strncmp(map_name, "einbroch.gat", 3) == 0 || // 3 first characters
  2910. strncmp(map_name, "ainbroch.gat", 3) == 0) { // writing error (3 first characters)
  2911. town = 19;
  2912. } else if (strncmp(map_name, "lighthalzen.gat", 3) == 0 || // 3 first characters
  2913. strncmp(map_name, "reichthalzen.gat", 3) == 0) { // 'alternative' name (3 first characters)
  2914. town = 20;
  2915. } else if (strncmp(map_name, "einbech.gat", 5) == 0) { // 5 first characters
  2916. town = 21;
  2917. } else if (strncmp(map_name, "hugel.gat", 3) == 0) { // 3 first characters
  2918. town = 22;
  2919. }
  2920. if (town >= -3 && town <= -1) {
  2921. if (sd->status.memo_point[-town-1].map) {
  2922. m = map_mapindex2mapid(sd->status.memo_point[-town-1].map);
  2923. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2924. clif_displaymessage(fd, msg_table[247]);
  2925. return -1;
  2926. }
  2927. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2928. clif_displaymessage(fd, msg_table[248]);
  2929. return -1;
  2930. }
  2931. if (pc_setpos(sd, sd->status.memo_point[-town-1].map, sd->status.memo_point[-town-1].x, sd->status.memo_point[-town-1].y, 3) == 0) {
  2932. clif_displaymessage(fd, msg_table[0]); // Warped.
  2933. } else {
  2934. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2935. return -1;
  2936. }
  2937. } else {
  2938. sprintf(atcmd_output, msg_table[164], -town-1); // Your memo point #%d doesn't exist.
  2939. clif_displaymessage(fd, atcmd_output);
  2940. return -1;
  2941. }
  2942. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  2943. m = map_mapname2mapid((char *)data[town].map);
  2944. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2945. clif_displaymessage(fd, msg_table[247]);
  2946. return -1;
  2947. }
  2948. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2949. clif_displaymessage(fd, msg_table[248]);
  2950. return -1;
  2951. }
  2952. if (pc_setpos(sd, mapindex_name2id((char *)data[town].map), data[town].x, data[town].y, 3) == 0) {
  2953. clif_displaymessage(fd, msg_table[0]); // Warped.
  2954. } else {
  2955. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2956. return -1;
  2957. }
  2958. } else { // if you arrive here, you have an error in town variable when reading of names
  2959. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2960. return -1;
  2961. }
  2962. }
  2963. return 0;
  2964. }
  2965. /*==========================================
  2966. *
  2967. *------------------------------------------
  2968. */
  2969. int atcommand_monster(
  2970. const int fd, struct map_session_data* sd,
  2971. const char* command, const char* message)
  2972. {
  2973. char name[NAME_LENGTH];
  2974. char monster[NAME_LENGTH];
  2975. int mob_id;
  2976. int number = 0;
  2977. int x = 0, y = 0;
  2978. int count;
  2979. int i, j, k;
  2980. int mx, my, range;
  2981. nullpo_retr(-1, sd);
  2982. memset(name, '\0', sizeof(name));
  2983. memset(monster, '\0', sizeof(monster));
  2984. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2985. if (!message || !*message) {
  2986. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  2987. return -1;
  2988. }
  2989. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) > 1 ||
  2990. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) > 1) {
  2991. //All data can be left as it is.
  2992. } else if ((count=sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y)) > 1) {
  2993. //Here, it is possible name was not given and we are using monster for it.
  2994. if (count < 3) //Blank mob's name.
  2995. name[0] = '\0';
  2996. } else if (sscanf(message, "%23s %23s %d %d %d", name, monster, &number, &x, &y) > 1) {
  2997. //All data can be left as it is.
  2998. } else if (sscanf(message, "%23s", monster) > 0) {
  2999. //As before, name may be already filled.
  3000. name[0] = '\0';
  3001. } else {
  3002. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  3003. return -1;
  3004. }
  3005. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3006. mob_id = mobdb_checkid(atoi(monster));
  3007. if (mob_id == 0) {
  3008. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  3009. return -1;
  3010. }
  3011. if (mob_id == MOBID_EMPERIUM) {
  3012. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  3013. return -1;
  3014. }
  3015. if (number <= 0)
  3016. number = 1;
  3017. if (strlen(name) < 1)
  3018. strcpy(name, "--ja--");
  3019. // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
  3020. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3021. number = battle_config.atc_spawn_quantity_limit;
  3022. if (battle_config.etc_log)
  3023. ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
  3024. count = 0;
  3025. range = (int)sqrt(number) / 2;
  3026. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  3027. for (i = 0; i < number; i++) {
  3028. j = 0;
  3029. k = 0;
  3030. while(j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area)
  3031. if (x <= 0)
  3032. mx = sd->bl.x + (rand() % range - (range / 2));
  3033. else
  3034. mx = x;
  3035. if (y <= 0)
  3036. my = sd->bl.y + (rand() % range - (range / 2));
  3037. else
  3038. my = y;
  3039. k = mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "");
  3040. }
  3041. count += (k != 0) ? 1 : 0;
  3042. }
  3043. if (count != 0)
  3044. if (number == count)
  3045. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  3046. else {
  3047. sprintf(atcmd_output, msg_table[240], count); // %d monster(s) summoned!
  3048. clif_displaymessage(fd, atcmd_output);
  3049. }
  3050. else {
  3051. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  3052. return -1;
  3053. }
  3054. return 0;
  3055. }
  3056. // small monster spawning [Valaris]
  3057. int atcommand_monstersmall(
  3058. const int fd, struct map_session_data* sd,
  3059. const char* command, const char* message) {
  3060. char name[NAME_LENGTH] = "";
  3061. char monster[NAME_LENGTH] = "";
  3062. int mob_id = 0;
  3063. int number = 0;
  3064. int x = 0;
  3065. int y = 0;
  3066. int count;
  3067. int i;
  3068. nullpo_retr(-1, sd);
  3069. if (!message || !*message) {
  3070. clif_displaymessage(fd, "Give a monster name/id please.");
  3071. return -1;
  3072. }
  3073. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3074. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3075. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3076. clif_displaymessage(fd, "Give a monster name/id please.");
  3077. return -1;
  3078. }
  3079. // If monster identifier/name argument is a name
  3080. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3081. mob_id = atoi(monster);
  3082. if (mob_id == 0) {
  3083. clif_displaymessage(fd, msg_table[40]);
  3084. return -1;
  3085. }
  3086. if (mob_id == MOBID_EMPERIUM) {
  3087. clif_displaymessage(fd, msg_table[83]);
  3088. return -1;
  3089. }
  3090. if (mobdb_checkid(mob_id) == 0) {
  3091. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3092. return -1;
  3093. }
  3094. if (number <= 0)
  3095. number = 1;
  3096. if (strlen(name) < 1)
  3097. strcpy(name, "--ja--");
  3098. // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
  3099. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3100. number = battle_config.atc_spawn_quantity_limit;
  3101. count = 0;
  3102. for (i = 0; i < number; i++) {
  3103. int mx, my;
  3104. if (x <= 0)
  3105. mx = sd->bl.x + (rand() % 11 - 5);
  3106. else
  3107. mx = x;
  3108. if (y <= 0)
  3109. my = sd->bl.y + (rand() % 11 - 5);
  3110. else
  3111. my = y;
  3112. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+MAX_MOB_DB, 1, "") != 0) ? 1 : 0;
  3113. }
  3114. if (count != 0)
  3115. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3116. else
  3117. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3118. return 0;
  3119. }
  3120. // big monster spawning [Valaris]
  3121. int atcommand_monsterbig(
  3122. const int fd, struct map_session_data* sd,
  3123. const char* command, const char* message) {
  3124. char name[NAME_LENGTH] = "";
  3125. char monster[NAME_LENGTH] = "";
  3126. int mob_id = 0;
  3127. int number = 0;
  3128. int x = 0;
  3129. int y = 0;
  3130. int count;
  3131. int i;
  3132. nullpo_retr(-1, sd);
  3133. if (!message || !*message) {
  3134. clif_displaymessage(fd, "Give a monster name/id please.");
  3135. return -1;
  3136. }
  3137. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3138. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3139. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3140. clif_displaymessage(fd, "Give a monster name/id please.");
  3141. return -1;
  3142. }
  3143. // If monster identifier/name argument is a name
  3144. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3145. mob_id = atoi(monster);
  3146. if (mob_id == 0) {
  3147. clif_displaymessage(fd, msg_table[40]);
  3148. return -1;
  3149. }
  3150. if (mob_id == MOBID_EMPERIUM) {
  3151. clif_displaymessage(fd, msg_table[83]);
  3152. return -1;
  3153. }
  3154. if (mobdb_checkid(mob_id) == 0) {
  3155. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3156. return -1;
  3157. }
  3158. if (number <= 0)
  3159. number = 1;
  3160. if (strlen(name) < 1)
  3161. strcpy(name, "--ja--");
  3162. // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
  3163. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3164. number = battle_config.atc_spawn_quantity_limit;
  3165. count = 0;
  3166. for (i = 0; i < number; i++) {
  3167. int mx, my;
  3168. if (x <= 0)
  3169. mx = sd->bl.x + (rand() % 11 - 5);
  3170. else
  3171. mx = x;
  3172. if (y <= 0)
  3173. my = sd->bl.y + (rand() % 11 - 5);
  3174. else
  3175. my = y;
  3176. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+2*MAX_MOB_DB, 1, "") != 0) ? 1 : 0;
  3177. }
  3178. if (count != 0)
  3179. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3180. else
  3181. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3182. return 0;
  3183. }
  3184. /*==========================================
  3185. *
  3186. *------------------------------------------
  3187. */
  3188. static int atkillmonster_sub(struct block_list *bl, va_list ap) {
  3189. struct mob_data *md;
  3190. int flag;
  3191. nullpo_retr(0, ap);
  3192. nullpo_retr(0, md=(struct mob_data *)bl);
  3193. flag = va_arg(ap, int);
  3194. if (flag)
  3195. mob_damage(NULL, md, md->hp, 2);
  3196. else
  3197. mob_delete(md);
  3198. return 0;
  3199. }
  3200. void atcommand_killmonster_sub(
  3201. const int fd, struct map_session_data* sd, const char* message,
  3202. const int drop)
  3203. {
  3204. int map_id;
  3205. char map_name[MAP_NAME_LENGTH];
  3206. if (!sd) return;
  3207. memset(map_name, '\0', sizeof(map_name));
  3208. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  3209. map_id = sd->bl.m;
  3210. else {
  3211. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  3212. strcat(map_name, ".gat");
  3213. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3214. map_id = sd->bl.m;
  3215. }
  3216. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  3217. clif_displaymessage(fd, msg_table[165]); // All monsters killed!
  3218. return;
  3219. }
  3220. /*==========================================
  3221. *
  3222. *------------------------------------------
  3223. */
  3224. int atcommand_killmonster(
  3225. const int fd, struct map_session_data* sd,
  3226. const char* command, const char* message)
  3227. {
  3228. if (!sd) return 0;
  3229. atcommand_killmonster_sub(fd, sd, message, 1);
  3230. return 0;
  3231. }
  3232. /*==========================================
  3233. *
  3234. *------------------------------------------
  3235. */
  3236. int atcommand_killmonster2(
  3237. const int fd, struct map_session_data* sd,
  3238. const char* command, const char* message)
  3239. {
  3240. if (!sd) return 0;
  3241. atcommand_killmonster_sub(fd, sd, message, 0);
  3242. return 0;
  3243. }
  3244. /*==========================================
  3245. *
  3246. *------------------------------------------
  3247. */
  3248. int atcommand_refine(
  3249. const int fd, struct map_session_data* sd,
  3250. const char* command, const char* message)
  3251. {
  3252. int i, position = 0, refine = 0, current_position, final_refine;
  3253. int count;
  3254. nullpo_retr(-1, sd);
  3255. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3256. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3257. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3258. return -1;
  3259. }
  3260. if (refine < -10)
  3261. refine = -10;
  3262. else if (refine > 10)
  3263. refine = 10;
  3264. else if (refine == 0)
  3265. refine = 1;
  3266. count = 0;
  3267. for (i = 0; i < MAX_INVENTORY; i++) {
  3268. if (sd->status.inventory[i].nameid && // 該当個所の装備を精錬する
  3269. (sd->status.inventory[i].equip & position ||
  3270. (sd->status.inventory[i].equip && !position))) {
  3271. final_refine = sd->status.inventory[i].refine + refine;
  3272. if (final_refine > 10)
  3273. final_refine = 10;
  3274. else if (final_refine < 0)
  3275. final_refine = 0;
  3276. if (sd->status.inventory[i].refine != final_refine) {
  3277. sd->status.inventory[i].refine = final_refine;
  3278. current_position = sd->status.inventory[i].equip;
  3279. pc_unequipitem(sd, i, 3);
  3280. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3281. clif_delitem(sd, i, 1);
  3282. clif_additem(sd, i, 1, 0);
  3283. pc_equipitem(sd, i, current_position);
  3284. clif_misceffect((struct block_list*)&sd->bl, 3);
  3285. count++;
  3286. }
  3287. }
  3288. }
  3289. if (count == 0)
  3290. clif_displaymessage(fd, msg_table[166]); // No item has been refined!
  3291. else if (count == 1)
  3292. clif_displaymessage(fd, msg_table[167]); // 1 item has been refined!
  3293. else {
  3294. sprintf(atcmd_output, msg_table[168], count); // %d items have been refined!
  3295. clif_displaymessage(fd, atcmd_output);
  3296. }
  3297. return 0;
  3298. }
  3299. /*==========================================
  3300. *
  3301. *------------------------------------------
  3302. */
  3303. int atcommand_produce(
  3304. const int fd, struct map_session_data* sd,
  3305. const char* command, const char* message)
  3306. {
  3307. char item_name[100];
  3308. int item_id, attribute = 0, star = 0;
  3309. int flag = 0;
  3310. struct item_data *item_data;
  3311. struct item tmp_item;
  3312. nullpo_retr(-1, sd);
  3313. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3314. memset(item_name, '\0', sizeof(item_name));
  3315. if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
  3316. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3317. return -1;
  3318. }
  3319. item_id = 0;
  3320. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  3321. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  3322. item_id = item_data->nameid;
  3323. if (itemdb_exists(item_id) &&
  3324. (item_id <= 500 || item_id > 1099) &&
  3325. (item_id < 4001 || item_id > 4148) &&
  3326. (item_id < 7001 || item_id > 10019) &&
  3327. itemdb_isequip(item_id)) {
  3328. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3329. attribute = ATTRIBUTE_NORMAL;
  3330. if (star < MIN_STAR || star > MAX_STAR)
  3331. star = 0;
  3332. memset(&tmp_item, 0, sizeof tmp_item);
  3333. tmp_item.nameid = item_id;
  3334. tmp_item.amount = 1;
  3335. tmp_item.identify = 1;
  3336. tmp_item.card[0] = 0x00ff;
  3337. tmp_item.card[1] = ((star * 5) << 8) + attribute;
  3338. tmp_item.card[2] = GetWord(sd->char_id, 0);
  3339. tmp_item.card[3] = GetWord(sd->char_id, 1);
  3340. clif_produceeffect(sd, 0, item_id); // 製造エフェクトパケット
  3341. clif_misceffect(&sd->bl, 3); // 他人にも成功を通知
  3342. //Logs (A)dmins items [Lupus]
  3343. if(log_config.pick > 0 ) {
  3344. log_pick(sd, "A", 0, tmp_item.nameid, 1, &tmp_item);
  3345. }
  3346. //Logs
  3347. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3348. clif_additem(sd, 0, 0, flag);
  3349. } else {
  3350. if (battle_config.error_log)
  3351. ShowError("@produce NOT WEAPON [%d]\n", item_id);
  3352. if (item_id != 0 && itemdb_exists(item_id))
  3353. sprintf(atcmd_output, msg_table[169], item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3354. else
  3355. sprintf(atcmd_output, msg_table[170]); // This item is not an equipment.
  3356. clif_displaymessage(fd, atcmd_output);
  3357. return -1;
  3358. }
  3359. return 0;
  3360. }
  3361. /*==========================================
  3362. * Sub-function to display actual memo points
  3363. *------------------------------------------
  3364. */
  3365. void atcommand_memo_sub(struct map_session_data* sd) {
  3366. int i;
  3367. if (!sd) return;
  3368. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3369. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3370. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3371. if (sd->status.memo_point[i].map)
  3372. sprintf(atcmd_output, "%d - %s (%d,%d)", i, mapindex_id2name(sd->status.memo_point[i].map), sd->status.memo_point[i].x, sd->status.memo_point[i].y);
  3373. else
  3374. sprintf(atcmd_output, msg_table[171], i); // %d - void
  3375. clif_displaymessage(sd->fd, atcmd_output);
  3376. }
  3377. return;
  3378. }
  3379. /*==========================================
  3380. *
  3381. *------------------------------------------
  3382. */
  3383. int atcommand_memo(
  3384. const int fd, struct map_session_data* sd,
  3385. const char* command, const char* message)
  3386. {
  3387. int position = 0;
  3388. nullpo_retr(-1, sd);
  3389. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3390. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3391. atcommand_memo_sub(sd);
  3392. else {
  3393. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3394. if (sd->bl.m >= 0 && (map[sd->bl.m].flag.nowarpto || map[sd->bl.m].flag.nomemo) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3395. clif_displaymessage(fd, msg_table[253]);
  3396. return -1;
  3397. }
  3398. if (sd->status.memo_point[position].map) {
  3399. sprintf(atcmd_output, msg_table[172], position, mapindex_id2name(sd->status.memo_point[position].map), sd->status.memo_point[position].x, sd->status.memo_point[position].y); // You replace previous memo position %d - %s (%d,%d).
  3400. clif_displaymessage(fd, atcmd_output);
  3401. }
  3402. sd->status.memo_point[position].map = map[sd->bl.m].index;
  3403. sd->status.memo_point[position].x = sd->bl.x;
  3404. sd->status.memo_point[position].y = sd->bl.y;
  3405. clif_skill_memo(sd, 0);
  3406. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3407. clif_displaymessage(fd, msg_table[173]); // Note: you don't have the 'Warp' skill level to use it.
  3408. atcommand_memo_sub(sd);
  3409. } else {
  3410. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3411. clif_displaymessage(fd, atcmd_output);
  3412. atcommand_memo_sub(sd);
  3413. return -1;
  3414. }
  3415. }
  3416. return 0;
  3417. }
  3418. /*==========================================
  3419. *
  3420. *------------------------------------------
  3421. */
  3422. int atcommand_gat(
  3423. const int fd, struct map_session_data* sd,
  3424. const char* command, const char* message)
  3425. {
  3426. int y;
  3427. nullpo_retr(-1, sd);
  3428. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3429. for (y = 2; y >= -2; y--) {
  3430. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3431. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3432. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  3433. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  3434. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  3435. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  3436. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  3437. clif_displaymessage(fd, atcmd_output);
  3438. }
  3439. return 0;
  3440. }
  3441. /*==========================================
  3442. *
  3443. *------------------------------------------
  3444. */
  3445. int atcommand_packet(
  3446. const int fd, struct map_session_data* sd,
  3447. const char* command, const char* message)
  3448. {
  3449. static int packet_mode = 0;
  3450. int i, x = 0, y = 0;
  3451. nullpo_retr(-1, sd);
  3452. if (strstr(command, "packetmode")) {
  3453. packet_mode = atoi(message);
  3454. clif_displaymessage(fd, "Packet mode changed.");
  3455. return 0;
  3456. }
  3457. if (!message || !*message || (i = sscanf(message, "%d %d", &x, &y)) < 1) {
  3458. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3459. return -1;
  3460. }
  3461. if (i == 1) y = 1;
  3462. switch (packet_mode)
  3463. {
  3464. case 0:
  3465. clif_status_change(&sd->bl, x, y);
  3466. break;
  3467. case 1:
  3468. sd->status.skill[sd->cloneskill_id].id=0;
  3469. sd->status.skill[sd->cloneskill_id].lv=0;
  3470. sd->status.skill[sd->cloneskill_id].flag=0;
  3471. sd->cloneskill_id = x;
  3472. sd->status.skill[x].id = x;
  3473. sd->status.skill[x].lv = skill_get_max(x);
  3474. sd->status.skill[x].flag = 13;//cloneskill flag
  3475. clif_skillinfoblock(sd);
  3476. break;
  3477. case 2:
  3478. clif_skill_nodamage(&sd->bl,&sd->bl,x,y,1);
  3479. case 3:
  3480. clif_skill_poseffect(&sd->bl,x,y,sd->bl.x,sd->bl.y,gettick());
  3481. default:
  3482. break;
  3483. //added later
  3484. }
  3485. return 0;
  3486. }
  3487. /*==========================================
  3488. * @waterlevel [Skotlex]
  3489. *------------------------------------------
  3490. */
  3491. int atcommand_waterlevel(
  3492. const int fd, struct map_session_data* sd,
  3493. const char* command, const char* message)
  3494. {
  3495. int newlevel;
  3496. if (!message || !*message || sscanf(message, "%d", &newlevel) < 1) {
  3497. sprintf(atcmd_output, "%s's current water level: %d", map[sd->bl.m].name, map_waterheight(map[sd->bl.m].name));
  3498. clif_displaymessage(fd, atcmd_output);
  3499. return 0;
  3500. }
  3501. if (map_setwaterheight(sd->bl.m, map[sd->bl.m].name, newlevel)) {
  3502. if (newlevel > 0)
  3503. sprintf(atcmd_output, "%s's water level changed to: %d", map[sd->bl.m].name, newlevel);
  3504. else
  3505. sprintf(atcmd_output, "Removed %s's water level information.", map[sd->bl.m].name);
  3506. clif_displaymessage(fd, atcmd_output);
  3507. } else {
  3508. sprintf(atcmd_output, "Failed to change %s's water level.", map[sd->bl.m].name);
  3509. clif_displaymessage(fd, atcmd_output);
  3510. }
  3511. return 0;
  3512. }
  3513. /*==========================================
  3514. * @stpoint (Rewritten by [Yor])
  3515. *------------------------------------------
  3516. */
  3517. int atcommand_statuspoint(
  3518. const int fd, struct map_session_data* sd,
  3519. const char* command, const char* message)
  3520. {
  3521. int point, new_status_point;
  3522. if (!message || !*message || (point = atoi(message)) == 0) {
  3523. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3524. return -1;
  3525. }
  3526. new_status_point = (int)sd->status.status_point + point;
  3527. if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow
  3528. new_status_point = 0x7FFF;
  3529. else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow
  3530. new_status_point = 0;
  3531. if (new_status_point != (int)sd->status.status_point) {
  3532. sd->status.status_point = (short)new_status_point;
  3533. clif_updatestatus(sd, SP_STATUSPOINT);
  3534. clif_displaymessage(fd, msg_table[174]); // Number of status points changed!
  3535. } else {
  3536. if (point < 0)
  3537. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3538. else
  3539. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3540. return -1;
  3541. }
  3542. return 0;
  3543. }
  3544. /*==========================================
  3545. * @skpoint (Rewritten by [Yor])
  3546. *------------------------------------------
  3547. */
  3548. int atcommand_skillpoint(
  3549. const int fd, struct map_session_data* sd,
  3550. const char* command, const char* message)
  3551. {
  3552. int point, new_skill_point;
  3553. nullpo_retr(-1, sd);
  3554. if (!message || !*message || (point = atoi(message)) == 0) {
  3555. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3556. return -1;
  3557. }
  3558. new_skill_point = (int)sd->status.skill_point + point;
  3559. if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow
  3560. new_skill_point = 0x7FFF;
  3561. else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow
  3562. new_skill_point = 0;
  3563. if (new_skill_point != (int)sd->status.skill_point) {
  3564. sd->status.skill_point = (short)new_skill_point;
  3565. clif_updatestatus(sd, SP_SKILLPOINT);
  3566. clif_displaymessage(fd, msg_table[175]); // Number of skill points changed!
  3567. } else {
  3568. if (point < 0)
  3569. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3570. else
  3571. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3572. return -1;
  3573. }
  3574. return 0;
  3575. }
  3576. /*==========================================
  3577. * @zeny (Rewritten by [Yor])
  3578. *------------------------------------------
  3579. */
  3580. int atcommand_zeny(
  3581. const int fd, struct map_session_data* sd,
  3582. const char* command, const char* message)
  3583. {
  3584. int zeny, new_zeny;
  3585. nullpo_retr(-1, sd);
  3586. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3587. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3588. return -1;
  3589. }
  3590. new_zeny = sd->status.zeny + zeny;
  3591. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3592. new_zeny = MAX_ZENY;
  3593. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3594. new_zeny = 0;
  3595. if (new_zeny != sd->status.zeny) {
  3596. sd->status.zeny = new_zeny;
  3597. clif_updatestatus(sd, SP_ZENY);
  3598. clif_displaymessage(fd, msg_table[176]); // Number of zenys changed!
  3599. } else {
  3600. if (zeny < 0)
  3601. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3602. else
  3603. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3604. return -1;
  3605. }
  3606. return 0;
  3607. }
  3608. /*==========================================
  3609. *
  3610. *------------------------------------------
  3611. */
  3612. int atcommand_param(
  3613. const int fd, struct map_session_data* sd,
  3614. const char* command, const char* message)
  3615. {
  3616. int i, index, value = 0, new_value;
  3617. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3618. short* status[] = {
  3619. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3620. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3621. };
  3622. nullpo_retr(-1, sd);
  3623. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3624. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3625. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3626. clif_displaymessage(fd, atcmd_output);
  3627. return -1;
  3628. }
  3629. index = -1;
  3630. for (i = 0; param[i] != NULL; i++) {
  3631. if (strcmpi(command, param[i]) == 0) {
  3632. index = i;
  3633. break;
  3634. }
  3635. }
  3636. if (index < 0 || index > MAX_STATUS_TYPE) { // normaly impossible...
  3637. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3638. clif_displaymessage(fd, atcmd_output);
  3639. return -1;
  3640. }
  3641. new_value = (int)*status[index] + value;
  3642. if (value > 0 && (value > pc_maxparameter(sd) || new_value > pc_maxparameter(sd))) // fix positiv overflow
  3643. new_value = pc_maxparameter(sd);
  3644. else if (value < 0 && (value < -(int)pc_maxparameter(sd) || new_value < 1)) // fix negativ overflow
  3645. new_value = 1;
  3646. if (new_value != (int)*status[index]) {
  3647. *status[index] = new_value;
  3648. clif_updatestatus(sd, SP_STR + index);
  3649. clif_updatestatus(sd, SP_USTR + index);
  3650. status_calc_pc(sd, 0);
  3651. clif_displaymessage(fd, msg_table[42]); // Stat changed.
  3652. } else {
  3653. if (value < 0)
  3654. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3655. else
  3656. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3657. return -1;
  3658. }
  3659. return 0;
  3660. }
  3661. /*==========================================
  3662. *
  3663. *------------------------------------------
  3664. */
  3665. //** Stat all by fritz (rewritten by [Yor])
  3666. int atcommand_stat_all(
  3667. const int fd, struct map_session_data* sd,
  3668. const char* command, const char* message)
  3669. {
  3670. int index, count, value = 0, new_value;
  3671. short* status[] = {
  3672. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3673. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3674. };
  3675. nullpo_retr(-1, sd);
  3676. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3677. value = pc_maxparameter(sd);
  3678. count = 0;
  3679. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3680. new_value = (int)*status[index] + value;
  3681. if (value > 0 && (value > pc_maxparameter(sd) || new_value > pc_maxparameter(sd))) // fix positiv overflow
  3682. new_value = pc_maxparameter(sd);
  3683. else if (value < 0 && (value < -(int)pc_maxparameter(sd) || new_value < 1)) // fix negative overflow
  3684. new_value = 1;
  3685. if (new_value != (int)*status[index]) {
  3686. *status[index] = new_value;
  3687. clif_updatestatus(sd, SP_STR + index);
  3688. clif_updatestatus(sd, SP_USTR + index);
  3689. status_calc_pc(sd, 0);
  3690. count++;
  3691. }
  3692. }
  3693. if (count > 0) // if at least 1 stat modified
  3694. clif_displaymessage(fd, msg_table[84]); // All stats changed!
  3695. else {
  3696. if (value < 0)
  3697. clif_displaymessage(fd, msg_table[177]); // Impossible to decrease a stat.
  3698. else
  3699. clif_displaymessage(fd, msg_table[178]); // Impossible to increase a stat.
  3700. return -1;
  3701. }
  3702. return 0;
  3703. }
  3704. /*==========================================
  3705. *
  3706. *------------------------------------------
  3707. */
  3708. int atcommand_guildlevelup(
  3709. const int fd, struct map_session_data* sd,
  3710. const char* command, const char* message)
  3711. {
  3712. int level = 0;
  3713. short added_level;
  3714. struct guild *guild_info;
  3715. nullpo_retr(-1, sd);
  3716. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3717. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3718. return -1;
  3719. }
  3720. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3721. clif_displaymessage(fd, msg_table[43]); // You're not in a guild.
  3722. return -1;
  3723. }
  3724. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3725. clif_displaymessage(fd, msg_table[44]); // You're not the master of your guild.
  3726. return -1;
  3727. }
  3728. added_level = (short)level;
  3729. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3730. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3731. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3732. added_level = 1 - guild_info->guild_lv;
  3733. if (added_level != 0) {
  3734. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3735. clif_displaymessage(fd, msg_table[179]); // Guild level changed.
  3736. } else {
  3737. clif_displaymessage(fd, msg_table[45]); // Guild level change failed.
  3738. return -1;
  3739. }
  3740. return 0;
  3741. }
  3742. /*==========================================
  3743. *
  3744. *------------------------------------------
  3745. */
  3746. int atcommand_makeegg(
  3747. const int fd, struct map_session_data* sd,
  3748. const char* command, const char* message)
  3749. {
  3750. struct item_data *item_data;
  3751. int id, pet_id;
  3752. nullpo_retr(-1, sd);
  3753. if (!message || !*message) {
  3754. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3755. return -1;
  3756. }
  3757. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3758. id = item_data->nameid;
  3759. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3760. id = atoi(message);
  3761. pet_id = search_petDB_index(id, PET_CLASS);
  3762. if (pet_id < 0)
  3763. pet_id = search_petDB_index(id, PET_EGG);
  3764. if (pet_id >= 0) {
  3765. sd->catch_target_class = pet_db[pet_id].class_;
  3766. intif_create_pet(
  3767. sd->status.account_id, sd->status.char_id,
  3768. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  3769. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3770. 100, 0, 1, pet_db[pet_id].jname);
  3771. } else {
  3772. clif_displaymessage(fd, msg_table[180]); // The monter/egg name/id doesn't exist.
  3773. return -1;
  3774. }
  3775. return 0;
  3776. }
  3777. /*==========================================
  3778. *
  3779. *------------------------------------------
  3780. */
  3781. int atcommand_hatch(
  3782. const int fd, struct map_session_data* sd,
  3783. const char* command, const char* message)
  3784. {
  3785. nullpo_retr(-1, sd);
  3786. if (sd->status.pet_id <= 0)
  3787. clif_sendegg(sd);
  3788. else {
  3789. clif_displaymessage(fd, msg_table[181]); // You already have a pet.
  3790. return -1;
  3791. }
  3792. return 0;
  3793. }
  3794. /*==========================================
  3795. *
  3796. *------------------------------------------
  3797. */
  3798. int atcommand_petfriendly(
  3799. const int fd, struct map_session_data* sd,
  3800. const char* command, const char* message)
  3801. {
  3802. int friendly;
  3803. int t;
  3804. nullpo_retr(-1, sd);
  3805. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3806. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3807. return -1;
  3808. }
  3809. if (sd->status.pet_id > 0 && sd->pd) {
  3810. if (friendly >= 0 && friendly <= 1000) {
  3811. if (friendly != sd->pet.intimate) {
  3812. t = sd->pet.intimate;
  3813. sd->pet.intimate = friendly;
  3814. clif_send_petstatus(sd);
  3815. if (battle_config.pet_status_support) {
  3816. if ((sd->pet.intimate > 0 && t <= 0) ||
  3817. (sd->pet.intimate <= 0 && t > 0)) {
  3818. if (sd->bl.prev != NULL)
  3819. status_calc_pc(sd, 0);
  3820. else
  3821. status_calc_pc(sd, 2);
  3822. }
  3823. }
  3824. clif_displaymessage(fd, msg_table[182]); // Pet friendly value changed!
  3825. } else {
  3826. clif_displaymessage(fd, msg_table[183]); // Pet friendly is already the good value.
  3827. return -1;
  3828. }
  3829. } else {
  3830. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3831. return -1;
  3832. }
  3833. } else {
  3834. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3835. return -1;
  3836. }
  3837. return 0;
  3838. }
  3839. /*==========================================
  3840. *
  3841. *------------------------------------------
  3842. */
  3843. int atcommand_pethungry(
  3844. const int fd, struct map_session_data* sd,
  3845. const char* command, const char* message)
  3846. {
  3847. int hungry;
  3848. nullpo_retr(-1, sd);
  3849. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3850. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3851. return -1;
  3852. }
  3853. if (sd->status.pet_id > 0 && sd->pd) {
  3854. if (hungry >= 0 && hungry <= 100) {
  3855. if (hungry != sd->pet.hungry) {
  3856. sd->pet.hungry = hungry;
  3857. clif_send_petstatus(sd);
  3858. clif_displaymessage(fd, msg_table[185]); // Pet hungry value changed!
  3859. } else {
  3860. clif_displaymessage(fd, msg_table[186]); // Pet hungry is already the good value.
  3861. return -1;
  3862. }
  3863. } else {
  3864. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3865. return -1;
  3866. }
  3867. } else {
  3868. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3869. return -1;
  3870. }
  3871. return 0;
  3872. }
  3873. /*==========================================
  3874. *
  3875. *------------------------------------------
  3876. */
  3877. int atcommand_petrename(
  3878. const int fd, struct map_session_data* sd,
  3879. const char* command, const char* message)
  3880. {
  3881. nullpo_retr(-1, sd);
  3882. if (sd->status.pet_id > 0 && sd->pd) {
  3883. if (sd->pet.rename_flag != 0) {
  3884. sd->pet.rename_flag = 0;
  3885. intif_save_petdata(sd->status.account_id, &sd->pet);
  3886. clif_send_petstatus(sd);
  3887. clif_displaymessage(fd, msg_table[187]); // You can now rename your pet.
  3888. } else {
  3889. clif_displaymessage(fd, msg_table[188]); // You can already rename your pet.
  3890. return -1;
  3891. }
  3892. } else {
  3893. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3894. return -1;
  3895. }
  3896. return 0;
  3897. }
  3898. /*==========================================
  3899. *
  3900. *------------------------------------------
  3901. */
  3902. int
  3903. atcommand_recall(
  3904. const int fd, struct map_session_data* sd,
  3905. const char* command, const char* message)
  3906. {
  3907. struct map_session_data *pl_sd = NULL;
  3908. nullpo_retr(-1, sd);
  3909. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3910. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3911. return -1;
  3912. }
  3913. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  3914. if(sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  3915. return -1;
  3916. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
  3917. return -1;
  3918. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3919. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3920. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3921. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3922. return -1;
  3923. }
  3924. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3925. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  3926. return -1;
  3927. }
  3928. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3929. sprintf(atcmd_output, msg_table[46], atcmd_player_name); // %s recalled!
  3930. clif_displaymessage(fd, atcmd_output);
  3931. } else {
  3932. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  3933. return -1;
  3934. }
  3935. } else {
  3936. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3937. return -1;
  3938. }
  3939. return 0;
  3940. }
  3941. /*==========================================
  3942. *
  3943. *------------------------------------------
  3944. */
  3945. int atcommand_revive(
  3946. const int fd, struct map_session_data* sd,
  3947. const char* command, const char* message)
  3948. {
  3949. struct map_session_data *pl_sd;
  3950. nullpo_retr(-1, sd);
  3951. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3952. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3953. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  3954. return -1;
  3955. }
  3956. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3957. if (pc_isdead(pl_sd)) {
  3958. pl_sd->status.hp = pl_sd->status.max_hp;
  3959. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3960. pc_setstand(pl_sd);
  3961. if (battle_config.pc_invincible_time > 0)
  3962. pc_setinvincibletimer(pl_sd, battle_config.pc_invincible_time);
  3963. clif_updatestatus(pl_sd, SP_HP);
  3964. clif_updatestatus(pl_sd, SP_SP);
  3965. clif_resurrection(&pl_sd->bl, 1);
  3966. clif_displaymessage(fd, msg_table[51]); // Character revived.
  3967. return 0;
  3968. }
  3969. return -1;
  3970. } else {
  3971. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3972. return -1;
  3973. }
  3974. return 0;
  3975. }
  3976. /*==========================================
  3977. * charblock command (usage: charblock <player_name>)
  3978. * This command do a definitiv ban on a player
  3979. *------------------------------------------
  3980. */
  3981. int atcommand_char_block(
  3982. const int fd, struct map_session_data* sd,
  3983. const char* command, const char* message)
  3984. {
  3985. nullpo_retr(-1, sd);
  3986. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3987. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  3988. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3989. return -1;
  3990. }
  3991. // check player name
  3992. if (strlen(atcmd_player_name) < 4) {
  3993. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3994. return -1;
  3995. } else if (strlen(atcmd_player_name) > 23) {
  3996. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3997. return -1;
  3998. } else {
  3999. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  4000. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4001. }
  4002. return 0;
  4003. }
  4004. /*==========================================
  4005. * charban command (usage: charban <time> <player_name>)
  4006. * This command do a limited ban on a player
  4007. * Time is done as follows:
  4008. * Adjustment value (-1, 1, +1, etc...)
  4009. * Modified element:
  4010. * a or y: year
  4011. * m: month
  4012. * j or d: day
  4013. * h: hour
  4014. * mn: minute
  4015. * s: second
  4016. * <example> @ban +1m-2mn1s-6y test_player
  4017. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  4018. *------------------------------------------
  4019. */
  4020. int atcommand_char_ban(
  4021. const int fd, struct map_session_data* sd,
  4022. const char* command, const char* message)
  4023. {
  4024. char * modif_p;
  4025. int year, month, day, hour, minute, second, value;
  4026. nullpo_retr(-1, sd);
  4027. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4028. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4029. if (!message || !*message || sscanf(message, "%s %99[^\n]", atcmd_output, atcmd_player_name) < 2) {
  4030. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  4031. return -1;
  4032. }
  4033. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4034. modif_p = atcmd_output;
  4035. year = month = day = hour = minute = second = 0;
  4036. while (modif_p[0] != '\0') {
  4037. value = atoi(modif_p);
  4038. if (value == 0)
  4039. modif_p++;
  4040. else {
  4041. if (modif_p[0] == '-' || modif_p[0] == '+')
  4042. modif_p++;
  4043. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4044. modif_p++;
  4045. if (modif_p[0] == 's') {
  4046. second = value;
  4047. modif_p++;
  4048. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  4049. minute = value;
  4050. modif_p = modif_p + 2;
  4051. } else if (modif_p[0] == 'h') {
  4052. hour = value;
  4053. modif_p++;
  4054. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4055. day = value;
  4056. modif_p++;
  4057. } else if (modif_p[0] == 'm') {
  4058. month = value;
  4059. modif_p++;
  4060. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4061. year = value;
  4062. modif_p++;
  4063. } else if (modif_p[0] != '\0') {
  4064. modif_p++;
  4065. }
  4066. }
  4067. }
  4068. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  4069. clif_displaymessage(fd, msg_table[85]); // Invalid time for ban command.
  4070. return -1;
  4071. }
  4072. // check player name
  4073. if (strlen(atcmd_player_name) < 4) {
  4074. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4075. return -1;
  4076. } else if (strlen(atcmd_player_name) > 23) {
  4077. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4078. return -1;
  4079. } else {
  4080. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  4081. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4082. }
  4083. return 0;
  4084. }
  4085. /*==========================================
  4086. * charunblock command (usage: charunblock <player_name>)
  4087. *------------------------------------------
  4088. */
  4089. int atcommand_char_unblock(
  4090. const int fd, struct map_session_data* sd,
  4091. const char* command, const char* message)
  4092. {
  4093. nullpo_retr(-1, sd);
  4094. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4095. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4096. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  4097. return -1;
  4098. }
  4099. // check player name
  4100. if (strlen(atcmd_player_name) < 4) {
  4101. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4102. return -1;
  4103. } else if (strlen(atcmd_player_name) > 23) {
  4104. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4105. return -1;
  4106. } else {
  4107. // send answer to login server via char-server
  4108. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  4109. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4110. }
  4111. return 0;
  4112. }
  4113. /*==========================================
  4114. * charunban command (usage: charunban <player_name>)
  4115. *------------------------------------------
  4116. */
  4117. int atcommand_char_unban(
  4118. const int fd, struct map_session_data* sd,
  4119. const char* command, const char* message)
  4120. {
  4121. nullpo_retr(-1, sd);
  4122. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4123. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4124. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  4125. return -1;
  4126. }
  4127. // check player name
  4128. if (strlen(atcmd_player_name) < 4) {
  4129. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4130. return -1;
  4131. } else if (strlen(atcmd_player_name) > 23) {
  4132. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4133. return -1;
  4134. } else {
  4135. // send answer to login server via char-server
  4136. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  4137. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4138. }
  4139. return 0;
  4140. }
  4141. /*==========================================
  4142. *
  4143. *------------------------------------------
  4144. */
  4145. int atcommand_night(
  4146. const int fd, struct map_session_data* sd,
  4147. const char* command, const char* message)
  4148. {
  4149. nullpo_retr(-1, sd);
  4150. if (night_flag != 1) {
  4151. map_night_timer(night_timer_tid, 0, 0, 1);
  4152. } else {
  4153. clif_displaymessage(fd, msg_table[89]); // Sorry, it's already the night. Impossible to execute the command.
  4154. return -1;
  4155. }
  4156. return 0;
  4157. }
  4158. /*==========================================
  4159. *
  4160. *------------------------------------------
  4161. */
  4162. int atcommand_day(
  4163. const int fd, struct map_session_data* sd,
  4164. const char* command, const char* message)
  4165. {
  4166. nullpo_retr(-1, sd);
  4167. if (night_flag != 0) {
  4168. map_day_timer(day_timer_tid, 0, 0, 1);
  4169. } else {
  4170. clif_displaymessage(fd, msg_table[90]); // Sorry, it's already the day. Impossible to execute the command.
  4171. return -1;
  4172. }
  4173. return 0;
  4174. }
  4175. /*==========================================
  4176. *
  4177. *------------------------------------------
  4178. */
  4179. int atcommand_doom(
  4180. const int fd, struct map_session_data* sd,
  4181. const char* command, const char* message)
  4182. {
  4183. struct map_session_data *pl_sd, **pl_allsd;
  4184. int i, users;
  4185. nullpo_retr(-1, sd);
  4186. clif_specialeffect(&sd->bl,450,2);
  4187. pl_allsd = map_getallusers(&users);
  4188. for(i = 0; i < users; i++) {
  4189. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  4190. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  4191. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4192. }
  4193. }
  4194. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4195. return 0;
  4196. }
  4197. /*==========================================
  4198. *
  4199. *------------------------------------------
  4200. */
  4201. int atcommand_doommap(
  4202. const int fd, struct map_session_data* sd,
  4203. const char* command, const char* message)
  4204. {
  4205. struct map_session_data *pl_sd, **pl_allsd;
  4206. int i, users;
  4207. nullpo_retr(-1, sd);
  4208. clif_specialeffect(&sd->bl,450,3);
  4209. pl_allsd = map_getallusers(&users);
  4210. for (i = 0; i < users; i++) {
  4211. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
  4212. pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
  4213. {
  4214. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  4215. // clif_specialeffect(&pl_sd->bl,450,1);
  4216. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4217. }
  4218. }
  4219. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4220. return 0;
  4221. }
  4222. /*==========================================
  4223. *
  4224. *------------------------------------------
  4225. */
  4226. static void atcommand_raise_sub(struct map_session_data* sd)
  4227. {
  4228. if (sd && sd->state.auth && pc_isdead(sd)) {
  4229. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4230. sd->status.hp = sd->status.max_hp;
  4231. sd->status.sp = sd->status.max_sp;
  4232. pc_setstand(sd);
  4233. clif_updatestatus(sd, SP_HP);
  4234. clif_updatestatus(sd, SP_SP);
  4235. clif_resurrection(&sd->bl, 1);
  4236. if (battle_config.pc_invincible_time > 0)
  4237. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  4238. clif_displaymessage(sd->fd, msg_table[63]); // Mercy has been shown.
  4239. }
  4240. }
  4241. /*==========================================
  4242. *
  4243. *------------------------------------------
  4244. */
  4245. int atcommand_raise(
  4246. const int fd, struct map_session_data* sd,
  4247. const char* command, const char* message)
  4248. {
  4249. int i, users;
  4250. struct map_session_data **all_sd;
  4251. nullpo_retr(-1, sd);
  4252. all_sd = map_getallusers(&users);
  4253. for (i = 0; i < users; i++) {
  4254. atcommand_raise_sub(all_sd[i]);
  4255. }
  4256. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4257. return 0;
  4258. }
  4259. /*==========================================
  4260. *
  4261. *------------------------------------------
  4262. */
  4263. int atcommand_raisemap(
  4264. const int fd, struct map_session_data* sd,
  4265. const char* command, const char* message)
  4266. {
  4267. struct map_session_data **pl_allsd;
  4268. int i, users;
  4269. nullpo_retr(-1, sd);
  4270. pl_allsd = map_getallusers(&users);
  4271. for (i = 0; i < users; i++) {
  4272. if (sd->bl.m == pl_allsd[i]->bl.m)
  4273. atcommand_raise_sub(pl_allsd[i]);
  4274. }
  4275. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4276. return 0;
  4277. }
  4278. /*==========================================
  4279. *
  4280. *------------------------------------------
  4281. */
  4282. int atcommand_kick(
  4283. const int fd, struct map_session_data* sd,
  4284. const char* command, const char* message)
  4285. {
  4286. struct map_session_data *pl_sd;
  4287. nullpo_retr(-1, sd);
  4288. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4289. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4290. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4291. return -1;
  4292. }
  4293. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4294. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4295. clif_GM_kick(sd, pl_sd, 1);
  4296. else {
  4297. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4298. return -1;
  4299. }
  4300. } else {
  4301. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4302. return -1;
  4303. }
  4304. return 0;
  4305. }
  4306. /*==========================================
  4307. *
  4308. *------------------------------------------
  4309. */
  4310. int atcommand_kickall(
  4311. const int fd, struct map_session_data* sd,
  4312. const char* command, const char* message)
  4313. {
  4314. struct map_session_data *pl_sd, **pl_allsd;
  4315. int i, users;
  4316. nullpo_retr(-1, sd);
  4317. pl_allsd = map_getallusers(&users);
  4318. for (i = 0; i < users; i++) {
  4319. if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4320. if (sd->status.account_id != pl_sd->status.account_id)
  4321. clif_GM_kick(sd, pl_sd, 0);
  4322. }
  4323. }
  4324. clif_displaymessage(fd, msg_table[195]); // All players have been kicked!
  4325. return 0;
  4326. }
  4327. /*==========================================
  4328. *
  4329. *------------------------------------------
  4330. */
  4331. int atcommand_allskill(
  4332. const int fd, struct map_session_data* sd,
  4333. const char* command, const char* message)
  4334. {
  4335. nullpo_retr(-1, sd);
  4336. pc_allskillup(sd); // all skills
  4337. sd->status.skill_point = 0; // 0 skill points
  4338. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4339. clif_displaymessage(fd, msg_table[76]); // You have received all skills.
  4340. return 0;
  4341. }
  4342. /*==========================================
  4343. *
  4344. *------------------------------------------
  4345. */
  4346. int atcommand_questskill(
  4347. const int fd, struct map_session_data* sd,
  4348. const char* command, const char* message)
  4349. {
  4350. int skill_id;
  4351. nullpo_retr(-1, sd);
  4352. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4353. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4354. return -1;
  4355. }
  4356. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4357. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4358. if (pc_checkskill(sd, skill_id) == 0) {
  4359. pc_skill(sd, skill_id, 1, 0);
  4360. clif_displaymessage(fd, msg_table[70]); // You have learned the skill.
  4361. } else {
  4362. clif_displaymessage(fd, msg_table[196]); // You already have this quest skill.
  4363. return -1;
  4364. }
  4365. } else {
  4366. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4367. return -1;
  4368. }
  4369. } else {
  4370. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4371. return -1;
  4372. }
  4373. return 0;
  4374. }
  4375. /*==========================================
  4376. *
  4377. *------------------------------------------
  4378. */
  4379. int atcommand_lostskill(
  4380. const int fd, struct map_session_data* sd,
  4381. const char* command, const char* message)
  4382. {
  4383. int skill_id;
  4384. nullpo_retr(-1, sd);
  4385. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4386. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4387. return -1;
  4388. }
  4389. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4390. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4391. if (pc_checkskill(sd, skill_id) > 0) {
  4392. sd->status.skill[skill_id].lv = 0;
  4393. sd->status.skill[skill_id].flag = 0;
  4394. clif_skillinfoblock(sd);
  4395. clif_displaymessage(fd, msg_table[71]); // You have forgotten the skill.
  4396. } else {
  4397. clif_displaymessage(fd, msg_table[201]); // You don't have this quest skill.
  4398. return -1;
  4399. }
  4400. } else {
  4401. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4402. return -1;
  4403. }
  4404. } else {
  4405. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4406. return -1;
  4407. }
  4408. return 0;
  4409. }
  4410. /*==========================================
  4411. *
  4412. *------------------------------------------
  4413. */
  4414. int atcommand_spiritball(
  4415. const int fd, struct map_session_data* sd,
  4416. const char* command, const char* message)
  4417. {
  4418. int number;
  4419. nullpo_retr(-1, sd);
  4420. if (!message || !*message || (number = atoi(message)) < 0) {
  4421. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4422. return -1;
  4423. }
  4424. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4425. if (number > 500)
  4426. number = 500;
  4427. if (number >= 0 && number <= 0x7FFF) {
  4428. if (sd->spiritball != number || number > 499) {
  4429. if (sd->spiritball > 0)
  4430. pc_delspiritball(sd, sd->spiritball, 1);
  4431. sd->spiritball = number;
  4432. clif_spiritball(sd);
  4433. // no message, player can look the difference
  4434. if (number > 1000)
  4435. clif_displaymessage(fd, msg_table[204]); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4436. } else {
  4437. clif_displaymessage(fd, msg_table[205]); // You already have this number of spiritballs.
  4438. return -1;
  4439. }
  4440. } else {
  4441. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4442. return -1;
  4443. }
  4444. return 0;
  4445. }
  4446. /*==========================================
  4447. *
  4448. *------------------------------------------
  4449. */
  4450. int atcommand_party(
  4451. const int fd, struct map_session_data* sd,
  4452. const char* command, const char* message)
  4453. {
  4454. char party[NAME_LENGTH];
  4455. nullpo_retr(-1, sd);
  4456. memset(party, '\0', sizeof(party));
  4457. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  4458. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4459. return -1;
  4460. }
  4461. party_create(sd, party, 0, 0);
  4462. return 0;
  4463. }
  4464. /*==========================================
  4465. *
  4466. *------------------------------------------
  4467. */
  4468. int atcommand_guild(
  4469. const int fd, struct map_session_data* sd,
  4470. const char* command, const char* message)
  4471. {
  4472. char guild[NAME_LENGTH];
  4473. int prev;
  4474. nullpo_retr(-1, sd);
  4475. memset(guild, '\0', sizeof(guild));
  4476. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  4477. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4478. return -1;
  4479. }
  4480. prev = battle_config.guild_emperium_check;
  4481. battle_config.guild_emperium_check = 0;
  4482. guild_create(sd, guild);
  4483. battle_config.guild_emperium_check = prev;
  4484. return 0;
  4485. }
  4486. /*==========================================
  4487. *
  4488. *------------------------------------------
  4489. */
  4490. int atcommand_agitstart(
  4491. const int fd, struct map_session_data* sd,
  4492. const char* command, const char* message)
  4493. {
  4494. nullpo_retr(-1, sd);
  4495. if (agit_flag == 1) {
  4496. clif_displaymessage(fd, msg_table[73]); // Already it has started siege warfare.
  4497. return -1;
  4498. }
  4499. agit_flag = 1;
  4500. guild_agit_start();
  4501. clif_displaymessage(fd, msg_table[72]); // Guild siege warfare start!
  4502. return 0;
  4503. }
  4504. /*==========================================
  4505. *
  4506. *------------------------------------------
  4507. */
  4508. int atcommand_agitend(
  4509. const int fd, struct map_session_data* sd,
  4510. const char* command, const char* message)
  4511. {
  4512. nullpo_retr(-1, sd);
  4513. if (agit_flag == 0) {
  4514. clif_displaymessage(fd, msg_table[75]); // Siege warfare hasn't started yet.
  4515. return -1;
  4516. }
  4517. agit_flag = 0;
  4518. guild_agit_end();
  4519. clif_displaymessage(fd, msg_table[74]); // Guild siege warfare end!
  4520. return 0;
  4521. }
  4522. /*==========================================
  4523. * @mapexitでマップサーバーを終了させる
  4524. *------------------------------------------
  4525. */
  4526. int atcommand_mapexit(
  4527. const int fd, struct map_session_data* sd,
  4528. const char* command, const char* message)
  4529. {
  4530. struct map_session_data *pl_sd, **pl_allsd;
  4531. int i, users;
  4532. nullpo_retr(-1, sd);
  4533. pl_allsd = map_getallusers(&users);
  4534. for (i = 0; i < users; i++) {
  4535. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
  4536. clif_GM_kick(sd, pl_sd, 0);
  4537. }
  4538. clif_GM_kick(sd, sd, 0);
  4539. flush_fifos();
  4540. runflag = 0;
  4541. return 0;
  4542. }
  4543. /*==========================================
  4544. * idsearch <part_of_name>: revrited by [Yor]
  4545. *------------------------------------------
  4546. */
  4547. int atcommand_idsearch(
  4548. const int fd, struct map_session_data* sd,
  4549. const char* command, const char* message)
  4550. {
  4551. char item_name[100];
  4552. unsigned int i, match;
  4553. struct item_data *item;
  4554. nullpo_retr(-1, sd);
  4555. memset(item_name, '\0', sizeof(item_name));
  4556. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4557. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4558. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4559. return -1;
  4560. }
  4561. sprintf(atcmd_output, msg_table[77], item_name); // The reference result of '%s' (name: id):
  4562. clif_displaymessage(fd, atcmd_output);
  4563. match = 0;
  4564. for(i = 0; i < 20000; i++) {
  4565. if ((item = itemdb_exists(i)) != NULL && strstr(item->jname, item_name) != NULL) {
  4566. match++;
  4567. sprintf(atcmd_output, msg_table[78], item->jname, item->nameid); // %s: %d
  4568. clif_displaymessage(fd, atcmd_output);
  4569. }
  4570. }
  4571. sprintf(atcmd_output, msg_table[79], match); // It is %d affair above.
  4572. clif_displaymessage(fd, atcmd_output);
  4573. return 0;
  4574. }
  4575. /*==========================================
  4576. * Recall All Characters Online To Your Location
  4577. *------------------------------------------
  4578. */
  4579. int atcommand_recallall(
  4580. const int fd, struct map_session_data* sd,
  4581. const char* command, const char* message)
  4582. {
  4583. struct map_session_data *pl_sd, **pl_allsd;
  4584. int i;
  4585. int count, users;
  4586. nullpo_retr(-1, sd);
  4587. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4588. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4589. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4590. return -1;
  4591. }
  4592. count = 0;
  4593. pl_allsd = map_getallusers(&users);
  4594. for (i = 0; i < users; i++) {
  4595. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4596. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4597. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4598. count++;
  4599. else {
  4600. if (pc_isdead(pl_sd)) { //Wake them up
  4601. pc_setstand(pl_sd);
  4602. pc_setrestartvalue(pl_sd,1);
  4603. }
  4604. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4605. }
  4606. }
  4607. }
  4608. clif_displaymessage(fd, msg_table[92]); // All characters recalled!
  4609. if (count) {
  4610. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4611. clif_displaymessage(fd, atcmd_output);
  4612. }
  4613. return 0;
  4614. }
  4615. /*==========================================
  4616. * Recall online characters of a guild to your location
  4617. *------------------------------------------
  4618. */
  4619. int atcommand_guildrecall(
  4620. const int fd, struct map_session_data* sd,
  4621. const char* command, const char* message)
  4622. {
  4623. struct map_session_data *pl_sd, **pl_allsd;
  4624. int i, users, count;
  4625. char guild_name[NAME_LENGTH];
  4626. struct guild *g;
  4627. nullpo_retr(-1, sd);
  4628. memset(guild_name, '\0', sizeof(guild_name));
  4629. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4630. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4631. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4632. return -1;
  4633. }
  4634. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4635. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4636. return -1;
  4637. }
  4638. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4639. (g = guild_search(atoi(message))) != NULL) {
  4640. count = 0;
  4641. pl_allsd = map_getallusers(&users);
  4642. for (i = 0; i < users; i++) {
  4643. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4644. pl_sd->status.guild_id == g->guild_id) {
  4645. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4646. count++;
  4647. else
  4648. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4649. }
  4650. }
  4651. sprintf(atcmd_output, msg_table[93], g->name); // All online characters of the %s guild are near you.
  4652. clif_displaymessage(fd, atcmd_output);
  4653. if (count) {
  4654. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4655. clif_displaymessage(fd, atcmd_output);
  4656. }
  4657. } else {
  4658. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  4659. return -1;
  4660. }
  4661. return 0;
  4662. }
  4663. /*==========================================
  4664. * Recall online characters of a party to your location
  4665. *------------------------------------------
  4666. */
  4667. int atcommand_partyrecall(
  4668. const int fd, struct map_session_data* sd,
  4669. const char* command, const char* message)
  4670. {
  4671. int i;
  4672. struct map_session_data *pl_sd, **pl_allsd;
  4673. char party_name[NAME_LENGTH];
  4674. struct party *p;
  4675. int count, users;
  4676. nullpo_retr(-1, sd);
  4677. memset(party_name, '\0', sizeof(party_name));
  4678. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4679. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4680. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4681. return -1;
  4682. }
  4683. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4684. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4685. return -1;
  4686. }
  4687. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4688. (p = party_search(atoi(message))) != NULL) {
  4689. count = 0;
  4690. pl_allsd = map_getallusers(&users);
  4691. for (i = 0; i < users; i++) {
  4692. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4693. pl_sd->status.party_id == p->party_id) {
  4694. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4695. count++;
  4696. else
  4697. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4698. }
  4699. }
  4700. sprintf(atcmd_output, msg_table[95], p->name); // All online characters of the %s party are near you.
  4701. clif_displaymessage(fd, atcmd_output);
  4702. if (count) {
  4703. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4704. clif_displaymessage(fd, atcmd_output);
  4705. }
  4706. } else {
  4707. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  4708. return -1;
  4709. }
  4710. return 0;
  4711. }
  4712. /*==========================================
  4713. *
  4714. *------------------------------------------
  4715. */
  4716. int atcommand_reloaditemdb(
  4717. const int fd, struct map_session_data* sd,
  4718. const char* command, const char* message)
  4719. {
  4720. nullpo_retr(-1, sd);
  4721. itemdb_reload();
  4722. clif_displaymessage(fd, msg_table[97]); // Item database reloaded.
  4723. return 0;
  4724. }
  4725. /*==========================================
  4726. *
  4727. *------------------------------------------
  4728. */
  4729. int atcommand_reloadmobdb(
  4730. const int fd, struct map_session_data* sd,
  4731. const char* command, const char* message)
  4732. {
  4733. nullpo_retr(-1, sd);
  4734. mob_reload();
  4735. do_final_pet();
  4736. read_petdb();
  4737. clif_displaymessage(fd, msg_table[98]); // Monster database reloaded.
  4738. return 0;
  4739. }
  4740. /*==========================================
  4741. *
  4742. *------------------------------------------
  4743. */
  4744. int atcommand_reloadskilldb(
  4745. const int fd, struct map_session_data* sd,
  4746. const char* command, const char* message)
  4747. {
  4748. nullpo_retr(-1, sd);
  4749. skill_reload();
  4750. clif_displaymessage(fd, msg_table[99]); // Skill database reloaded.
  4751. return 0;
  4752. }
  4753. /*==========================================
  4754. * @reloadatcommand
  4755. * atcommand_athena.conf のリロード
  4756. *------------------------------------------
  4757. */
  4758. int
  4759. atcommand_reloadatcommand(
  4760. const int fd, struct map_session_data* sd,
  4761. const char* command, const char* message)
  4762. {
  4763. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  4764. clif_displaymessage(fd, msg_table[254]);
  4765. return 0;
  4766. }
  4767. /*==========================================
  4768. * @reloadbattleconf
  4769. * battle_athena.conf のリロード
  4770. *------------------------------------------
  4771. */
  4772. int
  4773. atcommand_reloadbattleconf(
  4774. const int fd, struct map_session_data* sd,
  4775. const char* command, const char* message)
  4776. {
  4777. battle_config_read(BATTLE_CONF_FILENAME);
  4778. mob_reload(); //Needed as well so rate changes take effect.
  4779. clif_displaymessage(fd, msg_table[255]);
  4780. return 0;
  4781. }
  4782. /*==========================================
  4783. * @reloadstatusdb
  4784. * job_db1.txt job_db2.txt job_db2-2.txt
  4785. * refine_db.txt size_fix.txt
  4786. * のリロード
  4787. *------------------------------------------
  4788. */
  4789. int
  4790. atcommand_reloadstatusdb(
  4791. const int fd, struct map_session_data* sd,
  4792. const char* command, const char* message)
  4793. {
  4794. status_readdb();
  4795. clif_displaymessage(fd, msg_table[256]);
  4796. return 0;
  4797. }
  4798. /*==========================================
  4799. * @reloadpcdb
  4800. * exp.txt skill_tree.txt attr_fix.txt
  4801. * のリロード
  4802. *------------------------------------------
  4803. */
  4804. int
  4805. atcommand_reloadpcdb(
  4806. const int fd, struct map_session_data* sd,
  4807. const char* command, const char* message)
  4808. {
  4809. pc_readdb();
  4810. clif_displaymessage(fd, msg_table[257]);
  4811. return 0;
  4812. }
  4813. /*==========================================
  4814. * @reloadmotd [Valaris]
  4815. * Reloads motd.txt
  4816. *------------------------------------------
  4817. */
  4818. int
  4819. atcommand_reloadmotd(
  4820. const int fd, struct map_session_data* sd,
  4821. const char* command, const char* message)
  4822. {
  4823. pc_read_motd();
  4824. clif_displaymessage(fd, msg_table[268]);
  4825. return 0;
  4826. }
  4827. /*==========================================
  4828. *
  4829. *------------------------------------------
  4830. */
  4831. int atcommand_reloadscript(
  4832. const int fd, struct map_session_data* sd,
  4833. const char* command, const char* message)
  4834. {
  4835. nullpo_retr(-1, sd);
  4836. atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  4837. atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  4838. atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  4839. flush_fifos();
  4840. //do_init_npc();
  4841. script_reload();
  4842. npc_reload();
  4843. npc_event_do_oninit();
  4844. clif_displaymessage(fd, msg_table[100]); // Scripts reloaded.
  4845. return 0;
  4846. }
  4847. /*==========================================
  4848. *
  4849. *------------------------------------------
  4850. */
  4851. int atcommand_reloadgmdb( // by [Yor]
  4852. const int fd, struct map_session_data* sd,
  4853. const char* command, const char* message)
  4854. {
  4855. nullpo_retr(-1, sd);
  4856. chrif_reloadGMdb();
  4857. clif_displaymessage(fd, msg_table[101]); // Login-server asked to reload GM accounts and their level.
  4858. return 0;
  4859. }
  4860. /*==========================================
  4861. * @mapinfo <map name> [0-3] by MC_Cameri
  4862. * => Shows information about the map [map name]
  4863. * 0 = no additional information
  4864. * 1 = Show users in that map and their location
  4865. * 2 = Shows NPCs in that map
  4866. * 3 = Shows the shops/chats in that map (not implemented)
  4867. *------------------------------------------
  4868. */
  4869. int atcommand_mapinfo(
  4870. const int fd, struct map_session_data* sd,
  4871. const char* command, const char* message)
  4872. {
  4873. struct map_session_data *pl_sd, **pl_allsd;
  4874. struct npc_data *nd = NULL;
  4875. struct chat_data *cd = NULL;
  4876. char direction[12];
  4877. int m_id, i, chat_num, users, list = 0;
  4878. unsigned short m_index;
  4879. nullpo_retr(-1, sd);
  4880. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4881. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4882. memset(direction, '\0', sizeof(direction));
  4883. sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
  4884. if (list < 0 || list > 3) {
  4885. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4886. return -1;
  4887. }
  4888. if (atcmd_player_name[0] == '\0') {
  4889. memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  4890. atcmd_player_name[MAP_NAME_LENGTH] = '\0';
  4891. m_id = map_mapindex2mapid(sd->mapindex);
  4892. } else {
  4893. if (strstr(atcmd_player_name, ".gat") == NULL && strstr(atcmd_player_name, ".afm") == NULL && strlen(atcmd_player_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  4894. strcat(atcmd_player_name, ".gat");
  4895. m_id = map_mapname2mapid(atcmd_player_name);
  4896. }
  4897. if (m_id < 0) {
  4898. clif_displaymessage(fd, msg_table[1]); // Map not found.
  4899. return -1;
  4900. }
  4901. m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
  4902. clif_displaymessage(fd, "------ Map Info ------");
  4903. chat_num = 0;
  4904. pl_allsd = map_getallusers(&users);
  4905. for (i = 0; i < users; i++) {
  4906. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  4907. chat_num++;
  4908. }
  4909. }
  4910. sprintf(atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", atcmd_player_name, map[m_id].users, map[m_id].npc_num, chat_num);
  4911. clif_displaymessage(fd, atcmd_output);
  4912. if (map[m_id].flag.alias)
  4913. strcat(atcmd_output, "This map is an alias (a named clone of some other map).");
  4914. clif_displaymessage(fd, "------ Map Flags ------");
  4915. strcpy(atcmd_output,"PvP Flags: ");
  4916. if (map[m_id].flag.pvp)
  4917. strcat(atcmd_output, "Pvp ON | ");
  4918. if (map[m_id].flag.nopvp)
  4919. strcat(atcmd_output, "NoPvp | ");
  4920. if (map[m_id].flag.pvp_noguild)
  4921. strcat(atcmd_output, "NoGuild | ");
  4922. if (map[m_id].flag.pvp_noparty)
  4923. strcat(atcmd_output, "NoParty | ");
  4924. if (map[m_id].flag.pvp_nightmaredrop)
  4925. strcat(atcmd_output, "NightmareDrop | ");
  4926. if (map[m_id].flag.pvp_nocalcrank)
  4927. strcat(atcmd_output, "NoCalcRank | ");
  4928. clif_displaymessage(fd, atcmd_output);
  4929. strcpy(atcmd_output,"GvG Flags: ");
  4930. if (map[m_id].flag.gvg)
  4931. strcat(atcmd_output, "GvG ON | ");
  4932. if (map[m_id].flag.gvg_dungeon)
  4933. strcat(atcmd_output, "GvG Dungeon | ");
  4934. if (map[m_id].flag.gvg_castle)
  4935. strcat(atcmd_output, "GvG Castle | ");
  4936. if (map[m_id].flag.gvg_noparty)
  4937. strcat(atcmd_output, "NoParty | ");
  4938. clif_displaymessage(fd, atcmd_output);
  4939. strcpy(atcmd_output,"Teleport Flags: ");
  4940. if (map[m_id].flag.noteleport)
  4941. strcat(atcmd_output, "NoTeleport | ");
  4942. if (map[m_id].flag.monster_noteleport)
  4943. strcat(atcmd_output, "Monster NoTeleport | ");
  4944. if (map[m_id].flag.nowarp)
  4945. strcat(atcmd_output, "NoWarp | ");
  4946. if (map[m_id].flag.nowarpto)
  4947. strcat(atcmd_output, "NoWarpTo | ");
  4948. if (map[m_id].flag.noreturn)
  4949. strcat(atcmd_output, "NoReturn | ");
  4950. if (map[m_id].flag.nogo)
  4951. strcat(atcmd_output, "NoGo | ");
  4952. if (map[m_id].flag.nomemo)
  4953. strcat(atcmd_output, "NoMemo | ");
  4954. clif_displaymessage(fd, atcmd_output);
  4955. sprintf(atcmd_output, "No Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.nopenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  4956. clif_displaymessage(fd, atcmd_output);
  4957. if (map[m_id].flag.nosave) {
  4958. if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  4959. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  4960. else
  4961. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  4962. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  4963. clif_displaymessage(fd, atcmd_output);
  4964. }
  4965. strcpy(atcmd_output,"Weather Flags: ");
  4966. if (map[m_id].flag.snow)
  4967. strcat(atcmd_output, "Snow | ");
  4968. if (map[m_id].flag.fog)
  4969. strcat(atcmd_output, "Fog | ");
  4970. if (map[m_id].flag.sakura)
  4971. strcat(atcmd_output, "Sakura | ");
  4972. if (map[m_id].flag.clouds)
  4973. strcat(atcmd_output, "Clouds | ");
  4974. if (map[m_id].flag.clouds2)
  4975. strcat(atcmd_output, "Clouds2 | ");
  4976. if (map[m_id].flag.fireworks)
  4977. strcat(atcmd_output, "Fireworks | ");
  4978. if (map[m_id].flag.leaves)
  4979. strcat(atcmd_output, "Leaves | ");
  4980. if (map[m_id].flag.rain)
  4981. strcat(atcmd_output, "Rain | ");
  4982. if (map[m_id].flag.indoors)
  4983. strcat(atcmd_output, "Indoors | ");
  4984. if (map[m_id].flag.nightenabled)
  4985. strcat(atcmd_output, "Displays Night | ");
  4986. clif_displaymessage(fd, atcmd_output);
  4987. strcpy(atcmd_output,"Other Flags: ");
  4988. if (map[m_id].flag.nobranch)
  4989. strcat(atcmd_output, "NoBranch | ");
  4990. if (map[m_id].flag.notrade)
  4991. strcat(atcmd_output, "NoTrade | ");
  4992. if (map[m_id].flag.noskill)
  4993. strcat(atcmd_output, "NoSkill | ");
  4994. if (map[m_id].flag.noicewall)
  4995. strcat(atcmd_output, "NoIcewall | ");
  4996. clif_displaymessage(fd, atcmd_output);
  4997. strcpy(atcmd_output,"Other Flags: ");
  4998. if (map[m_id].flag.nobaseexp)
  4999. strcat(atcmd_output, "NoBaseEXP | ");
  5000. if (map[m_id].flag.nojobexp)
  5001. strcat(atcmd_output, "NoJobEXP | ");
  5002. if (map[m_id].flag.nomobloot)
  5003. strcat(atcmd_output, "NoMobLoot | ");
  5004. if (map[m_id].flag.nomvploot)
  5005. strcat(atcmd_output, "NoMVPLoot | ");
  5006. clif_displaymessage(fd, atcmd_output);
  5007. switch (list) {
  5008. case 0:
  5009. // Do nothing. It's list 0, no additional display.
  5010. break;
  5011. case 1:
  5012. clif_displaymessage(fd, "----- Players in Map -----");
  5013. for (i = 0; i < users; i++) {
  5014. if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
  5015. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  5016. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  5017. clif_displaymessage(fd, atcmd_output);
  5018. }
  5019. }
  5020. break;
  5021. case 2:
  5022. clif_displaymessage(fd, "----- NPCs in Map -----");
  5023. for (i = 0; i < map[m_id].npc_num;) {
  5024. nd = map[m_id].npc[i];
  5025. switch(nd->dir) {
  5026. case 0: strcpy(direction, "North"); break;
  5027. case 1: strcpy(direction, "North West"); break;
  5028. case 2: strcpy(direction, "West"); break;
  5029. case 3: strcpy(direction, "South West"); break;
  5030. case 4: strcpy(direction, "South"); break;
  5031. case 5: strcpy(direction, "South East"); break;
  5032. case 6: strcpy(direction, "East"); break;
  5033. case 7: strcpy(direction, "North East"); break;
  5034. case 9: strcpy(direction, "North"); break;
  5035. default: strcpy(direction, "Unknown"); break;
  5036. }
  5037. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  5038. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  5039. clif_displaymessage(fd, atcmd_output);
  5040. }
  5041. break;
  5042. case 3:
  5043. clif_displaymessage(fd, "----- Chats in Map -----");
  5044. for (i = 0; i < users; i++) {
  5045. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  5046. pl_sd->mapindex == m_index &&
  5047. cd->usersd[0] == pl_sd) {
  5048. sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
  5049. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  5050. clif_displaymessage(fd, atcmd_output);
  5051. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  5052. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  5053. clif_displaymessage(fd, atcmd_output);
  5054. }
  5055. }
  5056. break;
  5057. default: // normally impossible to arrive here
  5058. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5059. return -1;
  5060. break;
  5061. }
  5062. return 0;
  5063. }
  5064. /*==========================================
  5065. *
  5066. *------------------------------------------
  5067. */
  5068. int atcommand_mount_peco(
  5069. const int fd, struct map_session_data* sd,
  5070. const char* command, const char* message)
  5071. {
  5072. nullpo_retr(-1, sd);
  5073. if (!pc_isriding(sd)) { // if actually no peco
  5074. if (pc_checkskill(sd, KN_RIDING)) {
  5075. pc_setoption(sd, sd->sc.option | 0x0020);
  5076. clif_displaymessage(fd, msg_table[102]); // Mounted Peco.
  5077. } else {
  5078. clif_displaymessage(fd, msg_table[213]); // You can not mount a peco with your job.
  5079. return -1;
  5080. }
  5081. } else { //Dismount
  5082. pc_setoption(sd, sd->sc.option & ~0x0020);
  5083. clif_displaymessage(fd, msg_table[214]); // Unmounted Peco.
  5084. }
  5085. return 0;
  5086. }
  5087. /*==========================================
  5088. *
  5089. *------------------------------------------
  5090. */
  5091. int atcommand_char_mount_peco(
  5092. const int fd, struct map_session_data* sd,
  5093. const char* command, const char* message)
  5094. {
  5095. struct map_session_data *pl_sd;
  5096. nullpo_retr(-1, sd);
  5097. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5098. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5099. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5100. return -1;
  5101. }
  5102. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5103. if (!pc_isriding(pl_sd)) { // if actually no peco
  5104. if (pc_checkskill(pl_sd, KN_RIDING)) {
  5105. pc_setoption(pl_sd, pl_sd->sc.option | 0x0020);
  5106. clif_displaymessage(fd, msg_table[216]); // Mounted Peco.
  5107. } else {
  5108. clif_displaymessage(fd, msg_table[217]); // You can not mount a peco with your job.
  5109. return -1;
  5110. }
  5111. } else { //Dismount
  5112. pc_setoption(pl_sd, pl_sd->sc.option & ~0x0020);
  5113. clif_displaymessage(fd, msg_table[218]); // Unmounted Peco.
  5114. }
  5115. } else {
  5116. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5117. return -1;
  5118. }
  5119. return 0;
  5120. }
  5121. /*==========================================
  5122. *Spy Commands by Syrus22
  5123. *------------------------------------------
  5124. */
  5125. int atcommand_guildspy(
  5126. const int fd, struct map_session_data* sd,
  5127. const char* command, const char* message)
  5128. {
  5129. char guild_name[NAME_LENGTH];
  5130. struct guild *g;
  5131. nullpo_retr(-1, sd);
  5132. memset(guild_name, '\0', sizeof(guild_name));
  5133. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5134. if (!enable_spy)
  5135. {
  5136. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5137. return -1;
  5138. }
  5139. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  5140. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5141. return -1;
  5142. }
  5143. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5144. (g = guild_search(atoi(message))) != NULL) {
  5145. if (sd->guildspy == g->guild_id) {
  5146. sd->guildspy = 0;
  5147. sprintf(atcmd_output, msg_table[103], g->name); // No longer spying on the %s guild.
  5148. clif_displaymessage(fd, atcmd_output);
  5149. } else {
  5150. sd->guildspy = g->guild_id;
  5151. sprintf(atcmd_output, msg_table[104], g->name); // Spying on the %s guild.
  5152. clif_displaymessage(fd, atcmd_output);
  5153. }
  5154. } else {
  5155. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  5156. return -1;
  5157. }
  5158. return 0;
  5159. }
  5160. /*==========================================
  5161. *
  5162. *------------------------------------------
  5163. */
  5164. int atcommand_partyspy(
  5165. const int fd, struct map_session_data* sd,
  5166. const char* command, const char* message)
  5167. {
  5168. char party_name[NAME_LENGTH];
  5169. struct party *p;
  5170. nullpo_retr(-1, sd);
  5171. memset(party_name, '\0', sizeof(party_name));
  5172. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5173. if (!enable_spy)
  5174. {
  5175. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5176. return -1;
  5177. }
  5178. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  5179. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5180. return -1;
  5181. }
  5182. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5183. (p = party_search(atoi(message))) != NULL) {
  5184. if (sd->partyspy == p->party_id) {
  5185. sd->partyspy = 0;
  5186. sprintf(atcmd_output, msg_table[105], p->name); // No longer spying on the %s party.
  5187. clif_displaymessage(fd, atcmd_output);
  5188. } else {
  5189. sd->partyspy = p->party_id;
  5190. sprintf(atcmd_output, msg_table[106], p->name); // Spying on the %s party.
  5191. clif_displaymessage(fd, atcmd_output);
  5192. }
  5193. } else {
  5194. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  5195. return -1;
  5196. }
  5197. return 0;
  5198. }
  5199. /*==========================================
  5200. * @repairall [Valaris]
  5201. *------------------------------------------
  5202. */
  5203. int atcommand_repairall(
  5204. const int fd, struct map_session_data* sd,
  5205. const char* command, const char* message)
  5206. {
  5207. int count, i;
  5208. nullpo_retr(-1, sd);
  5209. count = 0;
  5210. for (i = 0; i < MAX_INVENTORY; i++) {
  5211. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5212. sd->status.inventory[i].attribute = 0;
  5213. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5214. count++;
  5215. }
  5216. }
  5217. if (count > 0) {
  5218. clif_misceffect(&sd->bl, 3);
  5219. clif_equiplist(sd);
  5220. clif_displaymessage(fd, msg_table[107]); // All items have been repaired.
  5221. } else {
  5222. clif_displaymessage(fd, msg_table[108]); // No item need to be repaired.
  5223. return -1;
  5224. }
  5225. return 0;
  5226. }
  5227. // Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
  5228. int atcommand_nuke(
  5229. const int fd, struct map_session_data* sd,
  5230. const char* command, const char* message)
  5231. {
  5232. struct map_session_data *pl_sd;
  5233. nullpo_retr(-1, sd);
  5234. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5235. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5236. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5237. return -1;
  5238. }
  5239. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5240. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5241. skill_castend_damage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5242. clif_displaymessage(fd, msg_table[109]); // Player has been nuked!
  5243. } else {
  5244. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5245. return -1;
  5246. }
  5247. } else {
  5248. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5249. return -1;
  5250. }
  5251. return 0;
  5252. }
  5253. /*==========================================
  5254. *
  5255. *------------------------------------------
  5256. */
  5257. int atcommand_shownpc(const int fd, struct map_session_data* sd,
  5258. const char* command, const char* message)
  5259. {
  5260. char NPCname[NAME_LENGTH];
  5261. nullpo_retr(-1, sd);
  5262. memset(NPCname, '\0', sizeof(NPCname));
  5263. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5264. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  5265. return -1;
  5266. }
  5267. if (npc_name2id(NPCname) != NULL) {
  5268. npc_enable(NPCname, 1);
  5269. clif_displaymessage(fd, msg_table[110]); // Npc Enabled.
  5270. } else {
  5271. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5272. return -1;
  5273. }
  5274. return 0;
  5275. }
  5276. /*==========================================
  5277. *
  5278. *------------------------------------------
  5279. */
  5280. int atcommand_hidenpc(const int fd, struct map_session_data* sd,
  5281. const char* command, const char* message)
  5282. {
  5283. char NPCname[NAME_LENGTH];
  5284. nullpo_retr(-1, sd);
  5285. memset(NPCname, '\0', sizeof(NPCname));
  5286. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5287. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5288. return -1;
  5289. }
  5290. if (npc_name2id(NPCname) != NULL) {
  5291. npc_enable(NPCname, 0);
  5292. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5293. } else {
  5294. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5295. return -1;
  5296. }
  5297. return 0;
  5298. }
  5299. int atcommand_loadnpc(const int fd, struct map_session_data* sd,
  5300. const char* command, const char* message)
  5301. {
  5302. FILE *fp;
  5303. if (!message || !*message) {
  5304. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  5305. return -1;
  5306. }
  5307. // check if script file exists
  5308. if ((fp = fopen(message, "r")) == NULL) {
  5309. clif_displaymessage(fd, msg_table[261]);
  5310. return -1;
  5311. }
  5312. fclose(fp);
  5313. // add to list of script sources and run it
  5314. npc_addsrcfile((char *)message);
  5315. npc_parsesrcfile((char *)message);
  5316. clif_displaymessage(fd, msg_table[262]);
  5317. return 0;
  5318. }
  5319. int atcommand_unloadnpc(const int fd, struct map_session_data* sd,
  5320. const char* command, const char* message)
  5321. {
  5322. struct npc_data *nd;
  5323. char NPCname[NAME_LENGTH];
  5324. nullpo_retr(-1, sd);
  5325. memset(NPCname, '\0', sizeof(NPCname));
  5326. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5327. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5328. return -1;
  5329. }
  5330. if ((nd = npc_name2id(NPCname)) != NULL) {
  5331. npc_unload(nd);
  5332. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5333. } else {
  5334. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5335. return -1;
  5336. }
  5337. return 0;
  5338. }
  5339. /*==========================================
  5340. * time in txt for time command (by [Yor])
  5341. *------------------------------------------
  5342. */
  5343. char * txt_time(unsigned int duration) {
  5344. int days, hours, minutes, seconds;
  5345. char temp[256];
  5346. static char temp1[256];
  5347. memset(temp, '\0', sizeof(temp));
  5348. memset(temp1, '\0', sizeof(temp1));
  5349. if (duration < 0)
  5350. duration = 0;
  5351. days = duration / (60 * 60 * 24);
  5352. duration = duration - (60 * 60 * 24 * days);
  5353. hours = duration / (60 * 60);
  5354. duration = duration - (60 * 60 * hours);
  5355. minutes = duration / 60;
  5356. seconds = duration - (60 * minutes);
  5357. if (days < 2)
  5358. sprintf(temp, msg_table[219], days); // %d day
  5359. else
  5360. sprintf(temp, msg_table[220], days); // %d days
  5361. if (hours < 2)
  5362. sprintf(temp1, msg_table[221], temp, hours); // %s %d hour
  5363. else
  5364. sprintf(temp1, msg_table[222], temp, hours); // %s %d hours
  5365. if (minutes < 2)
  5366. sprintf(temp, msg_table[223], temp1, minutes); // %s %d minute
  5367. else
  5368. sprintf(temp, msg_table[224], temp1, minutes); // %s %d minutes
  5369. if (seconds < 2)
  5370. sprintf(temp1, msg_table[225], temp, seconds); // %s and %d second
  5371. else
  5372. sprintf(temp1, msg_table[226], temp, seconds); // %s and %d seconds
  5373. return temp1;
  5374. }
  5375. /*==========================================
  5376. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5377. * Calculation management of GM modification (@day/@night GM commands) is done
  5378. *------------------------------------------
  5379. */
  5380. int atcommand_servertime(const int fd, struct map_session_data* sd,
  5381. const char* command, const char* message)
  5382. {
  5383. struct TimerData * timer_data;
  5384. struct TimerData * timer_data2;
  5385. time_t time_server; // variable for number of seconds (used with time() function)
  5386. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5387. char temp[256];
  5388. nullpo_retr(-1, sd);
  5389. memset(temp, '\0', sizeof(temp));
  5390. time(&time_server); // get time in seconds since 1/1/1970
  5391. datetime = localtime(&time_server); // convert seconds in structure
  5392. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5393. strftime(temp, sizeof(temp)-1, msg_table[230], datetime); // Server time (normal time): %A, %B %d %Y %X.
  5394. clif_displaymessage(fd, temp);
  5395. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5396. if (night_flag == 0)
  5397. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5398. else
  5399. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5400. } else if (battle_config.night_duration == 0)
  5401. if (night_flag == 1) { // we start with night
  5402. timer_data = get_timer(day_timer_tid);
  5403. sprintf(temp, msg_table[233], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  5404. clif_displaymessage(fd, temp);
  5405. clif_displaymessage(fd, msg_table[234]); // Game time: After, the game will be in permanent daylight.
  5406. } else
  5407. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5408. else if (battle_config.day_duration == 0)
  5409. if (night_flag == 0) { // we start with day
  5410. timer_data = get_timer(night_timer_tid);
  5411. sprintf(temp, msg_table[235], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5412. clif_displaymessage(fd, temp);
  5413. clif_displaymessage(fd, msg_table[236]); // Game time: After, the game will be in permanent night.
  5414. } else
  5415. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5416. else {
  5417. if (night_flag == 0) {
  5418. timer_data = get_timer(night_timer_tid);
  5419. timer_data2 = get_timer(day_timer_tid);
  5420. sprintf(temp, msg_table[235], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5421. clif_displaymessage(fd, temp);
  5422. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  5423. sprintf(temp, msg_table[237], txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
  5424. else
  5425. sprintf(temp, msg_table[237], txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  5426. clif_displaymessage(fd, temp);
  5427. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5428. clif_displaymessage(fd, temp);
  5429. } else {
  5430. timer_data = get_timer(day_timer_tid);
  5431. timer_data2 = get_timer(night_timer_tid);
  5432. sprintf(temp, msg_table[233], txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5433. clif_displaymessage(fd, temp);
  5434. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  5435. sprintf(temp, msg_table[239], txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
  5436. else
  5437. sprintf(temp, msg_table[239], txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  5438. clif_displaymessage(fd, temp);
  5439. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5440. clif_displaymessage(fd, temp);
  5441. }
  5442. }
  5443. return 0;
  5444. }
  5445. /*==========================================
  5446. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5447. * removes <quantity> item from a character
  5448. * item can be equiped or not.
  5449. * Inspired from a old command created by RoVeRT
  5450. *------------------------------------------
  5451. */
  5452. int atcommand_chardelitem(const int fd, struct map_session_data* sd,
  5453. const char* command, const char* message)
  5454. {
  5455. struct map_session_data *pl_sd;
  5456. char item_name[100];
  5457. int i, number = 0, item_id, item_position, count;
  5458. struct item_data *item_data;
  5459. nullpo_retr(-1, sd);
  5460. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5461. memset(item_name, '\0', sizeof(item_name));
  5462. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5463. if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 || number < 1) {
  5464. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5465. return -1;
  5466. }
  5467. item_id = 0;
  5468. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5469. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5470. item_id = item_data->nameid;
  5471. if (item_id > 500) {
  5472. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5473. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5474. item_position = pc_search_inventory(pl_sd, item_id);
  5475. if (item_position >= 0) {
  5476. count = 0;
  5477. for(i = 0; i < number && item_position >= 0; i++) {
  5478. //Logs (A)dmins items [Lupus]
  5479. if(log_config.pick > 0 ) {
  5480. log_pick(pl_sd, "A", 0, pl_sd->status.inventory[item_position].nameid, -1, &pl_sd->status.inventory[item_position]);
  5481. }
  5482. //Logs
  5483. pc_delitem(pl_sd, item_position, 1, 0);
  5484. count++;
  5485. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5486. }
  5487. sprintf(atcmd_output, msg_table[113], count); // %d item(s) removed by a GM.
  5488. clif_displaymessage(pl_sd->fd, atcmd_output);
  5489. if (number == count)
  5490. sprintf(atcmd_output, msg_table[114], count); // %d item(s) removed from the player.
  5491. else
  5492. sprintf(atcmd_output, msg_table[115], count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5493. clif_displaymessage(fd, atcmd_output);
  5494. } else {
  5495. clif_displaymessage(fd, msg_table[116]); // Character does not have the item.
  5496. return -1;
  5497. }
  5498. } else {
  5499. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5500. return -1;
  5501. }
  5502. } else {
  5503. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5504. return -1;
  5505. }
  5506. } else {
  5507. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  5508. return -1;
  5509. }
  5510. return 0;
  5511. }
  5512. /*==========================================
  5513. * @jail <char_name> by [Yor]
  5514. * Special warp! No check with nowarp and nowarpto flag
  5515. *------------------------------------------
  5516. */
  5517. int atcommand_jail(
  5518. const int fd, struct map_session_data* sd,
  5519. const char* command, const char* message)
  5520. {
  5521. struct map_session_data *pl_sd;
  5522. int x, y;
  5523. unsigned short m_index;
  5524. nullpo_retr(-1, sd);
  5525. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5526. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5527. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5528. return -1;
  5529. }
  5530. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5531. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5532. switch(rand() % 2) {
  5533. case 0:
  5534. x = 24;
  5535. y = 75;
  5536. break;
  5537. default:
  5538. x = 49;
  5539. y = 75;
  5540. break;
  5541. }
  5542. m_index = mapindex_name2id(MAP_JAIL);
  5543. if (pc_setpos(pl_sd, m_index, x, y, 3) == 0) {
  5544. pc_setsavepoint(pl_sd, m_index, x, y); // Save Char Respawn Point in the jail room [Lupus]
  5545. clif_displaymessage(pl_sd->fd, msg_table[117]); // GM has send you in jails.
  5546. clif_displaymessage(fd, msg_table[118]); // Player warped in jails.
  5547. } else {
  5548. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5549. return -1;
  5550. }
  5551. } else {
  5552. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5553. return -1;
  5554. }
  5555. } else {
  5556. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5557. return -1;
  5558. }
  5559. return 0;
  5560. }
  5561. /*==========================================
  5562. * @unjail/@discharge <char_name> by [Yor]
  5563. * Special warp! No check with nowarp and nowarpto flag
  5564. *------------------------------------------
  5565. */
  5566. int atcommand_unjail(
  5567. const int fd, struct map_session_data* sd,
  5568. const char* command, const char* message)
  5569. {
  5570. struct map_session_data *pl_sd;
  5571. unsigned short m_index;
  5572. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5573. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5574. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5575. return -1;
  5576. }
  5577. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5578. m_index = mapindex_name2id(MAP_PRONTERA);
  5579. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5580. if (pl_sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5581. clif_displaymessage(fd, msg_table[119]); // This player is not in jails.
  5582. return -1;
  5583. } else if (pc_setpos(pl_sd, m_index, 0, 0, 3) == 0) { //old coords: 156,191
  5584. pc_setsavepoint(pl_sd, m_index, 0, 0); // Save char respawn point in Prontera
  5585. clif_displaymessage(pl_sd->fd, msg_table[120]); // GM has discharge you.
  5586. clif_displaymessage(fd, msg_table[121]); // Player warped to Prontera.
  5587. } else {
  5588. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5589. return -1;
  5590. }
  5591. } else {
  5592. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5593. return -1;
  5594. }
  5595. } else {
  5596. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5597. return -1;
  5598. }
  5599. return 0;
  5600. }
  5601. /*==========================================
  5602. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5603. *------------------------------------------
  5604. */
  5605. int atcommand_disguise(
  5606. const int fd, struct map_session_data* sd,
  5607. const char* command, const char* message)
  5608. {
  5609. int id = 0;
  5610. nullpo_retr(-1, sd);
  5611. if (!message || !*message) {
  5612. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5613. return -1;
  5614. }
  5615. if ((id = atoi(message)) > 0)
  5616. { //Acquired an ID
  5617. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  5618. id = 0; //Invalid id for either mobs or npcs.
  5619. } else { //Acquired a Name
  5620. if ((id = mobdb_searchname(message)) == 0)
  5621. {
  5622. struct npc_data* nd = npc_name2id(message);
  5623. if (nd != NULL)
  5624. id = nd->n;
  5625. }
  5626. }
  5627. if (id == 0)
  5628. { // Monster/NPC name/id hasn't been found.
  5629. clif_displaymessage(fd, msg_table[123]);
  5630. return -1;
  5631. }
  5632. /* The previous way....
  5633. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5634. mob_id = atoi(message);
  5635. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5636. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5637. (mob_id >= 813 && mob_id <= 858) || // NPC
  5638. (mob_id > 1000 && mob_id < 1582)) { // monsters
  5639. */
  5640. pc_stop_walking(sd,0);
  5641. clif_clearchar(&sd->bl, 0);
  5642. sd->disguise = id;
  5643. sd->state.disguised = 1; // set to override items with disguise script [Valaris]
  5644. clif_changeoption(&sd->bl);
  5645. clif_spawnpc(sd);
  5646. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5647. return 0;
  5648. }
  5649. /*==========================================
  5650. * DisguiseAll
  5651. *------------------------------------------
  5652. */
  5653. int atcommand_disguiseall(
  5654. const int fd, struct map_session_data* sd,
  5655. const char* command, const char* message)
  5656. {
  5657. int mob_id=0, i=0, users;
  5658. struct map_session_data *pl_sd, **pl_allsd;
  5659. nullpo_retr(-1, sd);
  5660. if (!message || !*message) {
  5661. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
  5662. return -1;
  5663. }
  5664. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5665. mob_id = atoi(message);
  5666. if (mobdb_checkid(mob_id) || npcdb_checkid(mob_id)) { //if mob or npc...
  5667. pl_allsd = map_getallusers(&users);
  5668. for(i=0; i < users; i++) {
  5669. if((pl_sd = pl_allsd[i])) {
  5670. pc_stop_walking(pl_sd,0);
  5671. clif_clearchar(&pl_sd->bl, 0);
  5672. pl_sd->disguise = mob_id;
  5673. pl_sd->state.disguised = 1; // set to override items with disguise script [Valaris]
  5674. clif_changeoption(&pl_sd->bl);
  5675. clif_spawnpc(pl_sd);
  5676. }
  5677. }
  5678. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5679. } else {
  5680. return -1;
  5681. }
  5682. return 0;
  5683. }
  5684. /*==========================================
  5685. * @undisguise by [Yor]
  5686. *------------------------------------------
  5687. */
  5688. int atcommand_undisguise(
  5689. const int fd, struct map_session_data* sd,
  5690. const char* command, const char* message)
  5691. {
  5692. nullpo_retr(-1, sd);
  5693. if (sd->disguise) {
  5694. pc_stop_walking(sd,0);
  5695. clif_clearchar(&sd->bl, 0);
  5696. sd->disguise = 0;
  5697. clif_changeoption(&sd->bl);
  5698. clif_spawnpc(sd);
  5699. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5700. } else {
  5701. clif_displaymessage(fd, msg_table[125]); // You're not disguised.
  5702. return -1;
  5703. }
  5704. return 0;
  5705. }
  5706. /*==========================================
  5707. * UndisguiseAll
  5708. *------------------------------------------
  5709. */
  5710. int atcommand_undisguiseall(
  5711. const int fd, struct map_session_data* sd,
  5712. const char* command, const char* message)
  5713. {
  5714. struct map_session_data *pl_sd, **pl_allsd;
  5715. int i, users;
  5716. nullpo_retr(-1, sd);
  5717. pl_allsd = map_getallusers(&users);
  5718. for(i=0; i < users; i++) {
  5719. if((pl_sd = pl_allsd[i]) && pl_sd->disguise) {
  5720. pc_stop_walking(pl_sd,0);
  5721. clif_clearchar(&pl_sd->bl, 0);
  5722. pl_sd->disguise = 0;
  5723. clif_changeoption(&pl_sd->bl);
  5724. clif_spawnpc(pl_sd);
  5725. }
  5726. }
  5727. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5728. return 0;
  5729. }
  5730. /*==========================================
  5731. * @exp by [Skotlex]
  5732. *------------------------------------------
  5733. */
  5734. int atcommand_exp(
  5735. const int fd, struct map_session_data* sd,
  5736. const char* command, const char* message)
  5737. {
  5738. char output[200];
  5739. double nextb, nextj;
  5740. nullpo_retr(-1, sd);
  5741. memset(output, '\0', sizeof(output));
  5742. nextb = pc_nextbaseexp(sd);
  5743. if (nextb)
  5744. nextb = sd->status.base_exp*100.0/nextb;
  5745. nextj = pc_nextjobexp(sd);
  5746. if (nextj)
  5747. nextj = sd->status.job_exp*100.0/nextj;
  5748. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  5749. clif_displaymessage(fd, output);
  5750. return 0;
  5751. }
  5752. /*==========================================
  5753. * @broadcast by [Valaris]
  5754. *------------------------------------------
  5755. */
  5756. int atcommand_broadcast(
  5757. const int fd, struct map_session_data* sd,
  5758. const char* command, const char* message)
  5759. {
  5760. nullpo_retr(-1, sd);
  5761. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5762. if (!message || !*message) {
  5763. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5764. return -1;
  5765. }
  5766. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5767. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  5768. return 0;
  5769. }
  5770. /*==========================================
  5771. * @localbroadcast by [Valaris]
  5772. *------------------------------------------
  5773. */
  5774. int atcommand_localbroadcast(
  5775. const int fd, struct map_session_data* sd,
  5776. const char* command, const char* message)
  5777. {
  5778. nullpo_retr(-1, sd);
  5779. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5780. if (!message || !*message) {
  5781. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5782. return -1;
  5783. }
  5784. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5785. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  5786. return 0;
  5787. }
  5788. /*==========================================
  5789. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  5790. *------------------------------------------
  5791. */
  5792. int atcommand_chardisguise(
  5793. const int fd, struct map_session_data* sd,
  5794. const char* command, const char* message)
  5795. {
  5796. int mob_id;
  5797. char mob_name[NAME_LENGTH];
  5798. struct map_session_data* pl_sd;
  5799. nullpo_retr(-1, sd);
  5800. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5801. memset(mob_name, '\0', sizeof(mob_name));
  5802. if (!message || !*message || sscanf(message, "%s %23[^\n]", mob_name, atcmd_player_name) < 2) {
  5803. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  5804. return -1;
  5805. }
  5806. if ((mob_id = atoi(mob_name)) > 0)
  5807. { //Acquired an ID
  5808. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id))
  5809. mob_id = 0; //Invalid id for either mobs or npcs.
  5810. } else { //Acquired a Name
  5811. if ((mob_id = mobdb_searchname(mob_name)) == 0)
  5812. {
  5813. struct npc_data* nd = npc_name2id(mob_name);
  5814. if (nd != NULL)
  5815. mob_id = nd->n;
  5816. }
  5817. }
  5818. if (mob_id == 0)
  5819. {
  5820. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5821. return -1;
  5822. }
  5823. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5824. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  5825. pc_stop_walking(pl_sd,0);
  5826. clif_clearchar(&pl_sd->bl, 0);
  5827. pl_sd->disguise = mob_id;
  5828. pl_sd->state.disguised = 1; // set to override items with disguise script [Valaris]
  5829. clif_changeoption(&pl_sd->bl);
  5830. clif_spawnpc(pl_sd);
  5831. clif_displaymessage(fd, msg_table[140]); // Character's disguise applied.
  5832. } else {
  5833. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5834. return -1;
  5835. }
  5836. } else {
  5837. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5838. return -1;
  5839. }
  5840. return 0;
  5841. }
  5842. /*==========================================
  5843. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  5844. *------------------------------------------
  5845. */
  5846. int atcommand_charundisguise(
  5847. const int fd, struct map_session_data* sd,
  5848. const char* command, const char* message)
  5849. {
  5850. struct map_session_data* pl_sd;
  5851. nullpo_retr(-1, sd);
  5852. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5853. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5854. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  5855. return -1;
  5856. }
  5857. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5858. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  5859. if (pl_sd->disguise) {
  5860. pc_stop_walking(pl_sd,0);
  5861. clif_clearchar(&pl_sd->bl, 0);
  5862. pl_sd->disguise = 0;
  5863. clif_changeoption(&pl_sd->bl);
  5864. clif_spawnpc(pl_sd);
  5865. clif_displaymessage(fd, msg_table[141]); // Character's undisguise applied.
  5866. } else {
  5867. clif_displaymessage(fd, msg_table[142]); // Character is not disguised.
  5868. return -1;
  5869. }
  5870. } else {
  5871. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5872. return -1;
  5873. }
  5874. } else {
  5875. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5876. return -1;
  5877. }
  5878. return 0;
  5879. }
  5880. /*==========================================
  5881. * @email <actual@email> <new@email> by [Yor]
  5882. *------------------------------------------
  5883. */
  5884. int atcommand_email(
  5885. const int fd, struct map_session_data* sd,
  5886. const char* command, const char* message)
  5887. {
  5888. char actual_email[100];
  5889. char new_email[100];
  5890. nullpo_retr(-1, sd);
  5891. memset(actual_email, '\0', sizeof(actual_email));
  5892. memset(new_email, '\0', sizeof(new_email));
  5893. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5894. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5895. return -1;
  5896. }
  5897. if (e_mail_check(actual_email) == 0) {
  5898. clif_displaymessage(fd, msg_table[144]); // Invalid actual email. If you have default e-mail, give a@a.com.
  5899. return -1;
  5900. } else if (e_mail_check(new_email) == 0) {
  5901. clif_displaymessage(fd, msg_table[145]); // Invalid new email. Please enter a real e-mail.
  5902. return -1;
  5903. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5904. clif_displaymessage(fd, msg_table[146]); // New email must be a real e-mail.
  5905. return -1;
  5906. } else if (strcmpi(actual_email, new_email) == 0) {
  5907. clif_displaymessage(fd, msg_table[147]); // New email must be different of the actual e-mail.
  5908. return -1;
  5909. } else {
  5910. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5911. clif_displaymessage(fd, msg_table[148]); // Information sended to login-server via char-server.
  5912. }
  5913. return 0;
  5914. }
  5915. /*==========================================
  5916. *@effect
  5917. *------------------------------------------
  5918. */
  5919. int atcommand_effect(
  5920. const int fd, struct map_session_data* sd,
  5921. const char* command, const char* message)
  5922. {
  5923. struct map_session_data *pl_sd, **pl_allsd;
  5924. int type = 0, flag = 0, i, users;
  5925. nullpo_retr(-1, sd);
  5926. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  5927. clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
  5928. return -1;
  5929. }
  5930. if(flag <=0){
  5931. clif_specialeffect(&sd->bl, type, flag);
  5932. clif_displaymessage(fd, msg_table[229]); // Your effect has changed.
  5933. }
  5934. else{
  5935. pl_allsd = map_getallusers(&users);
  5936. for (i = 0; i < users; i++) {
  5937. if ((pl_sd = pl_allsd[i])) {
  5938. clif_specialeffect(&pl_sd->bl, type, flag);
  5939. clif_displaymessage(pl_sd->fd, msg_table[229]); // Your effect has changed.
  5940. }
  5941. }
  5942. }
  5943. return 0;
  5944. }
  5945. /*==========================================
  5946. * @charcartlist <character>: Displays the items list of a player's cart.
  5947. *------------------------------------------
  5948. */
  5949. int
  5950. atcommand_character_cart_list(
  5951. const int fd, struct map_session_data* sd,
  5952. const char* command, const char* message)
  5953. {
  5954. char outputtmp[200];
  5955. struct map_session_data *pl_sd;
  5956. struct item_data *item_data, *item_temp;
  5957. int i, j, count, counter, counter2;
  5958. nullpo_retr(-1, sd);
  5959. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5960. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5961. memset(outputtmp, '\0', sizeof(outputtmp));
  5962. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5963. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  5964. return -1;
  5965. }
  5966. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5967. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  5968. counter = 0;
  5969. count = 0;
  5970. for (i = 0; i < MAX_CART; i++) {
  5971. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  5972. counter = counter + pl_sd->status.cart[i].amount;
  5973. count++;
  5974. if (count == 1) {
  5975. sprintf(atcmd_output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  5976. clif_displaymessage(fd, atcmd_output);
  5977. }
  5978. if (pl_sd->status.cart[i].refine)
  5979. sprintf(atcmd_output, "%d %s %+d (%s %+d, id: %d)", pl_sd->status.cart[i].amount, item_data->name, pl_sd->status.cart[i].refine, item_data->jname, pl_sd->status.cart[i].refine, pl_sd->status.cart[i].nameid);
  5980. else
  5981. sprintf(atcmd_output, "%d %s (%s, id: %d)", pl_sd->status.cart[i].amount, item_data->name, item_data->jname, pl_sd->status.cart[i].nameid);
  5982. clif_displaymessage(fd, atcmd_output);
  5983. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5984. counter2 = 0;
  5985. for (j = 0; j < item_data->slot; j++) {
  5986. if (pl_sd->status.cart[i].card[j]) {
  5987. if ( (item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  5988. if (atcmd_output[0] == '\0')
  5989. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  5990. else
  5991. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  5992. strcat(atcmd_output, outputtmp);
  5993. }
  5994. }
  5995. }
  5996. if (atcmd_output[0] != '\0') {
  5997. atcmd_output[strlen(atcmd_output) - 2] = ')';
  5998. atcmd_output[strlen(atcmd_output) - 1] = '\0';
  5999. clif_displaymessage(fd, atcmd_output);
  6000. }
  6001. }
  6002. }
  6003. if (count == 0)
  6004. clif_displaymessage(fd, "No item found in the cart of this player.");
  6005. else {
  6006. sprintf(atcmd_output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6007. clif_displaymessage(fd, atcmd_output);
  6008. }
  6009. } else {
  6010. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  6011. return -1;
  6012. }
  6013. } else {
  6014. clif_displaymessage(fd, msg_table[3]); // Character not found.
  6015. return -1;
  6016. }
  6017. return 0;
  6018. }
  6019. /*==========================================
  6020. * @killer by MouseJstr
  6021. * enable killing players even when not in pvp
  6022. *------------------------------------------
  6023. */
  6024. int
  6025. atcommand_killer(
  6026. const int fd, struct map_session_data* sd,
  6027. const char* command, const char* message)
  6028. {
  6029. nullpo_retr(-1, sd);
  6030. sd->special_state.killer = !sd->special_state.killer;
  6031. if(sd->special_state.killer)
  6032. clif_displaymessage(fd, msg_table[241]);
  6033. else
  6034. clif_displaymessage(fd, msg_table[242]);
  6035. return 0;
  6036. }
  6037. /*==========================================
  6038. * @killable by MouseJstr
  6039. * enable other people killing you
  6040. *------------------------------------------
  6041. */
  6042. int
  6043. atcommand_killable(
  6044. const int fd, struct map_session_data* sd,
  6045. const char* command, const char* message)
  6046. {
  6047. nullpo_retr(-1, sd);
  6048. sd->special_state.killable = !sd->special_state.killable;
  6049. if(sd->special_state.killable)
  6050. clif_displaymessage(fd, msg_table[242]);
  6051. else
  6052. clif_displaymessage(fd, msg_table[241]);
  6053. return 0;
  6054. }
  6055. /*==========================================
  6056. * @charkillable by MouseJstr
  6057. * enable another player to be killed
  6058. *------------------------------------------
  6059. */
  6060. int
  6061. atcommand_charkillable(
  6062. const int fd, struct map_session_data* sd,
  6063. const char* command, const char* message)
  6064. {
  6065. struct map_session_data *pl_sd = NULL;
  6066. nullpo_retr(-1, sd);
  6067. if (!message || !*message)
  6068. return -1;
  6069. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6070. return -1;
  6071. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  6072. if(pl_sd->special_state.killable)
  6073. clif_displaymessage(fd, "The player is now killable");
  6074. else
  6075. clif_displaymessage(fd, "The player is no longer killable");
  6076. return 0;
  6077. }
  6078. /*==========================================
  6079. * @skillon by MouseJstr
  6080. * turn skills on for the map
  6081. *------------------------------------------
  6082. */
  6083. int
  6084. atcommand_skillon(
  6085. const int fd, struct map_session_data* sd,
  6086. const char* command, const char* message)
  6087. {
  6088. nullpo_retr(-1, sd);
  6089. map[sd->bl.m].flag.noskill = 0;
  6090. clif_displaymessage(fd, msg_table[244]);
  6091. return 0;
  6092. }
  6093. /*==========================================
  6094. * @skilloff by MouseJstr
  6095. * Turn skills off on the map
  6096. *------------------------------------------
  6097. */
  6098. int
  6099. atcommand_skilloff(
  6100. const int fd, struct map_session_data* sd,
  6101. const char* command, const char* message)
  6102. {
  6103. nullpo_retr(-1, sd);
  6104. map[sd->bl.m].flag.noskill = 1;
  6105. clif_displaymessage(fd, msg_table[243]);
  6106. return 0;
  6107. }
  6108. /*==========================================
  6109. * @npcmove by MouseJstr
  6110. *
  6111. * move a npc
  6112. *------------------------------------------
  6113. */
  6114. int
  6115. atcommand_npcmove(const int fd, struct map_session_data* sd,
  6116. const char* command, const char* message)
  6117. {
  6118. int x = 0, y = 0;
  6119. struct npc_data *nd = 0;
  6120. nullpo_retr(-1, sd);
  6121. if (!message || !*message)
  6122. return -1;
  6123. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  6124. if (sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  6125. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6126. return -1;
  6127. }
  6128. //Who's idea was this? nullpo's are meant to check pointers that SHOULDN'T be null unless there's a bug... [Skotlex]
  6129. // nullpo_retr(-1, (nd = npc_name2id(atcmd_player_name)));
  6130. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  6131. return -1;
  6132. npc_enable(atcmd_player_name, 0);
  6133. nd->bl.x = x;
  6134. nd->bl.y = y;
  6135. npc_enable(atcmd_player_name, 1);
  6136. return 0;
  6137. }
  6138. /*==========================================
  6139. * @addwarp by MouseJstr
  6140. *
  6141. * Create a new static warp point.
  6142. *------------------------------------------
  6143. */
  6144. int
  6145. atcommand_addwarp(const int fd, struct map_session_data* sd,
  6146. const char* command, const char* message)
  6147. {
  6148. char w1[64], w3[64], w4[64];
  6149. int x,y,ret;
  6150. nullpo_retr(-1, sd);
  6151. if (!message || !*message)
  6152. return -1;
  6153. if (sscanf(message, "%99s %d %d[^\n]", atcmd_player_name, &x, &y ) < 3)
  6154. return -1;
  6155. sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
  6156. sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y);
  6157. sprintf(w4,"1,1,%s.gat,%d,%d", atcmd_player_name, x, y);
  6158. ret = npc_parse_warp(w1, "warp", w3, w4);
  6159. sprintf(atcmd_output, "New warp NPC => %s",w3);
  6160. clif_displaymessage(fd, atcmd_output);
  6161. return ret;
  6162. }
  6163. /*==========================================
  6164. * @follow by [MouseJstr]
  6165. *
  6166. * Follow a player .. staying no more then 5 spaces away
  6167. *------------------------------------------
  6168. */
  6169. int
  6170. atcommand_follow(const int fd, struct map_session_data* sd,
  6171. const char* command, const char* message)
  6172. {
  6173. struct map_session_data *pl_sd = NULL;
  6174. nullpo_retr(-1, sd);
  6175. if (!message || !*message) {
  6176. if (sd->followtarget == -1)
  6177. return -1;
  6178. pc_stop_following (sd);
  6179. clif_displaymessage(fd, "Stop following");
  6180. return 0;
  6181. }
  6182. if ((pl_sd = map_nick2sd((char *) message)) != NULL) {
  6183. if (sd->followtarget == pl_sd->bl.id)
  6184. pc_stop_following (sd);
  6185. else
  6186. pc_follow(sd, pl_sd->bl.id);
  6187. return 0;
  6188. }
  6189. return 1;
  6190. }
  6191. /*==========================================
  6192. * @dropall by [MouseJstr]
  6193. *
  6194. * Drop all your possession on the ground
  6195. *------------------------------------------
  6196. */
  6197. int
  6198. atcommand_dropall(const int fd, struct map_session_data* sd,
  6199. const char* command, const char* message)
  6200. {
  6201. int i;
  6202. nullpo_retr(-1, sd);
  6203. for (i = 0; i < MAX_INVENTORY; i++) {
  6204. if (sd->status.inventory[i].amount) {
  6205. if(sd->status.inventory[i].equip != 0)
  6206. pc_unequipitem(sd, i, 3);
  6207. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6208. }
  6209. }
  6210. return 0;
  6211. }
  6212. /*==========================================
  6213. * @chardropall by [MouseJstr]
  6214. *
  6215. * Throw all the characters possessions on the ground. Normally
  6216. * done in response to them being disrespectful of a GM
  6217. *------------------------------------------
  6218. */
  6219. int
  6220. atcommand_chardropall(const int fd, struct map_session_data* sd,
  6221. const char* command, const char* message)
  6222. {
  6223. int i;
  6224. struct map_session_data *pl_sd = NULL;
  6225. nullpo_retr(-1, sd);
  6226. if (!message || !*message)
  6227. return -1;
  6228. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6229. return -1;
  6230. for (i = 0; i < MAX_INVENTORY; i++) {
  6231. if (pl_sd->status.inventory[i].amount) {
  6232. if(pl_sd->status.inventory[i].equip != 0)
  6233. pc_unequipitem(pl_sd, i, 3);
  6234. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6235. }
  6236. }
  6237. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6238. clif_displaymessage(fd, "It is done");
  6239. //clif_displaymessage(fd, "It is offical.. your a jerk");
  6240. return 0;
  6241. }
  6242. /*==========================================
  6243. * @storeall by [MouseJstr]
  6244. *
  6245. * Put everything into storage to simplify your inventory to make
  6246. * debugging easie
  6247. *------------------------------------------
  6248. */
  6249. int
  6250. atcommand_storeall(const int fd, struct map_session_data* sd,
  6251. const char* command, const char* message)
  6252. {
  6253. int i;
  6254. nullpo_retr(-1, sd);
  6255. if (storage_storageopen(sd) == 1) {
  6256. clif_displaymessage(fd, "run this command again..");
  6257. return 0;
  6258. }
  6259. for (i = 0; i < MAX_INVENTORY; i++) {
  6260. if (sd->status.inventory[i].amount) {
  6261. if(sd->status.inventory[i].equip != 0)
  6262. pc_unequipitem(sd, i, 3);
  6263. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6264. }
  6265. }
  6266. storage_storageclose(sd);
  6267. clif_displaymessage(fd, "It is done");
  6268. return 0;
  6269. }
  6270. /*==========================================
  6271. * @charstoreall by [MouseJstr]
  6272. *
  6273. * A way to screw with players who piss you off
  6274. *------------------------------------------
  6275. */
  6276. int
  6277. atcommand_charstoreall(const int fd, struct map_session_data* sd,
  6278. const char* command, const char* message)
  6279. {
  6280. int i;
  6281. struct map_session_data *pl_sd = NULL;
  6282. nullpo_retr(-1, sd);
  6283. if (!message || !*message)
  6284. return -1;
  6285. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6286. return -1;
  6287. if (storage_storageopen(pl_sd) == 1) {
  6288. clif_displaymessage(fd, "Had to open the characters storage window...");
  6289. clif_displaymessage(fd, "run this command again..");
  6290. return 0;
  6291. }
  6292. for (i = 0; i < MAX_INVENTORY; i++) {
  6293. if (pl_sd->status.inventory[i].amount) {
  6294. if(pl_sd->status.inventory[i].equip != 0)
  6295. pc_unequipitem(pl_sd, i, 3);
  6296. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6297. }
  6298. }
  6299. storage_storageclose(pl_sd);
  6300. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6301. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6302. clif_displaymessage(pl_sd->fd, " -- the management");
  6303. clif_displaymessage(fd, "It is done");
  6304. return 0;
  6305. }
  6306. /*==========================================
  6307. * @skillid by [MouseJstr]
  6308. *
  6309. * lookup a skill by name
  6310. *------------------------------------------
  6311. */
  6312. int
  6313. atcommand_skillid(const int fd, struct map_session_data* sd,
  6314. const char* command, const char* message)
  6315. {
  6316. int skillen, idx;
  6317. nullpo_retr(-1, sd);
  6318. if (!message || !*message)
  6319. return -1;
  6320. skillen = strlen(message);
  6321. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  6322. if ((skill_db[idx].name != NULL && strnicmp(skill_db[idx].name, message, skillen) == 0) ||
  6323. (skill_db[idx].desc != NULL && strnicmp(skill_db[idx].desc, message, skillen) == 0))
  6324. {
  6325. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  6326. clif_displaymessage(fd, atcmd_output);
  6327. }
  6328. }
  6329. return 0;
  6330. }
  6331. /*==========================================
  6332. * @useskill by [MouseJstr]
  6333. *
  6334. * A way of using skills without having to find them in the skills menu
  6335. *------------------------------------------
  6336. */
  6337. int
  6338. atcommand_useskill(const int fd, struct map_session_data* sd,
  6339. const char* command, const char* message)
  6340. {
  6341. struct map_session_data *pl_sd = NULL;
  6342. int skillnum;
  6343. int skilllv;
  6344. char target[255];
  6345. nullpo_retr(-1, sd);
  6346. if (!message || !*message)
  6347. return -1;
  6348. if(sscanf(message, "%d %d %99[^\n]", &skillnum, &skilllv, target) != 3) {
  6349. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6350. return -1;
  6351. }
  6352. if((pl_sd=map_nick2sd(target)) == NULL) {
  6353. return -1;
  6354. }
  6355. if (skill_get_inf(skillnum) & INF_GROUND_SKILL)
  6356. skill_use_pos(sd, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6357. else
  6358. skill_use_id(sd, pl_sd->bl.id, skillnum, skilllv);
  6359. return 0;
  6360. }
  6361. /*==========================================
  6362. * @skilltree by [MouseJstr]
  6363. *
  6364. * prints the skill tree for a player required to get to a skill
  6365. *------------------------------------------
  6366. */
  6367. int
  6368. atcommand_skilltree(const int fd, struct map_session_data* sd,
  6369. const char* command, const char* message)
  6370. {
  6371. struct map_session_data *pl_sd = NULL;
  6372. int skillnum, skillidx = -1;
  6373. int meets = 1, j, c=0;
  6374. char target[NAME_LENGTH], *tbl;
  6375. struct skill_tree_entry *ent;
  6376. nullpo_retr(-1, sd);
  6377. if (!message || !*message)
  6378. return -1;
  6379. if(sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  6380. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6381. return -1;
  6382. }
  6383. if((pl_sd=map_nick2sd(target)) == NULL)
  6384. return -1;
  6385. c = pc_calc_skilltree_normalize_job(pl_sd);
  6386. tbl = job_name(c);
  6387. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
  6388. tbl, pc_checkskill(pl_sd, 1));
  6389. clif_displaymessage(fd, atcmd_output);
  6390. for (j = 0; skill_tree[c][j].id != 0; j++) {
  6391. if (skill_tree[c][j].id == skillnum) {
  6392. skillidx = j;
  6393. break;
  6394. }
  6395. }
  6396. if (skillidx == -1) {
  6397. sprintf(atcmd_output, "I do not believe the player can use that skill");
  6398. clif_displaymessage(fd, atcmd_output);
  6399. return 0;
  6400. }
  6401. ent = &skill_tree[c][skillidx];
  6402. for(j=0;j<5;j++)
  6403. if( ent->need[j].id &&
  6404. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6405. {
  6406. char *desc = (skill_db[ ent->need[j].id ].desc) ? skill_db[ ent->need[j].id ].desc : "Unknown skill";
  6407. sprintf(atcmd_output, "player requires level %d of skill %s",
  6408. ent->need[j].lv, desc);
  6409. clif_displaymessage(fd, atcmd_output);
  6410. meets = 0;
  6411. }
  6412. if (meets == 1) {
  6413. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  6414. clif_displaymessage(fd, atcmd_output);
  6415. }
  6416. return 0;
  6417. }
  6418. // Hand a ring with partners name on it to this char
  6419. void getring (struct map_session_data *sd)
  6420. {
  6421. int flag,item_id = 0;
  6422. struct item item_tmp;
  6423. if(sd->status.sex==0)
  6424. item_id = 2635;
  6425. else
  6426. item_id = 2634;
  6427. memset(&item_tmp,0,sizeof(item_tmp));
  6428. item_tmp.nameid=item_id;
  6429. item_tmp.identify=1;
  6430. item_tmp.card[0]=255;
  6431. item_tmp.card[2]=sd->status.partner_id;
  6432. item_tmp.card[3]=sd->status.partner_id >> 16;
  6433. //Logs (A)dmins items [Lupus]
  6434. if(log_config.pick > 0 ) {
  6435. log_pick(sd, "A", 0, item_id, 1, &item_tmp);
  6436. }
  6437. //Logs
  6438. if((flag = pc_additem(sd,&item_tmp,1))) {
  6439. clif_additem(sd,0,0,flag);
  6440. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0);
  6441. }
  6442. }
  6443. /*==========================================
  6444. * @marry by [MouseJstr], fixed by Lupus
  6445. *
  6446. * Marry two players
  6447. *------------------------------------------
  6448. */
  6449. int
  6450. atcommand_marry(const int fd, struct map_session_data* sd,
  6451. const char* command, const char* message)
  6452. {
  6453. struct map_session_data *pl_sd1 = NULL;
  6454. struct map_session_data *pl_sd2 = NULL;
  6455. char player1[128], player2[128]; //Length used for return error msgs
  6456. nullpo_retr(-1, sd);
  6457. if (!message || !*message || sscanf(message, "%23[^,],%23[^\r\n]", player1, player2) != 2) {
  6458. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  6459. return -1;
  6460. }
  6461. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6462. sprintf(player2, "Cannot find player '%s' online", player1);
  6463. clif_displaymessage(fd, player2);
  6464. return -1;
  6465. }
  6466. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6467. sprintf(player1, "Cannot find player '%s' online", player2);
  6468. clif_displaymessage(fd, player1);
  6469. return -1;
  6470. }
  6471. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6472. clif_displaymessage(fd, "They are married.. wish them well");
  6473. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  6474. // Auto-give named rings (Aru)
  6475. getring (pl_sd1);
  6476. getring (pl_sd2);
  6477. return 0;
  6478. }
  6479. return -1;
  6480. }
  6481. /*==========================================
  6482. * @divorce by [MouseJstr], fixed by [Lupus]
  6483. *
  6484. * divorce two players
  6485. *------------------------------------------
  6486. */
  6487. int
  6488. atcommand_divorce(const int fd, struct map_session_data* sd,
  6489. const char* command, const char* message)
  6490. {
  6491. struct map_session_data *pl_sd = NULL;
  6492. nullpo_retr(-1, sd);
  6493. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  6494. clif_displaymessage(fd, "Usage: @divorce <player>.");
  6495. return -1;
  6496. }
  6497. if((pl_sd=map_nick2sd((char *) atcmd_player_name)) != NULL) {
  6498. if (pc_divorce(pl_sd) != 0) {
  6499. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  6500. clif_displaymessage(fd, atcmd_output);
  6501. return -1;
  6502. } else {
  6503. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  6504. clif_displaymessage(fd, atcmd_output);
  6505. return 0;
  6506. }
  6507. }
  6508. sprintf(atcmd_output, "Cannot find player '%s' online", atcmd_player_name);
  6509. clif_displaymessage(fd, atcmd_output);
  6510. return -1;
  6511. }
  6512. #ifdef DMALLOC
  6513. unsigned long dmark_;
  6514. int
  6515. atcommand_dmstart(const int fd, struct map_session_data* sd,
  6516. const char* command, const char* message)
  6517. {
  6518. dmark_ = dmalloc_mark();
  6519. clif_displaymessage(fd, "debug mark set");
  6520. return 0;
  6521. }
  6522. int
  6523. atcommand_dmtick(const int fd, struct map_session_data* sd,
  6524. const char* command, const char* message)
  6525. {
  6526. dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
  6527. dmark_ = dmalloc_mark();
  6528. clif_displaymessage(fd, "malloc changes logged");
  6529. return 0;
  6530. }
  6531. #endif
  6532. /*==========================================
  6533. * @grind by [MouseJstr]
  6534. *------------------------------------------
  6535. */
  6536. int
  6537. atcommand_grind(const int fd, struct map_session_data* sd,
  6538. const char* command, const char* message)
  6539. {
  6540. struct map_session_data *pl_sd = NULL;
  6541. int skillnum;
  6542. int inf;
  6543. char target[NAME_LENGTH];
  6544. nullpo_retr(-1, sd);
  6545. if (!message || !*message)
  6546. return -1;
  6547. if(sscanf(message, "%23s", target) != 1) {
  6548. clif_displaymessage(fd, "Usage: @grind <target>");
  6549. return -1;
  6550. }
  6551. if((pl_sd=map_nick2sd(target)) == NULL)
  6552. return -1;
  6553. for (skillnum = 1; skillnum < 500; skillnum++) {
  6554. sd->status.sp = sd->status.max_sp;
  6555. atcommand_alive(fd, sd, command, message);
  6556. inf = skill_get_inf(skillnum);
  6557. if (inf & INF_GROUND_SKILL)
  6558. skill_use_pos(sd, pl_sd->bl.x+5, pl_sd->bl.y+5, skillnum, 1);
  6559. else if (!(inf & INF_SUPPORT_SKILL))
  6560. skill_use_id(sd, pl_sd->bl.id, skillnum, 1);
  6561. }
  6562. return 0;
  6563. }
  6564. /*==========================================
  6565. * @grind2 by [MouseJstr]
  6566. *------------------------------------------
  6567. */
  6568. int
  6569. atcommand_grind2(const int fd, struct map_session_data* sd,
  6570. const char* command, const char* message)
  6571. {
  6572. int i, x, y, id;
  6573. for (i = 1000; i <2000; i++) {
  6574. x = sd->bl.x + (rand() % 10 - 5);
  6575. y = sd->bl.y + (rand() % 10 - 5);
  6576. id = mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
  6577. }
  6578. return 0;
  6579. }
  6580. /*==========================================
  6581. * @changelook by [Celest]
  6582. *------------------------------------------
  6583. */
  6584. int
  6585. atcommand_changelook(const int fd, struct map_session_data* sd,
  6586. const char* command, const char* message)
  6587. {
  6588. int i, j = 0, k = 0;
  6589. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  6590. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  6591. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  6592. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  6593. return -1;
  6594. } else if (i == 2) {
  6595. if (j < 1) j = 1;
  6596. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  6597. j = pos[j - 1];
  6598. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  6599. k = j; // swap
  6600. j = LOOK_HEAD_TOP;
  6601. }
  6602. clif_changelook(&sd->bl,j,k);
  6603. return 0;
  6604. }
  6605. /*==========================================
  6606. *Turns on/off Autotrade for a specific player
  6607. *------------------------------------------
  6608. *by durf (changed by Lupus)
  6609. */
  6610. int
  6611. atcommand_autotrade(
  6612. const int fd, struct map_session_data* sd,
  6613. const char* command, const char* message)
  6614. {
  6615. nullpo_retr(-1, sd);
  6616. if (sd->vender_id) //check if player's vending
  6617. {
  6618. sd->state.autotrade = 1;
  6619. clif_authfail_fd(fd, 15);
  6620. }
  6621. else
  6622. {
  6623. //"You should be vending to use @Autotrade."
  6624. clif_displaymessage(fd, msg_txt(549));
  6625. }
  6626. return 0;
  6627. }
  6628. /*==========================================
  6629. * Changes Master of your Guild to a specified guild member
  6630. *------------------------------------------
  6631. *by durf (changed by Lupus)
  6632. */
  6633. int
  6634. atcommand_changegm(
  6635. const int fd, struct map_session_data* sd,
  6636. const char* command, const char* message)
  6637. {
  6638. struct guild *g;
  6639. struct map_session_data *pl_sd;
  6640. nullpo_retr(-1, sd);
  6641. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  6642. {
  6643. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  6644. return -1;
  6645. }
  6646. if (strlen(message)==0)
  6647. {
  6648. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  6649. return -1;
  6650. }
  6651. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  6652. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  6653. return -1;
  6654. }
  6655. guild_gm_change(sd->status.guild_id, pl_sd);
  6656. return 0;
  6657. }
  6658. /*==========================================
  6659. *Changes the leader of a party.
  6660. *------------------------------------------
  6661. *by Skotlex
  6662. */
  6663. int
  6664. atcommand_changeleader(
  6665. const int fd, struct map_session_data* sd,
  6666. const char* command, const char* message)
  6667. {
  6668. struct party *p;
  6669. struct map_session_data *pl_sd;
  6670. int mi, pl_mi;
  6671. nullpo_retr(-1, sd);
  6672. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  6673. {
  6674. clif_displaymessage(fd, "You need to be a party's leader to use this command.");
  6675. return -1;
  6676. }
  6677. for (mi = 0; mi < MAX_PARTY && p->member[mi].sd != sd; mi++);
  6678. if (mi == MAX_PARTY)
  6679. return -1; //Shouldn't happen
  6680. if (!p->member[mi].leader)
  6681. {
  6682. clif_displaymessage(fd, "You need to be the party's leader to use this command.");
  6683. return -1;
  6684. }
  6685. if (strlen(message)==0)
  6686. {
  6687. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  6688. return -1;
  6689. }
  6690. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  6691. clif_displaymessage(fd, "Target character must be online and be in your party.");
  6692. return -1;
  6693. }
  6694. for (pl_mi = 0; pl_mi < MAX_PARTY && p->member[pl_mi].sd != pl_sd; pl_mi++);
  6695. if (pl_mi == MAX_PARTY)
  6696. return -1; //Shouldn't happen
  6697. //Change leadership.
  6698. p->member[mi].leader = 0;
  6699. if (p->member[mi].sd->fd)
  6700. clif_displaymessage(p->member[mi].sd->fd, "Leadership transferred.");
  6701. p->member[pl_mi].leader = 1;
  6702. if (p->member[pl_mi].sd->fd)
  6703. clif_displaymessage(p->member[pl_mi].sd->fd, "You've become the party leader.");
  6704. intif_party_leaderchange(p->party_id,p->member[pl_mi].account_id,p->member[pl_mi].char_id);
  6705. //Update info.
  6706. clif_party_main_info(p,-1);
  6707. clif_party_info(p,-1);
  6708. return 0;
  6709. }
  6710. /*==========================================
  6711. *Turns on/off AutoLoot for a specific player
  6712. *------------------------------------------
  6713. *by Upa-Kun
  6714. */
  6715. int
  6716. atcommand_autoloot(
  6717. const int fd, struct map_session_data* sd,
  6718. const char* command, const char* message)
  6719. {
  6720. int rate;
  6721. double drate;
  6722. nullpo_retr(-1, sd);
  6723. if (!message || !*message) {
  6724. if (sd->state.autoloot)
  6725. rate = 0;
  6726. else
  6727. rate = 10000;
  6728. } else {
  6729. drate = atof(message);
  6730. rate = (int)(drate*100);
  6731. }
  6732. if (rate > 10000) rate = 10000;
  6733. else if (rate < 0) rate = 0;
  6734. sd->state.autoloot = rate;
  6735. if (sd->state.autoloot) {
  6736. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  6737. clif_displaymessage(fd, atcmd_output);
  6738. }else
  6739. clif_displaymessage(fd, "Autoloot is now off.");
  6740. return 0;
  6741. }
  6742. /*==========================================
  6743. * It is made to rain.
  6744. *------------------------------------------
  6745. */
  6746. int
  6747. atcommand_rain(
  6748. const int fd, struct map_session_data* sd,
  6749. const char* command, const char* message)
  6750. {
  6751. nullpo_retr(-1, sd);
  6752. if (map[sd->bl.m].flag.rain) {
  6753. map[sd->bl.m].flag.rain=0;
  6754. clif_weather(sd->bl.m);
  6755. clif_displaymessage(fd, "The rain has stopped.");
  6756. } else {
  6757. map[sd->bl.m].flag.rain=1;
  6758. clif_weather(sd->bl.m);
  6759. clif_displaymessage(fd, "It is made to rain.");
  6760. }
  6761. return 0;
  6762. }
  6763. /*==========================================
  6764. * It is made to snow.
  6765. *------------------------------------------
  6766. */
  6767. int
  6768. atcommand_snow(
  6769. const int fd, struct map_session_data* sd,
  6770. const char* command, const char* message)
  6771. {
  6772. nullpo_retr(-1, sd);
  6773. if (map[sd->bl.m].flag.snow) {
  6774. map[sd->bl.m].flag.snow=0;
  6775. clif_weather(sd->bl.m);
  6776. clif_displaymessage(fd, "Snow has stopped falling.");
  6777. } else {
  6778. map[sd->bl.m].flag.snow=1;
  6779. clif_weather(sd->bl.m);
  6780. clif_displaymessage(fd, "It is made to snow.");
  6781. }
  6782. return 0;
  6783. }
  6784. /*==========================================
  6785. * Cherry tree snowstorm is made to fall. (Sakura)
  6786. *------------------------------------------
  6787. */
  6788. int
  6789. atcommand_sakura(
  6790. const int fd, struct map_session_data* sd,
  6791. const char* command, const char* message)
  6792. {
  6793. nullpo_retr(-1, sd);
  6794. if (map[sd->bl.m].flag.sakura) {
  6795. map[sd->bl.m].flag.sakura=0;
  6796. clif_weather(sd->bl.m);
  6797. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  6798. } else {
  6799. map[sd->bl.m].flag.sakura=1;
  6800. clif_weather(sd->bl.m);
  6801. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6802. }
  6803. return 0;
  6804. }
  6805. /*==========================================
  6806. * Clouds appear.
  6807. *------------------------------------------
  6808. */
  6809. int
  6810. atcommand_clouds(
  6811. const int fd, struct map_session_data* sd,
  6812. const char* command, const char* message)
  6813. {
  6814. nullpo_retr(-1, sd);
  6815. if (map[sd->bl.m].flag.clouds) {
  6816. map[sd->bl.m].flag.clouds=0;
  6817. clif_weather(sd->bl.m);
  6818. clif_displaymessage(fd, "The clouds has disappear.");
  6819. } else {
  6820. map[sd->bl.m].flag.clouds=1;
  6821. clif_weather(sd->bl.m);
  6822. clif_displaymessage(fd, "Clouds appear.");
  6823. }
  6824. return 0;
  6825. }
  6826. /*==========================================
  6827. * Different type of clouds using effect 516
  6828. *------------------------------------------
  6829. */
  6830. int
  6831. atcommand_clouds2(
  6832. const int fd, struct map_session_data* sd,
  6833. const char* command, const char* message)
  6834. {
  6835. nullpo_retr(-1, sd);
  6836. if (map[sd->bl.m].flag.clouds2) {
  6837. map[sd->bl.m].flag.clouds2=0;
  6838. clif_weather(sd->bl.m);
  6839. clif_displaymessage(fd, "The alternative clouds disappear.");
  6840. } else {
  6841. map[sd->bl.m].flag.clouds2=1;
  6842. clif_weather(sd->bl.m);
  6843. clif_displaymessage(fd, "Alternative clouds appear.");
  6844. }
  6845. return 0;
  6846. }
  6847. /*==========================================
  6848. * Fog hangs over.
  6849. *------------------------------------------
  6850. */
  6851. int
  6852. atcommand_fog(
  6853. const int fd, struct map_session_data* sd,
  6854. const char* command, const char* message)
  6855. {
  6856. nullpo_retr(-1, sd);
  6857. if (map[sd->bl.m].flag.fog) {
  6858. map[sd->bl.m].flag.fog=0;
  6859. clif_weather(sd->bl.m);
  6860. clif_displaymessage(fd, "The fog has gone.");
  6861. } else {
  6862. map[sd->bl.m].flag.fog=1;
  6863. clif_weather(sd->bl.m);
  6864. clif_displaymessage(fd, "Fog hangs over.");
  6865. }
  6866. return 0;
  6867. }
  6868. /*==========================================
  6869. * Fallen leaves fall.
  6870. *------------------------------------------
  6871. */
  6872. int
  6873. atcommand_leaves(
  6874. const int fd, struct map_session_data* sd,
  6875. const char* command, const char* message)
  6876. {
  6877. nullpo_retr(-1, sd);
  6878. if (map[sd->bl.m].flag.leaves) {
  6879. map[sd->bl.m].flag.leaves=0;
  6880. clif_weather(sd->bl.m);
  6881. clif_displaymessage(fd, "Leaves no longer fall.");
  6882. } else {
  6883. map[sd->bl.m].flag.leaves=1;
  6884. clif_weather(sd->bl.m);
  6885. clif_displaymessage(fd, "Fallen leaves fall.");
  6886. }
  6887. return 0;
  6888. }
  6889. /*==========================================
  6890. * Fireworks appear.
  6891. *------------------------------------------
  6892. */
  6893. int
  6894. atcommand_fireworks(
  6895. const int fd, struct map_session_data* sd,
  6896. const char* command, const char* message)
  6897. {
  6898. nullpo_retr(-1, sd);
  6899. if (map[sd->bl.m].flag.fireworks) {
  6900. map[sd->bl.m].flag.fireworks=0;
  6901. clif_weather(sd->bl.m);
  6902. clif_displaymessage(fd, "Fireworks are ended.");
  6903. } else {
  6904. map[sd->bl.m].flag.fireworks=1;
  6905. clif_weather(sd->bl.m);
  6906. clif_displaymessage(fd, "Fireworks are launched.");
  6907. }
  6908. return 0;
  6909. }
  6910. /*==========================================
  6911. * Clearing Weather Effects by Dexity
  6912. *------------------------------------------
  6913. */
  6914. int
  6915. atcommand_clearweather(
  6916. const int fd, struct map_session_data* sd,
  6917. const char* command, const char* message)
  6918. {
  6919. nullpo_retr(-1, sd);
  6920. map[sd->bl.m].flag.rain=0;
  6921. map[sd->bl.m].flag.snow=0;
  6922. map[sd->bl.m].flag.sakura=0;
  6923. map[sd->bl.m].flag.clouds=0;
  6924. map[sd->bl.m].flag.clouds2=0;
  6925. map[sd->bl.m].flag.fog=0;
  6926. map[sd->bl.m].flag.fireworks=0;
  6927. map[sd->bl.m].flag.leaves=0;
  6928. clif_weather(sd->bl.m);
  6929. return 0;
  6930. }
  6931. /*===============================================================
  6932. * Sound Command - plays a sound for everyone! [Codemaster]
  6933. *---------------------------------------------------------------
  6934. */
  6935. int
  6936. atcommand_sound(
  6937. const int fd, struct map_session_data *sd,
  6938. const char *command, const char *message)
  6939. {
  6940. char sound_file[100];
  6941. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6942. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  6943. return -1;
  6944. }
  6945. memset(sound_file, '\0', sizeof(sound_file));
  6946. if(sscanf(message, "%99[^\n]", sound_file) < 1)
  6947. return -1;
  6948. if(strstr(sound_file, ".wav") == NULL)
  6949. strcat(sound_file, ".wav");
  6950. clif_soundeffectall(&sd->bl, sound_file,0);
  6951. return 0;
  6952. }
  6953. /*==========================================
  6954. * MOB Search
  6955. *------------------------------------------
  6956. */
  6957. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  6958. {
  6959. int mob_id,fd;
  6960. static int number=0;
  6961. struct mob_data *md;
  6962. nullpo_retr(0, bl);
  6963. if(!ap){
  6964. number=0;
  6965. return 0;
  6966. }
  6967. mob_id = va_arg(ap,int);
  6968. fd = va_arg(ap,int);
  6969. md = (struct mob_data *)bl;
  6970. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  6971. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  6972. ++number,bl->x, bl->y,md->name);
  6973. clif_displaymessage(fd, atcmd_output);
  6974. }
  6975. return 0;
  6976. }
  6977. int atcommand_mobsearch(
  6978. const int fd, struct map_session_data* sd,
  6979. const char* command, const char* message)
  6980. {
  6981. char mob_name[100];
  6982. int mob_id,map_id = 0;
  6983. nullpo_retr(-1, sd);
  6984. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  6985. return -1;
  6986. if ((mob_id = atoi(mob_name)) == 0)
  6987. mob_id = mobdb_searchname(mob_name);
  6988. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6989. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6990. clif_displaymessage(fd, atcmd_output);
  6991. return 0;
  6992. }
  6993. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6994. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6995. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6996. map_id = sd->bl.m;
  6997. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  6998. mob_name, mapindex_id2name(sd->mapindex));
  6999. clif_displaymessage(fd, atcmd_output);
  7000. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  7001. atmobsearch_sub(&sd->bl,0); // 番号リセット
  7002. return 0;
  7003. }
  7004. /*==========================================
  7005. * ドロップアイテムの掃除
  7006. *------------------------------------------
  7007. */
  7008. /*==========================================
  7009. * cleanmap
  7010. *------------------------------------------
  7011. */
  7012. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  7013. {
  7014. nullpo_retr(0, bl);
  7015. map_clearflooritem(bl->id);
  7016. return 0;
  7017. }
  7018. int
  7019. atcommand_cleanmap(
  7020. const int fd, struct map_session_data* sd,
  7021. const char* command, const char* message)
  7022. {
  7023. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  7024. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  7025. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  7026. BL_ITEM);
  7027. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  7028. return 0;
  7029. }
  7030. /*==========================================
  7031. * NPC/PETに話させる
  7032. *------------------------------------------
  7033. */
  7034. int
  7035. atcommand_npctalk(
  7036. const int fd, struct map_session_data* sd,
  7037. const char* command, const char* message)
  7038. {
  7039. char name[NAME_LENGTH],mes[100],temp[100];
  7040. struct npc_data *nd;
  7041. if (sscanf(message, "%23[^,],%99[^\n]", name, mes) < 2)
  7042. return -1;
  7043. if (!(nd = npc_name2id(name)))
  7044. return -1;
  7045. snprintf(temp, sizeof temp ,"%s : %s",name,mes);
  7046. clif_message(&nd->bl, temp);
  7047. return 0;
  7048. }
  7049. int
  7050. atcommand_pettalk(
  7051. const int fd, struct map_session_data* sd,
  7052. const char* command, const char* message)
  7053. {
  7054. char mes[100],temp[100];
  7055. struct pet_data *pd;
  7056. nullpo_retr(-1, sd);
  7057. if(!sd->status.pet_id || !(pd=sd->pd))
  7058. return -1;
  7059. if (sscanf(message, "%99[^\n]", mes) < 1)
  7060. return -1;
  7061. snprintf(temp, sizeof temp ,"%s : %s",sd->pet.name,mes);
  7062. clif_message(&pd->bl, temp);
  7063. return 0;
  7064. }
  7065. /*==========================================
  7066. * @users
  7067. * サーバー内の人数マップを表示させる
  7068. * 手抜きのため汚くなっているのは仕様です。
  7069. *------------------------------------------
  7070. */
  7071. static struct dbt *users_db = NULL;
  7072. static int users_all;
  7073. static int atcommand_users_sub1(struct map_session_data* sd,va_list va) {
  7074. int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
  7075. users_all++;
  7076. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  7077. return 0;
  7078. }
  7079. static int atcommand_users_sub2(DBKey key,void* val,va_list va) {
  7080. char buf[256];
  7081. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  7082. sprintf(buf,"%s : %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
  7083. clif_displaymessage(sd->fd,buf);
  7084. return 0;
  7085. }
  7086. int
  7087. atcommand_users(
  7088. const int fd, struct map_session_data* sd,
  7089. const char* command, const char* message)
  7090. {
  7091. char buf[256];
  7092. users_all = 0;
  7093. users_db->clear(users_db, NULL);
  7094. clif_foreachclient(atcommand_users_sub1);
  7095. users_db->foreach(users_db,atcommand_users_sub2,sd);
  7096. sprintf(buf,"all : %d",users_all);
  7097. clif_displaymessage(fd,buf);
  7098. return 0;
  7099. }
  7100. /*==========================================
  7101. *
  7102. *------------------------------------------
  7103. */
  7104. int
  7105. atcommand_summon(
  7106. const int fd, struct map_session_data* sd,
  7107. const char* command, const char* message)
  7108. {
  7109. char name[NAME_LENGTH];
  7110. int mob_id = 0;
  7111. int x = 0;
  7112. int y = 0;
  7113. int id = 0;
  7114. int duration = 0;
  7115. struct mob_data *md;
  7116. unsigned int tick=gettick();
  7117. nullpo_retr(-1, sd);
  7118. if (!message || !*message)
  7119. return -1;
  7120. if (sscanf(message, "%23s %d", name, &duration) < 1)
  7121. return -1;
  7122. if (duration < 1)
  7123. duration =1;
  7124. else if (duration > 60)
  7125. duration =60;
  7126. if ((mob_id = atoi(name)) == 0)
  7127. mob_id = mobdb_searchname(name);
  7128. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  7129. return -1;
  7130. x = sd->bl.x + (rand() % 10 - 5);
  7131. y = sd->bl.y + (rand() % 10 - 5);
  7132. id = mob_once_spawn(sd,"this", x, y, "--ja--", mob_id, 1, "");
  7133. if((md=(struct mob_data *)map_id2bl(id))){
  7134. md->master_id=sd->bl.id;
  7135. md->special_state.ai=1;
  7136. md->mode=md->db->mode|MD_AGGRESSIVE;
  7137. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,id,0);
  7138. clif_misceffect2(&md->bl,344);
  7139. }
  7140. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,x,y,tick);
  7141. return 0;
  7142. }
  7143. /*==========================================
  7144. * @adjcmdlvl by [MouseJstr]
  7145. *
  7146. * Temp adjust the GM level required to use a GM command
  7147. *
  7148. * Used during beta testing to allow players to use GM commands
  7149. * for short periods of time
  7150. *------------------------------------------
  7151. */
  7152. int
  7153. atcommand_adjcmdlvl(
  7154. const int fd, struct map_session_data* sd,
  7155. const char* command, const char* message)
  7156. {
  7157. int i, newlev;
  7158. char cmd[100];
  7159. nullpo_retr(-1, sd);
  7160. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  7161. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  7162. return -1;
  7163. }
  7164. for (i = 0; (atcommand_info[i].command) && atcommand_info[i].type != AtCommand_None; i++)
  7165. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  7166. atcommand_info[i].level = newlev;
  7167. clif_displaymessage(fd, "@command level changed.");
  7168. return 0;
  7169. }
  7170. clif_displaymessage(fd, "@command not found.");
  7171. return -1;
  7172. }
  7173. /*==========================================
  7174. * @adjgmlvl by [MouseJstr]
  7175. *
  7176. * Create a temp GM
  7177. *
  7178. * Used during beta testing to allow players to use GM commands
  7179. * for short periods of time
  7180. *------------------------------------------
  7181. */
  7182. int
  7183. atcommand_adjgmlvl(
  7184. const int fd, struct map_session_data* sd,
  7185. const char* command, const char* message)
  7186. {
  7187. int newlev;
  7188. char user[NAME_LENGTH];
  7189. struct map_session_data *pl_sd;
  7190. nullpo_retr(-1, sd);
  7191. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  7192. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  7193. return -1;
  7194. }
  7195. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  7196. return -1;
  7197. pc_set_gm_level(pl_sd->status.account_id, newlev);
  7198. return 0;
  7199. }
  7200. /*==========================================
  7201. * @trade by [MouseJstr]
  7202. *
  7203. * Open a trade window with a remote player
  7204. *
  7205. * If I have to jump to a remote player one more time, I am
  7206. * gonna scream!
  7207. *------------------------------------------
  7208. */
  7209. int
  7210. atcommand_trade(
  7211. const int fd, struct map_session_data* sd,
  7212. const char* command, const char* message)
  7213. {
  7214. struct map_session_data *pl_sd = NULL;
  7215. nullpo_retr(-1, sd);
  7216. if (!message || !*message)
  7217. return -1;
  7218. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7219. trade_traderequest(sd, pl_sd->bl.id);
  7220. return 0;
  7221. }
  7222. return -1;
  7223. }
  7224. /*==========================================
  7225. * @setbattleflag by [MouseJstr]
  7226. *
  7227. * set a battle_config flag without having to reboot
  7228. */
  7229. int
  7230. atcommand_setbattleflag(
  7231. const int fd, struct map_session_data* sd,
  7232. const char* command, const char* message)
  7233. {
  7234. char flag[128], value[128];
  7235. nullpo_retr(-1, sd);
  7236. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  7237. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  7238. return -1;
  7239. }
  7240. if (battle_set_value(flag, value) == 0)
  7241. clif_displaymessage(fd, "unknown battle_config flag");
  7242. else
  7243. clif_displaymessage(fd, "battle_config set as requested");
  7244. return 0;
  7245. }
  7246. /*===========================
  7247. * @unmute [Valaris]
  7248. *===========================
  7249. */
  7250. int atcommand_unmute(
  7251. const int fd, struct map_session_data* sd,
  7252. const char* command, const char* message)
  7253. {
  7254. struct map_session_data *pl_sd = NULL;
  7255. nullpo_retr(-1, sd);
  7256. if(!battle_config.muting_players) {
  7257. clif_displaymessage(fd, "Please enable the muting system before using it.");
  7258. return 0;
  7259. }
  7260. if (!message || !*message)
  7261. return -1;
  7262. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7263. if(pl_sd->sc.data[SC_NOCHAT].timer!=-1) {
  7264. pl_sd->status.manner = 0; // have to set to 0 first [celest]
  7265. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  7266. clif_displaymessage(sd->fd,"Player unmuted");
  7267. }
  7268. else
  7269. clif_displaymessage(sd->fd,"Player is not muted");
  7270. }
  7271. return 0;
  7272. }
  7273. /*==========================================
  7274. * @uptime by MC Cameri
  7275. *------------------------------------------
  7276. */
  7277. int
  7278. atcommand_uptime(
  7279. const int fd, struct map_session_data* sd,
  7280. const char* command, const char* message)
  7281. {
  7282. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  7283. minute = 60, days = 0, hours = 0, minutes = 0;
  7284. nullpo_retr(-1, sd);
  7285. seconds = get_uptime();
  7286. days = seconds/day;
  7287. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  7288. hours = seconds/hour;
  7289. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  7290. minutes = seconds/minute;
  7291. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  7292. snprintf(atcmd_output, sizeof(atcmd_output), msg_table[245], days, hours, minutes, seconds);
  7293. clif_displaymessage(fd, atcmd_output);
  7294. return 0;
  7295. }
  7296. /*==========================================
  7297. * @changesex <sex>
  7298. * => Changes one's sex. Argument sex can be
  7299. * 0 or 1, m or f, male or female.
  7300. *------------------------------------------
  7301. */
  7302. int
  7303. atcommand_changesex(
  7304. const int fd, struct map_session_data* sd,
  7305. const char* command, const char* message)
  7306. {
  7307. nullpo_retr(-1, sd);
  7308. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  7309. return 0;
  7310. }
  7311. /*================================================
  7312. * @mute - Mutes a player for a set amount of time
  7313. *------------------------------------------------
  7314. */
  7315. int atcommand_mute(
  7316. const int fd, struct map_session_data* sd,
  7317. const char* command, const char* message)
  7318. {
  7319. struct map_session_data *pl_sd = NULL;
  7320. int manner;
  7321. nullpo_retr(-1, sd);
  7322. if(!battle_config.muting_players) {
  7323. clif_displaymessage(fd, "Please enable the muting system before using it.");
  7324. return 0;
  7325. }
  7326. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  7327. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  7328. return -1;
  7329. }
  7330. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  7331. clif_GM_silence(sd, pl_sd, 0);
  7332. pl_sd->status.manner -= manner;
  7333. if(pl_sd->status.manner < 0)
  7334. status_change_start(&pl_sd->bl,SC_NOCHAT,100,0,0,0,0,0,0);
  7335. }
  7336. else {
  7337. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7338. return -1;
  7339. }
  7340. return 0;
  7341. }
  7342. /*==========================================
  7343. * @refresh (like @jumpto <<yourself>>)
  7344. *------------------------------------------
  7345. */
  7346. int atcommand_refresh(
  7347. const int fd, struct map_session_data* sd,
  7348. const char* command, const char* message)
  7349. {
  7350. nullpo_retr(-1, sd);
  7351. clif_refresh(sd);
  7352. return 0;
  7353. }
  7354. /*==========================================
  7355. * @petid <part of pet name>
  7356. * => Displays a list of matching pets.
  7357. *------------------------------------------
  7358. */
  7359. int
  7360. atcommand_petid(const int fd, struct map_session_data* sd,
  7361. const char* command, const char* message)
  7362. {
  7363. char searchtext[100];
  7364. char temp0[100];
  7365. char temp1[100];
  7366. int cnt = 0, i = 0;
  7367. nullpo_retr(-1, sd);
  7368. if (!message || !*message)
  7369. return -1;
  7370. if (sscanf(message, "%99s", searchtext) < 1)
  7371. return -1;
  7372. estr_lower(searchtext);
  7373. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  7374. clif_displaymessage(fd,temp0);
  7375. while (i < MAX_PET_DB) {
  7376. strcpy(temp1,pet_db[i].name);
  7377. strcpy(temp1, estr_lower(temp1));
  7378. strcpy(temp0,pet_db[i].jname);
  7379. strcpy(temp0, estr_lower(temp1));
  7380. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  7381. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
  7382. pet_db[i].jname);
  7383. if (cnt >= 100) { // Only if there are custom pets
  7384. clif_displaymessage(fd, "Be more specific, can't send more than"
  7385. " 100 results.");
  7386. } else {
  7387. clif_displaymessage(fd, temp0);
  7388. }
  7389. cnt++;
  7390. }
  7391. i++;
  7392. }
  7393. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  7394. clif_displaymessage(fd, temp0);
  7395. return 0;
  7396. }
  7397. /*==========================================
  7398. * @identify
  7399. * => GM's magnifier.
  7400. *------------------------------------------
  7401. */
  7402. int
  7403. atcommand_identify(
  7404. const int fd, struct map_session_data* sd,
  7405. const char* command, const char* message)
  7406. {
  7407. int i,num;
  7408. nullpo_retr(-1, sd);
  7409. for(i=num=0;i<MAX_INVENTORY;i++){
  7410. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7411. num++;
  7412. }
  7413. }
  7414. if (num > 0) {
  7415. clif_item_identify_list(sd);
  7416. } else {
  7417. clif_displaymessage(fd,"There are no items to appraise.");
  7418. }
  7419. return 0;
  7420. }
  7421. /*==========================================
  7422. * @gmotd (Global MOTD)
  7423. * by davidsiaw :P
  7424. *------------------------------------------
  7425. */
  7426. int
  7427. atcommand_gmotd(
  7428. const int fd, struct map_session_data* sd,
  7429. const char* command, const char* message)
  7430. {
  7431. char buf[256];
  7432. FILE *fp;
  7433. nullpo_retr(-1, sd);
  7434. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7435. while (fgets(buf, 250, fp) != NULL){
  7436. int i;
  7437. for( i=0; buf[i]; i++){
  7438. if( buf[i]=='\r' || buf[i]=='\n'){
  7439. buf[i]=0;
  7440. break;
  7441. }
  7442. }
  7443. intif_GMmessage(buf,strlen(buf)+1,8);
  7444. }
  7445. fclose(fp);
  7446. }
  7447. return 0;
  7448. }
  7449. int atcommand_misceffect(
  7450. const int fd, struct map_session_data* sd,
  7451. const char* command, const char* message)
  7452. {
  7453. int effect = 0;
  7454. nullpo_retr(-1, sd);
  7455. if (!message || !*message)
  7456. return -1;
  7457. if (sscanf(message, "%d", &effect) < 1)
  7458. return -1;
  7459. clif_misceffect(&sd->bl,effect);
  7460. return 0;
  7461. }
  7462. int charid2sessionid(int charid)
  7463. {
  7464. struct map_session_data *pl_sd = NULL;
  7465. pl_sd = map_charid2sd(charid);
  7466. if (pl_sd) return pl_sd->fd;
  7467. return 0;
  7468. }
  7469. int accountid2sessionid(int accountid)
  7470. {
  7471. struct map_session_data *pl_sd = NULL;
  7472. pl_sd = map_id2sd(accountid);
  7473. if (pl_sd) return pl_sd->fd;
  7474. return 0;
  7475. }
  7476. /*==========================================
  7477. * Jump to a player by PID number
  7478. * Original by Dino9021
  7479. * Added in by nsstrunks
  7480. *------------------------------------------
  7481. */
  7482. int atcommand_jumptoid(
  7483. const int fd, struct map_session_data* sd,
  7484. const char* command, const char* message)
  7485. {
  7486. int cid=0;
  7487. int session_id=0;
  7488. struct map_session_data *pl_sd;
  7489. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7490. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7491. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7492. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7493. return -1;
  7494. }
  7495. cid=atoi(message);
  7496. if ((session_id=charid2sessionid(cid))!=0)
  7497. {
  7498. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7499. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7500. clif_displaymessage(fd, msg_table[247]);
  7501. return -1;
  7502. }
  7503. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7504. clif_displaymessage(fd, msg_table[248]);
  7505. return -1;
  7506. }
  7507. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7508. sprintf(atcmd_output, msg_table[4], pl_sd->status.name); // Jump to %s
  7509. clif_displaymessage(fd, atcmd_output);
  7510. } else {
  7511. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7512. return -1;
  7513. }
  7514. }
  7515. else
  7516. {
  7517. clif_displaymessage(fd,msg_table[3]);
  7518. }
  7519. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7520. return 0;
  7521. }
  7522. /*==========================================
  7523. * Jump to a player by PID number
  7524. * Original by Dino9021
  7525. * Added in by nsstrunks
  7526. *------------------------------------------
  7527. */
  7528. int atcommand_jumptoid2(
  7529. const int fd, struct map_session_data* sd,
  7530. const char* command, const char* message)
  7531. {
  7532. int aid=0;
  7533. int session_id=0;
  7534. struct map_session_data *pl_sd;
  7535. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7536. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7537. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7538. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7539. return -1;
  7540. }
  7541. aid=atoi(message);
  7542. if ((session_id=accountid2sessionid(aid))!=0)
  7543. {
  7544. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7545. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7546. clif_displaymessage(fd, msg_table[247]);
  7547. return -1;
  7548. }
  7549. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7550. clif_displaymessage(fd, msg_table[248]);
  7551. return -1;
  7552. }
  7553. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7554. sprintf(atcmd_output, msg_table[4], pl_sd->status.name); // Jump to %s
  7555. clif_displaymessage(fd, atcmd_output);
  7556. } else {
  7557. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7558. return -1;
  7559. }
  7560. }
  7561. else
  7562. {
  7563. clif_displaymessage(fd,msg_table[3]);
  7564. }
  7565. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7566. return 0;
  7567. }
  7568. /*==========================================
  7569. * Recall a player by PID number
  7570. * Original by Dino9021
  7571. * Added in by nsstrunks
  7572. *------------------------------------------
  7573. */
  7574. int atcommand_recallid(
  7575. const int fd, struct map_session_data* sd,
  7576. const char* command, const char* message)
  7577. {
  7578. int cid=0;
  7579. int session_id=0;
  7580. struct map_session_data *pl_sd;
  7581. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7582. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7583. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7584. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  7585. return -1;
  7586. }
  7587. cid=atoi(message);
  7588. if ((session_id=charid2sessionid(cid))!=0)
  7589. {
  7590. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7591. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7592. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7593. clif_displaymessage(fd, msg_table[247]);
  7594. return -1;
  7595. }
  7596. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7597. clif_displaymessage(fd, msg_table[248]);
  7598. return -1;
  7599. }
  7600. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7601. sprintf(atcmd_output, msg_table[46], pl_sd->status.name); // Jump to %s
  7602. clif_displaymessage(fd, atcmd_output);
  7603. } else {
  7604. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7605. return -1;
  7606. }
  7607. } else {
  7608. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7609. return -1;
  7610. }
  7611. }
  7612. else
  7613. {
  7614. clif_displaymessage(fd,msg_table[3]);
  7615. }
  7616. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7617. return 0;
  7618. }
  7619. /*==========================================
  7620. * Recall a player by PID number
  7621. * Original by Dino9021
  7622. * Added in by nsstrunks
  7623. *------------------------------------------
  7624. */
  7625. int atcommand_recallid2(
  7626. const int fd, struct map_session_data* sd,
  7627. const char* command, const char* message)
  7628. {
  7629. int aid=0;
  7630. int session_id=0;
  7631. struct map_session_data *pl_sd;
  7632. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7633. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7634. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7635. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  7636. return -1;
  7637. }
  7638. aid=atoi(message);
  7639. if ((session_id=accountid2sessionid(aid))!=0)
  7640. {
  7641. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7642. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7643. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7644. clif_displaymessage(fd, msg_table[247]);
  7645. return -1;
  7646. }
  7647. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7648. clif_displaymessage(fd, msg_table[248]);
  7649. return -1;
  7650. }
  7651. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7652. sprintf(atcmd_output, msg_table[46], pl_sd->status.name); // Jump to %s
  7653. clif_displaymessage(fd, atcmd_output);
  7654. } else {
  7655. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7656. return -1;
  7657. }
  7658. } else {
  7659. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7660. return -1;
  7661. }
  7662. }
  7663. else
  7664. {
  7665. clif_displaymessage(fd,msg_table[3]);
  7666. }
  7667. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7668. return 0;
  7669. }
  7670. /*==========================================
  7671. * Kick a player by PID number
  7672. * Original by Dino9021
  7673. * Added in by nsstrunks
  7674. *------------------------------------------
  7675. */
  7676. int atcommand_kickid(
  7677. const int fd, struct map_session_data* sd,
  7678. const char* command, const char* message)
  7679. {
  7680. struct map_session_data *pl_sd;
  7681. int cid=0;
  7682. int session_id=0;
  7683. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7684. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7685. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  7686. return -1;
  7687. }
  7688. cid=atoi(message);
  7689. if ((session_id=charid2sessionid(cid))!=0)
  7690. {
  7691. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7692. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7693. clif_GM_kick(sd, pl_sd, 1);
  7694. else {
  7695. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7696. return -1;
  7697. }
  7698. } else {
  7699. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7700. return -1;
  7701. }
  7702. }
  7703. else
  7704. {
  7705. clif_displaymessage(fd,msg_table[3]);
  7706. }
  7707. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7708. return 0;
  7709. }
  7710. /*==========================================
  7711. * Kick a player by PID number
  7712. * Original by Dino9021
  7713. * Added in by nsstrunks
  7714. *------------------------------------------
  7715. */
  7716. int atcommand_kickid2(
  7717. const int fd, struct map_session_data* sd,
  7718. const char* command, const char* message)
  7719. {
  7720. struct map_session_data *pl_sd;
  7721. int aid=0;
  7722. int session_id=0;
  7723. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7724. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7725. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  7726. return -1;
  7727. }
  7728. aid=atoi(message);
  7729. if ((session_id=accountid2sessionid(aid))!=0)
  7730. {
  7731. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7732. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7733. clif_GM_kick(sd, pl_sd, 1);
  7734. else {
  7735. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7736. return -1;
  7737. }
  7738. } else {
  7739. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7740. return -1;
  7741. }
  7742. }
  7743. else
  7744. {
  7745. clif_displaymessage(fd,msg_table[3]);
  7746. }
  7747. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7748. return 0;
  7749. }
  7750. /*==========================================
  7751. * Revive a player by PID number
  7752. * Original by Dino9021
  7753. * Added in by nsstrunks
  7754. *------------------------------------------
  7755. */
  7756. int atcommand_reviveid(
  7757. const int fd, struct map_session_data* sd,
  7758. const char* command, const char* message)
  7759. {
  7760. int cid=0;
  7761. int session_id=0;
  7762. struct map_session_data *pl_sd;
  7763. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7764. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7765. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  7766. return -1;
  7767. }
  7768. cid=atoi(message);
  7769. if ((session_id=charid2sessionid(cid))!=0)
  7770. {
  7771. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7772. pl_sd->status.hp = pl_sd->status.max_hp;
  7773. pc_setstand(pl_sd);
  7774. if (battle_config.pc_invincible_time > 0)
  7775. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7776. clif_updatestatus(pl_sd, SP_HP);
  7777. clif_updatestatus(pl_sd, SP_SP);
  7778. clif_resurrection(&pl_sd->bl, 1);
  7779. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7780. } else {
  7781. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7782. return -1;
  7783. }
  7784. }
  7785. else
  7786. {
  7787. clif_displaymessage(fd,msg_table[3]);
  7788. }
  7789. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7790. return 0;
  7791. }
  7792. /*==========================================
  7793. * Revive a player by PID number
  7794. * Original by Dino9021
  7795. * Added in by nsstrunks
  7796. *------------------------------------------
  7797. */
  7798. int atcommand_reviveid2(
  7799. const int fd, struct map_session_data* sd,
  7800. const char* command, const char* message)
  7801. {
  7802. int aid=0;
  7803. int session_id=0;
  7804. struct map_session_data *pl_sd;
  7805. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7806. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7807. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  7808. return -1;
  7809. }
  7810. aid=atoi(message);
  7811. if ((session_id=accountid2sessionid(aid))!=0)
  7812. {
  7813. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7814. pl_sd->status.hp = pl_sd->status.max_hp;
  7815. pc_setstand(pl_sd);
  7816. if (battle_config.pc_invincible_time > 0)
  7817. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7818. clif_updatestatus(pl_sd, SP_HP);
  7819. clif_updatestatus(pl_sd, SP_SP);
  7820. clif_resurrection(&pl_sd->bl, 1);
  7821. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7822. } else {
  7823. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7824. return -1;
  7825. }
  7826. }
  7827. else
  7828. {
  7829. clif_displaymessage(fd,msg_table[3]);
  7830. }
  7831. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7832. return 0;
  7833. }
  7834. /*==========================================
  7835. * Kill a player by PID number
  7836. * Original by Dino9021
  7837. * Added in by nsstrunks
  7838. *------------------------------------------
  7839. */
  7840. int atcommand_killid(
  7841. const int fd, struct map_session_data* sd,
  7842. const char* command, const char* message)
  7843. {
  7844. int cid=0;
  7845. int session_id=0;
  7846. struct map_session_data *pl_sd;
  7847. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7848. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7849. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  7850. return -1;
  7851. }
  7852. cid=atoi(message);
  7853. if ((session_id=charid2sessionid(cid))!=0)
  7854. {
  7855. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7856. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7857. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  7858. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7859. } else {
  7860. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7861. return -1;
  7862. }
  7863. } else {
  7864. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7865. return -1;
  7866. }
  7867. }
  7868. else
  7869. {
  7870. clif_displaymessage(fd,msg_table[3]);
  7871. }
  7872. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7873. return 0;
  7874. }
  7875. /*==========================================
  7876. * Kill a player by PID number
  7877. * Original by Dino9021
  7878. * Added in by nsstrunks
  7879. *------------------------------------------
  7880. */
  7881. int atcommand_killid2(
  7882. const int fd, struct map_session_data* sd,
  7883. const char* command, const char* message)
  7884. {
  7885. int aid=0;
  7886. int session_id=0;
  7887. struct map_session_data *pl_sd;
  7888. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7889. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7890. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  7891. return -1;
  7892. }
  7893. aid=atoi(message);
  7894. if ((session_id=accountid2sessionid(aid))!=0)
  7895. {
  7896. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7897. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7898. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  7899. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7900. } else {
  7901. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7902. return -1;
  7903. }
  7904. } else {
  7905. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7906. return -1;
  7907. }
  7908. }
  7909. else
  7910. {
  7911. clif_displaymessage(fd,msg_table[3]);
  7912. }
  7913. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7914. return 0;
  7915. }
  7916. /*==========================================
  7917. * Make a player killable, by PID
  7918. * Original by Dino9021
  7919. * Added in by nsstrunks
  7920. *------------------------------------------
  7921. */
  7922. int
  7923. atcommand_charkillableid(
  7924. const int fd, struct map_session_data* sd,
  7925. const char* command, const char* message)
  7926. {
  7927. struct map_session_data *pl_sd = NULL;
  7928. int cid=0;
  7929. int session_id=0;
  7930. if (!message || (cid = atoi(message)) == 0 || !*message)
  7931. return -1;
  7932. cid=atoi(message);
  7933. if ((session_id=charid2sessionid(cid))!=0)
  7934. {
  7935. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  7936. return -1;
  7937. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  7938. if(pl_sd->special_state.killable)
  7939. clif_displaymessage(fd, "The player is now killable");
  7940. else
  7941. clif_displaymessage(fd, "The player is no longer killable");
  7942. }
  7943. else
  7944. {
  7945. clif_displaymessage(fd,msg_table[3]);
  7946. }
  7947. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7948. return 0;
  7949. }
  7950. /*==========================================
  7951. * Make a player killable, by PID
  7952. * Original by Dino9021
  7953. * Added in by nsstrunks
  7954. *------------------------------------------
  7955. */
  7956. int
  7957. atcommand_charkillableid2(
  7958. const int fd, struct map_session_data* sd,
  7959. const char* command, const char* message)
  7960. {
  7961. struct map_session_data *pl_sd = NULL;
  7962. int aid=0;
  7963. int session_id=0;
  7964. if (!message || (aid = atoi(message)) == 0 || !*message)
  7965. return -1;
  7966. aid=atoi(message);
  7967. if ((session_id=accountid2sessionid(aid))!=0)
  7968. {
  7969. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  7970. return -1;
  7971. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  7972. if(pl_sd->special_state.killable)
  7973. clif_displaymessage(fd, "The player is now killable");
  7974. else
  7975. clif_displaymessage(fd, "The player is no longer killable");
  7976. }
  7977. else
  7978. {
  7979. clif_displaymessage(fd,msg_table[3]);
  7980. }
  7981. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7982. return 0;
  7983. }
  7984. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  7985. /*==========================================
  7986. * Mail System commands by [Valaris]
  7987. *------------------------------------------
  7988. */
  7989. int atcommand_listmail(
  7990. const int fd, struct map_session_data* sd,
  7991. const char* command, const char* message)
  7992. {
  7993. if(!mail_server_enable)
  7994. return 0;
  7995. nullpo_retr(-1, sd);
  7996. if(strlen(command)==12)
  7997. mail_check(sd,3);
  7998. else if(strlen(command)==9)
  7999. mail_check(sd,2);
  8000. else
  8001. mail_check(sd,1);
  8002. return 0;
  8003. }
  8004. int atcommand_readmail(
  8005. const int fd, struct map_session_data* sd,
  8006. const char* command, const char* message)
  8007. {
  8008. int index;
  8009. if(!mail_server_enable)
  8010. return 0;
  8011. nullpo_retr(-1, sd);
  8012. if (!message || !*message) {
  8013. clif_displaymessage(sd->fd,"You must specify a message number.");
  8014. return 0;
  8015. }
  8016. index = atoi(message);
  8017. if (index < 1) {
  8018. clif_displaymessage(sd->fd,"Message number cannot be negative or zero.");
  8019. return 0;
  8020. }
  8021. if(strlen(command)==11)
  8022. mail_delete(sd,index);
  8023. else
  8024. mail_read(sd,index);
  8025. return 0;
  8026. }
  8027. int atcommand_sendmail(
  8028. const int fd, struct map_session_data* sd,
  8029. const char* command, const char* message)
  8030. {
  8031. char name[NAME_LENGTH],text[80];
  8032. if(!mail_server_enable)
  8033. return 0;
  8034. nullpo_retr(-1, sd);
  8035. if (!message || !*message) {
  8036. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8037. return 0;
  8038. }
  8039. if ((sscanf(message, "\"%23[^\"]\" %79[^\n]", name, text) < 2) &&
  8040. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  8041. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8042. return 0;
  8043. }
  8044. if(strlen(command)==17)
  8045. mail_send(sd,name,text,1);
  8046. else
  8047. mail_send(sd,name,text,0);
  8048. return 0;
  8049. }
  8050. /*==========================================
  8051. * Refresh online command for SQL [Valaris]
  8052. * Will refresh and check online column of
  8053. * players and set correctly.
  8054. *------------------------------------------
  8055. */
  8056. int atcommand_refreshonline(
  8057. const int fd, struct map_session_data* sd,
  8058. const char* command, const char* message)
  8059. {
  8060. send_users_tochar(-1, gettick(), 0, 0);
  8061. return 0;
  8062. }
  8063. #endif /* end sql only */
  8064. /*==========================================
  8065. * Show Monster DB Info v 1.0
  8066. * originally by [Lupus] eAthena
  8067. *------------------------------------------
  8068. */
  8069. int atcommand_mobinfo(
  8070. const int fd, struct map_session_data* sd,
  8071. const char* command, const char* message)
  8072. {
  8073. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  8074. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  8075. unsigned char melement[11][8] = {"None", "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  8076. char atcmd_output2[200];
  8077. struct item_data *item_data;
  8078. struct mob_db *mob;
  8079. int mob_id;
  8080. int i, j;
  8081. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8082. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  8083. if (!message || !*message) {
  8084. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  8085. return -1;
  8086. }
  8087. // If monster identifier/name argument is a name
  8088. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  8089. mob_id = mobdb_checkid(atoi(message));
  8090. if (mob_id == 0) {
  8091. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  8092. return -1;
  8093. }
  8094. mob = mob_db(mob_id);
  8095. // stats
  8096. if (mob->mexp)
  8097. sprintf(atcmd_output, "MVP Monster: '%s'/'%s' (%d)", mob->name, mob->jname, mob_id);
  8098. else
  8099. sprintf(atcmd_output, "Monster: '%s'/'%s' (%d)", mob->name, mob->jname, mob_id);
  8100. clif_displaymessage(fd, atcmd_output);
  8101. sprintf(atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%d Job EXP:%d", mob->lv, mob->max_hp, mob->max_sp, mob->base_exp, mob->job_exp);
  8102. clif_displaymessage(fd, atcmd_output);
  8103. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d", mob->def, mob->mdef, mob->str, mob->agi, mob->vit, mob->int_, mob->dex, mob->luk);
  8104. clif_displaymessage(fd, atcmd_output);
  8105. if (mob->element < 20) {
  8106. //Element - None, Level 0
  8107. i = 0;
  8108. j = 0;
  8109. } else {
  8110. i = mob->element % 20 + 1;
  8111. j = mob->element / 20;
  8112. }
  8113. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)", mob->atk1, mob->atk2, mob->range, mob->range2 , mob->range3, msize[mob->size], mrace[mob->race], melement[i], j);
  8114. clif_displaymessage(fd, atcmd_output);
  8115. // drops
  8116. clif_displaymessage(fd, " Drops:");
  8117. strcpy(atcmd_output, " ");
  8118. j = 0;
  8119. for (i = 0; i < 10; i++) {
  8120. if (mob->dropitem[i].nameid <= 0 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  8121. continue;
  8122. if (mob->dropitem[i].p > 0) {
  8123. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->dropitem[i].p / 100);
  8124. strcat(atcmd_output, atcmd_output2);
  8125. if (++j % 3 == 0) {
  8126. clif_displaymessage(fd, atcmd_output);
  8127. strcpy(atcmd_output, " ");
  8128. }
  8129. }
  8130. }
  8131. if (j == 0)
  8132. clif_displaymessage(fd, "This monster has no drops.");
  8133. else if (j % 3 != 0)
  8134. clif_displaymessage(fd, atcmd_output);
  8135. // mvp
  8136. if (mob->mexp) {
  8137. sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  8138. clif_displaymessage(fd, atcmd_output);
  8139. strcpy(atcmd_output, " MVP Items:");
  8140. j = 0;
  8141. for (i = 0; i < 3; i++) {
  8142. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  8143. continue;
  8144. if (mob->mvpitem[i].p > 0) {
  8145. j++;
  8146. if (j == 1)
  8147. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8148. else
  8149. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8150. strcat(atcmd_output, atcmd_output2);
  8151. }
  8152. }
  8153. if (j == 0)
  8154. clif_displaymessage(fd, "This monster has no MVP prizes.");
  8155. else
  8156. clif_displaymessage(fd, atcmd_output);
  8157. }
  8158. return 0;
  8159. }
  8160. /*==========================================
  8161. * Show Items DB Info v 1.0
  8162. * originally by [Lupus] eAthena
  8163. *------------------------------------------
  8164. */
  8165. int atcommand_iteminfo(
  8166. const int fd, struct map_session_data* sd,
  8167. const char* command, const char* message)
  8168. {
  8169. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  8170. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  8171. struct item_data *item_data;
  8172. int item_id=0;
  8173. if (!message || !*message) {
  8174. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @iteminfo <item_name_or_ID>).");
  8175. return -1;
  8176. }
  8177. if ((item_data = itemdb_searchname(message)) != NULL ||
  8178. (item_data = itemdb_exists(atoi(message))) != NULL)
  8179. item_id = item_data->nameid;
  8180. if (item_id >= 500) {
  8181. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  8182. item_data->name,item_data->jname,item_data->slot,item_id,
  8183. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  8184. (item_data->script==NULL)? "None" : "With script"
  8185. );
  8186. clif_displaymessage(fd, atcmd_output);
  8187. sprintf(atcmd_output, "NPC Buy:%dz%s, Sell:%dz%s | Weight: %d ", item_data->value_buy, item_data->flag.value_notdc ? "(No Discount!)":"", item_data->value_sell, item_data->flag.value_notoc ? "(No Overcharge!)":"", item_data->weight );
  8188. clif_displaymessage(fd, atcmd_output);
  8189. if (item_data->maxchance == 10000)
  8190. strcpy(atcmd_output, " - Available in the shops only");
  8191. else if (item_data->maxchance)
  8192. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  8193. else
  8194. strcpy(atcmd_output, " - Monsters don't drop this item");
  8195. clif_displaymessage(fd, atcmd_output);
  8196. return 0;
  8197. }
  8198. clif_displaymessage(fd, "Item not found.");
  8199. return -1;
  8200. }
  8201. /*==========================================
  8202. * @adopt by [Veider]
  8203. *
  8204. * adopt a novice
  8205. *------------------------------------------
  8206. */
  8207. int
  8208. atcommand_adopt(const int fd, struct map_session_data* sd,
  8209. const char* command, const char* message)
  8210. {
  8211. struct map_session_data *pl_sd1 = NULL;
  8212. struct map_session_data *pl_sd2 = NULL;
  8213. struct map_session_data *pl_sd3 = NULL;
  8214. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  8215. nullpo_retr(-1, sd);
  8216. if (!message || !*message)
  8217. return -1;
  8218. if (sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) != 3) {
  8219. clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
  8220. return -1;
  8221. }
  8222. if (battle_config.etc_log)
  8223. printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  8224. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  8225. sprintf(player2, "Cannot find player %s online", player1);
  8226. clif_displaymessage(fd, player2);
  8227. return -1;
  8228. }
  8229. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  8230. sprintf(player1, "Cannot find player %s online", player2);
  8231. clif_displaymessage(fd, player1);
  8232. return -1;
  8233. }
  8234. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  8235. sprintf(player1, "Cannot find player %s online", player3);
  8236. clif_displaymessage(fd, player1);
  8237. return -1;
  8238. }
  8239. if((pl_sd1->status.base_level < 70) || (pl_sd2->status.base_level < 70)){
  8240. clif_displaymessage(fd, "They are too young to be parents!");
  8241. return -1;
  8242. }
  8243. if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
  8244. clif_displaymessage(fd, "They are family.. wish them luck");
  8245. return 0;
  8246. }
  8247. else
  8248. return -1;
  8249. }
  8250. int atcommand_version(
  8251. const int fd, struct map_session_data* sd,
  8252. const char* command, const char* message)
  8253. {
  8254. const char * revision;
  8255. if ((revision = get_svn_revision()) != 0) {
  8256. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  8257. clif_displaymessage(fd,atcmd_output);
  8258. } else
  8259. clif_displaymessage(fd,"Cannot determine SVN revision");
  8260. return 0;
  8261. }
  8262. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  8263. {
  8264. int time, id;
  8265. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  8266. if (pl_sd == NULL)
  8267. return 0;
  8268. id = va_arg(ap, int);
  8269. time = va_arg(ap, int);
  8270. if (id != bl->id && !pc_isGM(pl_sd)) {
  8271. pl_sd->status.manner -= time;
  8272. if (pl_sd->status.manner < 0)
  8273. status_change_start(&pl_sd->bl,SC_NOCHAT,100,0,0,0,0,0,0);
  8274. }
  8275. return 0;
  8276. }
  8277. /*==========================================
  8278. * @mutearea by MouseJstr
  8279. *------------------------------------------
  8280. */
  8281. int atcommand_mutearea(
  8282. const int fd, struct map_session_data* sd,
  8283. const char* command, const char* message)
  8284. {
  8285. int time;
  8286. nullpo_retr(0, sd);
  8287. if(!battle_config.muting_players) {
  8288. clif_displaymessage(fd, "Please enable the muting system before using it.");
  8289. return 0;
  8290. }
  8291. time = atoi(message);
  8292. if (time <= 0)
  8293. time = 15; // 15 minutes default
  8294. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  8295. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  8296. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  8297. return 0;
  8298. }
  8299. static int atcommand_shuffle_sub(struct block_list *bl,va_list ap)
  8300. {
  8301. struct map_session_data *pl_sd = (struct map_session_data *) bl;
  8302. if (bl == NULL)
  8303. return 0;
  8304. if (!pc_isGM(pl_sd))
  8305. pc_setpos(pl_sd, pl_sd->mapindex, rand() % 399 + 1, rand() % 399 + 1, 3);
  8306. return 0;
  8307. }
  8308. /*==========================================
  8309. * @shuffle by MouseJstr
  8310. *------------------------------------------
  8311. */
  8312. int atcommand_shuffle(
  8313. const int fd, struct map_session_data* sd,
  8314. const char* command, const char* message)
  8315. {
  8316. nullpo_retr(0, sd);
  8317. if (strcmp(message, "area")== 0) {
  8318. map_foreachinarea(atcommand_shuffle_sub,sd->bl.m,
  8319. sd->bl.x-AREA_SIZE,sd->bl.y-AREA_SIZE,
  8320. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC);
  8321. } else if (strcmp(message, "map")== 0) {
  8322. map_foreachinmap(atcommand_shuffle_sub,sd->bl.m, BL_PC);
  8323. } else if (strcmp(message, "world") == 0) {
  8324. struct map_session_data **pl_allsd;
  8325. int i, users;
  8326. pl_allsd = map_getallusers(&users);
  8327. for (i = 0; i < users; i++)
  8328. atcommand_shuffle_sub(&pl_allsd[i]->bl, 0);
  8329. } else
  8330. clif_displaymessage(fd, "options are area, map, or world");
  8331. return 0;
  8332. }
  8333. int atcommand_rates(
  8334. const int fd, struct map_session_data* sd,
  8335. const char* command, const char* message)
  8336. {
  8337. char buf[255];
  8338. nullpo_retr(0, sd);
  8339. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  8340. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  8341. clif_displaymessage(fd, buf);
  8342. return 0;
  8343. }
  8344. /*==========================================
  8345. * @me by lordalfa
  8346. * => Displays the OUTPUT string on top of
  8347. * the Visible players Heads.
  8348. *------------------------------------------
  8349. */
  8350. int atcommand_me(
  8351. const int fd, struct map_session_data* sd,
  8352. const char* command, const char* message)
  8353. {
  8354. char tempmes[200];
  8355. nullpo_retr(-1, sd);
  8356. memset(tempmes, '\0', sizeof(tempmes));
  8357. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8358. if (!message || !*message) {
  8359. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  8360. return -1;
  8361. }
  8362. sscanf(message, "%199[^\n]", tempmes);
  8363. sprintf(atcmd_output, "* %s %s *", sd->status.name, tempmes);
  8364. clif_disp_overhead(sd, atcmd_output);
  8365. return 0;
  8366. }
  8367. /*==========================================
  8368. * @size
  8369. * => Resize your character sprite. [Valaris]
  8370. *------------------------------------------
  8371. */
  8372. int atcommand_size(
  8373. const int fd, struct map_session_data* sd,
  8374. const char* command, const char* message)
  8375. {
  8376. int size=0;
  8377. nullpo_retr(-1, sd);
  8378. if (!message || !*message)
  8379. return -1;
  8380. if (sscanf(message,"%d", &size) < 1)
  8381. return -1;
  8382. if(sd->state.size) {
  8383. sd->state.size=0;
  8384. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8385. }
  8386. if(size==1) {
  8387. sd->state.size=1;
  8388. clif_specialeffect(&sd->bl,420,0);
  8389. } else if(size==2) {
  8390. sd->state.size=2;
  8391. clif_specialeffect(&sd->bl,422,0);
  8392. }
  8393. return 0;
  8394. }
  8395. /*==========================================
  8396. * @monsterignore
  8397. * => Makes monsters ignore you. [Valaris]
  8398. *------------------------------------------
  8399. */
  8400. int atcommand_monsterignore(
  8401. const int fd, struct map_session_data* sd,
  8402. const char* command, const char* message)
  8403. {
  8404. nullpo_retr(-1, sd);
  8405. if (!sd->state.monster_ignore) {
  8406. sd->state.monster_ignore = 1;
  8407. clif_displaymessage(sd->fd, "Monsters will now ignore you.");
  8408. } else {
  8409. sd->state.monster_ignore = 0;
  8410. clif_displaymessage(sd->fd, "Monsters are no longer ignoring you.");
  8411. }
  8412. return 0;
  8413. }
  8414. /*==========================================
  8415. * @fakename
  8416. * => Gives your character a fake name. [Valaris]
  8417. *------------------------------------------
  8418. */
  8419. int atcommand_fakename(
  8420. const int fd, struct map_session_data* sd,
  8421. const char* command, const char* message)
  8422. {
  8423. char name[NAME_LENGTH];
  8424. nullpo_retr(-1, sd);
  8425. if((!message || !*message) && strlen(sd->fakename) > 1) {
  8426. sd->fakename[0]='\0';
  8427. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8428. clif_displaymessage(sd->fd,"Returned to real name.");
  8429. return 0;
  8430. }
  8431. if (!message || !*message) {
  8432. clif_displaymessage(sd->fd,"You must enter a name.");
  8433. return 0;
  8434. }
  8435. if (sscanf(message, "%23[^\n]", name) < 1) {
  8436. return 0;
  8437. }
  8438. if(strlen(name) < 2) {
  8439. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  8440. return 0;
  8441. }
  8442. memcpy(sd->fakename,name,NAME_LENGTH-1);
  8443. clif_charnameack(0, &sd->bl);
  8444. clif_displaymessage(sd->fd,"Fake name enabled.");
  8445. return 0;
  8446. }
  8447. /*==========================================
  8448. * @mapflag [flagap name] [1|0|on|off] [map name] by Lupus
  8449. * => Shows information about the map flags [map name]
  8450. * Also set flags
  8451. *------------------------------------------
  8452. */
  8453. int atcommand_mapflag(
  8454. const int fd, struct map_session_data* sd,
  8455. const char* command, const char* message)
  8456. {
  8457. // WIP
  8458. return 0;
  8459. }
  8460. /*===================================
  8461. * Remove some messages
  8462. *-----------------------------------
  8463. */
  8464. int atcommand_showexp(
  8465. const int fd, struct map_session_data* sd,
  8466. const char* command, const char* message)
  8467. {
  8468. if (sd->state.showexp) {
  8469. sd->state.showexp = 0;
  8470. clif_displaymessage(fd, "Gained exp will not be shown.");
  8471. return 0;
  8472. }
  8473. sd->state.showexp = 1;
  8474. clif_displaymessage(fd, "Gained exp is now shown");
  8475. return 0;
  8476. }
  8477. int atcommand_showzeny(
  8478. const int fd, struct map_session_data* sd,
  8479. const char* command, const char* message)
  8480. {
  8481. if (sd->state.showzeny) {
  8482. sd->state.showzeny = 0;
  8483. clif_displaymessage(fd, "Gained zeny will not be shown.");
  8484. return 0;
  8485. }
  8486. sd->state.showzeny = 1;
  8487. clif_displaymessage(fd, "Gained zeny is now shown");
  8488. return 0;
  8489. }
  8490. int atcommand_showdelay(
  8491. const int fd, struct map_session_data* sd,
  8492. const char* command, const char* message)
  8493. {
  8494. if (sd->state.showdelay) {
  8495. sd->state.showdelay = 0;
  8496. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  8497. return 0;
  8498. }
  8499. sd->state.showdelay = 1;
  8500. clif_displaymessage(fd, "Skill delay failures are shown now.");
  8501. return 0;
  8502. }
  8503. /*==========================================
  8504. * Duel organizing functions [LuzZza]
  8505. *
  8506. * @duel [limit|nick] - create a duel
  8507. * @invite <nick> - invite player
  8508. * @accept - accept invitation
  8509. * @reject - reject invitation
  8510. * @leave - leave duel
  8511. *------------------------------------------
  8512. */
  8513. int atcommand_invite(
  8514. const int fd, struct map_session_data* sd,
  8515. const char* command, const char* message)
  8516. {
  8517. unsigned int did = sd->duel_group;
  8518. struct map_session_data *target_sd = map_nick2sd((char *)message);
  8519. if(did <= 0) {
  8520. // "Duel: @invite without @duel."
  8521. clif_displaymessage(fd, msg_txt(350));
  8522. return 0;
  8523. }
  8524. if(duel_list[did].max_players_limit > 0 &&
  8525. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  8526. // "Duel: Limit of players is reached."
  8527. clif_displaymessage(fd, msg_txt(351));
  8528. return 0;
  8529. }
  8530. if(target_sd == NULL) {
  8531. // "Duel: Player not found."
  8532. clif_displaymessage(fd, msg_txt(352));
  8533. return 0;
  8534. }
  8535. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8536. // "Duel: Player already in duel."
  8537. clif_displaymessage(fd, msg_txt(353));
  8538. return 0;
  8539. }
  8540. duel_invite(did, sd, target_sd);
  8541. // "Duel: Invitation has been sent."
  8542. clif_displaymessage(fd, msg_txt(354));
  8543. return 0;
  8544. }
  8545. int atcommand_duel(
  8546. const int fd, struct map_session_data* sd,
  8547. const char* command, const char* message)
  8548. {
  8549. char output[256];
  8550. unsigned int maxpl=0, newduel;
  8551. struct map_session_data *target_sd;
  8552. /* // Commnted because it can be disabled in at-comms conf.
  8553. if(!battle_config.duel_enable) {
  8554. clif_displaymessage(fd, "Duel: duel is disable.");
  8555. return 0;
  8556. }
  8557. */
  8558. if(sd->duel_group > 0) {
  8559. duel_showinfo(sd->duel_group, sd);
  8560. return 0;
  8561. }
  8562. if(sd->duel_invite > 0) {
  8563. // "Duel: @duel without @reject."
  8564. clif_displaymessage(fd, msg_txt(355));
  8565. return 0;
  8566. }
  8567. if(!duel_checktime(sd)) {
  8568. // "Duel: You can take part in duel only one time per %d minutes."
  8569. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8570. clif_displaymessage(fd, output);
  8571. return 0;
  8572. }
  8573. if(strlen(message) > 0) {
  8574. if(sscanf(message, "%d", &maxpl) >= 1) {
  8575. if(maxpl < 2 || maxpl > 65535) {
  8576. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  8577. return 0;
  8578. }
  8579. duel_create(sd, maxpl);
  8580. } else {
  8581. target_sd = map_nick2sd((char *)message);
  8582. if(target_sd != NULL) {
  8583. if((newduel = duel_create(sd, 2)) != -1) {
  8584. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8585. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  8586. return 0;
  8587. }
  8588. duel_invite(newduel, sd, target_sd);
  8589. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  8590. }
  8591. } else {
  8592. // "Duel: Player not found."
  8593. clif_displaymessage(fd, msg_txt(352));
  8594. return 0;
  8595. }
  8596. }
  8597. } else
  8598. duel_create(sd, 0);
  8599. return 0;
  8600. }
  8601. int atcommand_leave(
  8602. const int fd, struct map_session_data* sd,
  8603. const char* command, const char* message)
  8604. {
  8605. if(sd->duel_group <= 0) {
  8606. // "Duel: @leave without @duel."
  8607. clif_displaymessage(fd, msg_txt(358));
  8608. return 0;
  8609. }
  8610. duel_leave(sd->duel_group, sd);
  8611. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  8612. return 0;
  8613. }
  8614. int atcommand_accept(
  8615. const int fd, struct map_session_data* sd,
  8616. const char* command, const char* message)
  8617. {
  8618. char output[256];
  8619. if(!duel_checktime(sd)) {
  8620. // "Duel: You can take part in duel only one time per %d minutes."
  8621. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8622. clif_displaymessage(fd, output);
  8623. return 0;
  8624. }
  8625. if(sd->duel_invite <= 0) {
  8626. // "Duel: @accept without invititation."
  8627. clif_displaymessage(fd, msg_txt(360));
  8628. return 0;
  8629. }
  8630. duel_accept(sd->duel_invite, sd);
  8631. // "Duel: Invitation has been accepted."
  8632. clif_displaymessage(fd, msg_txt(361));
  8633. return 0;
  8634. }
  8635. int atcommand_reject(
  8636. const int fd, struct map_session_data* sd,
  8637. const char* command, const char* message)
  8638. {
  8639. if(sd->duel_invite <= 0) {
  8640. // "Duel: @reject without invititation."
  8641. clif_displaymessage(fd, msg_txt(362));
  8642. return 0;
  8643. }
  8644. duel_reject(sd->duel_invite, sd);
  8645. // "Duel: Invitation has been rejected."
  8646. clif_displaymessage(fd, msg_txt(363));
  8647. return 0;
  8648. }
  8649. /*===================================
  8650. * Away message (@away, @aw) [LuzZza]
  8651. *-----------------------------------
  8652. */
  8653. int atcommand_away(
  8654. const int fd, struct map_session_data* sd,
  8655. const char* command, const char* message)
  8656. {
  8657. if(strlen(message) > 0) {
  8658. if(strlen(message) > 128)
  8659. return -1;
  8660. strcpy(sd->away_message, message);
  8661. //"Away automessage has been activated."
  8662. clif_displaymessage(fd, msg_txt(546));
  8663. } else {
  8664. if(strlen(sd->away_message) > 0) {
  8665. sd->away_message[0] = 0;
  8666. //"Away automessage has been disabled."
  8667. clif_displaymessage(fd, msg_txt(547));
  8668. return 0;
  8669. }
  8670. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  8671. clif_displaymessage(fd, msg_txt(548));
  8672. }
  8673. return 0;
  8674. }
  8675. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  8676. int atcommand_clone(
  8677. const int fd, struct map_session_data* sd,
  8678. const char* command, const char* message)
  8679. {
  8680. int x=0,y=0,flag=0,master=0,i=0;
  8681. struct map_session_data *pl_sd=NULL;
  8682. if (!message || !*message) {
  8683. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  8684. return 0;
  8685. }
  8686. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  8687. clif_displaymessage(fd, "Player not found.");
  8688. return 0;
  8689. }
  8690. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  8691. clif_displaymessage(fd, "Cannot clone a player of higher GM level than yourself.");
  8692. return 0;
  8693. }
  8694. if (strcmpi(command, "@clone") == 0)
  8695. flag = 1;
  8696. else if (strcmpi(command, "@slaveclone") == 0) {
  8697. flag = 2;
  8698. master = sd->bl.id;
  8699. if (battle_config.atc_slave_clone_limit
  8700. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  8701. clif_displaymessage(fd, "You've reached your slave clones limit.");
  8702. return 0;
  8703. }
  8704. }
  8705. do {
  8706. x = sd->bl.x + (rand() % 10 - 5);
  8707. y = sd->bl.y + (rand() % 10 - 5);
  8708. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  8709. if (i >= 10) {
  8710. x = sd->bl.x;
  8711. y = sd->bl.y;
  8712. }
  8713. if((x = mob_clone_spawn(pl_sd, (char*)mapindex_id2name(sd->mapindex), x, y, "", master, 0, flag?1:0, 0)) > 0) {
  8714. clif_displaymessage(fd, msg_txt(126+flag*2));
  8715. return 0;
  8716. }
  8717. clif_displaymessage(fd, msg_txt(127+flag*2));
  8718. return 0;
  8719. }
  8720. /*===================================
  8721. * Main chat [LuzZza]
  8722. * Usage: @main <on|off|message>
  8723. *-----------------------------------
  8724. */
  8725. int atcommand_main(
  8726. const int fd, struct map_session_data* sd,
  8727. const char* command, const char* message)
  8728. {
  8729. if(strlen(message) > 0) {
  8730. if(strlen(message) > 128)
  8731. return -1;
  8732. if(strcmpi(message, "on") == 0) {
  8733. if(!sd->state.mainchat) {
  8734. sd->state.mainchat = 1;
  8735. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8736. } else {
  8737. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  8738. }
  8739. } else if(strcmpi(message, "off") == 0) {
  8740. if(sd->state.mainchat) {
  8741. sd->state.mainchat = 0;
  8742. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  8743. } else {
  8744. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  8745. }
  8746. } else {
  8747. if(!sd->state.mainchat) {
  8748. sd->state.mainchat = 1;
  8749. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8750. }
  8751. if (sd->sc.data[SC_NOCHAT].timer != -1) {
  8752. clif_displaymessage(fd, msg_txt(387));
  8753. return -1;
  8754. }
  8755. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  8756. // I use 0xFE000000 color for signalizing that this message is
  8757. // main chat message. 0xFE000000 is invalid color, same using
  8758. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  8759. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  8760. }
  8761. } else {
  8762. if(sd->state.mainchat)
  8763. // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  8764. clif_displaymessage(fd, msg_txt(384));
  8765. else
  8766. // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  8767. clif_displaymessage(fd, msg_txt(385));
  8768. }
  8769. return 0;
  8770. }
  8771. void do_init_atcommand() {
  8772. users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
  8773. duel_count = 0;
  8774. memset(&duel_list[0], 0, sizeof(duel_list));
  8775. return;
  8776. }
  8777. void do_final_atcommand() {
  8778. users_db->destroy(users_db,NULL);
  8779. }