| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389 |
- ////////////////////////////////////////////////////////////////////////////////
- /// Standard Callbacks /////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- public OnFilterScriptInit()
- {
- print("----------------------------------------------");
- print("----Texture Studio By [uL]Pottus and Crayder--");
- print("------------------------------------Loaded----");
- SystemDB = db_open_persistent("tstudio/system.db");
- ThemeDataDB = db_open_persistent("tstudio/themedata.db");
-
- sqlite_ThemeSetup();
- sqlite_LoadBindString();
-
- ResetSettings();
- Streamer_ToggleErrorCallback(1); // Enable Streammer Error Callback
-
- #if defined AddSimpleModel // DL-SUPPORT
- Streamer_SetVisibleItems(STREAMER_TYPE_OBJECT, 1500);
- #endif
-
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("----------------------------------------------");
- print("----Texture Studio By [uL]Pottus and Crayder--");
- print("------------------------------------Unloaded--");
- // Delete all map objects
- DeleteMapObjects(false);
- // Clear all removed buildings
- ClearRemoveBuildings();
- foreach(new i : Player)
- {
- ClearCopyBuffer(i);
- }
-
- // Always close map
- if(MapOpen)
- {
- db_free_persistent(EditMap);
- sqlite_UpdateSettings();
- }
- db_free_persistent(SystemDB);
- db_free_persistent(ThemeDataDB);
- foreach(new i : Player)
- {
- CancelSelectTextDraw(i);
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- RemoveAllBuildings(playerid);
-
- SendClientMessage(playerid, STEALTH_GREEN, "Welcome to Texture Studio!");
- SendClientMessage(playerid, STEALTH_GREEN, sprintf("There are currently %i commands registered, check \"/thelp\" to see them!", Command_GetPlayerCommandCount(playerid)));
-
- new bool:found, bool:warn, string[36];
- for (new i, j = Command_GetPlayerCommandCount(playerid); i < j; i++)
- {
- format(string, 36, "%s", Command_GetNext(i, playerid));
- //foreach(new c : Command()) {
-
- for(new k; k < sizeof(Commands); k++) {
- if(!strcmp(Commands[k][cName], string)) {
- found = true;
- break;
- }
- }
- if(!found) {
- printf(" /thelp missing command: %s", string);
- warn = true;
- }
- else
- found = false;
- }
- if(warn)
- printf("Warning: There's something missing or extra in /thelp for player %i.\n (Report to Crayder on SA-MP Discord if this message ever shows)", playerid);
-
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- CurrObject[playerid] = -1;
- EditingMode[playerid] = false;
- TextDrawOpen[playerid] = false;
- PivotPointOn[playerid] = false;
- SetEditMode(playerid, EDIT_MODE_NONE);
- SetCurrTextDraw(playerid, TEXTDRAW_NONE);
- ClearCopyBuffer(playerid);
- return 1;
- }
- public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ) return 0;
- SetCurrObject(playerid, index)
- {
- if(CanSelectObject(playerid, index))
- {
- CurrObject[playerid] = index;
- CallLocalFunction("OnPlayerObjectSelectChange", "ii", playerid, index);
- return 1;
- }
- return 0;
- }
- OnPlayerKeyStateChangeOEdit(playerid,newkeys,oldkeys)
- {
- #pragma unused oldkeys
- if(GetEditMode(playerid) == EDIT_MODE_OBJECT)
- {
- // Clone object
- if(newkeys & KEY_WALK)
- {
- Edit_SetObjectPos(CurrObject[playerid], CurrEditPos[playerid][0], CurrEditPos[playerid][1], CurrEditPos[playerid][2], CurrEditPos[playerid][3], CurrEditPos[playerid][4], CurrEditPos[playerid][5], true);
- SetCurrObject(playerid, CloneObject(CurrObject[playerid]));
- EditDynamicObject(playerid, ObjectData[CurrObject[playerid]][oID]);
- SendClientMessage(playerid, STEALTH_GREEN, "Object has been cloned");
- }
- // Update object position
- else if(newkeys & KEY_SECONDARY_ATTACK)
- {
- Edit_SetObjectPos(CurrObject[playerid], CurrEditPos[playerid][0], CurrEditPos[playerid][1], CurrEditPos[playerid][2], CurrEditPos[playerid][3], CurrEditPos[playerid][4], CurrEditPos[playerid][5], true);
- SendClientMessage(playerid, STEALTH_GREEN, "Object position updated and saved");
- }
- }
- return 0;
- }
- // player finished editing an object; Fix For new streamer version
- public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ) return 0;
- // player finished editing an object
- public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
- {
- //printf("%i, %i, %i, %i", playerid, objectid, response, GetEditMode(playerid));
- switch(GetEditMode(playerid))
- {
- case EDIT_MODE_OBJECT:
- {
- // Player finished editing an object
- if(response == EDIT_RESPONSE_FINAL)
- {
- Edit_SetObjectPos(CurrObject[playerid], x, y, z, rx, ry, rz, true);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Object edit has been saved");
- EditingMode[playerid] = false;
- SetEditMode(playerid, EDIT_MODE_NONE);
- }
- else if(response == EDIT_RESPONSE_UPDATE)
- {
- CurrEditPos[playerid][0] = x;
- CurrEditPos[playerid][1] = y;
- CurrEditPos[playerid][2] = z;
- CurrEditPos[playerid][3] = rx;
- CurrEditPos[playerid][4] = ry;
- CurrEditPos[playerid][5] = rz;
- }
- // Cancel editing
- else if(response == EDIT_RESPONSE_CANCEL)
- {
- SetDynamicObjectPos(ObjectData[CurrObject[playerid]][oID], ObjectData[CurrObject[playerid]][oX], ObjectData[CurrObject[playerid]][oY], ObjectData[CurrObject[playerid]][oZ]);
- SetDynamicObjectRot(ObjectData[CurrObject[playerid]][oID], ObjectData[CurrObject[playerid]][oRX], ObjectData[CurrObject[playerid]][oRY], ObjectData[CurrObject[playerid]][oRZ]);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "Cancelled object editing");
- EditingMode[playerid] = false;
- SetEditMode(playerid, EDIT_MODE_NONE);
- }
- }
- case EDIT_MODE_PIVOT:
- {
- if(response == EDIT_RESPONSE_FINAL)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Pivot has been saved");
- DestroyDynamicObject(PivotObject[playerid]);
- PivotPoint[playerid][xPos] = x;
- PivotPoint[playerid][yPos] = y;
- PivotPoint[playerid][zPos] = z;
- EditingMode[playerid] = false;
- SetEditMode(playerid, EDIT_MODE_NONE);
- }
- else if(response == EDIT_RESPONSE_CANCEL)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "Cancelled Pivot editing");
- DestroyDynamicObject(PivotObject[playerid]);
- EditingMode[playerid] = false;
- SetEditMode(playerid, EDIT_MODE_NONE);
- }
- }
- case EDIT_MODE_OBJECTGROUP: OnPlayerEditDOGroup(playerid, objectid, response, x, y, z, rx, ry, rz);
- case EDIT_MODE_OBM: OnPlayerEditDOOBM(playerid, objectid, response, x, y, z, rx, ry, rz);
- case EDIT_MODE_VOBJECT: OnPlayerEditVObject(playerid, objectid, response, x, y, z, rx, ry, rz);
- }
- #if defined MA_OnPlayerEditDynamicObject
- MA_OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz);
- #endif
- return 0;
- }
- #if defined _ALS_OnPlayerEditDynamicObject
- #undef OnPlayerEditDynamicObject
- #else
- #define _ALS_OnPlayerEditDynamicObject
- #endif
- #define OnPlayerEditDynamicObject MA_OnPlayerEditDynamicObject
- #if defined MA_OnPlayerEditDynamicObject
- forward MA_OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz);
- #endif
- // Player clicked a dynamic object; Fix For new streamer version
- public OnPlayerSelectObject(playerid, type, objectid, modelid, Float:fX, Float:fY, Float:fZ) return 0;
- // Player clicked a dynamic object
- public OnPlayerSelectDynamicObject(playerid, objectid, modelid, Float:x, Float:y, Float:z)
- {
- switch(GetEditMode(playerid))
- {
- case EDIT_MODE_SELECTION:
- {
- new Keys,ud,lr,index;
- GetPlayerKeys(playerid,Keys,ud,lr);
- // Find edit object
- foreach(new i : Objects)
- {
- // Object found
- if(ObjectData[i][oID] == objectid)
- {
- index = i;
- break;
- }
- }
- if(Keys & KEY_CTRL_BACK || (InFlyMode(playerid) && (Keys & KEY_SECONDARY_ATTACK)))
- //if(Keys & KEY_CTRL_BACK)
- {
- CopyCopyBuffer(playerid, index);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Copied object textures/color/text to buffer");
- }
- else if(Keys & KEY_WALK)
- {
- PasteCopyBuffer(playerid, index);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Pasted your copy buffer to object");
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- if(SetCurrObject(playerid, index)) {
- new line[128];
- format(line, sizeof(line), "You have selected object index %i for editing", index);
- SendClientMessage(playerid, STEALTH_GREEN, line);
- }
- else
- SendClientMessage(playerid, STEALTH_YELLOW, "You can not select objects in this object's group");
- }
- }
- }
- return 0;
- }
- // Streamer Error Log
- public Streamer_OnPluginError(const error[])
- {
- printf("Streamer Plugin Error: %s", error);
- }
- // Player clicked textdraw
- public OnPlayerClickTextDraw(playerid, Text:clickedid)
- {
- // Text editing mode
- if(GetCurrTextDraw(playerid) == TEXTDRAW_TEXTEDIT) if(ClickTextDrawEditText(playerid, Text:clickedid)) return 1;
- if(GetCurrTextDraw(playerid) == TEXTDRAW_MATERIALS) if(ClickTextDrawEditMat(playerid, Text:clickedid)) return 1;
- if(GetCurrTextDraw(playerid) == TEXTDRAW_LISTSEL) if(ClickTextDrawListSel(playerid, Text:clickedid)) return 1;
- if(GetCurrTextDraw(playerid) == TEXTDRAW_OSEARCH) if(ClickTextDrawOSearch(playerid, Text:clickedid)) return 1;
- #if defined MA_OnPlayerClickTextDraw
- return MA_OnPlayerClickTextDraw(playerid, Text:clickedid);
- #endif
- return 0;
- }
- #if defined _ALS_OnPlayerClickTextDraw
- #undef OnPlayerClickTextDraw
- #else
- #define _ALS_OnPlayerClickTextDraw
- #endif
- #define OnPlayerClickTextDraw MA_OnPlayerClickTextDraw
- #if defined MA_OnPlayerClickTextDraw
- forward MA_OnPlayerClickTextDraw(playerid, Text:clickedid);
- #endif
- // Player clicked player textdraw
- public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
- {
- // Text editing mode
- if(GetCurrTextDraw(playerid) == TEXTDRAW_TEXTEDIT) if(ClickPlayerTextDrawEditText(playerid, PlayerText:playertextid)) return 1;
- if(GetCurrTextDraw(playerid) == TEXTDRAW_MATERIALS) if(ClickPlayerTextDrawEditMat(playerid, PlayerText:playertextid)) return 1;
- if(GetCurrTextDraw(playerid) == TEXTDRAW_LISTSEL) if(ClickPlayerTextListSel(playerid, PlayerText:playertextid)) return 1;
- if(GetCurrTextDraw(playerid) == TEXTDRAW_OSEARCH) if(ClickPlayerTextDrawOSearch(playerid, PlayerText:playertextid)) return 1;
- #if defined MA_OnPlayerClickPlayerTextDraw
- return MA_OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid);
- #endif
- return 0;
- }
- #if defined _ALS_OnPlayerClickPlayerTD
- #undef OnPlayerClickPlayerTextDraw
- #else
- #define _ALS_OnPlayerClickPlayerTD
- #endif
- #define OnPlayerClickPlayerTextDraw MA_OnPlayerClickPlayerTextDraw
- #if defined MA_OnPlayerClickPlayerTextDraw
- forward MA_OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid);
- #endif
- public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
- {
- if(OnPlayerKeyStateChangeOEdit(playerid,newkeys,oldkeys)) return 1;
- if(OnPlayerKeyStateChange3DMenu(playerid,newkeys,oldkeys)) return 1;
- if(OnPlayerKeyStateGroupChange(playerid, newkeys, oldkeys)) return 1;
- if(OnPlayerKeyStateMenuChange(playerid, newkeys, oldkeys)) return 1;
- if(OnPlayerKeyStateChangeTex(playerid,newkeys,oldkeys)) return 1;
- if(OnPlayerKeyStateChangeLSel(playerid,newkeys,oldkeys)) return 1;
- if(OnPlayerKeyStateChangeCMD(playerid,newkeys,oldkeys)) return 1;
- return 1;
- }
- ////////////////////////////////////////////////////////////////////////////////
- /// Standard Callbacks End//////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- /// Sqlite query functions /////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- // Load query stmt
- static DBStatement:loadstmt;
- // Loads map objects from a data base
- sqlite_LoadMapObjects()
- {
- new tmpobject[OBJECTINFO];
- new currindex;
- loadstmt = db_prepare(EditMap, "SELECT * FROM `Objects`");
- // Bind our results
- stmt_bind_result_field(loadstmt, 0, DB::TYPE_INT, currindex);
- stmt_bind_result_field(loadstmt, 1, DB::TYPE_INT, tmpobject[oModel]);
- stmt_bind_result_field(loadstmt, 2, DB::TYPE_FLOAT, tmpobject[oX]);
- stmt_bind_result_field(loadstmt, 3, DB::TYPE_FLOAT, tmpobject[oY]);
- stmt_bind_result_field(loadstmt, 4, DB::TYPE_FLOAT, tmpobject[oZ]);
- stmt_bind_result_field(loadstmt, 5, DB::TYPE_FLOAT, tmpobject[oRX]);
- stmt_bind_result_field(loadstmt, 6, DB::TYPE_FLOAT, tmpobject[oRY]);
- stmt_bind_result_field(loadstmt, 7, DB::TYPE_FLOAT, tmpobject[oRZ]);
- stmt_bind_result_field(loadstmt, 8, DB::TYPE_ARRAY, tmpobject[oTexIndex], MAX_MATERIALS);
- stmt_bind_result_field(loadstmt, 9, DB::TYPE_ARRAY, tmpobject[oColorIndex], MAX_MATERIALS);
- stmt_bind_result_field(loadstmt, 10, DB::TYPE_INT, tmpobject[ousetext]);
- stmt_bind_result_field(loadstmt, 11, DB::TYPE_INT, tmpobject[oFontFace]);
- stmt_bind_result_field(loadstmt, 12, DB::TYPE_INT, tmpobject[oFontSize]);
- stmt_bind_result_field(loadstmt, 13, DB::TYPE_INT, tmpobject[oFontBold]);
- stmt_bind_result_field(loadstmt, 14, DB::TYPE_INT, tmpobject[oFontColor]);
- stmt_bind_result_field(loadstmt, 15, DB::TYPE_INT, tmpobject[oBackColor]);
- stmt_bind_result_field(loadstmt, 16, DB::TYPE_INT, tmpobject[oAlignment]);
- stmt_bind_result_field(loadstmt, 17, DB::TYPE_INT, tmpobject[oTextFontSize]);
- stmt_bind_result_field(loadstmt, 18, DB::TYPE_STRING, tmpobject[oObjectText], MAX_TEXT_LENGTH);
- stmt_bind_result_field(loadstmt, 19, DB::TYPE_INT, tmpobject[oGroup]);
- stmt_bind_result_field(loadstmt, 20, DB::TYPE_STRING, tmpobject[oNote], 64);
- stmt_bind_result_field(loadstmt, 21, DB::TYPE_FLOAT, tmpobject[oDD]);
- // Execute query
- if(stmt_execute(loadstmt))
- {
- new count;
- while(stmt_fetch_row(loadstmt))
- {
- // Load object into database at specified index (Don't save to sqlite database)
- AddDynamicObject(tmpobject[oModel], tmpobject[oX], tmpobject[oY], tmpobject[oZ], tmpobject[oRX], tmpobject[oRY], tmpobject[oRZ], currindex, false, .dd = tmpobject[oDD]);
- // Set textures and colors
- for(new i = 0; i < MAX_MATERIALS; i++)
- {
- ObjectData[currindex][oTexIndex][i] = tmpobject[oTexIndex][i];
- ObjectData[currindex][oColorIndex][i] = tmpobject[oColorIndex][i];
- }
- // Get all text settings
- ObjectData[currindex][ousetext] = tmpobject[ousetext];
- ObjectData[currindex][oFontFace] = tmpobject[oFontFace];
- ObjectData[currindex][oFontSize] = tmpobject[oFontSize];
- ObjectData[currindex][oFontBold] = tmpobject[oFontBold];
- ObjectData[currindex][oFontColor] = tmpobject[oFontColor];
- ObjectData[currindex][oBackColor] = tmpobject[oBackColor];
- ObjectData[currindex][oAlignment] = tmpobject[oAlignment];
- ObjectData[currindex][oTextFontSize] = tmpobject[oTextFontSize];
- ObjectData[currindex][oGroup] = tmpobject[oGroup];
- // Get any text string
- format(ObjectData[currindex][oObjectText], MAX_TEXT_LENGTH, "%s", tmpobject[oObjectText]);
- format(ObjectData[currindex][oNote], MAX_TEXT_LENGTH, "%s", tmpobject[oNote]);
- // We need to update textures and materials
- UpdateMaterial(currindex);
- // Update the object text
- UpdateObjectText(currindex);
- // Update 3d text
- UpdateObject3DText(currindex, true);
-
- count++;
- }
- stmt_close(loadstmt);
- return count;
- }
- stmt_close(loadstmt);
- return 0;
- }
- // Insert stmt statement
- new DBStatement:insertstmt;
- new InsertObjectString[512];
- // Sqlite query functions
- sqlite_InsertObject(index)
- {
- // Inserts a new index
- if(!InsertObjectString[0])
- {
- // Prepare query
- strimplode(" ",
- InsertObjectString,
- sizeof(InsertObjectString),
- "INSERT INTO `Objects`",
- "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
- );
- // Prepare data base for writing
- }
- insertstmt = db_prepare(EditMap, InsertObjectString);
- // Bind values
- // Bind our results
- stmt_bind_value(insertstmt, 0, DB::TYPE_INT, index);
- stmt_bind_value(insertstmt, 1, DB::TYPE_INT, ObjectData[index][oModel]);
- stmt_bind_value(insertstmt, 2, DB::TYPE_FLOAT, ObjectData[index][oX]);
- stmt_bind_value(insertstmt, 3, DB::TYPE_FLOAT, ObjectData[index][oY]);
- stmt_bind_value(insertstmt, 4, DB::TYPE_FLOAT, ObjectData[index][oZ]);
- stmt_bind_value(insertstmt, 5, DB::TYPE_FLOAT, ObjectData[index][oRX]);
- stmt_bind_value(insertstmt, 6, DB::TYPE_FLOAT, ObjectData[index][oRY]);
- stmt_bind_value(insertstmt, 7, DB::TYPE_FLOAT, ObjectData[index][oRZ]);
- stmt_bind_value(insertstmt, 8, DB::TYPE_ARRAY, ObjectData[index][oTexIndex], MAX_MATERIALS);
- stmt_bind_value(insertstmt, 9, DB::TYPE_ARRAY, ObjectData[index][oColorIndex], MAX_MATERIALS);
- stmt_bind_value(insertstmt, 10, DB::TYPE_INT, ObjectData[index][ousetext]);
- stmt_bind_value(insertstmt, 11, DB::TYPE_INT, ObjectData[index][oFontFace]);
- stmt_bind_value(insertstmt, 12, DB::TYPE_INT, ObjectData[index][oFontSize]);
- stmt_bind_value(insertstmt, 13, DB::TYPE_INT, ObjectData[index][oFontBold]);
- stmt_bind_value(insertstmt, 14, DB::TYPE_INT, ObjectData[index][oFontColor]);
- stmt_bind_value(insertstmt, 15, DB::TYPE_INT, ObjectData[index][oBackColor]);
- stmt_bind_value(insertstmt, 16, DB::TYPE_INT, ObjectData[index][oAlignment]);
- stmt_bind_value(insertstmt, 17, DB::TYPE_INT, ObjectData[index][oTextFontSize]);
- stmt_bind_value(insertstmt, 18, DB::TYPE_STRING, ObjectData[index][oObjectText], MAX_TEXT_LENGTH);
- stmt_bind_value(insertstmt, 19, DB::TYPE_INT, ObjectData[index][oGroup]);
- stmt_bind_value(insertstmt, 20, DB::TYPE_STRING, ObjectData[index][oNote]);
- stmt_bind_value(insertstmt, 21, DB::TYPE_FLOAT, ObjectData[index][oDD]);
- stmt_execute(insertstmt);
- stmt_close(insertstmt);
- }
- // Remove a object from the database
- sqlite_RemoveObject(index)
- {
- new Query[128];
- format(Query, sizeof(Query), "DELETE FROM `Objects` WHERE `IndexID` = '%i'", index);
- db_free_result(db_query(EditMap, Query));
- return 1;
- }
- sqlite_CreateNewMap()
- {
- sqlite_CreateMapDB();
- sqlite_CreateRBDB();
- sqlite_CreateVehicle();
- sqlite_CreateSettings();
- sqlite_InitSettings();
- }
- new NewMapString[512];
- sqlite_CreateMapDB()
- {
- if(!NewMapString[0])
- {
- strimplode(" ",
- NewMapString,
- sizeof(NewMapString),
- "CREATE TABLE IF NOT EXISTS `Objects`",
- "(IndexID INTEGER,",
- "ModelID INTEGER,",
- "xPos REAL,",
- "yPos REAL,",
- "zPos REAL,",
- "rxRot REAL,",
- "ryRot REAL,",
- "rzRot REAL,",
- "TextureIndex TEXT,",
- "ColorIndex TEXT,",
- "usetext INTEGER,",
- "FontFace INTEGER,",
- "FontSize INTEGER,",
- "FontBold INTEGER,",
- "FontColor INTEGER,",
- "BackColor INTEGER,",
- "Alignment INTEGER,",
- "TextFontSize INTEGER,",
- "ObjectText TEXT,",
- "GroupID INTEGER,",
- "Note TEXT,",
- "DrawDistance REAL DEFAULT 300.0);"
- );
- }
- db_exec(EditMap, NewMapString);
- }
- // Version 1.2 removebuilding import lines
- new NewRemoveString[512];
- sqlite_CreateRBDB()
- {
- if(!NewRemoveString[0])
- {
- strimplode(" ",
- NewRemoveString,
- sizeof(NewRemoveString),
- "CREATE TABLE IF NOT EXISTS `RemovedBuildings`",
- "(ModelID INTEGER,",
- "xPos REAL,",
- "yPos REAL,",
- "zPos REAL,",
- "Range REAL);"
- );
- }
- db_exec(EditMap, NewRemoveString);
- }
- new NewSettingsString[512];
- sqlite_CreateSettings()
- {
- if(!NewSettingsString[0])
- {
- strimplode(" ",
- NewSettingsString,
- sizeof(NewSettingsString),
- "CREATE TABLE IF NOT EXISTS `Settings`",
- "(Version INTEGER DEFAULT 0,",
- "LastTime INTEGER DEFAULT 0,",
- "Author TEXT DEFAULT 'Creator',",
- "SpawnX REAL DEFAULT 0.0,",
- "SpawnY REAL DEFAULT 0.0,",
- "SpawnZ REAL DEFAULT 0.0,",
- "Interior INTEGER DEFAULT -1,",
- "VirtualWorld INTEGER DEFAULT -1);"
- );
- }
- db_exec(EditMap, NewSettingsString);
- }
- new DBStatement:insertsettingstmt;
- new InitSettingsString[512];
- sqlite_InitSettings()
- {
- // Insert the initial values
- if(!InitSettingsString[0])
- {
- // Prepare query
- strimplode(" ",
- InitSettingsString,
- sizeof(InitSettingsString),
- "INSERT INTO `Settings`",
- "VALUES(?, ?, ?, ?, ?, ?, ?, ?)"
- );
- // Prepare data base for writing
- }
- insertsettingstmt = db_prepare(EditMap, InitSettingsString);
-
- // Bind our results
- stmt_bind_value(insertsettingstmt, 0, DB::TYPE_INT, MapSetting[mVersion]);
- stmt_bind_value(insertsettingstmt, 1, DB::TYPE_INT, MapSetting[mLastEdit]);
- stmt_bind_value(insertsettingstmt, 2, DB::TYPE_STRING, MapSetting[mAuthor]);
- stmt_bind_value(insertsettingstmt, 3, DB::TYPE_FLOAT, MapSetting[mSpawn][xPos]);
- stmt_bind_value(insertsettingstmt, 4, DB::TYPE_FLOAT, MapSetting[mSpawn][yPos]);
- stmt_bind_value(insertsettingstmt, 5, DB::TYPE_FLOAT, MapSetting[mSpawn][zPos]);
- stmt_bind_value(insertsettingstmt, 6, DB::TYPE_INT, MapSetting[mInterior]);
- stmt_bind_value(insertsettingstmt, 7, DB::TYPE_INT, MapSetting[mVirtualWorld]);
- stmt_execute(insertsettingstmt);
- stmt_close(insertsettingstmt);
- }
- // Makes any version updates
- sqlite_UpdateDB()
- {
- sqlite_CreateRBDB();
- sqlite_CreateVehicle();
-
- new dbver = db_query_int(EditMap, "SELECT Version FROM Settings");
- new major = (dbver >> 16) & 0xFF, minor = (dbver >> 8) & 0xFF, patch = (dbver & 0xFF) + 96;
-
- #pragma unused major, minor, patch
-
- if(minor < 9)
- {
- ResetSettings();
- sqlite_CreateSettings();
- sqlite_InitSettings();
- // Version 1.3
- if(!ColumnExists(EditMap, "Objects", "GroupID")) db_exec(EditMap, "ALTER TABLE `Objects` ADD COLUMN `GroupID` INTEGER DEFAULT 0");
-
- // Version 1.9
- if(!ColumnExists(EditMap, "Objects", "Note"))
- {
- db_exec(EditMap, "ALTER TABLE `Objects` ADD COLUMN `Note` TEXT DEFAULT ''");
- db_exec(EditMap, "ALTER TABLE `Objects` ADD COLUMN `DrawDistance` REAL DEFAULT 300.0");
- db_exec(EditMap, "ALTER TABLE `Vehicles` ADD COLUMN `CarSiren` INTEGER DEFAULT 0");
- }
- }
-
- /* example: Less than 1.9b
- if(major <= 1 && minor <= 9 && patch <= 'b'))
- {
- print("worked");
- sqlite_CreateRangeRemoved();
- sqlite_InitSettings();
- }*/
-
-
- /*new dbver = db_query_int(EditMap, "SELECT Version FROM Settings");
- if(dbver != TS_VERSION)
- {
- printf("Map version (%i.%i%c) does not match TS version (%i.%i%c)",
- (dbver & 0x00FF0000), (dbver & 0x0000FF00), (dbver & 0x000000FF) + 96,
- (TS_VERSION & 0x00FF0000), (TS_VERSION & 0x0000FF00), (TS_VERSION & 0x000000FF) + 96);
-
- if((dbver & 0x00FF0000) > (TS_VERSION & 0x00FF0000)) // Major version, changes were made that are needed to edit this map
- printf("Map major version is higher than TS version, update TS to edit this map.");
- else if((dbver & 0x0000FF00) > (TS_VERSION & 0x0000FF00)) // Minor version, changes were made that affect this map
- printf("Map minor version is higher than TS version, update TS to edit this map correctly.");
- else if((dbver & 0x000000FF) > (TS_VERSION & 0x000000FF)) // Patch, backwards compatible
- printf("Your version of TS is old, consider updating.");
-
- if((dbver & 0x00FF0000) < (TS_VERSION & 0x00FF0000)) // Major version, making updates
- printf("Map major version is lower than TS version, updating map.");
- else if((dbver & 0x0000FF00) < (TS_VERSION & 0x0000FF00)) // Minor version, making updates
- printf("Map minor version is lower than TS version, updating map.");
- else if((dbver & 0x000000FF) < (TS_VERSION & 0x000000FF)) // Patch, backwards compatible
- printf("Map version is compatible with TS version.");
- }*/
-
- sqlite_UpdateSettings();
- return 1;
- }
- new DBStatement:texturestmt;
- new TextureUpdateString[512];
- // Saves a specific texture index to DB
- sqlite_SaveMaterialIndex(index)
- {
- // Inserts a new index
- if(!TextureUpdateString[0])
- {
- // Prepare query
- strimplode(" ",
- TextureUpdateString,
- sizeof(TextureUpdateString),
- "UPDATE `Objects` SET",
- "`TextureIndex` = ?",
- "WHERE `IndexID` = ?"
- );
- }
- texturestmt = db_prepare(EditMap, TextureUpdateString);
- // Bind values
- stmt_bind_value(texturestmt, 0, DB::TYPE_ARRAY, ObjectData[index][oTexIndex], MAX_MATERIALS);
- stmt_bind_value(texturestmt, 1, DB::TYPE_INT, index);
- // Execute stmt
- stmt_execute(texturestmt);
- stmt_close(texturestmt);
- return 1;
- }
- new DBStatement:colorstmt;
- new ColorUpdateString[512];
- // Saves a specific texture index to DB
- sqlite_SaveColorIndex(index)
- {
- // Inserts a new index
- if(!ColorUpdateString[0])
- {
- // Prepare query
- strimplode(" ",
- ColorUpdateString,
- sizeof(ColorUpdateString),
- "UPDATE `Objects` SET",
- "`ColorIndex` = ?",
- "WHERE `IndexID` = ?"
- );
- }
- colorstmt = db_prepare(EditMap, ColorUpdateString);
- // Bind values
- stmt_bind_value(colorstmt, 0, DB::TYPE_ARRAY, ObjectData[index][oColorIndex], MAX_MATERIALS);
- stmt_bind_value(colorstmt, 1, DB::TYPE_INT, index);
- // Execute stmt
- stmt_execute(colorstmt);
- stmt_close(colorstmt);
- return 1;
- }
- new DBStatement:posupdatestmt;
- new PosUpdateString[512];
- sqlite_UpdateObjectPos(index)
- {
- // Inserts a new index
- if(!PosUpdateString[0])
- {
- // Prepare query
- strimplode(" ",
- PosUpdateString,
- sizeof(PosUpdateString),
- "UPDATE `Objects` SET",
- "`xPos` = ?,",
- "`yPos` = ?,",
- "`zPos` = ?,",
- "`rxRot` = ?,",
- "`ryRot` = ?,",
- "`rzRot` = ?",
- "WHERE `IndexID` = ?"
- );
- }
- posupdatestmt = db_prepare(EditMap, PosUpdateString);
- // Bind values
- stmt_bind_value(posupdatestmt, 0, DB::TYPE_FLOAT, ObjectData[index][oX]);
- stmt_bind_value(posupdatestmt, 1, DB::TYPE_FLOAT, ObjectData[index][oY]);
- stmt_bind_value(posupdatestmt, 2, DB::TYPE_FLOAT, ObjectData[index][oZ]);
- stmt_bind_value(posupdatestmt, 3, DB::TYPE_FLOAT, ObjectData[index][oRX]);
- stmt_bind_value(posupdatestmt, 4, DB::TYPE_FLOAT, ObjectData[index][oRY]);
- stmt_bind_value(posupdatestmt, 5, DB::TYPE_FLOAT, ObjectData[index][oRZ]);
- stmt_bind_value(posupdatestmt, 6, DB::TYPE_INT, index);
- // Execute stmt
- stmt_execute(posupdatestmt);
- stmt_close(posupdatestmt);
- foreach(new i : Player)
- {
- if(CurrObject[i] == index) OnObjectUpdatePos(i, index);
- }
- return 1;
- }
- new DBStatement:ddupdatestmt;
- new DDUpdateString[512];
- sqlite_UpdateObjectDD(index)
- {
- // Inserts a new index
- if(!DDUpdateString[0])
- {
- // Prepare query
- strimplode(" ",
- DDUpdateString,
- sizeof(DDUpdateString),
- "UPDATE `Objects` SET",
- "`DrawDistance` = ?",
- "WHERE `IndexID` = ?"
- );
- }
- ddupdatestmt = db_prepare(EditMap, DDUpdateString);
- // Bind values
- stmt_bind_value(ddupdatestmt, 0, DB::TYPE_FLOAT, ObjectData[index][oDD]);
- stmt_bind_value(ddupdatestmt, 1, DB::TYPE_INT, index);
- // Execute stmt
- stmt_execute(ddupdatestmt);
- stmt_close(ddupdatestmt);
- return 1;
- }
- // Update sql object text
- new DBStatement:objecttextallsave;
- new ObjectTextSave[512];
- sqlite_SaveAllObjectText(index)
- {
- if(!ObjectTextSave[0])
- {
- strimplode(" ",
- ObjectTextSave,
- sizeof(ObjectTextSave),
- "UPDATE `Objects` SET",
- "`usetext` = ?,",
- "`FontFace` = ?,",
- "`FontSize` = ?,",
- "`FontBold` = ?,",
- "`FontColor` = ?,",
- "`BackColor` = ?,",
- "`Alignment` = ?,",
- "`TextFontSize` = ?,",
- "`ObjectText` = ?",
- "WHERE `IndexID` = ?"
- );
- }
- objecttextallsave = db_prepare(EditMap, ObjectTextSave);
- // Bind values
- stmt_bind_value(objecttextallsave, 0, DB::TYPE_INT, ObjectData[index][ousetext]);
- stmt_bind_value(objecttextallsave, 1, DB::TYPE_INT, ObjectData[index][oFontFace]);
- stmt_bind_value(objecttextallsave, 2, DB::TYPE_INT, ObjectData[index][oFontSize]);
- stmt_bind_value(objecttextallsave, 3, DB::TYPE_INT, ObjectData[index][oFontBold]);
- stmt_bind_value(objecttextallsave, 4, DB::TYPE_INT, ObjectData[index][oFontColor]);
- stmt_bind_value(objecttextallsave, 5, DB::TYPE_INT, ObjectData[index][oBackColor]);
- stmt_bind_value(objecttextallsave, 6, DB::TYPE_INT, ObjectData[index][oAlignment]);
- stmt_bind_value(objecttextallsave, 7, DB::TYPE_INT, ObjectData[index][oTextFontSize]);
- stmt_bind_value(objecttextallsave, 8, DB::TYPE_STRING, ObjectData[index][oObjectText]);
- stmt_bind_value(objecttextallsave, 9, DB::TYPE_INT, index);
- stmt_execute(objecttextallsave);
- stmt_close(objecttextallsave);
- }
- // Update sql use text
- new DBStatement:usetextupdatestmt;
- new UseTextString[512];
- sqlite_ObjUseText(index)
- {
- if(!UseTextString[0])
- {
- strimplode(" ",
- UseTextString,
- sizeof(UseTextString),
- "UPDATE `Objects` SET",
- "`usetext` = ?",
- "WHERE `IndexID` = ?"
- );
- }
- usetextupdatestmt = db_prepare(EditMap, UseTextString);
- // Bind values
- stmt_bind_value(usetextupdatestmt, 0, DB::TYPE_INT, ObjectData[index][ousetext]);
- stmt_bind_value(usetextupdatestmt, 1, DB::TYPE_INT, index);
- // Execute stmt
- stmt_execute(usetextupdatestmt);
- stmt_close(usetextupdatestmt);
- return 1;
- }
- // Update sql fontface
- new DBStatement:fontfaceupdatestmt;
- new FontFaceString[512];
- sqlite_ObjFontFace(index)
- {
- if(!FontFaceString[0])
- {
- strimplode(" ",
- FontFaceString,
- sizeof(FontFaceString),
- "UPDATE `Objects` SET",
- "`FontFace` = ?",
- "WHERE `IndexID` = ?"
- );
- }
- fontfaceupdatestmt = db_prepare(EditMap, FontFaceString);
- // Bind values
- stmt_bind_value(fontfaceupdatestmt, 0, DB::TYPE_INT, ObjectData[index][oFontFace]);
- stmt_bind_value(fontfaceupdatestmt, 1, DB::TYPE_INT, index);
- // Execute stmt
- stmt_execute(fontfaceupdatestmt);
- stmt_close(fontfaceupdatestmt);
- return 1;
- }
- // Update sql fontsize
- new DBStatement:fontsizeupdatestmt;
- new FontSizeString[512];
- sqlite_ObjFontSize(index)
- {
- if(!FontSizeString[0])
- {
- strimplode(" ",
- FontSizeString,
- sizeof(FontSizeString),
- "UPDATE `Objects` SET",
- "`FontSize` = ?",
- "WHERE `IndexID` = ?"
- );
- }
- fontsizeupdatestmt = db_prepare(EditMap, FontSizeString);
- // Bind values
- stmt_bind_value(fontsizeupdatestmt, 0, DB::TYPE_INT, ObjectData[index][oFontSize]);
- stmt_bind_value(fontsizeupdatestmt, 1, DB::TYPE_INT, index);
- // Execute stmt
- stmt_execute(fontsizeupdatestmt);
- stmt_close(fontsizeupdatestmt);
- return 1;
- }
- // Update sql fontbold
- new DBStatement:fontboldupdatestmt;
- new FontBoldString[512];
- sqlite_ObjFontBold(index)
- {
- if(!FontBoldString[0])
- {
- strimplode(" ",
- FontBoldString,
- sizeof(FontBoldString),
- "UPDATE `Objects` SET",
- "`FontBold` = ?",
- "WHERE `IndexID` = ?"
- );
- }
- fontboldupdatestmt = db_prepare(EditMap, FontBoldString);
- // Bind values
- stmt_bind_value(fontboldupdatestmt, 0, DB::TYPE_INT, ObjectData[index][oFontBold]);
- stmt_bind_value(fontboldupdatestmt, 1, DB::TYPE_INT, index);
- // Execute stmt
- stmt_execute(fontboldupdatestmt);
- stmt_close(fontboldupdatestmt);
- return 1;
- }
- // Update sql fontcolor
- new DBStatement:fontcolorupdatestmt;
- new FontColorString[512];
- sqlite_ObjFontColor(index)
- {
- if(!FontColorString[0])
- {
- strimplode(" ",
- FontColorString,
- sizeof(FontColorString),
- "UPDATE `Objects` SET",
- "`FontColor` = ?",
- "WHERE `IndexID` = ?"
- );
- }
- fontcolorupdatestmt = db_prepare(EditMap, FontColorString);
- // Bind values
- stmt_bind_value(fontcolorupdatestmt, 0, DB::TYPE_INT, ObjectData[index][oFontColor]);
- stmt_bind_value(fontcolorupdatestmt, 1, DB::TYPE_INT, index);
- // Execute stmt
- stmt_execute(fontcolorupdatestmt);
- stmt_close(fontcolorupdatestmt);
- return 1;
- }
- // Update sql backcolor
- new DBStatement:backcolorupdatestmt;
- new BackColorString[512];
- sqlite_ObjBackColor(index)
- {
- if(!BackColorString[0])
- {
- strimplode(" ",
- BackColorString,
- sizeof(BackColorString),
- "UPDATE `Objects` SET",
- "`BackColor` = ?",
- "WHERE `IndexID` = ?"
- );
- }
- backcolorupdatestmt = db_prepare(EditMap, BackColorString);
- // Bind values
- stmt_bind_value(backcolorupdatestmt, 0, DB::TYPE_INT, ObjectData[index][oBackColor]);
- stmt_bind_value(backcolorupdatestmt, 1, DB::TYPE_INT, index);
- // Execute stmt
- stmt_execute(backcolorupdatestmt);
- stmt_close(backcolorupdatestmt);
- return 1;
- }
- // Update sql alignment
- new DBStatement:alignmentupdatestmt;
- new AlignmentString[512];
- sqlite_ObjAlignment(index)
- {
- if(!AlignmentString[0])
- {
- strimplode(" ",
- AlignmentString,
- sizeof(AlignmentString),
- "UPDATE `Objects` SET",
- "`Alignment` = ?",
- "WHERE `IndexID` = ?"
- );
- }
- alignmentupdatestmt = db_prepare(EditMap, AlignmentString);
- // Bind values
- stmt_bind_value(alignmentupdatestmt, 0, DB::TYPE_INT, ObjectData[index][oAlignment]);
- stmt_bind_value(alignmentupdatestmt, 1, DB::TYPE_INT, index);
- // Execute stmt
- stmt_execute(alignmentupdatestmt);
- stmt_close(alignmentupdatestmt);
- return 1;
- }
- // Update sql textsize
- new DBStatement:textsizeupdatestmt;
- new TextSizeString[512];
- sqlite_ObjFontTextSize(index)
- {
- if(!TextSizeString[0])
- {
- strimplode(" ",
- TextSizeString,
- sizeof(TextSizeString),
- "UPDATE `Objects` SET",
- "`TextFontSize` = ?",
- "WHERE `IndexID` = ?"
- );
- }
- textsizeupdatestmt = db_prepare(EditMap, TextSizeString);
- // Bind values
- stmt_bind_value(textsizeupdatestmt, 0, DB::TYPE_INT, ObjectData[index][oTextFontSize]);
- stmt_bind_value(textsizeupdatestmt, 1, DB::TYPE_INT, index);
- // Execute stmt
- stmt_execute(textsizeupdatestmt);
- stmt_close(textsizeupdatestmt);
- return 1;
- }
- // Update sql object text
- new DBStatement:objecttextupdatestmt;
- new ObjectTextString[512];
- sqlite_ObjObjectText(index)
- {
- if(!ObjectTextString[0])
- {
- strimplode(" ",
- ObjectTextString,
- sizeof(ObjectTextString),
- "UPDATE `Objects` SET",
- "`ObjectText` = ?",
- "WHERE `IndexID` = ?"
- );
- }
- objecttextupdatestmt = db_prepare(EditMap, ObjectTextString);
- // Bind values
- stmt_bind_value(objecttextupdatestmt, 0, DB::TYPE_STRING, ObjectData[index][oObjectText]);
- stmt_bind_value(objecttextupdatestmt, 1, DB::TYPE_INT, index);
- // Execute stmt
- stmt_execute(objecttextupdatestmt);
- stmt_close(objecttextupdatestmt);
- return 1;
- }
- // Update sql object group
- new DBStatement:objectgroupupdatestmt;
- new ObjectGroupString[512];
- sqlite_ObjGroup(index)
- {
- if(!ObjectTextString[0])
- {
- strimplode(" ",
- ObjectGroupString,
- sizeof(ObjectGroupString),
- "UPDATE `Objects` SET",
- "`GroupID` = ?",
- "WHERE `IndexID` = ?"
- );
- }
- objectgroupupdatestmt = db_prepare(EditMap, ObjectGroupString);
- // Bind values
- stmt_bind_value(objectgroupupdatestmt, 0, DB::TYPE_INT, ObjectData[index][oGroup]);
- stmt_bind_value(objectgroupupdatestmt, 1, DB::TYPE_INT, index);
- // Execute stmt
- stmt_execute(objectgroupupdatestmt);
- stmt_close(objectgroupupdatestmt);
- return 1;
- }
- // Update sql object model
- new DBStatement:objectmodelupdatestmt;
- new ObjectModelString[512];
- sqlite_ObjModel(index)
- {
- if(!ObjectModelString[0])
- {
- strimplode(" ",
- ObjectModelString,
- sizeof(ObjectModelString),
- "UPDATE `Objects` SET",
- "`ModelID` = ?",
- "WHERE `IndexID` = ?"
- );
- }
- objectmodelupdatestmt = db_prepare(EditMap, ObjectModelString);
- // Bind values
- stmt_bind_value(objectmodelupdatestmt, 0, DB::TYPE_INT, ObjectData[index][oModel]);
- stmt_bind_value(objectmodelupdatestmt, 1, DB::TYPE_INT, index);
- // Execute stmt
- stmt_execute(objectmodelupdatestmt);
- stmt_close(objectmodelupdatestmt);
- return 1;
- }
- // Update sql object note
- new DBStatement:objectnoteupdatestmt;
- new ObjectNoteString[512];
- sqlite_ObjNote(index)
- {
- if(!ObjectNoteString[0])
- {
- strimplode(" ",
- ObjectNoteString,
- sizeof(ObjectNoteString),
- "UPDATE `Objects` SET",
- "`Note` = ?",
- "WHERE `IndexID` = ?"
- );
- }
- objectnoteupdatestmt = db_prepare(EditMap, ObjectNoteString);
- // Bind values
- stmt_bind_value(objectnoteupdatestmt, 0, DB::TYPE_STRING, ObjectData[index][oNote]);
- stmt_bind_value(objectnoteupdatestmt, 1, DB::TYPE_INT, index);
- // Execute stmt
- stmt_execute(objectnoteupdatestmt);
- stmt_close(objectnoteupdatestmt);
- return 1;
- }
- // Insert a remove building to DB
- new DBStatement:insertremovebuldingstmt;
- new InsertRemoveBuildingString[256];
- sqlite_InsertRemoveBuilding(index)
- {
- // Inserts a new index
- if(!InsertRemoveBuildingString[0])
- {
- // Prepare query
- strimplode(" ",
- InsertRemoveBuildingString,
- sizeof(InsertRemoveBuildingString),
- "INSERT INTO `RemovedBuildings`",
- "VALUES(?, ?, ?, ?, ?)"
- );
- // Prepare data base for writing
- }
- insertremovebuldingstmt = db_prepare(EditMap, InsertRemoveBuildingString);
- // Bind our results
- stmt_bind_value(insertremovebuldingstmt, 0, DB::TYPE_INT, RemoveData[index][rModel]);
- stmt_bind_value(insertremovebuldingstmt, 1, DB::TYPE_FLOAT, RemoveData[index][rX]);
- stmt_bind_value(insertremovebuldingstmt, 2, DB::TYPE_FLOAT, RemoveData[index][rY]);
- stmt_bind_value(insertremovebuldingstmt, 3, DB::TYPE_FLOAT, RemoveData[index][rZ]);
- stmt_bind_value(insertremovebuldingstmt, 4, DB::TYPE_FLOAT, RemoveData[index][rRange]);
- stmt_execute(insertremovebuldingstmt);
- stmt_close(insertremovebuldingstmt);
- }
- // Update settings in DB
- new DBStatement:updatesettingstmt;
- new InsertSettingsString[256];
- sqlite_UpdateSettings()
- {
- if(!InsertSettingsString[0])
- {
- strimplode(" ",
- InsertSettingsString,
- sizeof(InsertSettingsString),
- "UPDATE `Settings` SET",
- "`Version` = ?,",
- "`LastTime` = ?,",
- "`Author` = ?,",
- "`SpawnX` = ?,",
- "`SpawnY` = ?,",
- "`SpawnZ` = ?,",
- "`Interior` = ?,",
- "`VirtualWorld` = ?",
- // Hacky way to change all of the data without a unique, pointless column
- "WHERE `Version` in (SELECT `Version` FROM Settings LIMIT 1)"
- );
- }
- updatesettingstmt = db_prepare(EditMap, InsertSettingsString);
-
- // Bind our results
- stmt_bind_value(updatesettingstmt, 0, DB::TYPE_INT, TS_VERSION);
- stmt_bind_value(updatesettingstmt, 1, DB::TYPE_INT, gettime());
- stmt_bind_value(updatesettingstmt, 2, DB::TYPE_STRING, MapSetting[mAuthor]);
- stmt_bind_value(updatesettingstmt, 3, DB::TYPE_FLOAT, MapSetting[mSpawn][xPos]);
- stmt_bind_value(updatesettingstmt, 4, DB::TYPE_FLOAT, MapSetting[mSpawn][yPos]);
- stmt_bind_value(updatesettingstmt, 5, DB::TYPE_FLOAT, MapSetting[mSpawn][zPos]);
- stmt_bind_value(updatesettingstmt, 6, DB::TYPE_INT, MapSetting[mInterior]);
- stmt_bind_value(updatesettingstmt, 7, DB::TYPE_INT, MapSetting[mVirtualWorld]);
- // Execute statement
- stmt_execute(updatesettingstmt);
- stmt_close(updatesettingstmt);
- }
- // Load any remove buildings
- new DBStatement:loadremovebuldingstmt;
- sqlite_LoadRemoveBuildings()
- {
- new tmpremove[REMOVEINFO];
- loadremovebuldingstmt = db_prepare(EditMap, "SELECT * FROM `RemovedBuildings`");
- // Bind our results
- stmt_bind_result_field(loadremovebuldingstmt, 0, DB::TYPE_INT, tmpremove[rModel]);
- stmt_bind_result_field(loadremovebuldingstmt, 1, DB::TYPE_FLOAT, tmpremove[rX]);
- stmt_bind_result_field(loadremovebuldingstmt, 2, DB::TYPE_FLOAT, tmpremove[rY]);
- stmt_bind_result_field(loadremovebuldingstmt, 3, DB::TYPE_FLOAT, tmpremove[rZ]);
- stmt_bind_result_field(loadremovebuldingstmt, 4, DB::TYPE_FLOAT, tmpremove[rRange]);
- // Execute query
- if(stmt_execute(loadremovebuldingstmt))
- {
- new count;
- while(stmt_fetch_row(loadremovebuldingstmt))
- {
- // Add the removed building
- AddRemoveBuilding(tmpremove[rModel], tmpremove[rX], tmpremove[rY], tmpremove[rZ], tmpremove[rRange], false);
- count++;
- }
- stmt_close(loadremovebuldingstmt);
- return count;
- }
- stmt_close(loadremovebuldingstmt);
- return 0;
- }
- // Load settings
- new DBStatement:loadsettingstmt;
- sqlite_LoadSettings()
- {
- new tmpsetting[MAPOPTIONS];
- loadsettingstmt = db_prepare(EditMap, "SELECT * FROM `Settings`");
- // Bind our results
- stmt_bind_result_field(loadsettingstmt, 0, DB::TYPE_INT, tmpsetting[mVersion]);
- stmt_bind_result_field(loadsettingstmt, 1, DB::TYPE_INT, tmpsetting[mLastEdit]);
- stmt_bind_result_field(loadsettingstmt, 2, DB::TYPE_STRING, tmpsetting[mAuthor], MAX_PLAYER_NAME);
- stmt_bind_result_field(loadsettingstmt, 3, DB::TYPE_FLOAT, tmpsetting[mSpawn][xPos]);
- stmt_bind_result_field(loadsettingstmt, 4, DB::TYPE_FLOAT, tmpsetting[mSpawn][yPos]);
- stmt_bind_result_field(loadsettingstmt, 5, DB::TYPE_FLOAT, tmpsetting[mSpawn][zPos]);
- stmt_bind_result_field(loadsettingstmt, 6, DB::TYPE_INT, tmpsetting[mInterior]);
- stmt_bind_result_field(loadsettingstmt, 7, DB::TYPE_INT, tmpsetting[mVirtualWorld]);
-
- // Set to default
- //ResetSettings();
- // Execute query
- if(stmt_execute(loadsettingstmt))
- {
- if(stmt_fetch_row(loadsettingstmt))
- {
- // Set to loaded data
- MapSetting = tmpsetting;
- return 1;
- }
- }
- stmt_close(loadsettingstmt);
- return 0;
- }
- ////////////////////////////////////////////////////////////////////////////////
- /// Sqlite query functions end /////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- /// Support functions //////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- // Resets all data on a object slot
- ResetObjectIndex(index)
- {
- new tmpobject[OBJECTINFO];
- ObjectData[index] = tmpobject;
- return 1;
- }
- // Sets the material/and or color of an object
- UpdateMaterial(index)
- {
- for(new i = 0; i < MAX_MATERIALS; i++)
- {
- if(ObjectData[index][oTexIndex][i] != 0) SetDynamicObjectMaterial(ObjectData[index][oID], i, GetTModel(ObjectData[index][oTexIndex][i]), GetTXDName(ObjectData[index][oTexIndex][i]), GetTextureName(ObjectData[index][oTexIndex][i]), ObjectData[index][oColorIndex][i]);
- else if(ObjectData[index][oColorIndex][i] != 0) SetDynamicObjectMaterial(ObjectData[index][oID], i, -1, "none", "none", ObjectData[index][oColorIndex][i]);
- }
- return 1;
- }
- // Highlights a object
- HighlightObject(index)
- {
- for(new i = 0; i < MAX_MATERIALS; i++) SetDynamicObjectMaterial(ObjectData[index][oID], i, -1, "none", "none", HIGHLIGHT_OBJECT_COLOR);
- return 1;
- }
- // Updates any text for an object
- UpdateObjectText(index)
- {
- // Dialogs return literal values this will fix that issue to display correctly
- new tmptext[MAX_TEXT_LENGTH];
- strcat(tmptext, ObjectData[index][oObjectText], MAX_TEXT_LENGTH);
- FixText(tmptext);
- if(ObjectData[index][ousetext])
- {
- SetDynamicObjectMaterialText(ObjectData[index][oID],
- 0,
- tmptext,
- FontSizes[ObjectData[index][oFontSize]],
- FontNames[ObjectData[index][oFontFace]],
- ObjectData[index][oTextFontSize],
- ObjectData[index][oFontBold],
- ObjectData[index][oFontColor],
- ObjectData[index][oBackColor],
- ObjectData[index][oAlignment]);
- return 1;
- }
- return 0;
- }
- // Fixes new line and tabs in material text
- FixText(text[])
- {
- new len = strlen(text);
- if(len > 1)
- {
- for(new i = 0; i < len; i++)
- {
- if(text[i] == 92)
- {
- // New line
- if(text[i+1] == 'n')
- {
- text[i] = '\n';
- for(new j = i+1; j < len; j++) text[j] = text[j+1], text[j+1] = 0;
- continue;
- }
- // Tab
- if(text[i+1] == 't')
- {
- text[i] = '\t';
- for(new j = i+1; j < len-1; j++) text[j] = text[j+1], text[j+1] = 0;
- continue;
- }
- // Literal
- if(text[i+1] == 92)
- {
- text[i] = 92;
- for(new j = i+1; j < len-1; j++) text[j] = text[j+1], text[j+1] = 0;
- }
- }
- }
- }
- return 1;
- }
- Edit_SetObjectPos(index, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, bool:save)
- {
- SaveUndoInfo(index, UNDO_TYPE_EDIT);
- ObjectData[index][oX] = x;
- ObjectData[index][oY] = y;
- ObjectData[index][oZ] = z;
- ObjectData[index][oRX] = rx;
- ObjectData[index][oRY] = ry;
- ObjectData[index][oRZ] = rz;
- SetDynamicObjectPos(ObjectData[index][oID], ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ]);
- SetDynamicObjectRot(ObjectData[index][oID], ObjectData[index][oRX], ObjectData[index][oRY], ObjectData[index][oRZ]);
- if(save)
- {
- // Update object 3d text position
- UpdateObject3DText(index);
- // Update the database
- sqlite_UpdateObjectPos(index);
- }
- return 1;
- }
- UpdateObject3DText(index, bool:newobject=false)
- {
- OnUpdateGroup3DText(index);
- if(!newobject) DestroyDynamic3DTextLabel(ObjectData[index][oTextID]);
- if(!TextOption[tShowText] && !TextOption[tAlwaysShowNew] && newobject)
- return 1;
-
- // 3D Text Label (To identify objects)
- new line[128];
- format(line, sizeof(line), "Ind: {33DD11}%i%s", index,
- (TextOption[tShowGroup] ? sprintf(" {FF8800}Grp:{33DD11} %i", ObjectData[index][oGroup]) : ("")));
-
- // Append note
- if(TextOption[tShowModel])
- {
- strcat(line, sprintf("\n{FF8800}Model: {33DD11}%i\n{FF8800}Name: {33DD11}%s", ObjectData[index][oModel], GetModelName(ObjectData[index][oModel])));
- }
-
- // Append note
- if(TextOption[tShowNote] && strlen(ObjectData[index][oNote]))
- {
- strcat(line, sprintf("\n{FF8800}Note: {33DD11}%s", ObjectData[index][oNote]));
- }
- // Shows the models index
- if(ObjectData[index][oAttachedVehicle] > -1)
- {
- ObjectData[index][oTextID] = CreateDynamic3DTextLabel(line, 0xFF8800FF, ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ], TEXT3D_DRAW_DIST, INVALID_PLAYER_ID, CarData[ObjectData[index][oAttachedVehicle]][CarID]);
- Update3DAttachCarPos(index, ObjectData[index][oAttachedVehicle]);
- }
- else ObjectData[index][oTextID] = CreateDynamic3DTextLabel(line, 0xFF8800FF, ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ], TEXT3D_DRAW_DIST);
- // Update the streamer
- foreach(new i : Player)
- {
- if(IsPlayerInRangeOfPoint(i, 300.0, ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ])) Streamer_Update(i);
- }
- return 1;
- }
- // Rotation functions (Thanks to Stylock)
- // Calculates group object / whole map rotations
- tsfunc AttachObjectToPoint(objectid, Float:px, Float:py, Float:pz, Float:prx, Float:pry, Float:prz, &Float:RetX, &Float:RetY, &Float:RetZ, &Float:RetRX, &Float:RetRY, &Float:RetRZ, sync_rotation = 1)
- {
- new
- Float:g_sin[3],
- Float:g_cos[3],
- Float:off_x,
- Float:off_y,
- Float:off_z;
- EDIT_FloatEulerFix(prx, pry, prz);
- off_x = ObjectData[objectid][oX] - px; // static offset
- off_y = ObjectData[objectid][oY] - py; // static offset
- off_z = ObjectData[objectid][oZ] - pz; // static offset
- // Calculate the new position
- EDIT_FloatConvertValue(prx, pry, prz, g_sin, g_cos);
- RetX = px + off_x * g_cos[1] * g_cos[2] - off_x * g_sin[0] * g_sin[1] * g_sin[2] - off_y * g_cos[0] * g_sin[2] + off_z * g_sin[1] * g_cos[2] + off_z * g_sin[0] * g_cos[1] * g_sin[2];
- RetY = py + off_x * g_cos[1] * g_sin[2] + off_x * g_sin[0] * g_sin[1] * g_cos[2] + off_y * g_cos[0] * g_cos[2] + off_z * g_sin[1] * g_sin[2] - off_z * g_sin[0] * g_cos[1] * g_cos[2];
- RetZ = pz - off_x * g_cos[0] * g_sin[1] + off_y * g_sin[0] + off_z * g_cos[0] * g_cos[1];
- if (sync_rotation)
- {
- // Calculate the new rotation
- EDIT_FloatConvertValue(asin(g_cos[0] * g_cos[1]), atan2(g_sin[0], g_cos[0] * g_sin[1]) + ObjectData[objectid][oRZ], atan2(g_cos[1] * g_cos[2] * g_sin[0] - g_sin[1] * g_sin[2], g_cos[2] * g_sin[1] - g_cos[1] * g_sin[0] * -g_sin[2]), g_sin, g_cos);
- EDIT_FloatConvertValue(asin(g_cos[0] * g_sin[1]), atan2(g_cos[0] * g_cos[1], g_sin[0]), atan2(g_cos[2] * g_sin[0] * g_sin[1] - g_cos[1] * g_sin[2], g_cos[1] * g_cos[2] + g_sin[0] * g_sin[1] * g_sin[2]), g_sin, g_cos);
- EDIT_FloatConvertValue(atan2(g_sin[0], g_cos[0] * g_cos[1]) + ObjectData[objectid][oRX], asin(g_cos[0] * g_sin[1]), atan2(g_cos[2] * g_sin[0] * g_sin[1] + g_cos[1] * g_sin[2], g_cos[1] * g_cos[2] - g_sin[0] * g_sin[1] * g_sin[2]), g_sin, g_cos);
- RetRX = asin(g_cos[1] * g_sin[0]);
- RetRY = atan2(g_sin[1], g_cos[0] * g_cos[1]) + ObjectData[objectid][oRY];
- RetRZ = atan2(g_cos[0] * g_sin[2] - g_cos[2] * g_sin[0] * g_sin[1], g_cos[0] * g_cos[2] + g_sin[0] * g_sin[1] * g_sin[2]);
- }
- }
- tsfunc AttachObjectToPoint_GroupEdit(objectid, Float:offx, Float:offy, Float:offz, Float:px, Float:py, Float:pz, Float:prx, Float:pry, Float:prz, &Float:RetX, &Float:RetY, &Float:RetZ, &Float:RetRX, &Float:RetRY, &Float:RetRZ, sync_rotation = 1)
- {
- new
- Float:g_sin[3],
- Float:g_cos[3],
- Float:off_x,
- Float:off_y,
- Float:off_z;
- EDIT_FloatEulerFix(prx, pry, prz);
- off_x = offx - px; // static offset
- off_y = offy - py; // static offset
- off_z = offz - pz; // static offset
- // Calculate the new position
- EDIT_FloatConvertValue(prx, pry, prz, g_sin, g_cos);
- RetX = px + off_x * g_cos[1] * g_cos[2] - off_x * g_sin[0] * g_sin[1] * g_sin[2] - off_y * g_cos[0] * g_sin[2] + off_z * g_sin[1] * g_cos[2] + off_z * g_sin[0] * g_cos[1] * g_sin[2];
- RetY = py + off_x * g_cos[1] * g_sin[2] + off_x * g_sin[0] * g_sin[1] * g_cos[2] + off_y * g_cos[0] * g_cos[2] + off_z * g_sin[1] * g_sin[2] - off_z * g_sin[0] * g_cos[1] * g_cos[2];
- RetZ = pz - off_x * g_cos[0] * g_sin[1] + off_y * g_sin[0] + off_z * g_cos[0] * g_cos[1];
- if (sync_rotation)
- {
- // Calculate the new rotation
- EDIT_FloatConvertValue(asin(g_cos[0] * g_cos[1]), atan2(g_sin[0], g_cos[0] * g_sin[1]) + ObjectData[objectid][oRZ], atan2(g_cos[1] * g_cos[2] * g_sin[0] - g_sin[1] * g_sin[2], g_cos[2] * g_sin[1] - g_cos[1] * g_sin[0] * -g_sin[2]), g_sin, g_cos);
- EDIT_FloatConvertValue(asin(g_cos[0] * g_sin[1]), atan2(g_cos[0] * g_cos[1], g_sin[0]), atan2(g_cos[2] * g_sin[0] * g_sin[1] - g_cos[1] * g_sin[2], g_cos[1] * g_cos[2] + g_sin[0] * g_sin[1] * g_sin[2]), g_sin, g_cos);
- EDIT_FloatConvertValue(atan2(g_sin[0], g_cos[0] * g_cos[1]) + ObjectData[objectid][oRX], asin(g_cos[0] * g_sin[1]), atan2(g_cos[2] * g_sin[0] * g_sin[1] + g_cos[1] * g_sin[2], g_cos[1] * g_cos[2] - g_sin[0] * g_sin[1] * g_sin[2]), g_sin, g_cos);
- RetRX = asin(g_cos[1] * g_sin[0]);
- RetRY = atan2(g_sin[1], g_cos[0] * g_cos[1]) + ObjectData[objectid][oRY];
- RetRZ = atan2(g_cos[0] * g_sin[2] - g_cos[2] * g_sin[0] * g_sin[1], g_cos[0] * g_cos[2] + g_sin[0] * g_sin[1] * g_sin[2]);
- }
- }
- tsfunc AttachPoint(Float:offx, Float:offy, Float:offz, Float:offrx, Float:offry, Float:offrz, Float:px, Float:py, Float:pz, Float:prx, Float:pry, Float:prz, &Float:RetX, &Float:RetY, &Float:RetZ, &Float:RetRX, &Float:RetRY, &Float:RetRZ, sync_rotation = 1)
- {
- new
- Float:g_sin[3],
- Float:g_cos[3],
- Float:off_x,
- Float:off_y,
- Float:off_z;
- EDIT_FloatEulerFix(prx, pry, prz);
- off_x = offx - px; // static offset
- off_y = offy - py; // static offset
- off_z = offz - pz; // static offset
- // Calculate the new position
- EDIT_FloatConvertValue(prx, pry, prz, g_sin, g_cos);
- RetX = px + off_x * g_cos[1] * g_cos[2] - off_x * g_sin[0] * g_sin[1] * g_sin[2] - off_y * g_cos[0] * g_sin[2] + off_z * g_sin[1] * g_cos[2] + off_z * g_sin[0] * g_cos[1] * g_sin[2];
- RetY = py + off_x * g_cos[1] * g_sin[2] + off_x * g_sin[0] * g_sin[1] * g_cos[2] + off_y * g_cos[0] * g_cos[2] + off_z * g_sin[1] * g_sin[2] - off_z * g_sin[0] * g_cos[1] * g_cos[2];
- RetZ = pz - off_x * g_cos[0] * g_sin[1] + off_y * g_sin[0] + off_z * g_cos[0] * g_cos[1];
- if (sync_rotation)
- {
- // Calculate the new rotation
- EDIT_FloatConvertValue(asin(g_cos[0] * g_cos[1]), atan2(g_sin[0], g_cos[0] * g_sin[1]) + offrz, atan2(g_cos[1] * g_cos[2] * g_sin[0] - g_sin[1] * g_sin[2], g_cos[2] * g_sin[1] - g_cos[1] * g_sin[0] * -g_sin[2]), g_sin, g_cos);
- EDIT_FloatConvertValue(asin(g_cos[0] * g_sin[1]), atan2(g_cos[0] * g_cos[1], g_sin[0]), atan2(g_cos[2] * g_sin[0] * g_sin[1] - g_cos[1] * g_sin[2], g_cos[1] * g_cos[2] + g_sin[0] * g_sin[1] * g_sin[2]), g_sin, g_cos);
- EDIT_FloatConvertValue(atan2(g_sin[0], g_cos[0] * g_cos[1]) + offrx, asin(g_cos[0] * g_sin[1]), atan2(g_cos[2] * g_sin[0] * g_sin[1] + g_cos[1] * g_sin[2], g_cos[1] * g_cos[2] - g_sin[0] * g_sin[1] * g_sin[2]), g_sin, g_cos);
- RetRX = asin(g_cos[1] * g_sin[0]);
- RetRY = atan2(g_sin[1], g_cos[0] * g_cos[1]) + offry;
- RetRZ = atan2(g_cos[0] * g_sin[2] - g_cos[2] * g_sin[0] * g_sin[1], g_cos[0] * g_cos[2] + g_sin[0] * g_sin[1] * g_sin[2]);
- }
- }
- tsfunc EDIT_FloatConvertValue(Float:rot_x, Float:rot_y, Float:rot_z, Float:sin[3], Float:cos[3])
- {
- sin[0] = floatsin(rot_x, degrees);
- sin[1] = floatsin(rot_y, degrees);
- sin[2] = floatsin(rot_z, degrees);
- cos[0] = floatcos(rot_x, degrees);
- cos[1] = floatcos(rot_y, degrees);
- cos[2] = floatcos(rot_z, degrees);
- return 1;
- }
- /*
- * Fixes a bug that causes objects to not rotate
- * correctly when rotating on the Z axis only.
- */
- tsfunc EDIT_FloatEulerFix(&Float:rot_x, &Float:rot_y, &Float:rot_z)
- {
- EDIT_FloatGetRemainder(rot_x, rot_y, rot_z);
- if((!floatcmp(rot_x, 0.0) || !floatcmp(rot_x, 360.0))
- && (!floatcmp(rot_y, 0.0) || !floatcmp(rot_y, 360.0)))
- {
- rot_y = 0.00000002;
- }
- return 1;
- }
- tsfunc EDIT_FloatGetRemainder(&Float:rot_x, &Float:rot_y, &Float:rot_z)
- {
- EDIT_FloatRemainder(rot_x, 360.0);
- EDIT_FloatRemainder(rot_y, 360.0);
- EDIT_FloatRemainder(rot_z, 360.0);
- return 1;
- }
- tsfunc EDIT_FloatRemainder(&Float:remainder, Float:value)
- {
- if(remainder >= value)
- {
- while(remainder >= value)
- {
- remainder = remainder - value;
- }
- }
- else if(remainder < 0.0)
- {
- while(remainder < 0.0)
- {
- remainder = remainder + value;
- }
- }
- return 1;
- }
- // Gets the center of the map
- GetMapCenter(&Float:X, &Float:Y, &Float:Z)
- {
- new Float:highX = -9999999.0;
- new Float:highY = -9999999.0;
- new Float:highZ = -9999999.0;
- new Float:lowX = 9999999.0;
- new Float:lowY = 9999999.0;
- new Float:lowZ = 9999999.0;
- new count;
- foreach(new i : Objects)
- {
- if(ObjectData[i][oX] > highX) highX = ObjectData[i][oX];
- if(ObjectData[i][oY] > highY) highY = ObjectData[i][oY];
- if(ObjectData[i][oZ] > highZ) highZ = ObjectData[i][oZ];
- if(ObjectData[i][oX] < lowX) lowX = ObjectData[i][oX];
- if(ObjectData[i][oY] < lowY) lowY = ObjectData[i][oY];
- if(ObjectData[i][oZ] < lowZ) lowZ = ObjectData[i][oZ];
- count++;
- }
- // Not enough objects grouped
- if(count < 2) return 0;
- X = (highX + lowX) / 2;
- Y = (highY + lowY) / 2;
- Z = (highZ + lowZ) / 2;
- return 1;
- }
- AddDynamicObject(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, index = -1, bool:sqlsave = true, Float:dd = 300.0)
- {
- // Index was not specified get a free index
- if(index == -1) index = Iter_Free(Objects);
- //Found free index
- if(index != -1)
- {
- // Add iterator
- Iter_Add(Objects, index);
- // Create object and set data
- ObjectData[index][oID] = CreateDynamicObject(modelid, x, y, z, rx, ry, rz, MapSetting[mVirtualWorld], MapSetting[mInterior], -1, dd);
- Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[index][oID], E_STREAMER_DRAW_DISTANCE, dd);
-
- #if defined COMPILE_MANGLE
- ObjectData[index][oCAID] = CA_CreateObject(modelid, x, y, z, rx, ry, rz, true);
- #endif
-
- // Update the streamer
- foreach(new i : Player)
- {
- if(IsPlayerInRangeOfPoint(i, 300.0, x, y, z)) Streamer_Update(i);
- }
- ObjectData[index][oModel] = modelid;
- ObjectData[index][oX] = x;
- ObjectData[index][oY] = y;
- ObjectData[index][oZ] = z;
- ObjectData[index][oRX] = rx;
- ObjectData[index][oRY] = ry;
- ObjectData[index][oRZ] = rz;
- ObjectData[index][oDD] = dd;
- ObjectData[index][oAttachedVehicle] = -1;
- if(sqlsave)
- {
- ObjectData[index][ousetext] = 0;
- ObjectData[index][oFontFace] = 0;
- ObjectData[index][oFontSize] = 0;
- ObjectData[index][oFontBold] = 0;
- ObjectData[index][oFontColor] = 0;
- ObjectData[index][oBackColor] = 0;
- ObjectData[index][oAlignment] = 0;
- ObjectData[index][oTextFontSize] = 20;
- ObjectData[index][oGroup] = 0;
- format(ObjectData[index][oObjectText], MAX_TEXT_LENGTH, "%s", "None");
- sqlite_InsertObject(index);
- }
- return index;
- }
- else print("Error: Tried to add too many dynamic objects");
- return index;
- }
- DeleteDynamicObject(index, bool:sqlsave = true)
- {
- OnDeleteGroup3DText(index);
- new next;
- if(Iter_Contains(Objects, index))
- {
- if(ObjectData[index][oAttachedVehicle] > -1) UpdateAttachedObjectRef(ObjectData[index][oAttachedVehicle], index);
- DestroyDynamicObject(ObjectData[index][oID]);
- DestroyDynamic3DTextLabel(ObjectData[index][oTextID]);
- Iter_SafeRemove(Objects, index, next);
- ResetObjectIndex(index);
- GroupUpdate(index);
-
- #if defined COMPILE_MANGLE
- CA_DestroyObject(ObjectData[index][oCAID]);
- #endif
- if(sqlsave) sqlite_RemoveObject(index);
- return next;
- }
- print("Error: Tried to delete a object which does not exist");
- return -1;
- }
- CloneObject(index, grouptask=0)
- {
- if(Iter_Contains(Objects, index))
- {
- new cindex = AddDynamicObject(ObjectData[index][oModel], ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ], ObjectData[index][oRX], ObjectData[index][oRY], ObjectData[index][oRZ], .dd = ObjectData[index][oDD]);
- ObjectData[cindex][ousetext] = ObjectData[index][ousetext];
- ObjectData[cindex][oFontFace] = ObjectData[index][oFontFace];
- ObjectData[cindex][oFontSize] = ObjectData[index][oFontSize];
- ObjectData[cindex][oFontBold] = ObjectData[index][oFontBold];
- ObjectData[cindex][oFontColor] = ObjectData[index][oFontColor];
- ObjectData[cindex][oBackColor] = ObjectData[index][oBackColor];
- ObjectData[cindex][oAlignment] = ObjectData[index][oAlignment];
- ObjectData[cindex][oTextFontSize] = ObjectData[index][oTextFontSize];
- ObjectData[cindex][oGroup] = ObjectData[index][oGroup];
- for(new i = 0; i < MAX_MATERIALS; i++)
- {
- ObjectData[cindex][oTexIndex][i] = ObjectData[index][oTexIndex][i];
- ObjectData[cindex][oColorIndex][i] = ObjectData[index][oColorIndex][i];
- }
- format(ObjectData[cindex][oNote], 64, "%s", ObjectData[index][oNote]);
- format(ObjectData[cindex][oObjectText], MAX_TEXT_LENGTH, "%s", ObjectData[index][oObjectText]);
- // Update the materials
- UpdateMaterial(cindex);
- // Update object text
- UpdateObjectText(cindex);
- // Update 3D text
- UpdateObject3DText(cindex, true);
- // Save materials to material database
- sqlite_SaveMaterialIndex(cindex);
- // Save colors to material database
- sqlite_SaveColorIndex(cindex);
- // Save any text
- sqlite_SaveAllObjectText(cindex);
- if(grouptask > 0) SaveUndoInfo(cindex, UNDO_TYPE_CREATED, grouptask);
- else SaveUndoInfo(cindex, UNDO_TYPE_CREATED);
- return cindex;
- }
- printf("ERROR: Tried to clone a non-existant object");
- return -1;
- }
- // Deletes all map objects
- DeleteMapObjects(bool:sqlsave)
- {
- if(sqlsave)
- {
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- i = DeleteDynamicObject(i, true);
- }
- db_end_transaction(EditMap);
- }
- else
- {
- foreach(new i : Objects)
- {
- i = DeleteDynamicObject(i, false);
- }
- }
-
- // Reset any player variables
- foreach(new i : Player)
- {
- SetCurrObject(i, -1);
- }
- return 1;
- }
- // Add a remove building
- AddRemoveBuilding(model, Float:x, Float:y, Float:z, Float:range, savesql = true)
- {
- for(new i = 0; i < MAX_REMOVE_BUILDING; i++)
- {
- if(RemoveData[i][rModel] == 0)
- {
- RemoveData[i][rModel] = model;
- RemoveData[i][rX] = x;
- RemoveData[i][rY] = y;
- RemoveData[i][rZ] = z;
- RemoveData[i][rRange] = range;
- if(savesql) sqlite_InsertRemoveBuilding(i);
- foreach(new j : Player)
- {
- RemoveBuildingForPlayer(j, model, x, y, z, range);
- }
- return 1;
- }
- }
- return 0;
- }
- ClearRemoveBuildings()
- {
- new count;
- for(new i = 0; i < MAX_REMOVE_BUILDING; i++)
- {
- if(RemoveData[i][rModel] != 0)
- {
- RemoveData[i][rModel] = 0;
- count++;
- }
- }
- if(count)
- {
- SendClientMessageToAll(STEALTH_YELLOW, "Warning: The previous map had removed objects you will have to reconnect to see them");
- ResetGTADeletedObjects();
- }
- return 1;
- }
- RemoveAllBuildings(playerid)
- {
- for(new i = 0; i < MAX_REMOVE_BUILDING; i++)
- {
- if(RemoveData[i][rModel] != 0)
- {
- RemoveBuildingForPlayer(playerid, RemoveData[i][rModel], RemoveData[i][rX], RemoveData[i][rY], RemoveData[i][rZ], RemoveData[i][rRange]);
- }
- }
- }
- // Is string a hexvalue
- IsHexValue(hstring[])
- {
- if(strlen(hstring) < 10) return 0;
- if(hstring[0] == 48 && hstring[1] == 120)
- {
- for(new i = 2; i < 10; i++)
- {
- if(hstring[i] == 48 || hstring[i] == 49 || hstring[i] == 50 || hstring[i] == 51 || hstring[i] == 52 ||
- hstring[i] == 53 || hstring[i] == 54 || hstring[i] == 55 || hstring[i] == 56 || hstring[i] == 57 ||
- hstring[i] == 65 || hstring[i] == 66 || hstring[i] == 67 || hstring[i] == 68 || hstring[i] == 69 ||
- hstring[i] == 70) continue;
- else return 0;
- }
- }
- else return 0;
- return 1;
- }
- // Get position in front of player also returns facing angle
- GetPosFaInFrontOfPlayer(playerid, Float:OffDist, &Float:Pxx, &Float:Pyy, &Float:Pzz, &Float:Fa, Float:rotoff = 0.0)
- {
- if(!IsPlayerConnected(playerid)) return 0;
- new
- Float:playerpos[3],
- Float:FacingA;
- GetPlayerPos(playerid, playerpos[0], playerpos[1], playerpos[2]);
- GetPlayerFacingAngle(playerid, FacingA);
- FacingA += rotoff;
- Pxx = (playerpos[0] + OffDist * floatsin(-FacingA,degrees));
- Pyy = (playerpos[1] + OffDist * floatcos(-FacingA,degrees));
- Pzz = playerpos[2];
- Fa = (FacingA > 180) ? (FacingA - 180) : (FacingA + 180);
- return 1;
- }
- ////////////////////////////////////////////////////////////////////////////////
- /// Support functions end///////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- /// Commands //////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- // Echo text to player useful for keybind (Autohotkey)
- YCMD:echo(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Echo text in the chat. Useful for binds and external keybinds.");
- return 1;
- }
- SendClientMessage(playerid, -1, arg);
- return 1;
- }
- // Pick a map to load
- YCMD:loadmap(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Load a saved map.");
- return 1;
- }
- // Map was already open
- if(MapOpen)
- {
- // Confirm open map
- inline Confirm(cpid, cdialogid, cresponse, clistitem, string:ctext[])
- {
- #pragma unused clistitem, cdialogid, cpid, ctext
- // Open a map
- if(cresponse)
- {
- // Update map settings
- sqlite_UpdateSettings();
-
- // Close map
- db_free_persistent(EditMap);
- // Delete all map objects
- DeleteMapObjects(false);
- // Clear all removed buildings
- ClearRemoveBuildings();
-
- // Reset settings
- ResetSettings();
- // Clean up vehicles
- ClearVehicles();
- // Clear copy buffer
- foreach(new i : Player)
- {
- ClearCopyBuffer(i);
- }
- // Load map
- LoadMap(playerid);
- }
- }
- Dialog_ShowCallback(playerid, using inline Confirm, DIALOG_STYLE_MSGBOX, "Texture Studio", "You have a map open are you sure you want to load another map?\n(Note: Your map is already saved)", "Ok", "Cancel");
- }
- else LoadMap(playerid);
- return 1;
- }
- // Resets settings array
- ResetSettings()
- {
- MapSetting[mVersion] = 0;
- format(MapSetting[mAuthor], MAX_PLAYER_NAME, "Creator");
- MapSetting[mLastEdit] = 0;
- MapSetting[mInterior] = -1;
- MapSetting[mVirtualWorld] = -1;
- MapSetting[mSpawn][xPos] = 0.0;
- MapSetting[mSpawn][yPos] = 0.0;
- MapSetting[mSpawn][zPos] = 0.0;
- return 1;
- }
- // Load map function call
- LoadMap(playerid)
- {
- // Loop through saved maps
- new dir:dHandle = dir_open("./scriptfiles/tstudio/SavedMaps/");
- new item[40], type;
- new line[1024];
- new extension[3];
- new fcount;
- // Create a load list
- while(dir_list(dHandle, item, type))
- {
- if(type != FM_DIR)
- {
- // We need to check extension
- if(strlen(item) > 3)
- {
- format(extension, sizeof(extension), "%s%s", item[strlen(item) - 2],item[strlen(item) - 1]);
- // File is apparently a db
- if(!strcmp(extension, "db"))
- {
- format(line, sizeof(line), "%s\n%s", item, line);
- fcount++;
- }
- }
- }
- }
- // Files were found
- if(fcount > 0)
- {
- inline Select(spid, sdialogid, sresponse, slistitem, string:stext[])
- {
- #pragma unused slistitem, sdialogid, spid
- // Player selected map to load
- if(sresponse)
- {
- ClearAllUndoInfo();
- format(MapName, sizeof(MapName), "tstudio/SavedMaps/%s", stext);
- // Map is now open
- EditMap = db_open_persistent(MapName);
- // Load the maps settings
- sqlite_LoadSettings();
-
- // Perform any version updates
- sqlite_UpdateDB();
- // Load the maps remove buildings
- new rmcount = sqlite_LoadRemoveBuildings();
- // Load the maps objects
- new ocount = sqlite_LoadMapObjects();
- // Load any vehicles
- sqlite_LoadCars();
- // Map is now open
- MapOpen = true;
- // Default editing mode
- EditingMode[playerid] = false;
- SetEditMode(playerid,EDIT_MODE_NONE);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, sprintf("You have loaded a map with %i objects and %i removed buildings.", ocount, rmcount));
-
- new DBResult:timeResult = db_query(EditMap, sprintf("SELECT datetime(%i, 'unixepoch', 'localtime')", MapSetting[mLastEdit]));
- new timestr[64];
- db_get_field(timeResult, 0, timestr, 64);
- db_free_result(timeResult);
-
- if(MapSetting[mLastEdit])
- {
- SendClientMessage(playerid, STEALTH_GREEN, sprintf("This map was created by %s.", MapSetting[mAuthor]));
- SendClientMessage(playerid, STEALTH_GREEN, sprintf("This map was last edited on %s.", timestr)); // by %s
- }
-
- // Update the maps settings, so the last edit time updates
- sqlite_UpdateSettings();
- }
- }
- Dialog_ShowCallback(playerid, using inline Select, DIALOG_STYLE_LIST, "Texture Studio (Load Map)", line, "Ok", "Cancel");
- }
- // No files found
- else
- {
- inline CreateMap(cpid, cdialogid, cresponse, clistitem, string:ctext[])
- {
- #pragma unused clistitem, cdialogid, cpid, ctext
- if(cresponse) NewMap(playerid);
- }
- Dialog_ShowCallback(playerid, using inline CreateMap, DIALOG_STYLE_MSGBOX, "Texture Studio", "There are no maps to load create a new map?", "Ok", "Cancel");
- }
- return 1;
- }
- // Rename a map
- YCMD:renamemap(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Rename a saved map.");
- return 1;
- }
- MapOpenCheck();
- // Confirm rename map
- inline Confirm(cpid, cdialogid, cresponse, clistitem, string:ctext[])
- {
- #pragma unused clistitem, cdialogid, cpid
- // Rename a map
- if(cresponse)
- {
- if(!isnull(ctext))
- {
- new newname[128];
- format(newname, 128, "tstudio/SavedMaps/%s.db", ctext);
-
- if(!fexist(newname))
- {
- // Close the old map
- db_free_persistent(EditMap);
-
- // Rename the old map
- file_copy(sprintf("./scriptfiles/%s", MapName), sprintf("./scriptfiles/%s", newname));
- file_delete(sprintf("./scriptfiles/%s", MapName));
- MapName = newname;
-
- // Open the new map
- EditMap = db_open_persistent(MapName);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "You have renamed a map");
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "A map with that name already exists");
- Dialog_ShowCallback(playerid, using inline Confirm, DIALOG_STYLE_INPUT, "Texture Studio", "Enter a new name for the current map below.", "Ok", "Cancel");
- }
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "You must give your map a filename");
- Dialog_ShowCallback(playerid, using inline Confirm, DIALOG_STYLE_INPUT, "Texture Studio", "Enter a new name for the current map below.", "Ok", "Cancel");
- }
- }
- }
- Dialog_ShowCallback(playerid, using inline Confirm, DIALOG_STYLE_INPUT, "Texture Studio", "Enter a new name for the current map below.", "Ok", "Cancel");
- return 1;
- }
- // Delete a map
- YCMD:deletemap(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Delete a saved map. (Use with caution!)");
- return 1;
- }
- MapOpenCheck();
- // Confirm delete map
- inline Confirm(cpid, cdialogid, cresponse, clistitem, string:ctext[])
- {
- #pragma unused clistitem, cdialogid, cpid, ctext
- // Delete a map
- if(cresponse)
- {
- // Close and delete map
- db_free_persistent(EditMap);
- fremove(MapName);
- ClearAllUndoInfo();
- // Delete all map objects
- DeleteMapObjects(false);
- // Clear all removed buildings
- ClearRemoveBuildings();
- // Clean up vehicles
- ClearVehicles();
- // No map open
- MapOpen = false;
- // Reset player variables
- foreach(new i : Player)
- {
- CancelEdit(i);
- EditingMode[i] = false;
- SetCurrObject(playerid, -1);
- ClearCopyBuffer(i);
- }
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "You have deleted a map");
- }
- }
- Dialog_ShowCallback(playerid, using inline Confirm, DIALOG_STYLE_MSGBOX, "Texture Studio", "Are you sure you want to delete this map?\n(Note: Once deleted, there is no going back)", "Ok", "Cancel");
- return 1;
- }
- // Create a new map
- YCMD:newmap(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Open a new map.");
- return 1;
- }
- // Map was already open
- if(MapOpen)
- {
- // Confirm open map
- inline Confirm(cpid, cdialogid, cresponse, clistitem, string:ctext[])
- {
- #pragma unused clistitem, cdialogid, cpid, ctext
- // Open a map
- if(cresponse)
- {
- // Close map
- db_free_persistent(EditMap);
- ClearAllUndoInfo();
- // Delete all map objects
- DeleteMapObjects(false);
- // Clear all removed buildings
- ClearRemoveBuildings();
- // Clean up vehicles
- ClearVehicles();
- // No map open
- MapOpen = false;
- // Load map
- NewMap(playerid);
- // Reset player variables
- foreach(new i : Player)
- {
- CancelEdit(i);
- EditingMode[i] = false;
- SetCurrObject(playerid, -1);
- ClearCopyBuffer(i);
- }
- }
- }
- Dialog_ShowCallback(playerid, using inline Confirm, DIALOG_STYLE_MSGBOX, "Texture Studio", "You have a map open are you sure you want to create a new map?\n(Note: Your map is already saved)", "Ok", "Cancel");
- }
- else NewMap(playerid);
- return 1;
- }
- // New map function call
- NewMap(playerid)
- {
- inline CreateMap(cpid, cdialogid, cresponse, clistitem, string:ctext[])
- {
- #pragma unused clistitem, cdialogid, cpid
- if(cresponse)
- {
- if(!isnull(ctext))
- {
- format(MapName, sizeof(MapName), "tstudio/SavedMaps/%s.db", ctext);
- if(!fexist(MapName))
- {
- // Open the map for editing
- EditMap = db_open_persistent(MapName);
- // Create new table for map
- sqlite_CreateNewMap();
-
- // Map is now open
- MapOpen = true;
- // Set map default settings
- MapSetting[mVersion] = TS_VERSION;
- MapSetting[mLastEdit] = gettime();
- GetPlayerName(playerid, MapSetting[mAuthor], MAX_PLAYER_NAME);
- MapSetting[mSpawn][xPos] = 0.0;
- MapSetting[mSpawn][yPos] = 0.0;
- MapSetting[mSpawn][zPos] = 0.0;
- MapSetting[mInterior] = -1;
- MapSetting[mVirtualWorld] = -1;
-
- // Update the map settings, to set the last edit time and insert the player name
- sqlite_UpdateSettings();
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "You have created a new map");
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "A map with that name already exists");
- NewMap(playerid);
- }
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "You must give your new map a filename");
- NewMap(playerid);
- }
- }
- }
- Dialog_ShowCallback(playerid, using inline CreateMap, DIALOG_STYLE_INPUT, "Texture Studio", "Enter a new map name", "Ok", "Cancel");
- }
- // Imports CreateObject() or CreateDynamic() raw code
- YCMD:importmap(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Import a map from a text file.");
- return 1;
- }
- if(MapOpen)
- {
- // The map already has objects
- if(Iter_Count(Objects))
- {
- // Ask to load more objects
- inline Import(ipid, idialogid, iresponse, ilistitem, string:itext[])
- {
- #pragma unused ilistitem, idialogid, ipid, itext
- if(iresponse) ImportMap(playerid);
- }
- Dialog_ShowCallback(playerid, using inline Import, DIALOG_STYLE_MSGBOX, "Texture Studio", "This map has objects are you import more objects?", "Ok", "Cancel");
- }
- // No map loaded import a new map
- else ImportMap(playerid);
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "A map must be open before trying to import");
- }
- return 1;
- }
- // Import map function
- ImportMap(playerid)
- {
- new dir:dHandle = dir_open("./scriptfiles/tstudio/ImportMaps/");
- new templine[256];
- new tempmap[256];
- new item[40], itype;
- new line[1024];
- new fcount;
- new templast, templastid[32];
- new tmp[16];
- new tmpobject[OBJECTINFO];
- new tmpremove[REMOVEINFO];
- // Create a load list
- while(dir_list(dHandle, item, itype))
- {
- if(itype != FM_DIR)
- {
- format(line, sizeof(line), "%s\n%s", item, line);
- fcount++;
- }
- }
- // Found import files
- if(fcount > 0)
- {
- inline Select(spid, sdialogid, sresponse, slistitem, string:stext[])
- {
- #pragma unused slistitem, sdialogid, spid
- // Selected a file
- if(sresponse)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Map importing has started, this make a while depending on map size");
- format(tempmap, 64, "tstudio/ImportMaps/%s",stext);
- new File:f;
- new icount, rcount;
- f = fopen(tempmap,io_read);
- // Read lines and import data
- db_begin_transaction(EditMap);
- while(fread(f,templine,sizeof(templine),false))
- {
- strtrim(templine);
-
- new type;
- if(strfind(templine, "CreateObject(", true) != -1) type = 1;
- else if(strfind(templine, "CreateDynamicObject(", true) != -1) type = 1;
- else if(strfind(templine, "RemoveBuildingForPlayer(", true) != -1) type = 2;
- else if(strfind(templine, "SetObjectMaterial(", true) != -1) type = 3;
- else if(strfind(templine, "SetDynamicObjectMaterial(", true) != -1) type = 3;
- else if(strfind(templine, "SetObjectMaterialText(", true) != -1) type = 4;
- else if(strfind(templine, "SetDynamicObjectMaterialText(", true) != -1) type = 4;
- else continue;
-
- new assignment = strfind(templine, "=");
- if(assignment != -1) {
- strmid(templastid, templine, 0, assignment);
- strtrim(templastid);
- }
-
- strmid(templine, templine, strfind(templine, "(") + 1, strfind(templine, ");"), sizeof(templine));
- if(type == 1)
- {
- if(sscanf(templine, "p<,>iffffff", tmpobject[oModel], tmpobject[oX], tmpobject[oY], tmpobject[oZ], tmpobject[oRX], tmpobject[oRY], tmpobject[oRZ]))
- continue;
-
- // Create the new object
- templast = AddDynamicObject(tmpobject[oModel], tmpobject[oX], tmpobject[oY], tmpobject[oZ], tmpobject[oRX], tmpobject[oRY], tmpobject[oRZ]);
- icount++;
- }
- else if(type == 2)
- {
- if(sscanf(templine, "p<,>s[16]iffff", tmp, tmpremove[rModel], tmpremove[rX], tmpremove[rY], tmpremove[rZ], tmpremove[rRange]))
- continue;
- // Delete building
- AddRemoveBuilding(tmpremove[rModel], tmpremove[rX], tmpremove[rY], tmpremove[rZ], tmpremove[rRange], true);
- rcount++;
- }
- else if(type == 3)
- {
- strreplace(templine, "\"", "");//"
-
- new tempindex, tempmodel, temptxd[32], temptexture[32], tempcolor;
- if(sscanf(templine, "p<,>s[16]iis[32]s[32]h", tmp, tempindex, tempmodel, temptxd, temptexture, tempcolor))
- continue;
-
- if(strcmp(tmp, templastid)) // Stuff before '=' doesn't equal stuff in first param
- continue;
-
- ObjectData[templast][oColorIndex][tempindex] = tempcolor;
- for(new i = 0; i < sizeof(ObjectTextures); i++)
- {
- if(!strcmp(ObjectTextures[i][TextureName], temptexture))
- {
- ObjectData[templast][oTexIndex][tempindex] = i;
- break;
- }
- }
-
- sqlite_SaveMaterialIndex(templast);
- sqlite_SaveColorIndex(templast);
-
- UpdateMaterial(templast);
- }
- else if(type == 4)
- {
- //SetObjectMaterialText(tmp, text[], index, mat_size, fontface[], fontsize, bold, color, backcolor, alignment)
-
- // start by extracting text[], removing it from the parameters
- // then sscanf all other params separate
- }
-
- UpdateObject3DText(templast, true);
- }
- db_end_transaction(EditMap);
- format(templine, sizeof(templine), "%i objects were imported, %i removed buildings were imported", icount, rcount);
- SendClientMessage(playerid, STEALTH_GREEN, templine);
- // Were done importing
- fclose(f);
- }
- }
- Dialog_ShowCallback(playerid, using inline Select, DIALOG_STYLE_LIST, "Texture Studio (Import Map)", line, "Ok", "Cancel");
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "There are no maps to import");
- }
- return 1;
- }
- YCMD:export(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Export current map.");
- return 1;
- }
- MapOpenCheck();
- inline Export(epid, edialogid, eresponse, elistitem, string:etext[])
- {
- #pragma unused elistitem, edialogid, epid, etext
- if(eresponse)
- {
- switch(elistitem)
- {
- case 0: BroadcastCommand(playerid, "/exportmap");
- case 1: BroadcastCommand(playerid, "/exportallmap");
- case 2: BroadcastCommand(playerid, "/avexport");
- case 3: BroadcastCommand(playerid, "/avexportall");
- }
- }
- }
- Dialog_ShowCallback(playerid, using inline Export, DIALOG_STYLE_LIST, "Texture Studio (Export Mode)", "Export Map\nExport All Map To Filerscript\nExport Current Car\nExport All Cars", "Ok", "Cancel");
- return 1;
- }
- // Export map to create object
- YCMD:exportmap(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Export current map to a text file.");
- return 1;
- }
- MapOpenCheck();
- // Ask for a map name
- inline ExportMap(epid, edialogid, eresponse, elistitem, string:etext[])
- {
- #pragma unused elistitem, edialogid, epid
- if(eresponse)
- {
- // Was a map name supplied ?
- if(!isnull(etext))
- {
- // Get the draw distance
- inline DrawDist(dpid, ddialogid, dresponse, dlistitem, string:dtext[])
- {
- #pragma unused dlistitem, ddialogid, dpid
- new Float:dist;
- // Set the drawdistance
- if(dresponse)
- {
- if(sscanf(dtext, "f", dist)) dist = 300.0;
- /*else foreach(new i : Objects)
- {
- if(ObjectData[i][oDD] == 300.0) // Default oDD
- ObjectData[i][oDD] = dist;
- }*/
- }
- else dist = 300.0;
-
- new exportmap[256];
- // Check map name length
- if(strlen(etext) >= 20)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "Choose a shorter map name to export to...");
- return 1;
- }
- // Format the output name
- format(exportmap, sizeof(exportmap), "tstudio/ExportMaps/%s.txt", etext);
- // Map exists ask to remove
- if(fexist(exportmap))
- {
- inline RemoveMap(rpid, rdialogid, rresponse, rlistitem, string:rtext[])
- {
- #pragma unused rlistitem, rdialogid, rpid, rtext
- // Remove map and export
- if(rresponse)
- {
- fremove(exportmap);
- MapExport(playerid, exportmap, dist);
- }
- }
- Dialog_ShowCallback(playerid, using inline RemoveMap, DIALOG_STYLE_MSGBOX, "Texture Studio (Export Map)", "A export exists with this name replace?", "Ok", "Cancel");
- }
- // We can start the export
- else MapExport(playerid, exportmap, dist);
- }
- Dialog_ShowCallback(playerid, using inline DrawDist, DIALOG_STYLE_INPUT, "Texture Studio (Map Export)", "Enter the draw distance for objects\n(Note: Default draw distance is 300.0)", "Ok", "Cancel");
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "You can't export a map with no name");
- Dialog_ShowCallback(playerid, using inline ExportMap, DIALOG_STYLE_INPUT, "Texture Studio (Map Export)", "Enter a export map name", "Ok", "Cancel");
- }
- }
- }
- Dialog_ShowCallback(playerid, using inline ExportMap, DIALOG_STYLE_INPUT, "Texture Studio (Map Export)", "Enter a export map name", "Ok", "Cancel");
- return 1;
- }
- // Start exporting
- MapExport(playerid, mapname[], Float:drawdist)
- {
- new exportmap[256];
- format(exportmap, sizeof(exportmap), "%s", mapname);
- inline ExportType(epid, edialogid, eresponse, elistitem, string:etext[])
- {
- #pragma unused edialogid, epid, etext
- if(eresponse)
- {
- new mobjects;
- new templine[256];
- new File:f;
- f = fopen(exportmap,io_write);
- fwrite(f,"//Map Exported with Texture Studio By: [uL]Pottus////////////////////////////////////////////////////////////////\r\n");
- fwrite(f,"//////////////////////////////////////////////and Crayder////////////////////////////////////////////////////////\r\n");
- fwrite(f,"/////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n");
- fwrite(f,"\r\n//Map Information////////////////////////////////////////////////////////////////////////////////////////////////\r\n");
-
- new DBResult:timeResult = db_query(EditMap, sprintf("SELECT datetime(%i, 'unixepoch', 'localtime')", gettime()));
- new timestr[64];
- db_get_field(timeResult, 0, timestr, 64);
- db_free_result(timeResult);
-
- fwrite(f,"/*\r\n");
- fwrite(f,sprintf("\tExported on \"%s\" by \"%s\"\r\n", timestr, ReturnPlayerName(playerid)));
- fwrite(f,sprintf("\tCreated by \"%s\"\r\n", MapSetting[mAuthor]));
- if(MapSetting[mSpawn][xPos])
- fwrite(f,sprintf("\tSpawn Position: %f, %f, %f\r\n", MapSetting[mSpawn][xPos], MapSetting[mSpawn][yPos], MapSetting[mSpawn][zPos]));
- fwrite(f,"*/");
-
- fwrite(f,"\r\n/////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n");
- if(RemoveData[0][rModel] != 0) fwrite(f,"\r\n//Remove Buildings///////////////////////////////////////////////////////////////////////////////////////////////\r\n");
- for(new i = 0; i < MAX_REMOVE_BUILDING; i++)
- {
- if(RemoveData[i][rModel] != 0)
- {
- format(templine, sizeof(templine), "RemoveBuildingForPlayer(playerid, %i, %.3f, %.3f, %.3f, %.3f);\r\n", RemoveData[i][rModel], RemoveData[i][rX], RemoveData[i][rY], RemoveData[i][rZ], RemoveData[i][rRange]);
- fwrite(f,templine);
- }
- }
- fwrite(f,"\r\n//Objects////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n");
- // Temp object for setting materials
- format(templine,sizeof(templine),"new tmpobjid;\r\n");
- fwrite(f,templine);
- // Write all objects with materials first
- foreach(new i : Objects)
- {
- if(ObjectData[i][oAttachedVehicle] > -1) continue;
- new bool:writeobject, Float:odd = (ObjectData[i][oDD] != 300.0 ? ObjectData[i][oDD] : drawdist);
- // Does the object have materials?
- for(new j = 0; j < MAX_MATERIALS; j++)
- {
- if(ObjectData[i][oTexIndex][j] != 0 || ObjectData[i][oColorIndex][j] != 0 || ObjectData[i][ousetext])
- {
- writeobject = true;
- break;
- }
- }
- // Object had materials we will write them to the export file
- if(writeobject)
- {
- mobjects++;
- // Write the create object line
- if(elistitem == 0)
- {
- format(templine,sizeof(templine),"tmpobjid = CreateObject(%i, %f, %f, %f, %f, %f, %f, %.2f); %s\r\n",ObjectData[i][oModel],ObjectData[i][oX],ObjectData[i][oY],ObjectData[i][oZ],ObjectData[i][oRX],ObjectData[i][oRY],ObjectData[i][oRZ],odd,
- strlen(ObjectData[i][oNote]) ? sprintf("// %s", ObjectData[i][oNote]) : (""));
- fwrite(f,templine);
- }
- // Write the create dynamic object line
- else if(elistitem == 1)
- {
- format(templine,sizeof(templine),"tmpobjid = CreateDynamicObjectEx(%i, %f, %f, %f, %f, %f, %f, %.2f, %.2f); %s\r\n",ObjectData[i][oModel],ObjectData[i][oX],ObjectData[i][oY],ObjectData[i][oZ],ObjectData[i][oRX],ObjectData[i][oRY],ObjectData[i][oRZ],odd,odd,
- strlen(ObjectData[i][oNote]) ? sprintf("// %s", ObjectData[i][oNote]) : (""));
- fwrite(f,templine);
- }
- else if(elistitem == 2)
- {
- format(templine,sizeof(templine),"tmpobjid = CreateDynamicObject(%i, %f, %f, %f, %f, %f, %f, -1, -1, -1, %.2f, %.2f); %s\r\n",ObjectData[i][oModel],ObjectData[i][oX],ObjectData[i][oY],ObjectData[i][oZ],ObjectData[i][oRX],ObjectData[i][oRY],ObjectData[i][oRZ],odd,odd,
- strlen(ObjectData[i][oNote]) ? sprintf("// %s", ObjectData[i][oNote]) : (""));
- fwrite(f,templine);
- }
- // Write all materials and colors
- for(new j = 0; j < MAX_MATERIALS; j++)
- {
- // Does object have a texture set?
- if(ObjectData[i][oTexIndex][j] != 0)
- {
- if(elistitem == 0)
- {
- format(templine,sizeof(templine),"SetObjectMaterial(tmpobjid, %i, %i, %c%s%c, %c%s%c, 0x%X);\r\n", j, GetTModel(ObjectData[i][oTexIndex][j]), 34, GetTXDName(ObjectData[i][oTexIndex][j]), 34, 34,GetTextureName(ObjectData[i][oTexIndex][j]), 34, ObjectData[i][oColorIndex][j]);
- fwrite(f,templine);
- }
- else if(elistitem == 1 || elistitem == 2)
- {
- format(templine,sizeof(templine),"SetDynamicObjectMaterial(tmpobjid, %i, %i, %c%s%c, %c%s%c, 0x%X);\r\n", j, GetTModel(ObjectData[i][oTexIndex][j]), 34, GetTXDName(ObjectData[i][oTexIndex][j]), 34, 34,GetTextureName(ObjectData[i][oTexIndex][j]), 34, ObjectData[i][oColorIndex][j]);
- fwrite(f,templine);
- }
- }
- // No texture how about a color?
- else if(ObjectData[i][oColorIndex][j] != 0)
- {
- if(elistitem == 0)
- {
- format(templine,sizeof(templine),"SetObjectMaterial(tmpobjid, %i, -1, %c%s%c, %c%s%c, 0x%X);\r\n", j, 34, "none", 34, 34,"none", 34, ObjectData[i][oColorIndex][j]);
- fwrite(f,templine);
- }
- else if(elistitem == 1 || elistitem == 2)
- {
- format(templine,sizeof(templine),"SetDynamicObjectMaterial(tmpobjid, %i, -1, %c%s%c, %c%s%c, 0x%X);\r\n", j, 34, "none", 34, 34,"none", 34, ObjectData[i][oColorIndex][j]);
- fwrite(f,templine);
- }
- }
- }
- // Write any text
- if(ObjectData[i][ousetext])
- {
- if(elistitem == 0)
- {
- format(templine,sizeof(templine),"SetObjectMaterialText(tmpobjid, %c%s%c, 0, %i, %c%s%c, %i, %i, 0x%X, 0x%X, %i);\r\n",
- 34, ObjectData[i][oObjectText], 34,
- FontSizes[ObjectData[i][oFontSize]],
- 34, FontNames[ObjectData[i][oFontFace]], 34,
- ObjectData[i][oTextFontSize],
- ObjectData[i][oFontBold],
- ObjectData[i][oFontColor],
- ObjectData[i][oBackColor],
- ObjectData[i][oAlignment]
- );
- }
- else if(elistitem == 1 || elistitem == 2)
- {
- format(templine,sizeof(templine),"SetDynamicObjectMaterialText(tmpobjid, 0, %c%s%c, %i, %c%s%c, %i, %i, 0x%X, 0x%X, %i);\r\n",
- 34, ObjectData[i][oObjectText], 34,
- FontSizes[ObjectData[i][oFontSize]],
- 34, FontNames[ObjectData[i][oFontFace]], 34,
- ObjectData[i][oTextFontSize],
- ObjectData[i][oFontBold],
- ObjectData[i][oFontColor],
- ObjectData[i][oBackColor],
- ObjectData[i][oAlignment]
- );
- }
- fwrite(f,templine);
- }
- }
- }
- if(mobjects)
- {
- fwrite(f,"/////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n");
- fwrite(f,"/////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n");
- fwrite(f,"/////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n");
- }
- // We need to write all of the objects that didn't have materials set now
- foreach(new i : Objects)
- {
- if(ObjectData[i][oAttachedVehicle] > -1) continue;
- new bool:writeobject = true, Float:odd = (ObjectData[i][oDD] != 300.0 ? ObjectData[i][oDD] : drawdist);
- // Does the object have materials?
- for(new j = 0; j < MAX_MATERIALS; j++)
- {
- // This object has already been written
- if(ObjectData[i][oTexIndex][j] != 0 || ObjectData[i][oColorIndex][j] != 0 || ObjectData[i][ousetext])
- {
- writeobject = false;
- break;
- }
- }
- // Object has not been exported yet export
- if(writeobject)
- {
- if(elistitem == 0)
- {
- format(templine,sizeof(templine),"tmpobjid = CreateObject(%i, %f, %f, %f, %f, %f, %f, %.2f); %s\r\n",ObjectData[i][oModel],ObjectData[i][oX],ObjectData[i][oY],ObjectData[i][oZ],ObjectData[i][oRX],ObjectData[i][oRY],ObjectData[i][oRZ],odd,
- strlen(ObjectData[i][oNote]) ? sprintf("// %s", ObjectData[i][oNote]) : (""));
- fwrite(f,templine);
- }
- else if(elistitem == 1)
- {
- format(templine,sizeof(templine),"tmpobjid = CreateDynamicObjectEx(%i, %f, %f, %f, %f, %f, %f, %.2f, %.2f); %s\r\n",ObjectData[i][oModel],ObjectData[i][oX],ObjectData[i][oY],ObjectData[i][oZ],ObjectData[i][oRX],ObjectData[i][oRY],ObjectData[i][oRZ],odd,odd,
- strlen(ObjectData[i][oNote]) ? sprintf("// %s", ObjectData[i][oNote]) : (""));
- fwrite(f,templine);
- }
- else if(elistitem == 2)
- {
- format(templine,sizeof(templine),"tmpobjid = CreateDynamicObject(%i, %f, %f, %f, %f, %f, %f, -1, -1, -1, %.2f, %.2f); %s\r\n",ObjectData[i][oModel],ObjectData[i][oX],ObjectData[i][oY],ObjectData[i][oZ],ObjectData[i][oRX],ObjectData[i][oRY],ObjectData[i][oRZ],odd,odd,
- strlen(ObjectData[i][oNote]) ? sprintf("// %s", ObjectData[i][oNote]) : (""));
- fwrite(f,templine);
- }
- }
- }
- fclose(f);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- format(templine, sizeof(templine), "Map has been exported to %s", exportmap);
- SendClientMessage(playerid, STEALTH_GREEN, templine);
- }
- }
- Dialog_ShowCallback(playerid, using inline ExportType, DIALOG_STYLE_LIST, "Texture Studio (Export Map)", "Type 1 - CreateObject()\nType 2 - CreateDynamicObjectEx()\nType 3 - CreateDynamicObject", "Ok", "Cancel");
- return 1;
- }
- // Export map to create object
- YCMD:exportallmap(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Export current map to a filterscript.");
- return 1;
- }
- MapOpenCheck();
- // Ask for a map name
- inline ExportMap(epid, edialogid, eresponse, elistitem, string:etext[])
- {
- #pragma unused elistitem, edialogid, epid
- if(eresponse)
- {
- // Was a map name supplied ?
- if(!isnull(etext))
- {
- // Get the draw distance
- inline DrawDist(dpid, ddialogid, dresponse, dlistitem, string:dtext[])
- {
- #pragma unused dlistitem, ddialogid, dpid
- new Float:dist;
- // Set the drawdistance
- if(dresponse)
- {
- if(sscanf(dtext, "f", dist)) dist = 300.0;
- }
- else dist = 300.0;
- new exportmap[256];
- // Check map name length
- if(strlen(etext) >= 20)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "Choose a shorter map name to export to...");
- return 1;
- }
- // Format the output name
- format(exportmap, sizeof(exportmap), "tstudio/ExportMaps/%s.pwn", etext);
- // Map exists ask to remove
- if(fexist(exportmap))
- {
- inline RemoveMap(rpid, rdialogid, rresponse, rlistitem, string:rtext[])
- {
- #pragma unused rlistitem, rdialogid, rpid, rtext
- // Remove map and export
- if(rresponse)
- {
- fremove(exportmap);
- MapExportAll(playerid, exportmap, dist);
- }
- }
- Dialog_ShowCallback(playerid, using inline RemoveMap, DIALOG_STYLE_MSGBOX, "Texture Studio (Export Map)", "A export exists with this name replace?", "Ok", "Cancel");
- }
- // We can start the export
- else MapExportAll(playerid, exportmap, dist);
- }
- Dialog_ShowCallback(playerid, using inline DrawDist, DIALOG_STYLE_INPUT, "Texture Studio (Map Export)", "Enter the draw distance for objects\n(Note: Default draw distance is 300.0)", "Ok", "Cancel");
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "You can't export a map with no name");
- Dialog_ShowCallback(playerid, using inline ExportMap, DIALOG_STYLE_INPUT, "Texture Studio (Map All Export)", "Enter a export map name", "Ok", "Cancel");
- }
- }
- }
- Dialog_ShowCallback(playerid, using inline ExportMap, DIALOG_STYLE_INPUT, "Texture Studio (Map All Export)", "Enter a export map name", "Ok", "Cancel");
- return 1;
- }
- static MapExportAll(playerid, name[], Float:drawdist)
- {
- new File:f = fopen(name, io_write);
- new templine[256];
- new mobjects;
- // Header
- fwrite(f,"//Map Filterscript Exported with Texture Studio By: [uL]Pottus///////////////////////////////////////////////////\r\n");
- fwrite(f,"///////////////////////////////////////////////////////////and Crayder///////////////////////////////////////////\r\n");
- fwrite(f,"/////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n");
- fwrite(f,"\r\n//Map Information////////////////////////////////////////////////////////////////////////////////////////////////\r\n");
-
- new DBResult:timeResult = db_query(EditMap, sprintf("SELECT datetime(%i, 'unixepoch', 'localtime')", gettime()));
- new timestr[64];
- db_get_field(timeResult, 0, timestr, 64);
- db_free_result(timeResult);
- fwrite(f,"/*\r\n");
- fwrite(f,sprintf("\tExported on \"%s\" by \"%s\"\r\n", timestr, ReturnPlayerName(playerid)));
- fwrite(f,sprintf("\tCreated by \"%s\"\r\n", MapSetting[mAuthor]));
- if(MapSetting[mSpawn][xPos])
- fwrite(f,sprintf("\tSpawn Position: %f, %f, %f\r\n", MapSetting[mSpawn][xPos], MapSetting[mSpawn][yPos], MapSetting[mSpawn][zPos]));
- fwrite(f,"*/");
-
- fwrite(f,"\r\n/////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n\r\n");
-
- // Includes
- fwrite(f, "#include <a_samp>\r\n");
- fwrite(f, "#include <streamer>\r\n\n");
- new CarCount = Iter_Count(Cars);
- new CurrCar;
- // Car id
- for(new i = 0; i < CarCount; i++)
- {
- format(templine, sizeof(templine), "new carvid_%i;\r\n", i);
- fwrite(f, templine);
- }
- fwrite(f, "\n");
- // Init script
- fwrite(f, "public OnFilterScriptInit()\r\n");
- fwrite(f, "{ \r\n");
- fwrite(f," new tmpobjid;\r\n\n");
- foreach(new i : Cars)
- {
- format(templine, sizeof(templine), " carvid_%i = CreateVehicle(%i,%.3f,%.3f,%.3f,%.3f,%i,%i,-1);\r\n",
- CurrCar++, CarData[i][CarModel], CarData[i][CarSpawnX], CarData[i][CarSpawnY], CarData[i][CarSpawnZ], CarData[i][CarSpawnFA], CarData[i][CarColor1], CarData[i][CarColor2]
- );
- fwrite(f, templine);
- }
- CurrCar = 0;
- fwrite(f, "\n");
- foreach(new i : Cars)
- {
- // Mod components
- for(new j = 0; j < MAX_CAR_COMPONENTS; j++)
- {
- if(CarData[i][CarComponents][j] > 0)
- {
- format(templine, sizeof(templine), " AddVehicleComponent(carvid_%i, %i);\r\n", CurrCar, CarData[i][CarComponents][j]);
- fwrite(f, templine);
- }
- }
- CurrCar++;
- }
- CurrCar = 0;
- fwrite(f, "\n");
- foreach(new i : Cars)
- {
- // Paintjob
- if(CarData[i][CarPaintJob] < 3)
- {
- format(templine, sizeof(templine), " ChangeVehiclePaintjob(carvid_%i, %i);\r\n", CurrCar, CarData[i][CarPaintJob]);
- fwrite(f, templine);
- }
- CurrCar++;
- }
- CurrCar = 0;
- fwrite(f, "\n");
- foreach(new i : Cars)
- {
- // Objects
- for(new j = 0; j < MAX_CAR_OBJECTS; j++)
- {
- // No object
- if(CarData[i][CarObjectRef][j] == -1) continue;
- new oindex = CarData[i][CarObjectRef][j];
- // Create object
- format(templine,sizeof(templine)," tmpobjid = CreateDynamicObject(%i,0.0,0.0,-1000.0,0.0,0.0,0.0,-1,-1,-1,300.0,300.0); %s\r\n",ObjectData[oindex][oModel],
- strlen(ObjectData[i][oNote]) ? sprintf("// %s", ObjectData[i][oNote]) : (""));
- fwrite(f,templine);
- // Write all materials and colors
- for(new k = 0; k < MAX_MATERIALS; k++)
- {
- // Does object have a texture set?
- if(ObjectData[oindex][oTexIndex][k] != 0)
- {
- format(templine,sizeof(templine)," SetDynamicObjectMaterial(tmpobjid, %i, %i, %c%s%c, %c%s%c, 0x%X);\r\n",
- k, GetTModel(ObjectData[oindex][oTexIndex][k]), 34, GetTXDName(ObjectData[oindex][oTexIndex][k]), 34, 34,GetTextureName(ObjectData[oindex][oTexIndex][k]), 34, ObjectData[oindex][oColorIndex][k]
- );
- fwrite(f,templine);
- }
- // No texture how about a color?
- else if(ObjectData[oindex][oColorIndex][k] != 0)
- {
- format(templine,sizeof(templine)," SetDynamicObjectMaterial(tmpobjid, %i, -1, %c%s%c, %c%s%c, 0x%X);\r\n", j, 34, "none", 34, 34,"none", 34, ObjectData[oindex][oColorIndex][k]);
- fwrite(f,templine);
- }
- }
- // Write any text
- if(ObjectData[oindex][ousetext])
- {
- format(templine,sizeof(templine)," SetDynamicObjectMaterialText(tmpobjid, 0, %c%s%c, %i, %c%s%c, %i, %i, 0x%X, 0x%X, %i);\r\n",
- 34, ObjectData[oindex][oObjectText], 34,
- FontSizes[ObjectData[oindex][oFontSize]],
- 34, FontNames[ObjectData[oindex][oFontFace]], 34,
- ObjectData[oindex][oTextFontSize],
- ObjectData[oindex][oFontBold],
- ObjectData[oindex][oFontColor],
- ObjectData[oindex][oBackColor],
- ObjectData[oindex][oAlignment]
- );
- fwrite(f,templine);
- }
- // Attach object to vehicle
- format(templine, sizeof(templine), " AttachDynamicObjectToVehicle(tmpobjid, carvid_%i, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f);\r\n",
- CurrCar, CarData[i][COX], CarData[i][COY][j], CarData[i][COZ][j], CarData[i][CORX][j], CarData[i][CORY][j], CarData[i][CORZ][j]
- );
- fwrite(f,templine);
- }
- CurrCar++;
- fwrite(f, "\n");
- }
- // Write Objects
- // Write all objects with materials first
- foreach(new i : Objects)
- {
- if(ObjectData[i][oAttachedVehicle] > -1) continue;
- new bool:writeobject, Float:odd = (ObjectData[i][oDD] != 300.0 ? ObjectData[i][oDD] : drawdist);
- // Does the object have materials?
- for(new j = 0; j < MAX_MATERIALS; j++)
- {
- if(ObjectData[i][oTexIndex][j] != 0 || ObjectData[i][oColorIndex][j] != 0 || ObjectData[i][ousetext])
- {
- writeobject = true;
- break;
- }
- }
- // Object had materials we will write them to the export file
- if(writeobject)
- {
- mobjects++;
- format(templine,sizeof(templine)," tmpobjid = CreateDynamicObject(%i, %f, %f, %f, %f, %f, %f, -1, -1, -1, %.2f, %.2f); %s\r\n",ObjectData[i][oModel],ObjectData[i][oX],ObjectData[i][oY],ObjectData[i][oZ],ObjectData[i][oRX],ObjectData[i][oRY],ObjectData[i][oRZ],odd,odd,
- strlen(ObjectData[i][oNote]) ? sprintf("// %s", ObjectData[i][oNote]) : (""));
- fwrite(f,templine);
- // Write all materials and colors
- for(new j = 0; j < MAX_MATERIALS; j++)
- {
- // Does object have a texture set?
- if(ObjectData[i][oTexIndex][j] != 0)
- {
- format(templine,sizeof(templine)," SetDynamicObjectMaterial(tmpobjid, %i, %i, %c%s%c, %c%s%c, 0x%X);\r\n", j, GetTModel(ObjectData[i][oTexIndex][j]), 34, GetTXDName(ObjectData[i][oTexIndex][j]), 34, 34,GetTextureName(ObjectData[i][oTexIndex][j]), 34, ObjectData[i][oColorIndex][j]);
- fwrite(f,templine);
- }
- // No texture how about a color?
- else if(ObjectData[i][oColorIndex][j] != 0)
- {
- format(templine,sizeof(templine)," SetDynamicObjectMaterial(tmpobjid, %i, -1, %c%s%c, %c%s%c, 0x%X);\r\n", j, 34, "none", 34, 34,"none", 34, ObjectData[i][oColorIndex][j]);
- fwrite(f,templine);
- }
- }
- // Write any text
- if(ObjectData[i][ousetext])
- {
- format(templine,sizeof(templine)," SetDynamicObjectMaterialText(tmpobjid, 0, %c%s%c, %i, %c%s%c, %i, %i, 0x%X, 0x%X, %i);\r\n",
- 34, ObjectData[i][oObjectText], 34,
- FontSizes[ObjectData[i][oFontSize]],
- 34, FontNames[ObjectData[i][oFontFace]], 34,
- ObjectData[i][oTextFontSize],
- ObjectData[i][oFontBold],
- ObjectData[i][oFontColor],
- ObjectData[i][oBackColor],
- ObjectData[i][oAlignment]
- );
- fwrite(f,templine);
- }
- }
- }
- // We need to write all of the objects that didn't have materials set now
- foreach(new i : Objects)
- {
- if(ObjectData[i][oAttachedVehicle] > -1) continue;
- new bool:writeobject = true, Float:odd = (ObjectData[i][oDD] != 300.0 ? ObjectData[i][oDD] : drawdist);
- // Does the object have materials?
- for(new j = 0; j < MAX_MATERIALS; j++)
- {
- // This object has already been written
- if(ObjectData[i][oTexIndex][j] != 0 || ObjectData[i][oColorIndex][j] != 0 || ObjectData[i][ousetext])
- {
- writeobject = false;
- break;
- }
- }
- // Object has not been exported yet export
- if(writeobject)
- {
- format(templine,sizeof(templine)," tmpobjid = CreateDynamicObject(%i, %f, %f, %f, %f, %f, %f, -1, -1, -1, %.2f, %.2f); %s\r\n",ObjectData[i][oModel],ObjectData[i][oX],ObjectData[i][oY],ObjectData[i][oZ],ObjectData[i][oRX],ObjectData[i][oRY],ObjectData[i][oRZ],odd,odd,
- strlen(ObjectData[i][oNote]) ? sprintf("// %s", ObjectData[i][oNote]) : (""));
- fwrite(f,templine);
- }
- }
- fwrite(f, "\r\n");
- fwrite(f, " for(new i = 0; i < MAX_PLAYERS; i++)\r\n");
- fwrite(f, " { \r\n");
- fwrite(f, " if(!IsPlayerConnected(i)) continue; \r\n");
- fwrite(f, " OnPlayerConnect(i); \r\n");
- fwrite(f, " } \r\n\n");
- fwrite(f, " return 1; \r\n\n");
- fwrite(f, "} \r\n\n");
- CurrCar = 0;
- // Exit script
- fwrite(f, "public OnFilterScriptExit()\r\n");
- fwrite(f, "{ \r\n");
- foreach(new i : Cars)
- {
- format(templine, sizeof(templine), " DestroyVehicle(carvid_%i);\r\n", CurrCar);
- fwrite(f, templine);
- CurrCar++;
- }
- fwrite(f, "} \r\n\n");
- // Remove building script
- fwrite(f, "public OnPlayerConnect(playerid)\r\n");
- fwrite(f, "{ \r\n");
- for(new i = 0; i < MAX_REMOVE_BUILDING; i++)
- {
- if(RemoveData[i][rModel] != 0)
- {
- format(templine, sizeof(templine), " RemoveBuildingForPlayer(playerid, %i, %.3f, %.3f, %.3f, %.3f);\r\n", RemoveData[i][rModel], RemoveData[i][rX], RemoveData[i][rY], RemoveData[i][rZ], RemoveData[i][rRange]);
- fwrite(f,templine);
- }
- }
- fwrite(f, "} \r\n\n");
- CurrCar = 0;
- // Vehicle respawn
- fwrite(f, "public OnVehicleSpawn(vehicleid)\r\n");
- fwrite(f, "{ \r\n");
- foreach(new i : Cars)
- {
- if(CurrCar == 0) format(templine, sizeof(templine), " if(vehicleid == carvid_%i)\r\n", CurrCar);
- else format(templine, sizeof(templine), " else if(vehicleid == carvid_%i)\r\n", CurrCar);
- fwrite(f, templine);
- fwrite(f, " {\r\n");
- // Mod components
- for(new j = 0; j < MAX_CAR_COMPONENTS; j++)
- {
- if(CarData[i][CarComponents][j] > 0)
- {
- format(templine, sizeof(templine), " AddVehicleComponent(carvid_%i, %i);\r\n", CurrCar, CarData[i][CarComponents][i]);
- fwrite(f, templine);
- }
- }
- // Paintjob
- if(CarData[i][CarPaintJob] < 3)
- {
- format(templine, sizeof(templine), " ChangeVehiclePaintjob(carvid_%i, %i);\r\n", CurrCar, CarData[i][CarPaintJob]);
- fwrite(f, templine);
- }
- fwrite(f, " }\r\n");
- CurrCar++;
- }
- fwrite(f, "} \r\n");
- fclose(f);
- format(templine, sizeof(templine), "Exported vehicles to filterscript %s", name);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, templine);
- return 1;
- }
- // Selects a object for editing
- YCMD:sel(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Select an object by index.");
- return 1;
- }
- NoEditingMode(playerid);
- MapOpenCheck();
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- if(isnull(arg)) return SendClientMessage(playerid, STEALTH_YELLOW, "Usage: /sel <index> selects a object to edit");
- new index = strval(arg);
- if(index < 0) return SendClientMessage(playerid, STEALTH_YELLOW, "The index can not be negative numbers");
- if(Iter_Contains(Objects, index))
- {
- if(SetCurrObject(playerid, index)) {
- new line[128];
- format(line, sizeof(line), "You have selected object index %i for editing", index);
- SendClientMessage(playerid, STEALTH_GREEN, line);
- }
- else
- SendClientMessage(playerid, STEALTH_YELLOW, "You can not select objects in this object's group");
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "That object does not exist!");
- return 1;
- }
- YCMD:dsel(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Deselect current object.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- NoEditingMode(playerid);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Selection has been deselected");
- SetCurrObject(playerid, -1);
- return 1;
- }
- // Selects the closest object to player
- YCMD:scsel(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Selects closest object.");
- return 1;
- }
- NoEditingMode(playerid);
- MapOpenCheck();
- new Float:dist = 9999999.0, Float:tmpdist, index = -1;
- foreach(new i : Objects)
- {
- if(!CanSelectObject(playerid, i))
- continue;
-
- tmpdist = GetPlayerDistanceFromPoint(playerid, ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ]);
- if(tmpdist < dist)
- {
- dist = tmpdist;
- index = i;
- }
- }
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- if(index > -1)
- {
- SetCurrObject(playerid, index);
- new line[128];
- format(line, sizeof(line), "You have selected object index %i for editing", index);
- SendClientMessage(playerid, STEALTH_GREEN, line);
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "There are no objects");
- return 1;
- }
- // Deletes the closest object to player
- YCMD:dcsel(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Destroy closest object.");
- return 1;
- }
- NoEditingMode(playerid);
- MapOpenCheck();
- new Float:dist = 9999999.0, Float:tmpdist, index = -1;
- foreach(new i : Objects)
- {
- if(!CanSelectObject(playerid, i))
- continue;
-
- tmpdist = GetPlayerDistanceFromPoint(playerid, ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ]);
- if(tmpdist < dist)
- {
- dist = tmpdist;
- index = i;
- }
- }
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- if(index > -1)
- {
- SaveUndoInfo(index, UNDO_TYPE_DELETED);
- DeleteDynamicObject(index);
- foreach(new i : Player)
- {
- if(i == playerid) continue;
- if(CurrObject[index] == CurrObject[i]) SetCurrObject(i, -1);
- }
- SetCurrObject(playerid, -1);
- new line[128];
- format(line, sizeof(line), "You have deleted object index %i", index);
- SendClientMessage(playerid, STEALTH_GREEN, line);
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "There are no objects");
- return 1;
- }
- YCMD:csel(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Select an object using cursor.");
- SendClientMessage(playerid, STEALTH_YELLOW, "Holding 'H' ('Enter' in /flymode) while clicking an object will copy properties to buffer.");
- SendClientMessage(playerid, STEALTH_YELLOW, "Holding 'Walk Key' while clicking an object will paste properties from buffer.");
- return 1;
- }
- NoEditingMode(playerid);
- MapOpenCheck();
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- if(Iter_Count(Objects))
- {
- SetEditMode(playerid, EDIT_MODE_SELECTION);
- SelectObject(playerid);
- SendClientMessage(playerid, STEALTH_GREEN, "Entered Object Selection Mode");
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "There are no objects right now");
- return 1;
- }
- // Set a material of an object
- YCMD:mtset(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Set the material of an object.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- if(GetEditMode(playerid) != EDIT_MODE_TEXTURING) NoEditingMode(playerid);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- new index = CurrObject[playerid];
- new mindex;
- new tref;
- if(GetMaterials(playerid, arg, mindex, tref))
- {
- SaveUndoInfo(index, UNDO_TYPE_EDIT);
- SetMaterials(index, mindex, tref);
- UpdateObjectText(index);
- UpdateTextureSlot(playerid, mindex);
- if(ObjectData[index][oAttachedVehicle] > -1) UpdateAttachedVehicleObject(ObjectData[index][oAttachedVehicle], index, VEHICLE_REATTACH_UPDATE);
- // Update the streamer
- foreach(new i : Player)
- {
- if(IsPlayerInRangeOfPoint(i, 300.0, ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ])) Streamer_Update(i);
- }
- SendClientMessage(playerid, STEALTH_GREEN, "Changed Material");
- }
- return 1;
- }
- // Set all materials of a certain type
- YCMD:mtsetall(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Set the material of all objects of the same model.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- new index = CurrObject[playerid];
- new mindex;
- new tref;
- new time = GetTickCount();
- if(GetMaterials(playerid, arg, mindex, tref))
- {
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- if(ObjectData[i][oModel] == ObjectData[CurrObject[playerid]][oModel])
- {
- SaveUndoInfo(i, UNDO_TYPE_EDIT, time);
- SetMaterials(i, mindex, tref);
- UpdateObjectText(i);
- if(ObjectData[i][oAttachedVehicle] > -1) UpdateAttachedVehicleObject(ObjectData[i][oAttachedVehicle], i, VEHICLE_REATTACH_UPDATE);
- }
- }
- db_end_transaction(EditMap);
- SendClientMessage(playerid, STEALTH_GREEN, "Changed All Materials");
- foreach(new i : Player)
- {
- if(IsPlayerInRangeOfPoint(i, 300.0, ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ])) Streamer_Update(i);
- }
- UpdateTextureSlot(playerid, mindex);
- }
- return 1;
- }
- YCMD:ogroup(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Set the group ID of current object.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- NoEditingMode(playerid);
- if (!(0 <= strval(arg) < MAX_GROUPS))
- return SendClientMessage(playerid, STEALTH_YELLOW, sprintf("The group id must be from 0 to %d", MAX_GROUPS - 1));
- new index = CurrObject[playerid];
- SaveUndoInfo(index, UNDO_TYPE_EDIT);
- ObjectData[index][oGroup] = strval(arg);
- sqlite_ObjGroup(index);
- UpdateObject3DText(index);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- new line[128];
- format(line, sizeof(line), "You have changed the group ID of this object to: %i", ObjectData[index][oGroup]);
- SendClientMessage(playerid, STEALTH_GREEN, line);
- return 1;
- }
- tsfunc ColumnExists(DB:database, table[], columnname[])
- {
- new q[128];
- format(q, sizeof(q), "pragma table_info(%s)", table);
- new DBResult:r = db_query(database, q);
- new Field[64];
- if(db_num_rows(r))
- {
- for(new i = 0; i < db_num_rows(r); i++)
- {
- db_get_field_assoc(r, "name", Field, 64);
- if(!strcmp(Field, columnname))
- {
- db_free_result(r);
- return 1;
- }
- db_next_row(r);
- }
- }
- db_free_result(r);
- return 0;
- }
- YCMD:clone(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Clone current object with all properties.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- NoEditingMode(playerid);
- SetCurrObject(playerid, CloneObject(CurrObject[playerid]));
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Cloned your selected object the new object is now your selection");
- return 1;
- }
- YCMD:copy(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Copy an objects properties to the clipboard.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- NoEditingMode(playerid);
- CopyCopyBuffer(playerid, CurrObject[playerid]);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Copied object textures/color/text to buffer");
- return 1;
- }
- CopyCopyBuffer(playerid, index)
- {
- for(new i = 0; i < MAX_MATERIALS; i++)
- {
- CopyBuffer[playerid][cTexIndex][i] = ObjectData[index][oTexIndex][i];
- CopyBuffer[playerid][cColorIndex][i] = ObjectData[index][oColorIndex][i];
- CopyBuffer[playerid][cusetext] = ObjectData[index][ousetext];
- CopyBuffer[playerid][cFontFace] = ObjectData[index][oFontFace];
- CopyBuffer[playerid][cFontSize] = ObjectData[index][oFontSize];
- CopyBuffer[playerid][cFontBold] = ObjectData[index][oFontBold];
- CopyBuffer[playerid][cFontColor] = ObjectData[index][oFontColor];
- CopyBuffer[playerid][cBackColor] = ObjectData[index][oBackColor];
- CopyBuffer[playerid][cAlignment] = ObjectData[index][oAlignment];
- CopyBuffer[playerid][cTextFontSize] = ObjectData[index][oTextFontSize];
- strcat((CopyBuffer[playerid][cObjectText][0] = '\0', CopyBuffer[playerid][cObjectText]), ObjectData[index][oObjectText], MAX_TEXT_LENGTH);
- }
- return 1;
- }
- YCMD:clear(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Clears current clipboard.");
- return 1;
- }
- ClearCopyBuffer(playerid);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Cleared your copy buffer");
- return 1;
- }
- YCMD:paste(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Paste copied propeties to current object.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- NoEditingMode(playerid);
- PasteCopyBuffer(playerid, CurrObject[playerid]);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Pasted your copy buffer to object");
- return 1;
- }
- PasteCopyBuffer(playerid, index)
- {
- for(new i = 0; i < MAX_MATERIALS; i++)
- {
- ObjectData[index][oTexIndex][i] = CopyBuffer[playerid][cTexIndex][i];
- ObjectData[index][oColorIndex][i] = CopyBuffer[playerid][cColorIndex][i];
- }
- ObjectData[index][ousetext] = CopyBuffer[playerid][cusetext];
- ObjectData[index][oFontFace] = CopyBuffer[playerid][cFontFace];
- ObjectData[index][oFontSize] = CopyBuffer[playerid][cFontSize];
- ObjectData[index][oFontBold] = CopyBuffer[playerid][cFontBold];
- ObjectData[index][oFontColor] = CopyBuffer[playerid][cFontColor];
- ObjectData[index][oBackColor] = CopyBuffer[playerid][cBackColor];
- ObjectData[index][oAlignment] = CopyBuffer[playerid][cAlignment];
- ObjectData[index][oTextFontSize] = CopyBuffer[playerid][cTextFontSize];
- strcat((ObjectData[index][oObjectText][0] = '\0', ObjectData[index][oObjectText]), CopyBuffer[playerid][cObjectText], MAX_TEXT_LENGTH);
- // Destroy the object
- DestroyDynamicObject(ObjectData[index][oID]);
- // Re-create object
- ObjectData[index][oID] = CreateDynamicObject(ObjectData[index][oModel], ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ], ObjectData[index][oRX], ObjectData[index][oRY], ObjectData[index][oRZ], MapSetting[mVirtualWorld], MapSetting[mInterior], -1, 300.0);
- Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[index][oID], E_STREAMER_DRAW_DISTANCE, 300.0);
- // Update the streamer
- foreach(new i : Player)
- {
- if(IsPlayerInRangeOfPoint(i, 300.0, ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ])) Streamer_Update(i);
- }
- // Update the materials
- UpdateMaterial(index);
- // Update object text
- UpdateObjectText(index);
- if(ObjectData[index][oAttachedVehicle] > -1) UpdateAttachedVehicleObject(ObjectData[index][oAttachedVehicle], index, VEHICLE_REATTACH_UPDATE);
- // Save materials to material database
- sqlite_SaveMaterialIndex(index);
- // Save colors to material database
- sqlite_SaveColorIndex(index);
- // Save all text
- sqlite_SaveAllObjectText(index);
- return 1;
- }
- ClearCopyBuffer(playerid)
- {
- for(new i = 0; i < MAX_MATERIALS; i++)
- {
- CopyBuffer[playerid][cTexIndex][i] = 0;
- CopyBuffer[playerid][cColorIndex][i] = 0;
- CopyBuffer[playerid][cusetext] = 0;
- CopyBuffer[playerid][cFontFace] = 0;
- CopyBuffer[playerid][cFontSize] = 0;
- CopyBuffer[playerid][cFontBold] = 0;
- CopyBuffer[playerid][cFontColor] = 0;
- CopyBuffer[playerid][cBackColor] = 0;
- CopyBuffer[playerid][cAlignment] = 0;
- CopyBuffer[playerid][cTextFontSize] = 20;
- format(CopyBuffer[playerid][cObjectText], MAX_TEXT_LENGTH, "None");
- }
- return 1;
- }
- // Gets the mindex and tref from command arguments
- GetMaterials(playerid, arg[], &mindex, &tref)
- {
- if(sscanf(arg, "ii", mindex, tref))
- {
- SendClientMessage(playerid, STEALTH_YELLOW, "Usage: /mtset <material index> <texture array reference>");
- return 0;
- }
- if(mindex < 0 || mindex > MAX_MATERIALS - 1)
- {
- new line[128];
- format(line, sizeof(line), "The material selection must be between <0 - %i>", MAX_MATERIALS - 1);
- SendClientMessage(playerid, STEALTH_YELLOW, line);
- return 0;
- }
- if(tref < 0 || tref > MAX_TEXTURES - 1)
- {
- new line[128];
- format(line, sizeof(line), "The texture reference must be between <0 - %i>", MAX_TEXTURES - 1);
- SendClientMessage(playerid, STEALTH_YELLOW, line);
- return 0;
- }
- return 1;
- }
- // Set the materials for an object
- SetMaterials(index, mindex, tref)
- {
- // Set the texture
- ObjectData[index][oTexIndex][mindex] = tref;
- // Destroy the object
- DestroyDynamicObject(ObjectData[index][oID]);
- // Re-create object
- ObjectData[index][oID] = CreateDynamicObject(ObjectData[index][oModel], ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ], ObjectData[index][oRX], ObjectData[index][oRY], ObjectData[index][oRZ], MapSetting[mVirtualWorld], MapSetting[mInterior], -1, 300.0);
- Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[index][oID], E_STREAMER_DRAW_DISTANCE, 300.0);
- // Update streamer for all
- foreach(new i : Player) Streamer_UpdateEx(i, ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ]);
- // Update the materials
- UpdateMaterial(index);
- // Save this material index to the data base
- sqlite_SaveMaterialIndex(index);
- }
- YCMD:ogoto(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Moves camera to the current object's position.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- NoEditingMode(playerid);
- if(!InFlyMode(playerid))
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "You must be in flymode to use this command");
- return 1;
- }
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Moved to object currently being edited");
- SetFlyModePos(playerid, ObjectData[CurrObject[playerid]][oX], ObjectData[CurrObject[playerid]][oY], ObjectData[CurrObject[playerid]][oZ]);
- return 1;
- }
- // Set a color of an object
- YCMD:mtcolor(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Set the color of an object.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- if(GetEditMode(playerid) != EDIT_MODE_TEXTURING) NoEditingMode(playerid);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- new index = CurrObject[playerid];
- new mindex;
- new HexColor[12];
- sscanf(arg, "is[12]", mindex, HexColor);
- if(mindex < 0 || mindex > MAX_MATERIALS - 1)
- {
- new line[128];
- format(line, sizeof(line), "The material selection must be between <0 - %i>", MAX_MATERIALS - 1);
- return SendClientMessage(playerid, STEALTH_YELLOW, line);
- }
- if(IsHexValue(HexColor))
- {
- SaveUndoInfo(index, UNDO_TYPE_EDIT);
- // Set the color
- sscanf(HexColor, "h", ObjectData[index][oColorIndex][mindex]);
- // Destroy the object
- DestroyDynamicObject(ObjectData[index][oID]);
- // Re-create object
- ObjectData[index][oID] = CreateDynamicObject(ObjectData[index][oModel], ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ], ObjectData[index][oRX], ObjectData[index][oRY], ObjectData[index][oRZ], MapSetting[mVirtualWorld], MapSetting[mInterior], -1, 300.0);
- Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[index][oID], E_STREAMER_DRAW_DISTANCE, 300.0);
- // Update the materials
- UpdateMaterial(index);
- UpdateObjectText(index);
- if(ObjectData[index][oAttachedVehicle] > -1) UpdateAttachedVehicleObject(ObjectData[index][oAttachedVehicle], index, VEHICLE_REATTACH_UPDATE);
- // Save this material index to the data base
- sqlite_SaveColorIndex(index);
- // Update texture tool
- UpdateTextureSlot(playerid, mindex);
- // Update the streamer
- foreach(new i : Player)
- {
- if(IsPlayerInRangeOfPoint(i, 300.0, ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ])) Streamer_Update(i);
- }
- SendClientMessage(playerid, STEALTH_GREEN, "Changed Color");
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "Invalid hex color.");
- }
- return 1;
- }
- // Set a color of an object
- YCMD:mtcolorall(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Set the color of all objects of the same model.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- new index = CurrObject[playerid];
- new mindex;
- new HexColor[12];
- sscanf(arg, "is[12]", mindex, HexColor);
- if(mindex < 0 || mindex > MAX_MATERIALS - 1)
- {
- new line[128];
- format(line, sizeof(line), "The material selection must be between <0 - %i>", MAX_MATERIALS - 1);
- return SendClientMessage(playerid, STEALTH_YELLOW, line);
- }
- if(IsHexValue(HexColor))
- {
- new hcolor;
- sscanf(HexColor, "h", hcolor);
- new time = GetTickCount();
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- if(ObjectData[i][oModel] == ObjectData[CurrObject[playerid]][oModel])
- {
- SaveUndoInfo(i, UNDO_TYPE_EDIT, time);
- ObjectData[i][oColorIndex][mindex] = hcolor;
- // Destroy the object
- DestroyDynamicObject(ObjectData[i][oID]);
- // Re-create object
- ObjectData[i][oID] = CreateDynamicObject(ObjectData[i][oModel], ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ], ObjectData[i][oRX], ObjectData[i][oRY], ObjectData[i][oRZ], MapSetting[mVirtualWorld], MapSetting[mInterior], -1, 300.0);
- Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[i][oID], E_STREAMER_DRAW_DISTANCE, 300.0);
- // Update the materials
- UpdateMaterial(i);
- UpdateObjectText(i);
- if(ObjectData[i][oAttachedVehicle] > -1) UpdateAttachedVehicleObject(ObjectData[i][oAttachedVehicle], i, VEHICLE_REATTACH_UPDATE);
- // Save this material index to the data base
- sqlite_SaveColorIndex(i);
- }
- }
- db_end_transaction(EditMap);
-
- // Update the streamer
- foreach(new i : Player)
- {
- if(IsPlayerInRangeOfPoint(i, 300.0, ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ])) Streamer_Update(i);
- }
- SendClientMessage(playerid, STEALTH_GREEN, "Changed All Color");
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "Invalid hex color.");
- }
- return 1;
- }
- YCMD:oswap(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Change the model of current object.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- new id = strval(arg);
- if(id > 0 && id < 20000)
- {
- new index = CurrObject[playerid];
- ObjectData[index][oModel] = id;
- SaveUndoInfo(index, UNDO_TYPE_EDIT);
- // Destroy the object
- DestroyDynamicObject(ObjectData[index][oID]);
- // Re-create object
- ObjectData[index][oID] = CreateDynamicObject(ObjectData[index][oModel], ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ], ObjectData[index][oRX], ObjectData[index][oRY], ObjectData[index][oRZ], MapSetting[mVirtualWorld], MapSetting[mInterior], -1, 300.0);
- Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[index][oID], E_STREAMER_DRAW_DISTANCE, 300.0);
- // Update streamer for all
- foreach(new i : Player) Streamer_UpdateEx(i, ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ]);
- // Update the materials
- UpdateMaterial(index);
- // Update the text
- UpdateObjectText(index);
- // Save changes to database
- sqlite_ObjModel(index);
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "Invalid Model");
- return 1;
- }
- // Reset all materials
- YCMD:mtreset(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Reset all materials and colors of current object.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- new index = CurrObject[playerid];
- SaveUndoInfo(index, UNDO_TYPE_EDIT);
- for(new i = 0; i < MAX_MATERIALS; i++)
- {
- ObjectData[index][oTexIndex][i] = 0;
- ObjectData[index][oColorIndex][i] = 0;
- UpdateTextureSlot(playerid, i);
- }
- UpdateMaterial(index);
- sqlite_SaveMaterialIndex(index);
- sqlite_SaveColorIndex(index);
- return 1;
- }
- // Enter edit mode
- YCMD:editobject(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Edit current object.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- if(ObjectData[CurrObject[playerid]][oAttachedVehicle] > -1) return EditVehicleObject(playerid);
- if(!EditingMode[playerid])
- {
- EditingMode[playerid] = true;
- SetEditMode(playerid, EDIT_MODE_OBJECT);
- EditDynamicObject(playerid, ObjectData[CurrObject[playerid]][oID]);
- SendClientMessage(playerid, STEALTH_GREEN, "Entered Edit Object Mode");
- CurrEditPos[playerid][0] = ObjectData[CurrObject[playerid]][oX];
- CurrEditPos[playerid][1] = ObjectData[CurrObject[playerid]][oY];
- CurrEditPos[playerid][2] = ObjectData[CurrObject[playerid]][oZ];
- CurrEditPos[playerid][3] = ObjectData[CurrObject[playerid]][oRX];
- CurrEditPos[playerid][4] = ObjectData[CurrObject[playerid]][oRY];
- CurrEditPos[playerid][5] = ObjectData[CurrObject[playerid]][oRZ];
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "You are in editing mode already");
- return 1;
- }
- // Create an object
- YCMD:cobject(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Creates an object and selects it.");
- return 1;
- }
- MapOpenCheck();
- NoEditingMode(playerid);
- new modelid;
- if(sscanf(arg, "i", modelid))
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "Usage: /cobject <modelid>");
- return 1;
- }
- // Set the initial object position
- new Float:px, Float:py, Float:pz, Float:fa;
- // Find the size of the object
- new Float:colradius = GetColSphereRadius(modelid);
- // Place in front of the player using collision radius
- GetPosFaInFrontOfPlayer(playerid, colradius + 1.0, px, py, pz, fa);
- pz -= 1.0;
- // Create the object
- SetCurrObject(playerid, AddDynamicObject(modelid, px, py, pz, 0.0, 0.0, 0.0));
- // Create 3D label
- UpdateObject3DText(CurrObject[playerid], true);
- // Object was created
- if(CurrObject[playerid] != -1)
- {
- // Update the streamer for this player
- Streamer_Update(playerid);
- SaveUndoInfo(CurrObject[playerid], UNDO_TYPE_CREATED);
- // Show output message
- new line[128];
- new modelarray = GetModelArray(modelid);
- if(modelarray > -1) format(line, sizeof(line), "Created Object Index: %i Model Name: %s", CurrObject[playerid], GetModelName(modelarray));
- else format(line, sizeof(line), "Created Object Index: %i Model Name: Unknown", CurrObject[playerid]);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, line);
- }
- // Too many objects already created
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "You have too many objects created to create anymore!");
- }
- return 1;
- }
- YCMD:dobject(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Destroys current object and deselects it.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- NoEditingMode(playerid);
- SaveUndoInfo(CurrObject[playerid], UNDO_TYPE_DELETED);
- DeleteDynamicObject(CurrObject[playerid]);
- foreach(new i : Player)
- {
- if(CurrObject[playerid] == CurrObject[i]) SetCurrObject(i, -1);
- }
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Your object has been destroyed");
- return 1;
- }
- YCMD:rotreset(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Reset all rotation axes of current object.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- NoEditingMode(playerid);
- ObjectData[CurrObject[playerid]][oRX] = 0.0;
- ObjectData[CurrObject[playerid]][oRY] = 0.0;
- ObjectData[CurrObject[playerid]][oRZ] = 0.0;
- SetDynamicObjectRot(ObjectData[CurrObject[playerid]][oID], ObjectData[CurrObject[playerid]][oRX], ObjectData[CurrObject[playerid]][oRY], ObjectData[CurrObject[playerid]][oRZ]);
- sqlite_UpdateObjectPos(CurrObject[playerid]);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Your objects rotation has been reset");
- return 1;
- }
- // Resets an objects materials and text
- YCMD:robject(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Reset all materials, colors, and text of current object.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- NoEditingMode(playerid);
- new index = CurrObject[playerid];
- for(new i = 0; i < MAX_MATERIALS; i++)
- {
- ObjectData[index][oTexIndex][i] = 0;
- ObjectData[index][oColorIndex][i] = 0;
- }
- ObjectData[index][ousetext] = 0;
- ObjectData[index][oFontFace] = 0;
- ObjectData[index][oFontSize] = 0;
- ObjectData[index][oFontBold] = 0;
- ObjectData[index][oFontColor] = 0;
- ObjectData[index][oBackColor] = 0;
- ObjectData[index][oAlignment] = 0;
- ObjectData[index][oTextFontSize] = 20;
- format(ObjectData[index][oObjectText], MAX_TEXT_LENGTH, "None");
- DestroyDynamicObject(ObjectData[index][oID]);
- ObjectData[index][oID] = CreateDynamicObject(ObjectData[index][oModel], ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ], ObjectData[index][oRX], ObjectData[index][oRY], ObjectData[index][oRZ], MapSetting[mVirtualWorld], MapSetting[mInterior], -1, 300.0);
- Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[index][oID], E_STREAMER_DRAW_DISTANCE, 300.0);
- sqlite_SaveColorIndex(index);
- sqlite_SaveMaterialIndex(index);
- sqlite_ObjUseText(index);
- sqlite_ObjFontFace(index);
- sqlite_ObjFontSize(index);
- sqlite_ObjFontBold(index);
- sqlite_ObjFontColor(index);
- sqlite_ObjBackColor(index);
- sqlite_ObjAlignment(index);
- sqlite_ObjFontTextSize(index);
- sqlite_ObjObjectText(index);
- // Update the streamer
- foreach(new i : Player)
- {
- if(IsPlayerInRangeOfPoint(i, 300.0, ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ])) Streamer_Update(i);
- }
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Reset object materials and text");
- return 1;
- }
- // Loops through all indexes and labels them with object text
- enum INDEXCOLORINFO { FaceColor, BackColor }
- stock const ShowIndexColors[MAX_MATERIALS][INDEXCOLORINFO] = {
- { 0xFFFFFF66, 0xFF00FF33 }, // { 0xFF000000, 0xFFFFFFFF },
- { 0xFFFFFF66, 0xFF00FF33 }, // { 0xFF800000, 0xFFFFFFFF },
- { 0xFFFFFF66, 0xFF00FF33 }, // { 0xFF008000, 0xFFFFFFFF },
- { 0xFFFFFF66, 0xFF00FF33 }, // { 0xFF000080, 0xFFFFFFFF },
- { 0xFFFFFF66, 0xFF00FF33 }, // { 0xFFC0C0C0, 0xFF000000 },
- { 0xFFFFFF66, 0xFF00FF33 }, // { 0xFFFF0000, 0xFF000000 },
- { 0xFFFFFF66, 0xFF00FF33 }, // { 0xFF00FF00, 0xFF000000 },
- { 0xFFFFFF66, 0xFF00FF33 }, // { 0xFF0000FF, 0xFF000000 },
- { 0xFFFFFF66, 0xFF00FF33 }, // { 0xFF808080, 0xFFFFFFFF },
- { 0xFFFFFF66, 0xFF00FF33 }, // { 0xFF800080, 0xFFFFFFFF },
- { 0xFFFFFF66, 0xFF00FF33 }, // { 0xFF808000, 0xFFFFFFFF },
- { 0xFFFFFF66, 0xFF00FF33 }, // { 0xFF008080, 0xFFFFFFFF },
- { 0xFFFFFF66, 0xFF00FF33 }, // { 0xFFFFFFFF, 0xFF000000 },
- { 0xFFFFFF66, 0xFF00FF33 }, // { 0xFFFF00FF, 0xFF000000 },
- { 0xFFFFFF66, 0xFF00FF33 }, // { 0xFFFFFF00, 0xFF000000 },
- { 0xFFFFFF66, 0xFF00FF33 } // { 0xFF00FFFF, 0xFF000000 }
- };
- YCMD:sindex(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Display texture slots of current object.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- // NoEditingMode(playerid);
- new size;
- if(isnull(arg)) size = 20;
- else size = strval(arg);
- if(size < 0 || size > 200) size = 20;
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Labelling your objects with text corresponding to index (/rindex to turn off label)");
- new line[8];
- for(new i = 0; i < MAX_MATERIALS; i++)
- {
- format(line, sizeof(line), "%i", i);
- SetDynamicObjectMaterialText(ObjectData[CurrObject[playerid]][oID],
- i,
- line,
- 10,
- "Ariel",
- size,
- 1,
- ShowIndexColors[i][FaceColor],
- ShowIndexColors[i][BackColor],
- 1);
- }
- return 1;
- }
- // Restores an object to it's original form
- YCMD:rindex(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Restore objects textures after displaying texture slots.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- // NoEditingMode(playerid);
- new index = CurrObject[playerid];
- // Destroy the object
- DestroyDynamicObject(ObjectData[index][oID]);
- // Re-create object
- ObjectData[index][oID] = CreateDynamicObject(ObjectData[index][oModel], ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ], ObjectData[index][oRX], ObjectData[index][oRY], ObjectData[index][oRZ], MapSetting[mVirtualWorld], MapSetting[mInterior], -1, 300.0);
- Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[index][oID], E_STREAMER_DRAW_DISTANCE, 300.0);
- // Update the streamer
- foreach(new i : Player)
- {
- if(IsPlayerInRangeOfPoint(i, 300.0, ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ])) Streamer_Update(i);
- }
- // Update the materials
- UpdateMaterial(index);
- // Update object text
- UpdateObjectText(index);
- if(ObjectData[index][oAttachedVehicle] > -1) UpdateAttachedVehicleObject(ObjectData[index][oAttachedVehicle], index, VEHICLE_REATTACH_UPDATE);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Reset current objects labels");
- return 1;
- }
- // Get information on a model
- YCMD:minfo(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "See information on the provided model ID.");
- return 1;
- }
-
- new model = strval(arg);
- if(isnull(arg) || !(0 <= model <= 19999)) {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "Usage: /minfo <ID [0-19999]>");
- return 1;
- }
-
- new Float:r = Float:GetColSphereRadius(model),
- Float:rOff[3], Float:Min[3], Float:Max[3];
-
- GetColSphereOffset(model, rOff[0], rOff[1], rOff[2]);
- GetModelBoundingBox(model, Min[0], Min[1], Min[2], Max[0], Max[1], Max[2]);
-
- new buffer[1024];
- strcat(buffer, sprintf("Bounding Sphere\n\tRadius: %f\n\tRadius Offset: %f, %f, %f\n\n",
- r, rOff[0], rOff[1], rOff[2]));
- strcat(buffer, sprintf("Axis Alligned Bounding Box\n\tMinimum: %f, %f, %f\n\t",
- Min[0], Min[1], Min[2]));
- strcat(buffer, sprintf("Maximun: %f, %f, %f\n\t",
- Max[0], Max[1], Max[2]));
- strcat(buffer, sprintf("Dimensions: %f, %f, %f",
- floatabs(Min[0] - Max[0]), floatabs(Min[1] - Max[1]), floatabs(Min[2] - Max[2])));
-
- Dialog_Show(
- playerid, DIALOG_STYLE_MSGBOX,
- sprintf("Model Information: %i", model),
- buffer,
- "Okay"
- );
- return 1;
- }
- // Set a pivot point
- YCMD:pivot(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Set the desired pivot to rotate around.");
- return 1;
- }
- MapOpenCheck();
- NoEditingMode(playerid);
- new Float:x, Float:y, Float:z, Float:fa;
- GetPosFaInFrontOfPlayer(playerid, 2.0, x, y, z, fa);
- PivotObject[playerid] = CreateDynamicObject(1974, x, y, z, 0.0, 0.0, 0.0, -1, -1, playerid);
- Streamer_SetFloatData(STREAMER_TYPE_OBJECT, PivotObject[playerid], E_STREAMER_DRAW_DISTANCE, 3000.0);
- SetDynamicObjectMaterial(PivotObject[playerid], 0, 10765, "airportgnd_sfse", "white", -256);
- Streamer_Update(playerid);
- EditingMode[playerid] = true;
- SetEditMode(playerid, EDIT_MODE_PIVOT);
- EditDynamicObject(playerid, PivotObject[playerid]);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Editing your pivot point");
- return 1;
- }
- YCMD:togpivot(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Toggle pivot rotation.");
- return 1;
- }
- MapOpenCheck();
- if(PivotPointOn[playerid])
- {
- PivotPointOn[playerid] = false;
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Pivot point turned off");
- }
- else
- {
- PivotPointOn[playerid] = true;
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Pivot point turned on");
- }
- return 1;
- }
- // Move object on X axis
- YCMD:ox(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Move current object along the X axis.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- NoEditingMode(playerid);
- new Float:dist;
- dist = floatstr(arg);
- if(dist == 0) dist = 1.0;
- SaveUndoInfo(CurrObject[playerid], UNDO_TYPE_EDIT);
- ObjectData[CurrObject[playerid]][oX] += dist;
- SetDynamicObjectPos(ObjectData[CurrObject[playerid]][oID], ObjectData[CurrObject[playerid]][oX], ObjectData[CurrObject[playerid]][oY], ObjectData[CurrObject[playerid]][oZ]);
- UpdateObject3DText(CurrObject[playerid]);
- sqlite_UpdateObjectPos(CurrObject[playerid]);
- return 1;
- }
- // Move object on Y axis
- YCMD:oy(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Move current object along the Y axis.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- NoEditingMode(playerid);
- new Float:dist;
- dist = floatstr(arg);
- if(dist == 0) dist = 1.0;
- SaveUndoInfo(CurrObject[playerid], UNDO_TYPE_EDIT);
- ObjectData[CurrObject[playerid]][oY] += dist;
- SetDynamicObjectPos(ObjectData[CurrObject[playerid]][oID], ObjectData[CurrObject[playerid]][oX], ObjectData[CurrObject[playerid]][oY], ObjectData[CurrObject[playerid]][oZ]);
- UpdateObject3DText(CurrObject[playerid]);
- sqlite_UpdateObjectPos(CurrObject[playerid]);
- return 1;
- }
- // Move object on Z axis
- YCMD:oz(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Move current object along the Z axis.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- NoEditingMode(playerid);
- new Float:dist;
- dist = floatstr(arg);
- if(dist == 0) dist = 1.0;
- SaveUndoInfo(CurrObject[playerid], UNDO_TYPE_EDIT);
- ObjectData[CurrObject[playerid]][oZ] += dist;
- SetDynamicObjectPos(ObjectData[CurrObject[playerid]][oID], ObjectData[CurrObject[playerid]][oX], ObjectData[CurrObject[playerid]][oY], ObjectData[CurrObject[playerid]][oZ]);
- UpdateObject3DText(CurrObject[playerid]);
- sqlite_UpdateObjectPos(CurrObject[playerid]);
- return 1;
- }
- // Move object on RX rot
- YCMD:rx(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Rotate currently object around the X axis.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- NoEditingMode(playerid);
- new Float:rot;
- rot = floatstr(arg);
- if(rot == 0) rot = 5.0;
- SaveUndoInfo(CurrObject[playerid], UNDO_TYPE_EDIT);
- if(PivotPointOn[playerid])
- {
- new i = CurrObject[playerid];
- AttachObjectToPoint(i, PivotPoint[playerid][xPos], PivotPoint[playerid][yPos], PivotPoint[playerid][zPos], rot, 0.0, 0.0, ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ], ObjectData[i][oRX], ObjectData[i][oRY], ObjectData[i][oRZ]);
- SetDynamicObjectPos(ObjectData[i][oID], ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ]);
- SetDynamicObjectRot(ObjectData[i][oID], ObjectData[i][oRX], ObjectData[i][oRY], ObjectData[i][oRZ]);
- UpdateObject3DText(CurrObject[playerid]);
- }
- else
- {
- ObjectData[CurrObject[playerid]][oRX] += rot;
- SetDynamicObjectRot(ObjectData[CurrObject[playerid]][oID], ObjectData[CurrObject[playerid]][oRX], ObjectData[CurrObject[playerid]][oRY], ObjectData[CurrObject[playerid]][oRZ]);
- }
- sqlite_UpdateObjectPos(CurrObject[playerid]);
- return 1;
- }
- // Move object on RX rot
- YCMD:ry(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Rotate currently object around the Y axis.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- NoEditingMode(playerid);
- new Float:rot;
- rot = floatstr(arg);
- if(rot == 0) rot = 5.0;
- SaveUndoInfo(CurrObject[playerid], UNDO_TYPE_EDIT);
- if(PivotPointOn[playerid])
- {
- new i = CurrObject[playerid];
- AttachObjectToPoint(i, PivotPoint[playerid][xPos], PivotPoint[playerid][yPos], PivotPoint[playerid][zPos], 0.0, rot, 0.0, ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ], ObjectData[i][oRX], ObjectData[i][oRY], ObjectData[i][oRZ]);
- SetDynamicObjectPos(ObjectData[i][oID], ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ]);
- SetDynamicObjectRot(ObjectData[i][oID], ObjectData[i][oRX], ObjectData[i][oRY], ObjectData[i][oRZ]);
- UpdateObject3DText(CurrObject[playerid]);
- }
- else
- {
- ObjectData[CurrObject[playerid]][oRY] += rot;
- SetDynamicObjectRot(ObjectData[CurrObject[playerid]][oID], ObjectData[CurrObject[playerid]][oRX], ObjectData[CurrObject[playerid]][oRY], ObjectData[CurrObject[playerid]][oRZ]);
- }
- sqlite_UpdateObjectPos(CurrObject[playerid]);
- return 1;
- }
- // Move object on RX rot
- YCMD:rz(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Rotate currently object around the Z axis.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- NoEditingMode(playerid);
- new Float:rot;
- rot = floatstr(arg);
- if(rot == 0) rot = 5.0;
- SaveUndoInfo(CurrObject[playerid], UNDO_TYPE_EDIT);
- if(PivotPointOn[playerid])
- {
- new i = CurrObject[playerid];
- AttachObjectToPoint(i, PivotPoint[playerid][xPos], PivotPoint[playerid][yPos], PivotPoint[playerid][zPos], 0.0, 0.0, rot, ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ], ObjectData[i][oRX], ObjectData[i][oRY], ObjectData[i][oRZ]);
- SetDynamicObjectPos(ObjectData[i][oID], ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ]);
- SetDynamicObjectRot(ObjectData[i][oID], ObjectData[i][oRX], ObjectData[i][oRY], ObjectData[i][oRZ]);
- UpdateObject3DText(CurrObject[playerid]);
- }
- else
- {
- ObjectData[CurrObject[playerid]][oRZ] += rot;
- SetDynamicObjectRot(ObjectData[CurrObject[playerid]][oID], ObjectData[CurrObject[playerid]][oRX], ObjectData[CurrObject[playerid]][oRY], ObjectData[CurrObject[playerid]][oRZ]);
- }
- sqlite_UpdateObjectPos(CurrObject[playerid]);
- return 1;
- }
- // Move all objects on X axis
- YCMD:dox(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Move all loaded objects along the X axis.");
- return 1;
- }
- MapOpenCheck();
- NoEditingMode(playerid);
- new Float:dist, time;
- time = GetTickCount();
- dist = floatstr(arg);
- if(dist == 0) dist = 1.0;
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- SaveUndoInfo(i, UNDO_TYPE_EDIT, time);
- ObjectData[i][oX] += dist;
- SetDynamicObjectPos(ObjectData[i][oID], ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ]);
- UpdateObject3DText(i);
- sqlite_UpdateObjectPos(i);
- }
- db_end_transaction(EditMap);
- return 1;
- }
- // Move all objects on Y axis
- YCMD:doy(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Move all loaded objects along the Y axis.");
- return 1;
- }
- MapOpenCheck();
- NoEditingMode(playerid);
- new Float:dist, time;
- time = GetTickCount();
- dist = floatstr(arg);
- if(dist == 0) dist = 1.0;
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- SaveUndoInfo(i, UNDO_TYPE_EDIT, time);
- ObjectData[i][oY] += dist;
- SetDynamicObjectPos(ObjectData[i][oID], ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ]);
- UpdateObject3DText(i);
- sqlite_UpdateObjectPos(i);
- }
- db_end_transaction(EditMap);
- return 1;
- }
- // Move all objects on Z axis
- YCMD:doz(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Move all loaded objects along the Z axis.");
- return 1;
- }
- MapOpenCheck();
- NoEditingMode(playerid);
- new Float:dist, time;
- time = GetTickCount();
- dist = floatstr(arg);
- if(dist == 0) dist = 1.0;
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- SaveUndoInfo(i, UNDO_TYPE_EDIT, time);
- ObjectData[i][oZ] += dist;
- SetDynamicObjectPos(ObjectData[i][oID], ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ]);
- UpdateObject3DText(i);
- sqlite_UpdateObjectPos(i);
- }
- db_end_transaction(EditMap);
- return 1;
- }
- // Rotate map on RX
- YCMD:drx(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Rotate all loaded objects around the X axis.");
- return 1;
- }
- MapOpenCheck();
- new Float:Delta, time;
- time = GetTickCount();
- if(isnull(arg)) Delta = 1.0;
- else if(sscanf(arg, "f", Delta))
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "Usage: /drx <rotation> ");
- return 1;
- }
- // We need to get the map center as the rotation node
- new Float:mCenterX, Float:mCenterY, Float:mCenterZ;
- if(GetMapCenter(mCenterX, mCenterY, mCenterZ))
- {
- // Loop through all objects and perform rotation calculations
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- SaveUndoInfo(i, UNDO_TYPE_EDIT, time);
- AttachObjectToPoint(i, mCenterX, mCenterY, mCenterZ, Delta, 0.0, 0.0, ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ], ObjectData[i][oRX], ObjectData[i][oRY], ObjectData[i][oRZ]);
- SetDynamicObjectPos(ObjectData[i][oID], ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ]);
- SetDynamicObjectRot(ObjectData[i][oID], ObjectData[i][oRX], ObjectData[i][oRY], ObjectData[i][oRZ]);
- UpdateObject3DText(i);
- sqlite_UpdateObjectPos(i);
- }
- db_end_transaction(EditMap);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Map RX rotation complete ");
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "There is not enough objects for this command to work");
- }
- return 1;
- }
- // Rotate map on RY
- YCMD:dry(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Rotate all loaded objects around the Y axis.");
- return 1;
- }
- MapOpenCheck();
- new Float:Delta, time;
- time = GetTickCount();
- if(isnull(arg)) Delta = 1.0;
- else if(sscanf(arg, "f", Delta))
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "Usage: /dry <rotation> ");
- return 1;
- }
- // We need to get the map center as the rotation node
- new Float:mCenterX, Float:mCenterY, Float:mCenterZ;
- if(GetMapCenter(mCenterX, mCenterY, mCenterZ))
- {
- // Loop through all objects and perform rotation calculations
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- SaveUndoInfo(i, UNDO_TYPE_EDIT, time);
- AttachObjectToPoint(i, mCenterX, mCenterY, mCenterZ, 0.0, Delta, 0.0, ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ], ObjectData[i][oRX], ObjectData[i][oRY], ObjectData[i][oRZ]);
- SetDynamicObjectPos(ObjectData[i][oID], ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ]);
- SetDynamicObjectRot(ObjectData[i][oID], ObjectData[i][oRX], ObjectData[i][oRY], ObjectData[i][oRZ]);
- UpdateObject3DText(i);
- sqlite_UpdateObjectPos(i);
- }
- db_end_transaction(EditMap);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Map RY rotation complete ");
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "There is not enough objects for this command to work");
- }
- return 1;
- }
- // Rotate map on RZ
- YCMD:drz(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Rotate all loaded objects around the Z axis.");
- return 1;
- }
- MapOpenCheck();
- new Float:Delta, time;
- time = GetTickCount();
- if(isnull(arg)) Delta = 1.0;
- else if(sscanf(arg, "f", Delta))
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "Usage: /drz <rotation> ");
- return 1;
- }
- // We need to get the map center as the rotation node
- new Float:mCenterX, Float:mCenterY, Float:mCenterZ;
- if(GetMapCenter(mCenterX, mCenterY, mCenterZ))
- {
- // Loop through all objects and perform rotation calculations
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- SaveUndoInfo(i, UNDO_TYPE_EDIT, time);
- AttachObjectToPoint(i, mCenterX, mCenterY, mCenterZ, 0.0, 0.0, Delta, ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ], ObjectData[i][oRX], ObjectData[i][oRY], ObjectData[i][oRZ]);
- SetDynamicObjectPos(ObjectData[i][oID], ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ]);
- SetDynamicObjectRot(ObjectData[i][oID], ObjectData[i][oRX], ObjectData[i][oRY], ObjectData[i][oRZ]);
- UpdateObject3DText(i);
- sqlite_UpdateObjectPos(i);
- }
- db_end_transaction(EditMap);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Map RZ rotation complete ");
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "There is not enough objects for this command to work");
- }
- return 1;
- }
- YCMD:odd(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Set a specific object's draw distance.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- NoEditingMode(playerid);
- new Float:dd;
- dd = floatstr(arg);
- if(dd == 0.0) dd = 300.0;
- SaveUndoInfo(CurrObject[playerid], UNDO_TYPE_EDIT);
- ObjectData[CurrObject[playerid]][oDD] = dd;
- Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[CurrObject[playerid]][oID], E_STREAMER_DRAW_DISTANCE, dd);
- Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[CurrObject[playerid]][oID], E_STREAMER_STREAM_DISTANCE, dd);
- sqlite_UpdateObjectDD(CurrObject[playerid]);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, sprintf("Objects draw distance set to %.2f", dd));
-
- return 1;
- }
- // Extras
- YCMD:hidetext3d(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Hide all 3D text labels.");
- return 1;
- }
- TextOption[tShowText] = false;
-
- HideGroupLabels(playerid);
- HideObjectText();
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "All 3D Text labels hidden");
- return 1;
- }
- YCMD:showtext3d(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Show all 3D text labels.");
- return 1;
- }
-
- /*/Experimental Multiplier
- new Float:mult = floatstr(arg);
- if(0.0 < mult <= 1.0)
- Streamer_SetRadiusMultiplier(STREAMER_TYPE_3D_TEXT_LABEL, mult, playerid);
- else if(mult) {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Invalid multiplier specified, must be between 0.0 and 1.0");
- return 1;
- }
- else
- Streamer_SetRadiusMultiplier(STREAMER_TYPE_3D_TEXT_LABEL, 1.0, playerid);*/
-
- TextOption[tShowText] = true;
-
- ShowGroupLabels(playerid);
- ShowObjectText();
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "All 3D Text labels shown");
- return 1;
- }
- YCMD:edittext3d(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Shows you a dialog with 3D text options.");
- return 1;
- }
-
- new optline[256];
-
- // Init the text menu
- inline SelectOption(spid, sdialogid, sresponse, slistitem, string:stext[])
- {
- #pragma unused slistitem, sdialogid, spid, stext
- if(sresponse)
- {
- // Toggle the selected option
- TextOption[TEXTOPTIONS:slistitem] = !TextOption[TEXTOPTIONS:slistitem];
-
- // Toggled text?
- if(slistitem == 0)
- {
- if(TextOption[tShowText])
- {
- ShowGroupLabels(playerid);
- ShowObjectText();
- }
- else
- {
- HideGroupLabels(playerid);
- HideObjectText();
- }
- }
-
- // Show it again
- format(optline, sizeof(optline), "{FFFF00}Text: %s\n{FFFF00}Object Note: %s\n{FFFF00}Model Info: %s\n{FFFF00}Group ID: %s\n{FFFF00}Grouped Text: %s\n{FFFF00}Always Show New Objects: %s\n",
- (TextOption[tShowText] ? ("{00AA00}Enabled") : ("{FF3000}Disabled")),
- (TextOption[tShowNote] ? ("{00AA00}Enabled") : ("{FF3000}Disabled")),
- (TextOption[tShowModel] ? ("{00AA00}Enabled") : ("{FF3000}Disabled")),
- (TextOption[tShowGroup] ? ("{00AA00}Enabled") : ("{FF3000}Disabled")),
- (TextOption[tShowGrouped] ? ("{00AA00}Enabled") : ("{FF3000}Disabled")),
- (TextOption[tAlwaysShowNew] ? ("{00AA00}Enabled") : ("{FF3000}Disabled"))
- );
-
- Dialog_ShowCallback(playerid, using inline SelectOption, DIALOG_STYLE_LIST, "Texture Studio - 3D Text Editor", optline, "Ok", "Cancel");
- }
- }
-
- // Show the dialog
- format(optline, sizeof(optline), "{FFFF00}Text: %s\n{FFFF00}Object Note: %s\n{FFFF00}Model Info: %s\n{FFFF00}Group ID: %s\n{FFFF00}Grouped Text: %s\n{FFFF00}Always Show New Objects: %s\n",
- (TextOption[tShowText] ? ("{00AA00}Enabled") : ("{FF3000}Disabled")),
- (TextOption[tShowNote] ? ("{00AA00}Enabled") : ("{FF3000}Disabled")),
- (TextOption[tShowModel] ? ("{00AA00}Enabled") : ("{FF3000}Disabled")),
- (TextOption[tShowGroup] ? ("{00AA00}Enabled") : ("{FF3000}Disabled")),
- (TextOption[tShowGrouped] ? ("{00AA00}Enabled") : ("{FF3000}Disabled")),
- (TextOption[tAlwaysShowNew] ? ("{00AA00}Enabled") : ("{FF3000}Disabled"))
- );
- Dialog_ShowCallback(playerid, using inline SelectOption, DIALOG_STYLE_LIST, "Texture Studio - 3D Text Editor", optline, "Ok", "Cancel");
- return 1;
- }
- YCMD:note(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Show or change an object's note.");
- return 1;
- }
-
- MapOpenCheck();
-
- new index, note[64];
- if(sscanf(arg, "iS()[64]", index, note))
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "Usage: /note <Index> <Optional: New Note>");
- return 1;
- }
-
- if(isnull(note) || !strlen(note))
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, sprintf("Object's note: %s", ObjectData[index][oNote]));
- }
- else
- {
- SaveUndoInfo(index, UNDO_TYPE_EDIT);
- format(ObjectData[index][oNote], 64, "%s", note);
- sqlite_ObjNote(index);
- UpdateObject3DText(index);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "Note changed");
- }
- return 1;
- }
- YCMD:setspawn(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Set this map's spawn position to your current position.");
- return 1;
- }
-
- MapOpenCheck();
-
- GetPlayerPos(playerid, MapSetting[mSpawn][xPos], MapSetting[mSpawn][yPos], MapSetting[mSpawn][zPos]);
- sqlite_UpdateSettings();
-
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, sprintf("You have set the map's spawn position to (%0.2f, %0.2f, %0.2f)", MapSetting[mSpawn][xPos], MapSetting[mSpawn][yPos], MapSetting[mSpawn][zPos]));
- return 1;
- }
- YCMD:gotomap(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Sends you to this map's spawn position.");
- return 1;
- }
-
- if(MapSetting[mSpawn][xPos] == 0.0)
- return SendClientMessage(playerid, STEALTH_YELLOW, "This map doesn't have a spawn position, set one with \"/setspawn\"");
-
- SetPlayerPos(playerid, MapSetting[mSpawn][xPos], MapSetting[mSpawn][yPos], MapSetting[mSpawn][zPos]);
-
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "You've been teleported to the map's spawn position");
- return 1;
- }
- HideObjectText()
- {
- foreach(new i : Objects)
- {
- UpdateDynamic3DTextLabelText(ObjectData[i][oTextID], 0, "");
- }
- return 1;
- }
- ShowObjectText()
- {
- foreach(new i : Objects)
- {
- UpdateObject3DText(i, false);
- }
- return 1;
- }
- YCMD:stopedit(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Reset editing mode.");
- return 1;
- }
- MapOpenCheck();
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- if(EditingMode[playerid])
- {
- EditingMode[playerid] = false;
- CancelEdit(playerid);
- SendClientMessage(playerid, STEALTH_GREEN, "Editing mode reset.");
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "You're not editing.");
- return 1;
- }
|