| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399 |
- // Group objects
- new Text3D:GroupObjectText[MAX_PLAYERS][MAX_TEXTURE_OBJECTS];
- new bool:GroupedObjects[MAX_PLAYERS][MAX_TEXTURE_OBJECTS];
- new Float:PivotOffset[MAX_PLAYERS][XYZ];
- new Float:LastPivot[MAX_PLAYERS][XYZR];
- new Float:LastGroupPosition[MAX_PLAYERS][XYZ];
- new bool:PivotReset[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- for(new j = 0; j < MAX_TEXTURE_OBJECTS; j++)
- {
- GroupObjectText[i][j] = Text3D:-1;
- }
- }
- #if defined GR_OnFilterScriptInit
- GR_OnFilterScriptInit();
- #endif
- return 1;
- }
- #if defined _ALS_OnFilterScriptInit
- #undef OnFilterScriptInit
- #else
- #define _ALS_OnFilterScriptInit
- #endif
- #define OnFilterScriptInit GR_OnFilterScriptInit
- #if defined GR_OnFilterScriptInit
- forward GR_OnFilterScriptInit();
- #endif
- public OnPlayerDisconnect(playerid, reason)
- {
- for(new i = 0; i < MAX_TEXTURE_OBJECTS; i++)
- {
- if(_:GroupObjectText[playerid][i])
- {
- DestroyDynamic3DTextLabel(GroupObjectText[playerid][i]);
- GroupObjectText[playerid][i] = Text3D:-1;
- }
- }
- ClearGroup(playerid);
- #if defined GR_OnPlayerDisconnect
- GR_OnPlayerDisconnect(playerid, reason);
- #endif
- return 1;
- }
- #if defined _ALS_OnPlayerDisconnect
- #undef OnPlayerDisconnect
- #else
- #define _ALS_OnPlayerDisconnect
- #endif
- #define OnPlayerDisconnect GR_OnPlayerDisconnect
- #if defined GR_OnPlayerDisconnect
- forward GR_OnPlayerDisconnect(playerid, reason);
- #endif
- HideGroupLabels(playerid)
- {
- for(new i = 0; i < MAX_TEXTURE_OBJECTS; i++)
- {
- if(_:GroupObjectText[playerid][i])
- {
- UpdateDynamic3DTextLabelText(GroupObjectText[playerid][i], 0, "");
- }
- }
- }
- ShowGroupLabels(playerid)
- {
- for(new i = 0; i < MAX_TEXTURE_OBJECTS; i++)
- {
- if(_:GroupObjectText[playerid][i])
- {
- UpdateDynamic3DTextLabelText(GroupObjectText[playerid][i], 0x7D26CDFF, "Grouped");
- }
- }
- }
- public OnUpdateGroup3DText(index)
- {
- foreach(new i : Player)
- {
- if(_:GroupObjectText[i][index] != -1)
- {
- DestroyDynamic3DTextLabel(GroupObjectText[i][index]);
- GroupObjectText[i][index] = Text3D:-1;
- }
- if(TextOption[tShowText] && TextOption[tShowGrouped] && GroupedObjects[i][index])
- {
- // 3D Text Label (To identify objects)
- new line[32];
- format(line, sizeof(line), "Grouped");
- // Shows the models index
- GroupObjectText[i][index] = CreateDynamic3DTextLabel(line, 0x7D26CDFF, ObjectData[index][oX], ObjectData[index][oY], ObjectData[index][oZ]+0.5, TEXT3D_DRAW_DIST, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, i);
- Streamer_Update(i);
- }
- }
- return 1;
- }
- public OnDeleteGroup3DText(index)
- {
- foreach(new i : Player)
- {
- if(GroupedObjects[i][index])
- {
- DestroyDynamic3DTextLabel(GroupObjectText[i][index]);
- GroupObjectText[i][index] = Text3D:-1;
- }
- }
- return 1;
- }
- public OnPlayerSelectDynamicObject(playerid, objectid, modelid, Float:x, Float:y, Float:z)
- {
- if(GetEditMode(playerid) == EDIT_MODE_GROUP)
- {
- 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(!CanSelectObject(playerid, index))
- SendClientMessage(playerid, STEALTH_YELLOW, "You can not select objects in this object's group");
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- // Try and add to group
- if(Keys & KEY_CTRL_BACK || (InFlyMode(playerid) && (Keys & KEY_SECONDARY_ATTACK)))
- {
- if(GroupedObjects[playerid][index]) SendClientMessage(playerid, STEALTH_YELLOW, "Object is already in your group selection");
- else
- {
- SendClientMessage(playerid, STEALTH_GREEN, "Object added to your group selection");
- GroupedObjects[playerid][index] = true;
- OnUpdateGroup3DText(index);
- }
- }
- // Try and remove from group
- else if(Keys & KEY_WALK)
- {
- if(!GroupedObjects[playerid][index]) SendClientMessage(playerid, STEALTH_YELLOW, "Object is not in your group selection");
- else
- {
- SendClientMessage(playerid, STEALTH_GREEN, "Object removed from your group selection");
- GroupedObjects[playerid][index] = false;
- OnUpdateGroup3DText(index);
- }
- }
- else
- {
- SendClientMessage(playerid, STEALTH_YELLOW, "Hold the 'H' ('Enter' in /flymode) key and click a object to select it");
- SendClientMessage(playerid, STEALTH_YELLOW, "Hold the 'Walk' key and click a object to deselect it");
- }
- }
- }
- #if defined GR_OnPlayerSelectDynamicObject
- GR_OnPlayerSelectDynamicObject(playerid, objectid, modelid, Float:x, Float:y, Float:z);
- #endif
- return 1;
- }
- #if defined _ALS_OnPlayerSelectDynamicObj
- #undef OnPlayerSelectDynamicObject
- #else
- #define _ALS_OnPlayerSelectDynamicObj
- #endif
- #define OnPlayerSelectDynamicObject GR_OnPlayerSelectDynamicObject
- #if defined GR_OnPlayerSelectDynamicObject
- forward GR_OnPlayerSelectDynamicObject(playerid, objectid, modelid, Float:x, Float:y, Float:z);
- #endif
- OnPlayerKeyStateGroupChange(playerid, newkeys, oldkeys)
- {
- #pragma unused newkeys
- if(GetEditMode(playerid) == EDIT_MODE_OBJECTGROUP)
- {
- if(oldkeys & KEY_WALK)
- {
- if(PivotReset[playerid] == false) return 1;
- SendClientMessage(playerid, STEALTH_GREEN, "Pivot has been set");
- PivotReset[playerid] = false;
- return 1;
- }
- }
- return 0;
- }
- OnPlayerEditDOGroup(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
- {
- #pragma unused objectid
- if(response == EDIT_RESPONSE_FINAL)
- {
- // Get the center (never changes)
- new Float:gCenterX, Float:gCenterY, Float:gCenterZ;
- GetGroupCenter(playerid, gCenterX, gCenterY, gCenterZ);
- new time = GetTickCount();
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- SaveUndoInfo(i, UNDO_TYPE_EDIT, time);
- new Float:offx, Float:offy, Float:offz;
- offx = (ObjectData[i][oX] + (LastGroupPosition[playerid][xPos] - gCenterX)) - PivotOffset[playerid][xPos];
- offy = (ObjectData[i][oY] + (LastGroupPosition[playerid][yPos] - gCenterY)) - PivotOffset[playerid][yPos];
- offz = (ObjectData[i][oZ] + (LastGroupPosition[playerid][zPos] - gCenterZ)) - PivotOffset[playerid][zPos];
- AttachObjectToPoint_GroupEdit(i, offx, offy, offz, x, y, z, rx, ry, rz, 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]);
- sqlite_UpdateObjectPos(i);
- UpdateObject3DText(i);
- }
- }
- db_end_transaction(EditMap);
- EditingMode[playerid] = false;
- SetEditMode(playerid, EDIT_MODE_NONE);
- DestroyDynamicObject(PivotObject[playerid]);
- }
- else if(response == EDIT_RESPONSE_UPDATE)
- {
- // Get the center (never changes)
- new Float:gCenterX, Float:gCenterY, Float:gCenterZ;
- GetGroupCenter(playerid, gCenterX, gCenterY, gCenterZ);
- new Keys,ud,lr;
- GetPlayerKeys(playerid,Keys,ud,lr);
- if(Keys & KEY_WALK)
- {
- if(!PivotReset[playerid])
- {
- SetDynamicObjectPos(PivotObject[playerid], LastGroupPosition[playerid][xPos], LastGroupPosition[playerid][yPos], LastGroupPosition[playerid][zPos]);
- SendClientMessage(playerid, STEALTH_YELLOW, "Save your object before changing the pivot again");
- }
- else
- {
- PivotOffset[playerid][xPos] = x - LastPivot[playerid][xPos];
- PivotOffset[playerid][yPos] = y - LastPivot[playerid][yPos];
- PivotOffset[playerid][zPos] = z - LastPivot[playerid][zPos];
- SetDynamicObjectRot(PivotObject[playerid], 0.0, 0.0, 0.0);
- }
- }
- else
- {
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- new Float:offx, Float:offy, Float:offz, Float:newx, Float:newy, Float:newz, Float:newrx, Float:newry, Float:newrz;
- offx = (ObjectData[i][oX] + (x - gCenterX)) - PivotOffset[playerid][xPos];
- offy = (ObjectData[i][oY] + (y - gCenterY)) - PivotOffset[playerid][yPos];
- offz = (ObjectData[i][oZ] + (z - gCenterZ)) - PivotOffset[playerid][zPos];
- AttachObjectToPoint_GroupEdit(i, offx, offy, offz, x, y, z, rx, ry, rz, newx, newy, newz, newrx, newry, newrz);
- SetDynamicObjectPos(ObjectData[i][oID], newx, newy, newz);
- SetDynamicObjectRot(ObjectData[i][oID], newrx, newry, newrz);
- }
- }
- LastGroupPosition[playerid][xPos] = x - PivotOffset[playerid][xPos];
- LastGroupPosition[playerid][yPos] = y - PivotOffset[playerid][yPos];
- LastGroupPosition[playerid][zPos] = z - PivotOffset[playerid][zPos];
- LastPivot[playerid][xPos] = x;
- LastPivot[playerid][yPos] = y;
- LastPivot[playerid][zPos] = z;
- LastPivot[playerid][xPos] = rx;
- LastPivot[playerid][yPos] = ry;
- LastPivot[playerid][zPos] = rz;
- PivotReset[playerid] = false;
- }
- }
- else if(response == EDIT_RESPONSE_CANCEL)
- {
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- 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]);
- EditingMode[playerid] = false;
- SetEditMode(playerid, EDIT_MODE_NONE);
- DestroyDynamicObject(PivotObject[playerid]);
- }
- }
- }
- return 1;
- }
- tsfunc ClearGroup(playerid)
- {
- for(new i = 0; i < MAX_TEXTURE_OBJECTS; i++)
- {
- GroupedObjects[playerid][i] = false;
- OnUpdateGroup3DText(i);
- }
- return 1;
- }
- tsfunc GroupUpdate(index)
- {
- foreach(new i : Player)
- {
- GroupedObjects[i][index] = false;
- }
- return 1;
- }
- #if defined COMPILE_MANGLE
- tsfunc GroupRotate(playerid, Float:rx, Float:ry, Float:rz, update = true)
- {
- new Float:gCenterX, Float:gCenterY, Float:gCenterZ;
- GetGroupCenter(playerid, gCenterX, gCenterY, gCenterZ);
- // Loop through all objects and perform rotation calculations
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- AttachObjectToPoint(i, gCenterX, gCenterY, gCenterZ, rx, ry, rz, ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ], ObjectData[i][oRX], ObjectData[i][oRY], ObjectData[i][oRZ]);
- if(update)
- {
- 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);
- }
- #endif
- YCMD:ginfront(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Move all grouped objects in front of the player.");
- return 1;
- }
- MapOpenCheck();
- new Float:radius;
- if(GetGroupRadius(playerid, radius))
- {
- radius += 1.0;
- new Float:x, Float:y, Float:z, Float:gcx, Float:gcy, Float:gcz, count, line[128];
- GetPlayerPos(playerid, x, y, z);
- GetPosFaInFrontOfPlayer(playerid, radius, x, y, z, gcz);
- GetGroupCenter(playerid, gcx, gcy, gcz);
-
- x -= gcx;
- y -= gcy;
- z -= gcz;
- new time = GetTickCount();
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- SaveUndoInfo(i, UNDO_TYPE_EDIT, time);
-
- ObjectData[i][oX] += x;
- ObjectData[i][oY] += y;
- ObjectData[i][oZ] += z;
-
- SetDynamicObjectPos(ObjectData[i][oID], ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ]);
- UpdateObject3DText(i);
- sqlite_UpdateObjectPos(i);
- count++;
- }
- }
- db_end_transaction(EditMap);
-
- format(line, sizeof(line), "Moved %i grouped objects to in front", count);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, line);
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "You do not have any objects grouped");
- }
- return 1;
- }
- GetGroupRadius(playerid, &Float:radius)
- {
- 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(GroupedObjects[playerid][i])
- {
- 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 < 1) return 0;
- radius = floatdiv(getdist3d(highX, highY, highZ, lowX, lowY, lowZ), 2);
- return 1;
- }
- tsfunc GetGroupCenter(playerid, &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(GroupedObjects[playerid][i])
- {
- 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 < 1) return 0;
- X = (highX + lowX) / 2;
- Y = (highY + lowY) / 2;
- Z = (highZ + lowZ) / 2;
- return 1;
- }
- YCMD:setgroup(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Sets the group ID of currently selected objects.");
- return 1;
- }
- MapOpenCheck();
- 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 groupid = strval(arg);
- new time = GetTickCount();
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- if(PlayerHasGroup(playerid))
- {
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- SaveUndoInfo(i, UNDO_TYPE_EDIT, time);
- ObjectData[i][oGroup] = groupid;
- OnUpdateGroup3DText(i);
- UpdateObject3DText(i);
- sqlite_ObjGroup(i);
- }
- }
- db_end_transaction(EditMap);
-
- new line[128];
- format(line, sizeof(line), "Set all objects in your group to group: %i", groupid);
- SendClientMessage(playerid, STEALTH_GREEN, line);
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "You have no objects to set to group!");
- return 1;
- }
- YCMD:selectgroup(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Select a group of objects by group ID.");
- return 1;
- }
- MapOpenCheck();
- NoEditingMode(playerid);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- new groupid = strval(arg);
-
- if(!CanSelectGroup(playerid, groupid))
- return SendClientMessage(playerid, STEALTH_YELLOW, "You can not select this group");
- if(PlayerHasGroup(playerid)) ClearGroup(playerid);
- new count;
- foreach(new i : Objects)
- {
- if(ObjectData[i][oGroup] == groupid)
- {
- GroupedObjects[playerid][i] = true;
- OnUpdateGroup3DText(i);
- UpdateObject3DText(i);
- count++;
- }
- }
- if(count)
- {
- new line[128];
- // Update the Group GUI
- UpdatePlayerGSelText(playerid);
- format(line, sizeof(line), "Selected group %i Objects: %i", groupid, count);
- SendClientMessage(playerid, STEALTH_GREEN, line);
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "There are no objects with this group id");
- return 1;
- }
- YCMD:gselmodel(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Select a group of objects by model ID.");
- return 1;
- }
- MapOpenCheck();
- NoEditingMode(playerid);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- new modelid = strval(arg);
- if(PlayerHasGroup(playerid)) ClearGroup(playerid);
- new count;
- foreach(new i : Objects)
- {
- if(!CanSelectObject(playerid, i))
- continue;
-
- if(ObjectData[i][oModel] == modelid)
- {
- GroupedObjects[playerid][i] = true;
- OnUpdateGroup3DText(i);
- UpdateObject3DText(i);
- count++;
- }
- }
- if(count)
- {
- new line[128];
- // Update the Group GUI
- UpdatePlayerGSelText(playerid);
- format(line, sizeof(line), "Selected model %i Objects: %i", modelid, count);
- SendClientMessage(playerid, STEALTH_GREEN, line);
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "There are no objects with this model id");
- return 1;
- }
- PlayerHasGroup(playerid)
- {
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- return 1;
- }
- }
- return 0;
- }
- // Edit a group
- YCMD:editgroup(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Edit currently edited objects simultaneously.");
- SendClientMessage(playerid, STEALTH_GREEN, "Hold 'Walk Key' to set the group rotation pivot, you can only do this once per edit.");
- return 1;
- }
- MapOpenCheck();
- NoEditingMode(playerid);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- if(PlayerHasGroup(playerid))
- {
- GetGroupCenter(playerid, LastPivot[playerid][xPos], LastPivot[playerid][yPos], LastPivot[playerid][zPos]);
- LastGroupPosition[playerid][xPos] = LastPivot[playerid][xPos];
- LastGroupPosition[playerid][yPos] = LastPivot[playerid][yPos];
- LastGroupPosition[playerid][zPos] = LastPivot[playerid][zPos];
- PivotOffset[playerid][xPos] = 0.0;
- PivotOffset[playerid][yPos] = 0.0;
- PivotOffset[playerid][zPos] = 0.0;
- PivotObject[playerid] = CreateDynamicObject(1974, LastPivot[playerid][xPos], LastPivot[playerid][yPos], LastPivot[playerid][zPos], 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;
- PivotReset[playerid] = true;
- SetEditMode(playerid, EDIT_MODE_OBJECTGROUP);
- EditDynamicObject(playerid, PivotObject[playerid]);
- SendClientMessage(playerid, STEALTH_GREEN, "Editing your group");
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "You must have at least one object grouped");
- return 1;
- }
- YCMD:gmtset(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Set the material of all currently selected objects.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- if(PlayerHasGroup(playerid))
- {
- new mindex;
- new tref;
- new time = GetTickCount();
- if(GetMaterials(playerid, arg, mindex, tref))
- {
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- 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)
- Streamer_Update(i);
-
- UpdateTextureSlot(playerid, mindex);
- }
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "You must have at least one object grouped");
-
- return 1;
- }
- YCMD:gmtcolor(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Set the material of all currently selected objects.");
- return 1;
- }
- MapOpenCheck();
- EditCheck(playerid);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- if(PlayerHasGroup(playerid))
- {
- new mindex;
- new time = GetTickCount();
- 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);
-
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- 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);
- SendClientMessage(playerid, STEALTH_GREEN, "Changed All Color");
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "Invalid hex color.");
- return 1;
- }
- foreach(new i : Player)
- Streamer_Update(i);
-
- UpdateTextureSlot(playerid, mindex);
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "You must have at least one object grouped");
-
- return 1;
- }
- YCMD:gsel(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Select/deselect objects using the cursor.");
- SendClientMessage(playerid, STEALTH_YELLOW, "Hold the 'H' ('Enter' in /flymode) key and click a object to select it");
- SendClientMessage(playerid, STEALTH_YELLOW, "Hold the 'Walk' key and click a object to deselect it");
- return 1;
- }
- NoEditingMode(playerid);
- MapOpenCheck();
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- if(Iter_Count(Objects))
- {
- SetEditMode(playerid, EDIT_MODE_GROUP);
- SelectObject(playerid);
- SendClientMessage(playerid, STEALTH_GREEN, "Entered Group Selection Mode");
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "There are no objects right now");
- return 1;
- }
- YCMD:gadd(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Add an object to current selection.");
- return 1;
- }
- MapOpenCheck();
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- if(isnull(arg)) return SendClientMessage(playerid, STEALTH_YELLOW, "You must supply an object index to group");
-
- new index, range;
- sscanf(arg, "iI(-1)", index, range);
-
- if(range == -1 && !CanSelectObject(playerid, index))
- return SendClientMessage(playerid, STEALTH_YELLOW, "You can not select objects in this object's group");
-
- if(index < 0 || (range != -1 && range < 0)) return SendClientMessage(playerid, STEALTH_YELLOW, "Index can not be less than 0");
- if(index >= MAX_TEXTURE_OBJECTS || range >= MAX_TEXTURE_OBJECTS)
- {
- new line[128];
- format(line, sizeof(line), "Index can not be greater than %i", MAX_TEXTURE_OBJECTS - 1);
- return SendClientMessage(playerid, STEALTH_YELLOW, line);
- }
- if(range != -1 && range <= index) return SendClientMessage(playerid, STEALTH_YELLOW, "The range can not be more than the index.");
-
- if(range != -1)
- {
- new count;
- for(new i = index; i <= range; i++)
- {
- if(CanSelectObject(playerid, i) && Iter_Contains(Objects, i) && !GroupedObjects[playerid][i])
- {
- // Update the Group GUI
- UpdatePlayerGSelText(playerid);
- GroupedObjects[playerid][i] = true;
- OnUpdateGroup3DText(i);
-
- count++;
- }
- }
- if(count) SendClientMessage(playerid, STEALTH_GREEN, sprintf("Added %i objects to your group selection", count));
- else SendClientMessage(playerid, STEALTH_YELLOW, "No objects in that range are in your group selection");
- }
- else
- {
- if(Iter_Contains(Objects, index))
- {
- if(GroupedObjects[playerid][index]) SendClientMessage(playerid, STEALTH_YELLOW, "Object is already in your group selection");
- else
- {
- // Update the Group GUI
- UpdatePlayerGSelText(playerid);
- SendClientMessage(playerid, STEALTH_GREEN, "Object added to your group selection");
- GroupedObjects[playerid][index] = true;
- OnUpdateGroup3DText(index);
- }
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "No object exists on that index");
- }
-
- return 1;
- }
- YCMD:grem(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Remove an object from your current selection.");
- return 1;
- }
- MapOpenCheck();
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- if(isnull(arg)) return SendClientMessage(playerid, STEALTH_YELLOW, "You must supply an object index to group");
-
- new index, range;
- sscanf(arg, "iI(-1)", index, range);
-
- if(index < 0 || (range != -1 && range < 0)) return SendClientMessage(playerid, STEALTH_YELLOW, "Index can not be less than 0");
- if(index >= MAX_TEXTURE_OBJECTS || range >= MAX_TEXTURE_OBJECTS)
- {
- new line[128];
- format(line, sizeof(line), "Index can not be greater than %i", MAX_TEXTURE_OBJECTS - 1);
- return SendClientMessage(playerid, STEALTH_YELLOW, line);
- }
- if(range != -1 && range <= index) return SendClientMessage(playerid, STEALTH_YELLOW, "The range can not be more than the index.");
-
- if(range != -1)
- {
- new count;
- for(new i = index; i <= range; i++)
- {
- if(Iter_Contains(Objects, i) && GroupedObjects[playerid][i])
- {
- // Update the Group GUI
- UpdatePlayerGSelText(playerid);
- GroupedObjects[playerid][i] = false;
- OnUpdateGroup3DText(i);
-
- count++;
- }
- }
- if(count) SendClientMessage(playerid, STEALTH_GREEN, sprintf("Removed %i objects from your group selection", count));
- else SendClientMessage(playerid, STEALTH_YELLOW, "No objects in that range are in your group selection");
- }
- else
- {
- if(Iter_Contains(Objects, index))
- {
- if(!GroupedObjects[playerid][index]) SendClientMessage(playerid, STEALTH_YELLOW, "Object is not in your group selection");
- else
- {
- // Update the Group GUI
- UpdatePlayerGSelText(playerid);
- SendClientMessage(playerid, STEALTH_GREEN, "Object removed from your group selection");
- GroupedObjects[playerid][index] = false;
- OnUpdateGroup3DText(index);
- }
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "No object exists on that index");
- }
-
- return 1;
- }
- YCMD:gclear(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Clears the current selection.");
- return 1;
- }
- MapOpenCheck();
- ClearGroup(playerid);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Your group selection has been cleared");
- // Update the Group GUI
- UpdatePlayerGSelText(playerid);
- return 1;
- }
- new bool:tmpgrp[MAX_TEXTURE_OBJECTS];
- YCMD:gclone(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Clone all currently selected objects.");
- return 1;
- }
- MapOpenCheck();
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- new index;
- new count;
- new time = GetTickCount();
- for(new i = 0; i < MAX_TEXTURE_OBJECTS; i++) { tmpgrp[i] = false; }
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- index = CloneObject(i, time);
- GroupedObjects[playerid][i] = false;
- tmpgrp[index] = true;
- OnUpdateGroup3DText(i);
- count++;
- }
- }
- db_end_transaction(EditMap);
- // Update grouped objects
- for(new i = 0; i < MAX_TEXTURE_OBJECTS; i++)
- {
- GroupedObjects[playerid][i] = tmpgrp[i];
- if(GroupedObjects[playerid][i] == true)
- OnUpdateGroup3DText(i);
- }
- if(count)
- {
- // Update the Group GUI
- UpdatePlayerGSelText(playerid);
- new line[128];
- format(line, sizeof(line), "Cloned group selection Objects: %i", count);
- SendClientMessage(playerid, STEALTH_GREEN, line);
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "No group objects to clone");
- return 1;
- }
- YCMD:gdelete(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Destroy all currently selected objects.");
- return 1;
- }
- MapOpenCheck();
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- new count;
- new time = GetTickCount();
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- SaveUndoInfo(i, UNDO_TYPE_DELETED, time);
- i = DeleteDynamicObject(i);
- count++;
- }
- }
- db_end_transaction(EditMap);
- if(count)
- {
- // Update the Group GUI
- UpdatePlayerGSelText(playerid);
- new line[128];
- format(line, sizeof(line), "Deleted group selection Objects: %i", count);
- SendClientMessage(playerid, STEALTH_GREEN, line);
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "No group objects to delete");
- return 1;
- }
- YCMD:gall(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Add all loaded objects to current selection.");
- return 1;
- }
- MapOpenCheck();
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- new count;
- foreach(new i : Objects)
- {
- if(!CanSelectObject(playerid, i))
- continue;
-
- GroupedObjects[playerid][i] = true;
- OnUpdateGroup3DText(i);
- count++;
- }
- if(count)
- {
- // Update the Group GUI
- UpdatePlayerGSelText(playerid);
- new line[128];
- format(line, sizeof(line), "Grouped All Objects", count);
- SendClientMessage(playerid, STEALTH_GREEN, line);
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "There are no objects to group");
- return 1;
- }
- YCMD:ginvert(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Invert all currently selected objects the selected axis.");
- return 1;
- }
- MapOpenCheck();
- // NoEditingMode(playerid);
- // EditCheck(playerid);
-
- inline Mirror(mxpid, mxdialogid, mxresponse, mxlistitem, string:mxtext[])
- {
- #pragma unused mxpid, mxdialogid, mxtext
- if(!mxresponse)
- return 1;
-
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
-
- new Float:gcx, Float:gcy, Float:gcz;
- GetGroupCenter(playerid, gcx, gcy, gcz);
- new time = GetTickCount();
-
- db_begin_transaction(EditMap);
- foreach(new i: Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- SaveUndoInfo(i, UNDO_TYPE_EDIT, time);
- switch(mxlistitem) {
- case 0: {
- ObjectData[i][oX] = -ObjectData[i][oX] + (2.0 * gcx);
- // ObjectData[i][oRY] = -ObjectData[i][oRY];
- // ObjectData[i][oRZ] = -ObjectData[i][oRZ];
-
- // ObjectData[i][oRY] += 180.0;
- // ObjectData[i][oRZ] += 180.0;
-
- // ObjectData[i][oRX] += 180.0;
- }
- case 1: {
- ObjectData[i][oY] = -ObjectData[i][oY] + (2.0 * gcy);
- // ObjectData[i][oRX] = -ObjectData[i][oRX];
- // ObjectData[i][oRZ] = -ObjectData[i][oRZ];
-
- // ObjectData[i][oRX] += 180.0;
- // ObjectData[i][oRZ] += 180.0;
- // ObjectData[i][oRY] += 180.0;
- }
- case 2: {
- ObjectData[i][oZ] = -ObjectData[i][oZ] + (2.0 * gcz);
- // ObjectData[i][oRX] = -ObjectData[i][oRX];
- // ObjectData[i][oRY] = -ObjectData[i][oRY];
-
- // ObjectData[i][oRX] += 180.0;
- // ObjectData[i][oRY] += 180.0;
- // ObjectData[i][oRZ] += 180.0;
- }
- }
- EDIT_FloatGetRemainder(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);
-
- //(Not added to GUI yet)
- // Update the Group GUI
- //UpdatePlayerGSelText(playerid);
-
- new c = mxlistitem == 0 ? 'X' : mxlistitem == 1 ? 'Y' : 'Z';
- SendClientMessage(playerid, STEALTH_GREEN, sprintf("Inverted all currently selected along the %c axis.", c));
- }
- Dialog_ShowCallback(playerid, using inline Mirror, DIALOG_STYLE_LIST, "Texture Studio - Select Mirror Axis", "X\nY\nZ", "Select", "");
- return 1;
- }
- // Move all grouped objects on X axis
- YCMD:gox(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Move all currently selected objects along the X axis.");
- return 1;
- }
- MapOpenCheck();
- new Float:dist;
- new time = GetTickCount();
- dist = floatstr(arg);
- if(dist == 0) dist = 1.0;
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- 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);
-
- // Update the Group GUI
- UpdatePlayerGSelText(playerid);
- return 1;
- }
- // Move all grouped objects on Y axis
- YCMD:goy(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Move all currently selected objects along the Y axis.");
- return 1;
- }
- MapOpenCheck();
- new Float:dist;
- new time = GetTickCount();
- dist = floatstr(arg);
- if(dist == 0) dist = 1.0;
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- 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);
- // Update the Group GUI
- UpdatePlayerGSelText(playerid);
- return 1;
- }
- // Move all grouped objects on Z axis
- YCMD:goz(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Move all currently selected objects along the Z axis.");
- return 1;
- }
- MapOpenCheck();
- new Float:dist;
- new time = GetTickCount();
- dist = floatstr(arg);
- if(dist == 0) dist = 1.0;
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- 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);
- // Update the Group GUI
- UpdatePlayerGSelText(playerid);
- return 1;
- }
- // Rotate map on RX
- YCMD:grx(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Rotate all currently selected objects around the X axis.");
- return 1;
- }
- MapOpenCheck();
- new time = GetTickCount();
- new Float:Delta;
- if(sscanf(arg, "f", Delta))
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "Usage: /grx <rotation> ");
- return 1;
- }
- // We need to get the map center as the rotation node
- new bool:value, Float:gCenterX, Float:gCenterY, Float:gCenterZ;
- if(PivotPointOn[playerid])
- {
- new bool:hasgroup;
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- gCenterX = PivotPoint[playerid][xPos];
- gCenterY = PivotPoint[playerid][yPos];
- gCenterZ = PivotPoint[playerid][zPos];
- value = true;
- hasgroup = true;
- break;
- }
- }
- if(!hasgroup)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "There is not enough objects for this command to work");
- }
- }
- else if(GetGroupCenter(playerid, gCenterX, gCenterY, gCenterZ)) value = true;
- if(value)
- {
- // Loop through all objects and perform rotation calculations
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- SaveUndoInfo(i, UNDO_TYPE_EDIT, time);
- AttachObjectToPoint(i, gCenterX, gCenterY, gCenterZ, 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);
- // Update the Group GUI
- UpdatePlayerGSelText(playerid);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Group 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 RX
- YCMD:gry(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Rotate all currently selected objects around the Y axis.");
- return 1;
- }
- MapOpenCheck();
- new time = GetTickCount();
- new Float:Delta;
- if(sscanf(arg, "f", Delta))
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "Usage: /gry <rotation> ");
- return 1;
- }
- // We need to get the map center as the rotation node
- new bool:value, Float:gCenterX, Float:gCenterY, Float:gCenterZ;
- if(PivotPointOn[playerid])
- {
- new bool:hasgroup;
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- gCenterX = PivotPoint[playerid][xPos];
- gCenterY = PivotPoint[playerid][yPos];
- gCenterZ = PivotPoint[playerid][zPos];
- value = true;
- hasgroup = true;
- break;
- }
- }
- if(!hasgroup)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "There is not enough objects for this command to work");
- }
- }
- else if(GetGroupCenter(playerid, gCenterX, gCenterY, gCenterZ)) value = true;
- if(value)
- {
- // Loop through all objects and perform rotation calculations
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- SaveUndoInfo(i, UNDO_TYPE_EDIT, time);
- AttachObjectToPoint(i, gCenterX, gCenterY, gCenterZ, 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);
- // Update the Group GUI
- UpdatePlayerGSelText(playerid);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Group 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 RX
- YCMD:grz(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Rotate all currently selected objects around the Z axis.");
- return 1;
- }
- MapOpenCheck();
- new time = GetTickCount();
- new Float:Delta;
- if(sscanf(arg, "f", Delta))
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "Usage: /grz <rotation> ");
- return 1;
- }
- // We need to get the map center as the rotation node
- new bool:value, Float:gCenterX, Float:gCenterY, Float:gCenterZ;
- if(PivotPointOn[playerid])
- {
- new bool:hasgroup;
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- gCenterX = PivotPoint[playerid][xPos];
- gCenterY = PivotPoint[playerid][yPos];
- gCenterZ = PivotPoint[playerid][zPos];
- value = true;
- hasgroup = true;
- break;
- }
- }
- if(!hasgroup)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "There is not enough objects for this command to work");
- }
- }
- else if(GetGroupCenter(playerid, gCenterX, gCenterY, gCenterZ)) value = true;
- if(value)
- {
- // Loop through all objects and perform rotation calculations
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- SaveUndoInfo(i, UNDO_TYPE_EDIT, time);
- AttachObjectToPoint(i, gCenterX, gCenterY, gCenterZ, 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);
- // Update the Group GUI
- UpdatePlayerGSelText(playerid);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Group 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:gdd(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Set a group's draw distance.");
- return 1;
- }
- MapOpenCheck();
- new time = GetTickCount();
- new Float:dd;
- sscanf(arg, "F(300.0)", dd);
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- SaveUndoInfo(i, UNDO_TYPE_EDIT, time);
- ObjectData[i][oDD] = dd;
- Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[i][oID], E_STREAMER_DRAW_DISTANCE, dd);
- Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[i][oID], E_STREAMER_STREAM_DISTANCE, dd);
- sqlite_UpdateObjectDD(i);
- }
- }
- db_end_transaction(EditMap);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, sprintf("Groups draw distance set to %.2f", dd));
- return 1;
- }
- // Export group of objects as an attached object
- YCMD:gaexport(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Export all currently selected objects as an attached object.");
- return 1;
- }
- MapOpenCheck();
- new count;
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- count++;
- break;
- }
- }
- if(count)
- {
- inline CreateAttachExport(cpid, cdialogid, cresponse, clistitem, string:ctext[])
- {
- #pragma unused clistitem, cdialogid, cpid
- if(cresponse)
- {
- if(!isnull(ctext))
- {
- 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 mapname[128];
-
- if(strlen(ctext) >= 20)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "Choose a shorter map name to export to...");
- return 1;
- }
-
- format(mapname, sizeof(mapname), "tstudio/AttachExport/%s.txt", ctext);
- if(!fexist(mapname)) AttachExport(playerid, mapname, dist);
- else
- {
- inline OverwriteAttachExport(opid, odialogid, oresponse, olistitem, string:otext[])
- {
- #pragma unused olistitem, odialogid, opid, otext
- if(oresponse)
- {
- fremove(mapname);
- AttachExport(playerid, mapname, dist);
- }
- }
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "A attached object export with that name already exists");
- Dialog_ShowCallback(playerid, using inline OverwriteAttachExport, DIALOG_STYLE_MSGBOX, "Texture Studio", "Attached file exists overwrite?", "Ok", "Cancel");
- }
- }
- 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 must give your attached export a filename");
- Dialog_ShowCallback(playerid, using inline CreateAttachExport, DIALOG_STYLE_INPUT, "Texture Studio", "Enter attached object export file", "Ok", "Cancel");
- }
- }
- }
- Dialog_ShowCallback(playerid, using inline CreateAttachExport, DIALOG_STYLE_INPUT, "Texture Studio", "Enter attached object export file", "Ok", "Cancel");
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "No object to save to prefab");
- }
- return 1;
- }
- AttachExport(playerid, mapname[], Float:drawdist)
- {
- // Choose a object as a center node
- inline SelectObjectCenterNode(spid, sdialogid, sresponse, slistitem, string:stext[])
- {
- #pragma unused slistitem, sdialogid, spid
- if(sresponse)
- {
- if(isnull(stext))
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "You must provide an index as center object");
- Dialog_ShowCallback(playerid, using inline SelectObjectCenterNode, DIALOG_STYLE_INPUT, "Texture Studio", "Enter object index of attach object center", "Ok", "Cancel");
- return 1;
- }
- new centerindex = strval(stext);
- if(centerindex < 0 || centerindex > MAX_TEXTURE_OBJECTS - 1)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "Invalid index");
- Dialog_ShowCallback(playerid, using inline SelectObjectCenterNode, DIALOG_STYLE_INPUT, "Texture Studio", "Enter object index of attach object center", "Ok", "Cancel");
- return 1;
- }
- if(!GroupedObjects[playerid][centerindex])
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "That object is not in your group selection");
- Dialog_ShowCallback(playerid, using inline SelectObjectCenterNode, DIALOG_STYLE_INPUT, "Texture Studio", "Enter object index of attach object center", "Ok", "Cancel");
- return 1;
- }
- // Get Offsets
- new Float:offx, Float:offy, Float:offz;
- offx = ObjectData[centerindex][oX];
- offy = ObjectData[centerindex][oY];
- offz = ObjectData[centerindex][oZ];
- new exportmap[256];
- format(exportmap, sizeof(exportmap), "%s", mapname);
- new mobjects;
- new templine[256];
- new File:f;
- new syncrot = 1;
- f = fopen(exportmap,io_write);
- if(!f) {
- SendClientMessage(playerid, -1, "For some reason this file isn't being created.");
- SendClientMessage(playerid, -1, "Trying to highjack the existing blank.txt instead (temporary solution).");
- f = fopen("tstudio/AttachExport/blank.txt",io_write);
- if(!f) {
- SendClientMessage(playerid, -1, "Failed to highjack...");
- }
- }
-
- fwrite(f,"//Attached Object Map Exported with Texture Studio By: [uL]Pottus////////////////////////////////////////////////\r\n");
- fwrite(f,"//////////////////////////////////////////////////////////////and Crayder////////////////////////////////////////\r\n");
- fwrite(f,"/////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n");
- // Temp object for setting materials
- format(templine,sizeof(templine),"new centobjid, tmpobjid;\r\n");
- fwrite(f,templine);
- format(templine,sizeof(templine),"centobjid = CreateObject(%i,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f);\r\n",ObjectData[centerindex][oModel],ObjectData[centerindex][oX],ObjectData[centerindex][oY],ObjectData[centerindex][oZ],ObjectData[centerindex][oRX],ObjectData[centerindex][oRY],ObjectData[centerindex][oRZ],drawdist);
- fwrite(f,templine);
- // Write all objects with materials first
- foreach(new i : Objects)
- {
- if(ObjectData[i][oAttachedVehicle] > -1 || !GroupedObjects[playerid][i] || centerindex == i) continue;
- new bool:writeobject;
- // 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
- format(templine,sizeof(templine),"tmpobjid = CreateObject(%i,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f);\r\n",ObjectData[i][oModel],ObjectData[i][oX],ObjectData[i][oY],ObjectData[i][oZ],ObjectData[i][oRX],ObjectData[i][oRY],ObjectData[i][oRZ],drawdist);
- 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),"SetObjectMaterial(tmpobjid, %i, %i, %c%s%c, %c%s%c, %i);\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),"SetObjectMaterial(tmpobjid, %i, -1, %c%s%c, %c%s%c, %i);\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),"SetObjectMaterialText(tmpobjid, %c%s%c, 0, %i, %c%s%c, %i, %i, %i, %i, %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);
- }
- // Attach the object
- format(templine,sizeof(templine),"AttachObjectToObject(tmpobjid,centobjid,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%i);\r\n",
- offx - ObjectData[i][oX],
- offy - ObjectData[i][oY],
- offz - ObjectData[i][oZ],
- ObjectData[i][oRX],
- ObjectData[i][oRY],
- ObjectData[i][oRZ],
- syncrot
- );
- 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 || !GroupedObjects[playerid][i] || centerindex == i) continue;
- new bool:skipobject = true;
- // 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])
- {
- skipobject = true;
- break;
- }
- }
- // Object has not been exported yet export
- if(!skipobject)
- {
- format(templine,sizeof(templine),"tmpobjid = CreateObject(%i,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f);\r\n",ObjectData[i][oModel],ObjectData[i][oX],ObjectData[i][oY],ObjectData[i][oZ],ObjectData[i][oRX],ObjectData[i][oRY],ObjectData[i][oRZ],drawdist);
- fwrite(f,templine);
- }
- // Attach the object
- format(templine,sizeof(templine),"AttachObjectToObject(tmpobjid,centobjid,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%i);\r\n",
- offx - ObjectData[i][oX],
- offy - ObjectData[i][oY],
- offz - ObjectData[i][oZ],
- ObjectData[i][oRX],
- ObjectData[i][oRY],
- ObjectData[i][oRZ],
- syncrot
- );
- 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 SelectObjectCenterNode, DIALOG_STYLE_INPUT, "Texture Studio", "Enter object index of attach object center", "Ok", "Cancel");
- return 1;
- }
- // Save objects as a prefab data base
- new NewPreFabString[512];
- new DB: PrefabDB;
- YCMD:gprefab(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Save current objects as a prefabricated group.");
- return 1;
- }
- MapOpenCheck();
- new count;
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- count++;
- break;
- }
- }
- if(count)
- {
- inline CreatePrefab(cpid, cdialogid, cresponse, clistitem, string:ctext[])
- {
- #pragma unused clistitem, cdialogid, cpid
- if(cresponse)
- {
- if(!isnull(ctext))
- {
- new mapname[128];
- format(mapname, sizeof(mapname), "tstudio/PreFabs/%s.db", ctext);
- if(!fexist(mapname))
- {
- // Open the map for editing
- PrefabDB = db_open_persistent(mapname);
- if(!NewPreFabString[0])
- {
- strimplode(" ",
- NewPreFabString,
- sizeof(NewPreFabString),
- "CREATE TABLE IF NOT EXISTS `Objects`",
- "(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);"
- );
- }
- db_exec(PrefabDB, NewPreFabString);
- // Prefab extra info
- db_exec(PrefabDB, "CREATE TABLE IF NOT EXISTS `PrefabInfo` (zOFF REAL);");
- db_exec(PrefabDB, "INSERT INTO `PrefabInfo` VALUES(0.0);");
- new Float:x, Float:y, Float:z;
- if(!GetGroupCenter(playerid, x, y, z))
- {
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- x = ObjectData[i][oX];
- y = ObjectData[i][oY];
- z = ObjectData[i][oZ];
- break;
- }
- }
- }
- count = 0;
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- sqlite_InsertPrefab(i, x, y, z);
- count++;
- }
- }
- db_end_transaction(EditMap);
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- new line[128];
- format(line, sizeof(line), "You have created a prefab Object Count: %i", count);
- SendClientMessage(playerid, STEALTH_GREEN, line);
- db_free_persistent(PrefabDB);
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "A prefab with that name already exists");
- Dialog_ShowCallback(playerid, using inline CreatePrefab, DIALOG_STYLE_INPUT, "Texture Studio", "Enter a prefab name", "Ok", "Cancel");
- }
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "You must give your prefab a filename");
- Dialog_ShowCallback(playerid, using inline CreatePrefab, DIALOG_STYLE_INPUT, "Texture Studio", "Enter a prefab name", "Ok", "Cancel");
- }
- }
- }
- Dialog_ShowCallback(playerid, using inline CreatePrefab, DIALOG_STYLE_INPUT, "Texture Studio", "Enter a prefab name", "Ok", "Cancel");
- }
- else
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_YELLOW, "No object to save to prefab");
- }
- return 1;
- }
- // Insert object to prefab DB
- new DBStatement:insertprefabstmt;
- new InsertPrefabString[512];
- sqlite_InsertPrefab(index, Float:x, Float:y, Float:z)
- {
- // Inserts a new index
- if(!InsertPrefabString[0])
- {
- // Prepare query
- strimplode(" ",
- InsertPrefabString,
- sizeof(InsertPrefabString),
- "INSERT INTO `Objects`",
- "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
- );
- }
- insertprefabstmt = db_prepare(PrefabDB, InsertPrefabString);
- // Bind our results
- stmt_bind_value(insertprefabstmt, 0, DB::TYPE_INT, ObjectData[index][oModel]);
- stmt_bind_value(insertprefabstmt, 1, DB::TYPE_FLOAT, ObjectData[index][oX]-x);
- stmt_bind_value(insertprefabstmt, 2, DB::TYPE_FLOAT, ObjectData[index][oY]-y);
- stmt_bind_value(insertprefabstmt, 3, DB::TYPE_FLOAT, ObjectData[index][oZ]-z);
- stmt_bind_value(insertprefabstmt, 4, DB::TYPE_FLOAT, ObjectData[index][oRX]);
- stmt_bind_value(insertprefabstmt, 5, DB::TYPE_FLOAT, ObjectData[index][oRY]);
- stmt_bind_value(insertprefabstmt, 6, DB::TYPE_FLOAT, ObjectData[index][oRZ]);
- stmt_bind_value(insertprefabstmt, 7, DB::TYPE_ARRAY, ObjectData[index][oTexIndex], MAX_MATERIALS);
- stmt_bind_value(insertprefabstmt, 8, DB::TYPE_ARRAY, ObjectData[index][oColorIndex], MAX_MATERIALS);
- stmt_bind_value(insertprefabstmt, 9, DB::TYPE_INT, ObjectData[index][ousetext]);
- stmt_bind_value(insertprefabstmt, 10, DB::TYPE_INT, ObjectData[index][oFontFace]);
- stmt_bind_value(insertprefabstmt, 11, DB::TYPE_INT, ObjectData[index][oFontSize]);
- stmt_bind_value(insertprefabstmt, 12, DB::TYPE_INT, ObjectData[index][oFontBold]);
- stmt_bind_value(insertprefabstmt, 13, DB::TYPE_INT, ObjectData[index][oFontColor]);
- stmt_bind_value(insertprefabstmt, 14, DB::TYPE_INT, ObjectData[index][oBackColor]);
- stmt_bind_value(insertprefabstmt, 15, DB::TYPE_INT, ObjectData[index][oAlignment]);
- stmt_bind_value(insertprefabstmt, 16, DB::TYPE_INT, ObjectData[index][oTextFontSize]);
- stmt_bind_value(insertprefabstmt, 17, DB::TYPE_STRING, ObjectData[index][oObjectText], MAX_TEXT_LENGTH);
- stmt_execute(insertprefabstmt);
- stmt_close(insertprefabstmt);
- }
- YCMD:prefabsetz(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Set prefabricated group Z axis offset.");
- return 1;
- }
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- if(isnull(arg)) ShowPrefabs(playerid);
- else
- {
- new Float:offset;
- new mapname[128];
- if(sscanf(arg, "s[128]f", mapname, offset)) return SendClientMessage(playerid, STEALTH_YELLOW, "You must supply a valid offset value!");
- format(mapname, sizeof(mapname), "tstudio/PreFabs/%s.db", mapname);
- if(fexist(mapname))
- {
- PrefabDB = db_open_persistent(mapname);
- new Query[128];
- format(Query, sizeof(Query), "UPDATE `PrefabInfo` SET `zOFF` = %f;", offset);
- db_exec(PrefabDB, Query);
- db_free_persistent(PrefabDB);
- SendClientMessage(playerid, STEALTH_GREEN, "Updated prefab Z-Load offset");
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "That prefab does not exist!");
- }
- return 1;
- }
- // Load a prefab specify a filename
- YCMD:prefab(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Load a prefabricated group of objects.");
- return 1;
- }
- MapOpenCheck();
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- if(isnull(arg)) ShowPrefabs(playerid);
- else
- {
- new mapname[128];
- format(mapname, sizeof(mapname), "tstudio/PreFabs/%s.db", arg);
- if(fexist(mapname))
- {
- PrefabDB = db_open_persistent(mapname);
- sqlite_LoadPrefab(playerid);
- db_free_persistent(PrefabDB);
- SendClientMessage(playerid, STEALTH_GREEN, "Prefab loaded and set to your group selection");
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "That prefab does not exist!");
- }
- return 1;
- }
- YCMD:0group(playerid, arg[], help)
- {
- if(help)
- {
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- SendClientMessage(playerid, STEALTH_GREEN, "Center all currently selected objects to the center of San Andreas.");
- return 1;
- }
- MapOpenCheck();
- new Float:gCenterX, Float:gCenterY, Float:gCenterZ;
- GetGroupCenter(playerid, gCenterX, gCenterY, gCenterZ);
- new bool:hasgroup;
- new time = GetTickCount();
- SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________");
- db_begin_transaction(EditMap);
- foreach(new i : Objects)
- {
- if(GroupedObjects[playerid][i])
- {
- SaveUndoInfo(i, UNDO_TYPE_EDIT, time);
- ObjectData[i][oX] -= gCenterX;
- ObjectData[i][oY] -= gCenterY;
- ObjectData[i][oZ] -= gCenterZ;
- SetDynamicObjectPos(ObjectData[i][oID], ObjectData[i][oX], ObjectData[i][oY], ObjectData[i][oZ]);
- sqlite_UpdateObjectPos(i);
- UpdateObject3DText(i);
- hasgroup = true;
- }
- }
- db_end_transaction(EditMap);
- if(hasgroup) SendClientMessage(playerid, STEALTH_GREEN, "Moved grouped objects to 0,0,0");
- else SendClientMessage(playerid, STEALTH_YELLOW, "You don't have any objects grouped");
- return 1;
- }
- tsfunc ShowPrefabs(playerid)
- {
- new dir:dHandle = dir_open("./scriptfiles/tstudio/PreFabs/");
- new item[40], type;
- new line[128];
- new extension[3];
- new fcount;
- new total;
- // 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 %s,", line, item);
- fcount++;
- total++;
- if(fcount == 8)
- {
- SendClientMessage(playerid, STEALTH_YELLOW, line);
- fcount = 0;
- line = "";
- }
- }
- }
- }
- }
- if(fcount != 0) SendClientMessage(playerid, STEALTH_YELLOW, line);
- if(total > 0)
- {
- format(line, sizeof(line), "Displaying %i prefabs", total);
- SendClientMessage(playerid, STEALTH_GREEN, line);
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "There are no prefabs to list!");
- return 1;
- }
- static DBStatement:loadprefabstmt;
- // Loads map objects from a data base
- sqlite_LoadPrefab(playerid, offset = true)
- {
- // Load query stmt
- loadprefabstmt = db_prepare(PrefabDB, "SELECT * FROM `Objects`");
- new tmpobject[OBJECTINFO];
- // Bind our results
- stmt_bind_result_field(loadprefabstmt, 0, DB::TYPE_INT, tmpobject[oModel]);
- stmt_bind_result_field(loadprefabstmt, 1, DB::TYPE_FLOAT, tmpobject[oX]);
- stmt_bind_result_field(loadprefabstmt, 2, DB::TYPE_FLOAT, tmpobject[oY]);
- stmt_bind_result_field(loadprefabstmt, 3, DB::TYPE_FLOAT, tmpobject[oZ]);
- stmt_bind_result_field(loadprefabstmt, 4, DB::TYPE_FLOAT, tmpobject[oRX]);
- stmt_bind_result_field(loadprefabstmt, 5, DB::TYPE_FLOAT, tmpobject[oRY]);
- stmt_bind_result_field(loadprefabstmt, 6, DB::TYPE_FLOAT, tmpobject[oRZ]);
- stmt_bind_result_field(loadprefabstmt, 7, DB::TYPE_ARRAY, tmpobject[oTexIndex], MAX_MATERIALS);
- stmt_bind_result_field(loadprefabstmt, 8, DB::TYPE_ARRAY, tmpobject[oColorIndex], MAX_MATERIALS);
- stmt_bind_result_field(loadprefabstmt, 9, DB::TYPE_INT, tmpobject[ousetext]);
- stmt_bind_result_field(loadprefabstmt, 10, DB::TYPE_INT, tmpobject[oFontFace]);
- stmt_bind_result_field(loadprefabstmt, 11, DB::TYPE_INT, tmpobject[oFontSize]);
- stmt_bind_result_field(loadprefabstmt, 12, DB::TYPE_INT, tmpobject[oFontBold]);
- stmt_bind_result_field(loadprefabstmt, 13, DB::TYPE_INT, tmpobject[oFontColor]);
- stmt_bind_result_field(loadprefabstmt, 14, DB::TYPE_INT, tmpobject[oBackColor]);
- stmt_bind_result_field(loadprefabstmt, 15, DB::TYPE_INT, tmpobject[oAlignment]);
- stmt_bind_result_field(loadprefabstmt, 16, DB::TYPE_INT, tmpobject[oTextFontSize]);
- stmt_bind_result_field(loadprefabstmt, 17, DB::TYPE_STRING, tmpobject[oObjectText], MAX_TEXT_LENGTH);
- // Get the ZOffset
- new Query[128];
- new DBResult:r;
- new Float:zoff;
- format(Query, sizeof(Query), "SELECT * FROM `PrefabInfo`");
- r = db_query(PrefabDB, Query);
- db_get_field_assoc(r, "zOFF", Query, 128);
- zoff = floatstr(Query);
- db_free_result(r);
- new Float:px, Float:py, Float:pz, Float:fa;
- new time = GetTickCount();
- if(offset) GetPosFaInFrontOfPlayer(playerid, 2.0, px, py, pz, fa);
- else GetPlayerPos(playerid, px, py, pz);
- // Clear any grouped objects
- ClearGroup(playerid);
- // Execute query
- if(stmt_execute(loadprefabstmt))
- {
- db_begin_transaction(EditMap);
- while(stmt_fetch_row(loadprefabstmt))
- {
- new index = AddDynamicObject(tmpobject[oModel], tmpobject[oX]+px, tmpobject[oY]+py, tmpobject[oZ]+pz+zoff, tmpobject[oRX], tmpobject[oRY], tmpobject[oRZ]);
- // Set textures and colors
- for(new i = 0; i < MAX_MATERIALS; i++)
- {
- ObjectData[index][oTexIndex][i] = tmpobject[oTexIndex][i];
- ObjectData[index][oColorIndex][i] = tmpobject[oColorIndex][i];
- }
- // Get all text settings
- ObjectData[index][ousetext] = tmpobject[ousetext];
- ObjectData[index][oFontFace] = tmpobject[oFontFace];
- ObjectData[index][oFontSize] = tmpobject[oFontSize];
- ObjectData[index][oFontBold] = tmpobject[oFontBold];
- ObjectData[index][oFontColor] = tmpobject[oFontColor];
- ObjectData[index][oBackColor] = tmpobject[oBackColor];
- ObjectData[index][oAlignment] = tmpobject[oAlignment];
- ObjectData[index][oTextFontSize] = tmpobject[oTextFontSize];
- ObjectData[index][oGroup] = 0;
- // Get any text string
- format(ObjectData[index][oObjectText], MAX_TEXT_LENGTH, "%s", tmpobject[oObjectText]);
- UpdateObject3DText(index, true);
- // Add new object to prefab
- GroupedObjects[playerid][index] = true;
- OnUpdateGroup3DText(index);
- // We need to update textures and materials
- UpdateMaterial(index);
- // Update the object text
- UpdateObjectText(index);
- // Save materials to material database
- sqlite_SaveMaterialIndex(index);
- // Save colors to material database
- sqlite_SaveColorIndex(index);
- // Save all text
- sqlite_SaveAllObjectText(index);
- SaveUndoInfo(index, UNDO_TYPE_CREATED, time);
- }
- db_end_transaction(EditMap);
- // Update the Group GUI
- UpdatePlayerGSelText(playerid);
- stmt_close(loadprefabstmt);
- return 1;
- }
- stmt_close(loadprefabstmt);
- return 0;
- }
|