diff --git a/filterscripts/tstudio.amx b/filterscripts/tstudio.amx index 8c92c26..405ec71 100644 Binary files a/filterscripts/tstudio.amx and b/filterscripts/tstudio.amx differ diff --git a/filterscripts/tstudio.pwn b/filterscripts/tstudio.pwn index 95e1f0d..f84af68 100644 --- a/filterscripts/tstudio.pwn +++ b/filterscripts/tstudio.pwn @@ -361,6 +361,7 @@ enum OBJECTINFO oTextFontSize, // Font text size oObjectText[MAX_TEXT_LENGTH], // Font text oAttachedVehicle, // Vehicle object is attached to + Float:oDD // Draw distance } // Copy object material / color diff --git a/filterscripts/tstudio/groups.pwn b/filterscripts/tstudio/groups.pwn index dc2fae6..ef787ff 100644 --- a/filterscripts/tstudio/groups.pwn +++ b/filterscripts/tstudio/groups.pwn @@ -1611,6 +1611,42 @@ YCMD:grz(playerid, arg[], help) 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) diff --git a/filterscripts/tstudio/tsmain.pwn b/filterscripts/tstudio/tsmain.pwn index 94e7cf0..79d9c36 100644 --- a/filterscripts/tstudio/tsmain.pwn +++ b/filterscripts/tstudio/tsmain.pwn @@ -352,6 +352,7 @@ sqlite_LoadMapObjects() 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)) @@ -360,7 +361,7 @@ sqlite_LoadMapObjects() 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); + 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++) @@ -417,7 +418,7 @@ sqlite_InsertObject(index) InsertObjectString, sizeof(InsertObjectString), "INSERT INTO `Objects`", - "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" + "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ); // Prepare data base for writing } @@ -448,6 +449,7 @@ sqlite_InsertObject(index) 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); @@ -501,7 +503,8 @@ sqlite_CreateMapDB() "TextFontSize INTEGER,", "ObjectText TEXT,", "GroupID INTEGER,", - "Note TEXT);" + "Note TEXT,", + "DrawDistance REAL);" ); } @@ -582,8 +585,10 @@ sqlite_UpdateDB() // Version 1.9a if((((dbver & 0x00FF0000) >> 16) <= 1 && ((dbver & 0x0000FF00) >> 8) < 9) || !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"); + } sqlite_UpdateSettings(); return 1; } @@ -698,6 +703,36 @@ sqlite_UpdateObjectPos(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; @@ -1595,7 +1630,7 @@ GetMapCenter(&Float:X, &Float:Y, &Float:Z) return 1; } -AddDynamicObject(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, index = -1, bool:sqlsave = true) +AddDynamicObject(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, index = -1, bool:sqlsave = true, Float:dd = 0.0) { // Index was not specified get a free index if(index == -1) index = Iter_Free(Objects); @@ -1607,8 +1642,8 @@ AddDynamicObject(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:r Iter_Add(Objects, index); // Create object and set data - ObjectData[index][oID] = CreateDynamicObject(modelid, x, y, z, rx, ry, rz, -1, -1, -1, 300.0); - Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[index][oID], E_STREAMER_DRAW_DISTANCE, 300.0); + ObjectData[index][oID] = CreateDynamicObject(modelid, x, y, z, rx, ry, rz, -1, -1, -1, dd != 0.0 ? dd : 300.0); + Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[index][oID], E_STREAMER_DRAW_DISTANCE, dd != 0.0 ? dd : 300.0); #if defined COMPILE_MANGLE ObjectData[index][oCAID] = CA_CreateObject(modelid, x, y, z, rx, ry, rz, true); @@ -1627,6 +1662,7 @@ AddDynamicObject(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:r ObjectData[index][oRX] = rx; ObjectData[index][oRY] = ry; ObjectData[index][oRZ] = rz; + ObjectData[index][oDD] = dd; ObjectData[index][oAttachedVehicle] = -1; @@ -1687,7 +1723,7 @@ 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]); + 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]; @@ -1698,6 +1734,7 @@ CloneObject(index, grouptask=0) ObjectData[cindex][oAlignment] = ObjectData[index][oAlignment]; ObjectData[cindex][oTextFontSize] = ObjectData[index][oTextFontSize]; ObjectData[cindex][oGroup] = ObjectData[index][oGroup]; + ObjectData[cindex][oNote] = ObjectData[index][oNote]; for(new i = 0; i < MAX_MATERIALS; i++) { @@ -2443,8 +2480,14 @@ YCMD:exportmap(playerid, arg[], help) 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]; @@ -2549,7 +2592,7 @@ MapExport(playerid, mapname[], Float:drawdist) { if(ObjectData[i][oAttachedVehicle] > -1) continue; - new bool:writeobject; + 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++) @@ -2569,7 +2612,7 @@ MapExport(playerid, mapname[], Float:drawdist) // 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],drawdist, + 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); } @@ -2577,13 +2620,13 @@ MapExport(playerid, mapname[], Float:drawdist) // 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],drawdist,drawdist, + 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],drawdist,drawdist, + 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); } @@ -2667,7 +2710,7 @@ MapExport(playerid, mapname[], Float:drawdist) { if(ObjectData[i][oAttachedVehicle] > -1) continue; - new bool:writeobject = true; + 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++) @@ -2685,19 +2728,19 @@ MapExport(playerid, mapname[], Float:drawdist) { 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],drawdist, + 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],drawdist,drawdist, + 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],drawdist,drawdist, + 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); } @@ -2957,7 +3000,7 @@ static MapExportAll(playerid, name[], Float:drawdist) { if(ObjectData[i][oAttachedVehicle] > -1) continue; - new bool:writeobject; + 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++) @@ -2974,7 +3017,7 @@ static MapExportAll(playerid, name[], Float:drawdist) { 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],drawdist,drawdist, + 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); @@ -3018,7 +3061,7 @@ static MapExportAll(playerid, name[], Float:drawdist) { if(ObjectData[i][oAttachedVehicle] > -1) continue; - new bool:writeobject = true; + 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++) @@ -3034,7 +3077,7 @@ static MapExportAll(playerid, name[], Float:drawdist) // 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],drawdist,drawdist, + 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); } @@ -4881,6 +4924,37 @@ YCMD:drz(playerid, arg[], help) 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) { diff --git a/filterscripts/tstudio/undo.pwn b/filterscripts/tstudio/undo.pwn index 053cb19..c5b330a 100644 --- a/filterscripts/tstudio/undo.pwn +++ b/filterscripts/tstudio/undo.pwn @@ -18,6 +18,7 @@ enum OBJECTUNDOINFO Float:uoRX, // Rotation Z Float:uoRY, // Rotation Z Float:uoRZ, // Rotation Z + Float:uoDD, // Draw distance uoTexIndex[MAX_MATERIALS], // Texture index ref uoColorIndex[MAX_MATERIALS], // Material List uousetext, // Use text @@ -29,7 +30,7 @@ enum OBJECTUNDOINFO uoAlignment, // Font alignment uoTextFontSize, // Font text size uoObjectText[MAX_TEXT_LENGTH], // Font text - uoNote[64], // Font text + uoNote[64], // Note uoAttachedVehicle, // Vehicle object is attached to uoIndex, // Store indexid object uoType, // Type of undo @@ -49,6 +50,7 @@ SaveUndoInfo(index, type, group=0) UndoBuffer[CurrBufferIndex][uoRX] = ObjectData[index][oRX]; UndoBuffer[CurrBufferIndex][uoRY] = ObjectData[index][oRY]; UndoBuffer[CurrBufferIndex][uoRZ] = ObjectData[index][oRZ]; + UndoBuffer[CurrBufferIndex][uoDD] = ObjectData[index][oDD]; UndoBuffer[CurrBufferIndex][uousetext] = ObjectData[index][ousetext]; UndoBuffer[CurrBufferIndex][uoFontFace] = ObjectData[index][oFontFace]; UndoBuffer[CurrBufferIndex][uoFontSize] = ObjectData[index][oFontSize]; @@ -115,6 +117,7 @@ UndoLastAction(lastgroup=0) ObjectData[index][oRX] = UndoBuffer[CurrBufferIndex][uoRX]; ObjectData[index][oRY] = UndoBuffer[CurrBufferIndex][uoRY]; ObjectData[index][oRZ] = UndoBuffer[CurrBufferIndex][uoRZ]; + ObjectData[index][oDD] = UndoBuffer[CurrBufferIndex][uoDD]; ObjectData[index][ousetext] = UndoBuffer[CurrBufferIndex][uousetext]; ObjectData[index][oFontFace] = UndoBuffer[CurrBufferIndex][uoFontFace]; ObjectData[index][oFontSize] = UndoBuffer[CurrBufferIndex][uoFontSize]; @@ -196,6 +199,7 @@ ClearUndoInfo(index) UndoBuffer[index][uoRX] = 0.0; UndoBuffer[index][uoRY] = 0.0; UndoBuffer[index][uoRZ] = 0.0; + UndoBuffer[index][uoDD] = 0.0; UndoBuffer[index][uousetext] = 0; UndoBuffer[index][uoFontFace] = 0; UndoBuffer[index][uoFontSize] = 0; @@ -212,6 +216,7 @@ ClearUndoInfo(index) } format(UndoBuffer[index][uoObjectText], MAX_TEXT_LENGTH, "None"); + UndoBuffer[index][uoNote][0] = EOS; UndoBuffer[index][uoIndex] = 0; UndoBuffer[index][uoType] = UNDO_TYPE_UNUSED;