Advertisement
Guest User

uoeditor

a guest
Jun 2nd, 2015
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 141.44 KB | None | 0 0
  1. /*
  2. Author:
  3.     Stylock
  4.  
  5. Changelog:
  6.     28-02-2015 (Update 3)
  7.         * Added file import feature
  8.         * Added snap to grid/snap to angle feature
  9.         * Added in-game configuration dialog
  10.         * Added support for Streamer plugin
  11.         * Added rotation sync parameter to the loop feature
  12.         * Overwriting an existing map file is now possible
  13.         * Improved map file recovery feature
  14.         * Improved fly mode camera mobility
  15.         * Improved movement/rotation speed setting when altering with keys
  16.         * Removed object model validity check due to SA-MP 0.3.7 objects
  17.         * Fixed a bug that caused infinite recursion
  18.         * Renamed normal mode to world mode
  19.         * Minor improvements and bug fixes
  20.     08-07-2012 (Update 2)
  21.         * Added new keyboard shortcuts
  22.         * Fixed a bug with file loading
  23.         * Minor bug fixes
  24.     16-06-2012 (Update 1)
  25.         * Renamed world mode to normal mode
  26.         * Corrected a mistake in the help dialog
  27.         * Added a new project file and removed the old one
  28.         * Fixed a bug in the undo feature causing objects to not get destroyed
  29.         * Upgraded several commands to support optional parameters
  30.     13-06-2012
  31.         * First release
  32. */
  33.  
  34. #define FILTERSCRIPT
  35.  
  36. #include <a_samp>
  37. #include <sscanf2>
  38. #include <zcmd>
  39.  
  40. // Config
  41. #define UOE_MAX_ADMINS      (2)     // Max rcon admins allowed to create maps
  42. #define UOE_TIMER_INT       (30)    // Timer interval
  43. #define UOE_MAX_ACTIONS     (300)   // Max actions that can be undone in a row
  44. #define UOE_DRAW_DISTANCE   (800)   // Object draw distance
  45.  
  46. // Invalid ID
  47. #define UOE_INVALID_ID      (-1)
  48.  
  49. // Directories
  50. #define UOE_IMPORT      "maps\\import\\"
  51. #define UOE_RECOVERY    "maps\\recovery\\"
  52. #define UOE_PROJECTS    "maps\\projects\\"
  53. #define UOE_SAVES       "maps\\saves\\"
  54.  
  55. #tryinclude <streamer>
  56.  
  57. #if !defined _inc_streamer
  58.     #define EDIT_OID_IsValid \
  59.         IsValidObject
  60.     #define EDIT_OID_Create \
  61.         CreateObject
  62.     #define EDIT_OID_Destroy \
  63.         DestroyObject
  64.     #define EDIT_OID_SetPos \
  65.         SetObjectPos
  66.     #define EDIT_OID_SetRot \
  67.         SetObjectRot
  68.     #define EDIT_OID_GetPos \
  69.         GetObjectPos
  70.     #define EDIT_OID_GetRot \
  71.         GetObjectRot
  72. #else
  73.     #define EDIT_OID_IsValid \
  74.         IsValidDynamicObject
  75.     #define EDIT_OID_Create \
  76.         CreateDynamicObject
  77.     #define EDIT_OID_Destroy \
  78.         DestroyDynamicObject
  79.     #define EDIT_OID_SetPos \
  80.         SetDynamicObjectPos
  81.     #define EDIT_OID_SetRot \
  82.         SetDynamicObjectRot
  83.     #define EDIT_OID_GetPos \
  84.         GetDynamicObjectPos
  85.     #define EDIT_OID_GetRot \
  86.         GetDynamicObjectRot
  87.     #define DrawDistance streamdistance
  88. #endif
  89.  
  90. #define PUBLIC:%1(%2) \
  91.     forward %1(%2); \
  92.     public %1(%2)
  93.  
  94. // In-game config
  95. enum E_CONFIG
  96. {
  97.     e_Select,
  98.     e_Key_Action,
  99. };
  100.  
  101. enum E_ROAD
  102. {
  103.     e_IDX,
  104.     e_SL,
  105.     e_MA,
  106. };
  107.  
  108. enum E_LOOP
  109. {
  110.     e_SL,
  111.     e_MA,
  112.     e_SR,
  113.     Float:e_O[3],
  114.     Float:e_R[3]
  115. };
  116.  
  117. enum E_EDIT
  118. {
  119.     e_UID,
  120.     e_MID,
  121.     e_Map,
  122.     e_Use,
  123.     e_Lock,
  124.     e_Info[24]
  125. };
  126.  
  127. enum E_ACTION
  128. {
  129.     e_Count,
  130.     e_Extra1,
  131.     e_Extra2,
  132.     Float:e_P[3],
  133.     Float:e_R[3],
  134.     e_EDIT[E_EDIT],
  135.     e_LOOP[E_LOOP],
  136.     e_ROAD[E_ROAD]
  137. };
  138.  
  139. enum E_EDITOR
  140. {
  141.     e_EDIT[E_EDIT],
  142.     e_LOOP[E_LOOP],
  143.     e_ROAD[E_ROAD]
  144. };
  145.  
  146. enum E_PLAYER
  147. {
  148.     e_NRG,
  149.     e_OID,
  150.     e_PID,
  151.     e_Fly,
  152.     e_Snap,
  153.     e_Time,
  154.     e_Timer,
  155.     e_Delay,
  156.     e_Active,
  157.     e_Hold[4],
  158.     e_Mode[3],
  159.     Float:e_Speed[2],
  160.     Float:e_Spawn[4],
  161.     PlayerText:e_Text,
  162.     PlayerText3D:e_3D[MAX_OBJECTS]
  163. };
  164.  
  165. enum E_AXIS
  166. {
  167.     e_OID,
  168.     e_Axis[9],
  169.     Float:e_O[3]
  170. };
  171.  
  172. new
  173.     g_ID[MAX_PLAYERS],
  174.     g_Undo[UOE_MAX_ADMINS],
  175.     g_File[UOE_MAX_ADMINS][10][16],
  176.     g_Axis[UOE_MAX_ADMINS][E_AXIS],
  177.     g_Config[UOE_MAX_ADMINS][E_CONFIG],
  178.     g_Player[UOE_MAX_ADMINS][E_PLAYER],
  179.     g_Editor[UOE_MAX_ADMINS][MAX_OBJECTS][E_EDITOR],
  180.     g_Action[UOE_MAX_ADMINS][UOE_MAX_ACTIONS][E_ACTION];
  181.  
  182. new
  183.     g_Update,
  184.     g_Unique,
  185.     g_Str[256],
  186.     Float:g_Float1[3],
  187.     Float:g_Float2[3],
  188.     Float:sx,
  189.     Float:sy,
  190.     Float:sz,
  191.     Float:cx,
  192.     Float:cy,
  193.     Float:cz;
  194.  
  195. public OnFilterScriptInit()
  196. {
  197.     for(new i = 0; i < UOE_MAX_ADMINS; ++i)
  198.     {
  199.         g_Axis[i][e_O][2] = 9.0;
  200.         g_Config[i][e_Select] = 1;
  201.         g_Player[i][e_Speed][0] = 1.0;
  202.         g_Player[i][e_Speed][1] = 0.6;
  203.         g_Player[i][e_Snap] = 10;
  204.         g_Player[i][e_PID] = UOE_INVALID_ID;
  205.         g_Player[i][e_OID] = UOE_INVALID_ID;
  206.         for(new x = 0; x < MAX_OBJECTS; ++x)
  207.         {
  208.             g_Player[i][e_3D][x] = PlayerText3D:UOE_INVALID_ID;
  209.         }
  210.     }
  211.     for(new i = 0; i < MAX_PLAYERS; ++i)
  212.     {
  213.         if(!IsPlayerAdmin(i))
  214.         {
  215.             g_ID[i] = UOE_INVALID_ID;
  216.         }
  217.         else
  218.         {
  219.             for(new x = 0; x < UOE_MAX_ADMINS; ++x)
  220.             {
  221.                 if(g_Player[x][e_PID] == UOE_INVALID_ID)
  222.                 {
  223.                     g_ID[i] = x;
  224.                     g_Player[x][e_PID] = i;
  225.                     EDIT_TEXTDRAW_Create(i);
  226.                     EDIT_MAP_EmptyRecovery(i);
  227.                     EDIT_MAP_RecoveryManager(i);
  228.                     SendClientMessage(i, 0x2D74FDFF, "Universal Object Editor activated. Type /ehelp to get started.");
  229.                     break;
  230.                 }
  231.             }
  232.         }
  233.     }
  234.     g_Unique = 1;
  235.     g_Update = SetTimer("EDIT_AutoSave", 1800000, 1);
  236.     return 1;
  237. }
  238.  
  239. public OnFilterScriptExit()
  240. {
  241.     new
  242.         pID;
  243.     for(new i = 0; i < UOE_MAX_ADMINS; ++i)
  244.     {
  245.         pID = g_Player[i][e_PID];
  246.         if(pID != UOE_INVALID_ID)
  247.         {
  248.             EDIT_MAP_AutoSave(pID);
  249.             for(new x = 1; x < MAX_OBJECTS; ++x)
  250.             {
  251.                 if(EDIT_OBJECT_IsValid(pID, x))
  252.                 {
  253.                     EDIT_OBJECT_Destroy(pID, x);
  254.                 }
  255.             }
  256.             if(g_Player[i][e_Active])
  257.             {
  258.                 CancelEdit(pID);
  259.             }
  260.             if(g_Player[i][e_Mode][0])
  261.             {
  262.                 TogglePlayerSpectating(pID, 0);
  263.             }
  264.             if(g_Player[i][e_Fly])
  265.             {
  266.                 DestroyObject(g_Player[i][e_Fly]);
  267.             }
  268.             if(g_Player[i][e_Timer])
  269.             {
  270.                 KillTimer(g_Player[i][e_Timer]);
  271.             }
  272.             EDIT_AXIS_Destroy(pID);
  273.             EDIT_VEHICLE_Destroy(pID);
  274.             EDIT_TEXTDRAW_Destroy(pID);
  275.             EDIT_MAP_EmptyRecovery(pID);
  276.         }
  277.     }
  278.     KillTimer(g_Update);
  279.     return 1;
  280. }
  281.  
  282. public OnPlayerDisconnect(playerid, reason)
  283. {
  284.     if(g_ID[playerid] != UOE_INVALID_ID)
  285.     {
  286.         EDIT_MAP_AutoSave(playerid);
  287.         for(new i = 1; i < MAX_OBJECTS; ++i)
  288.         {
  289.             if(EDIT_OBJECT_IsValid(playerid, i))
  290.             {
  291.                 EDIT_OBJECT_Destroy(playerid, i);
  292.             }
  293.             g_Player[g_ID[playerid]][e_3D][i] = PlayerText3D:UOE_INVALID_ID;
  294.         }
  295.         for(new i = 0; i <= 9; ++i)
  296.         {
  297.             g_File[g_ID[playerid]][i][0] = 0;
  298.         }
  299.         if(g_Player[g_ID[playerid]][e_Timer])
  300.         {
  301.             KillTimer(g_Player[g_ID[playerid]][e_Timer]);
  302.             g_Player[g_ID[playerid]][e_Timer] = 0;
  303.         }
  304.         EDIT_AXIS_Destroy(playerid);
  305.         EDIT_VEHICLE_Destroy(playerid);
  306.         EDIT_TEXTDRAW_Destroy(playerid);
  307.         EDIT_ACTION_ResetData(playerid, UOE_INVALID_ID);
  308.         DestroyObject(g_Player[g_ID[playerid]][e_Fly]);
  309.         g_Player[g_ID[playerid]][e_PID] = UOE_INVALID_ID;
  310.         g_Player[g_ID[playerid]][e_OID] = UOE_INVALID_ID;
  311.         g_Player[g_ID[playerid]][e_Snap] = 10;
  312.         g_Player[g_ID[playerid]][e_Speed][0] = 1.0;
  313.         g_Player[g_ID[playerid]][e_Speed][1] = 0.6;
  314.         g_Player[g_ID[playerid]][e_Mode][0] = 0;
  315.         g_Player[g_ID[playerid]][e_Mode][1] = 0;
  316.         g_Player[g_ID[playerid]][e_Mode][2] = 0;
  317.         g_Player[g_ID[playerid]][e_Active] = 0;
  318.         g_Axis[g_ID[playerid]][e_O][0] = 0.0;
  319.         g_Axis[g_ID[playerid]][e_O][1] = 0.0;
  320.         g_Axis[g_ID[playerid]][e_O][2] = 9.0;
  321.         g_ID[playerid] = UOE_INVALID_ID;
  322.     }
  323.     return 1;
  324. }
  325.  
  326. public OnPlayerRequestClass(playerid)
  327. {
  328.     if(g_ID[playerid] != UOE_INVALID_ID)
  329.     {
  330.         if(g_Player[g_ID[playerid]][e_Active])
  331.         {
  332.             g_Player[g_ID[playerid]][e_Active] = 0;
  333.             CancelEdit(playerid);
  334.         }
  335.         EDIT_OBJECT_SetActive(playerid, UOE_INVALID_ID);
  336.     }
  337.     return 1;
  338. }
  339.  
  340. public OnPlayerDeath(playerid, killerid, reason)
  341. {
  342.     if(g_ID[playerid] != UOE_INVALID_ID)
  343.     {
  344.         if(g_Player[g_ID[playerid]][e_Mode][0])
  345.         {
  346.             SpawnPlayer(playerid);
  347.         }
  348.         if(g_Player[g_ID[playerid]][e_Active])
  349.         {
  350.             g_Player[g_ID[playerid]][e_Active] = 0;
  351.             CancelEdit(playerid);
  352.         }
  353.     }
  354.     return 1;
  355. }
  356.  
  357. public OnPlayerSpawn(playerid)
  358. {
  359.     if(g_ID[playerid] != UOE_INVALID_ID)
  360.     {
  361.         if(g_Player[g_ID[playerid]][e_Mode][0])
  362.         {
  363.             if(g_Player[g_ID[playerid]][e_Mode][0] == 2)
  364.             {
  365.                 SetTimerEx("EDIT_SpawnPlayer", 1000, 0, "i", playerid);
  366.                 GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~g~prepare to teleport...", 1000, 3);
  367.             }
  368.             else
  369.             {
  370.                 if(EDIT_OID_IsValid(g_Player[g_ID[playerid]][e_Fly]))
  371.                 {
  372.                     TogglePlayerSpectating(playerid, 1);
  373.                     AttachCameraToObject(playerid, g_Player[g_ID[playerid]][e_Fly]);
  374.                 }
  375.             }
  376.         }
  377.         if(g_Player[g_ID[playerid]][e_Active])
  378.         {
  379.             g_Player[g_ID[playerid]][e_Active] = 0;
  380.             CancelEdit(playerid);
  381.         }
  382.     }
  383.     return 0;
  384. }
  385.  
  386. public OnRconLoginAttempt(ip[], password[], success)
  387. {
  388.     if(success)
  389.     {
  390.         new
  391.             ip_addr[16];
  392.         for(new i = 0; i < MAX_PLAYERS; ++i)
  393.         {
  394.             if(IsPlayerConnected(i) && !IsPlayerNPC(i))
  395.             {
  396.                 if(g_ID[i] == UOE_INVALID_ID)
  397.                 {
  398.                     GetPlayerIp(i, ip_addr, 16);
  399.                     if(!strcmp(ip, ip_addr, false))
  400.                     {
  401.                         for(new x = 0; x < UOE_MAX_ADMINS; ++x)
  402.                         {
  403.                             if(g_Player[x][e_PID] == UOE_INVALID_ID)
  404.                             {
  405.                                 g_ID[i] = x;
  406.                                 g_Player[x][e_PID] = i;
  407.                                 EDIT_TEXTDRAW_Create(i);
  408.                                 EDIT_MAP_EmptyRecovery(i);
  409.                                 EDIT_MAP_RecoveryManager(i);
  410.                                 SendClientMessage(i, 0x2D74FDFF, "Universal Object Editor activated. Type /ehelp to get started.");
  411.                                 SetPlayerWeather(i, 11);
  412.                                 SetPlayerTime(i, 0, 30);
  413.                                 return 1;
  414.                             }
  415.                         }
  416.                     }
  417.                 }
  418.             }
  419.         }
  420.     }
  421.     return 1;
  422. }
  423.  
  424. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  425. {
  426.     if(g_ID[playerid] != UOE_INVALID_ID)
  427.     {
  428.         if((newkeys - oldkeys) == 16)
  429.         {
  430.             if(!IsPlayerInAnyVehicle(playerid))
  431.             {
  432.                 if(newkeys & 1024)
  433.                 {
  434.                     EDIT_FLY_Switch(playerid);
  435.                     return 1;
  436.                 }
  437.             }
  438.             else
  439.             {
  440.                 if(newkeys & 4)
  441.                 {
  442.                     EDIT_FLY_Switch(playerid);
  443.                     return 1;
  444.                 }
  445.             }
  446.         }
  447.         if(!g_Player[g_ID[playerid]][e_Mode][0])
  448.         {
  449.             if((newkeys - oldkeys) == 131072)
  450.             {
  451.                 if(!g_Player[g_ID[playerid]][e_Mode][0])
  452.                 {
  453.                     EDIT_VEHICLE_Spawn(playerid, 522, 0);
  454.                     return 1;
  455.                 }
  456.             }
  457.         }
  458.         else
  459.         {
  460.             if((newkeys - oldkeys) == 16384)
  461.             {
  462.                 new
  463.                     oID;
  464.                 oID = g_Player[g_ID[playerid]][e_OID];
  465.                 if(EDIT_OBJECT_IsValid(playerid, oID))
  466.                 {
  467.                     EDIT_ACTION_Save(playerid, oID);
  468.                     EDIT_OBJECT_SetModel(playerid, oID, g_Editor[g_ID[playerid]][oID][e_EDIT][e_MID] + 1);
  469.                     return 1;
  470.                 }
  471.             }
  472.             if((newkeys - oldkeys) == 8192)
  473.             {
  474.                 new
  475.                     oID;
  476.                 oID = g_Player[g_ID[playerid]][e_OID];
  477.                 if(EDIT_OBJECT_IsValid(playerid, oID))
  478.                 {
  479.                     EDIT_ACTION_Save(playerid, oID);
  480.                     EDIT_OBJECT_SetModel(playerid, oID, g_Editor[g_ID[playerid]][oID][e_EDIT][e_MID] - 1);
  481.                     return 1;
  482.                 }
  483.             }
  484.             if((newkeys - oldkeys) == 4)
  485.             {
  486.                 new
  487.                     oID;
  488.                 oID = g_Player[g_ID[playerid]][e_OID];
  489.                 if(!EDIT_OBJECT_IsValid(playerid, oID))
  490.                 {
  491.                     g_Player[g_ID[playerid]][e_Active] = 1;
  492.                     g_Player[g_ID[playerid]][e_Hold][0] = 0;
  493.                     g_Player[g_ID[playerid]][e_Hold][1] = 0;
  494.                     g_Player[g_ID[playerid]][e_Delay] = GetTickCount();
  495.                     SelectObject(playerid);
  496.                 }
  497.                 EDIT_OBJECT_SetActive(playerid, UOE_INVALID_ID);
  498.                 return 1;
  499.             }
  500.             if((newkeys - oldkeys) == 2)
  501.             {
  502.                 if(newkeys & 1024)
  503.                 {
  504.                     if(!g_Player[g_ID[playerid]][e_Mode][2])
  505.                     {
  506.                         EDIT_AXIS_Hide(playerid);
  507.                         g_Player[g_ID[playerid]][e_Mode][2] = 1;
  508.                     }
  509.                     else
  510.                     {
  511.                         if(g_Player[g_ID[playerid]][e_Mode][2] == 1)
  512.                         {
  513.                             if(g_Player[g_ID[playerid]][e_Snap])
  514.                             {
  515.                                 EDIT_AXIS_Hide(playerid);
  516.                                 g_Player[g_ID[playerid]][e_Mode][2] = 2;
  517.                             }
  518.                             else
  519.                             {
  520.                                 EDIT_AXIS_Show(playerid);
  521.                                 g_Player[g_ID[playerid]][e_Mode][2] = 0;
  522.                             }
  523.                         }
  524.                         else
  525.                         {
  526.                             EDIT_AXIS_Show(playerid);
  527.                             g_Player[g_ID[playerid]][e_Mode][2] = 0;
  528.                         }
  529.                     }
  530.                 }
  531.                 else
  532.                 {
  533.                     if(!g_Player[g_ID[playerid]][e_Mode][1])
  534.                     {
  535.                         g_Player[g_ID[playerid]][e_Mode][1] = 1;
  536.                     }
  537.                     else
  538.                     {
  539.                         g_Player[g_ID[playerid]][e_Mode][1] = 0;
  540.                     }
  541.                 }
  542.                 PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
  543.                 EDIT_TEXTDRAW_Update(playerid);
  544.                 return 1;
  545.             }
  546.             if((newkeys - oldkeys) == 16)
  547.             {
  548.                 switch(g_Config[g_ID[playerid]][e_Key_Action])
  549.                 {
  550.                     case 0:
  551.                     {
  552.                         new
  553.                             oID;
  554.                         oID = g_Player[g_ID[playerid]][e_OID];
  555.                         if(EDIT_OBJECT_IsValid(playerid, oID))
  556.                         {
  557.                             if(EDIT_ROAD_IsValidModel(playerid, oID))
  558.                             {
  559.                                 new
  560.                                     road;
  561.                                 road = EDIT_ROAD_GetNearest(playerid, oID);
  562.                                 if(road)
  563.                                 {
  564.                                     if(!g_Editor[g_ID[playerid]][oID][e_ROAD][e_IDX])
  565.                                     {
  566.                                         SendClientMessage(playerid, 0xCD5C5CFF, "This road model is not supported by the road attachment feature.");
  567.                                     }
  568.                                     else
  569.                                     {
  570.                                         EDIT_ACTION_Save(playerid, oID);
  571.                                         EDIT_ROAD_AttachFirst(playerid, oID, road);
  572.                                     }
  573.                                 }
  574.                                 else
  575.                                 {
  576.                                     SendClientMessage(playerid, 0xCD5C5CFF, "No roads found nearby.");
  577.                                 }
  578.                             }
  579.                         }
  580.                     }
  581.                     case 1:
  582.                     {
  583.                         new
  584.                             oID;
  585.                         oID = g_Player[g_ID[playerid]][e_OID];
  586.                         if(EDIT_OBJECT_IsValid(playerid, oID))
  587.                         {
  588.                             new
  589.                                 Float:cam_x1,
  590.                                 Float:cam_y1,
  591.                                 Float:cam_z1,
  592.                                 Float:cam_x2,
  593.                                 Float:cam_y2,
  594.                                 Float:cam_z2;
  595.                             EDIT_ACTION_Save(playerid, oID, 0);
  596.                             EDIT_LOOP_SetMA(playerid, oID, 0);
  597.                             EDIT_ROAD_SetMA(playerid, oID, 0);
  598.                             GetPlayerCameraPos(playerid, cam_x1, cam_y1, cam_z1);
  599.                             GetPlayerCameraFrontVector(playerid, cam_x2, cam_y2, cam_z2);
  600.                             cam_x1 = cam_x1 + cam_x2 * 20.0;
  601.                             cam_y1 = cam_y1 + cam_y2 * 20.0;
  602.                             cam_z1 = cam_z1 + cam_z2 * 20.0;
  603.                             EDIT_OBJECT_SetPos(playerid, oID, cam_x1, cam_y1, cam_z1);
  604.                             EDIT_ROAD_SetPos(playerid, oID);
  605.                             EDIT_LOOP_SetPos(playerid, oID);
  606.                             PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
  607.                         }
  608.                     }
  609.                     case 2:
  610.                     {
  611.                         new
  612.                             oID;
  613.                         oID = g_Player[g_ID[playerid]][e_OID];
  614.                         if(EDIT_OBJECT_IsValid(playerid, oID))
  615.                         {
  616.                             new
  617.                                 Float:float1[3];
  618.                             EDIT_OBJECT_GetPos(playerid, oID, float1);
  619.                             if(g_Player[g_ID[playerid]][e_Mode][0])
  620.                             {
  621.                                 SetObjectPos(g_Player[g_ID[playerid]][e_Fly], float1[0], float1[1], float1[2] + 4.0);
  622.                             }
  623.                         }
  624.                     }
  625.                     case 3:
  626.                     {
  627.                         new
  628.                             oID;
  629.                         oID = g_Player[g_ID[playerid]][e_OID];
  630.                         if(EDIT_OBJECT_IsValid(playerid, oID))
  631.                         {
  632.                             EDIT_ACTION_Save(playerid, oID);
  633.                             EDIT_OBJECT_Destroy(playerid, oID);
  634.                         }
  635.                     }
  636.                     case 4:
  637.                     {
  638.                         if(EDIT_ACTION_Undo(playerid))
  639.                         {
  640.                             SendClientMessage(playerid, 0x99FF66FF, "Editor: Last action has been undone.");
  641.                         }
  642.                         else
  643.                         {
  644.                             PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  645.                         }
  646.                     }
  647.                 }
  648.                 return 1;
  649.             }
  650.         }
  651.     }
  652.     return 1;
  653. }
  654.  
  655. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  656. {
  657.     switch(dialogid)
  658.     {
  659.         case 100:
  660.         {
  661.             if(response)
  662.             {
  663.                 PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
  664.                 EDIT_DIALOG_Show(playerid, 1);
  665.             }
  666.             else
  667.             {
  668.                 PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
  669.             }
  670.             return 1;
  671.         }
  672.         case 101:
  673.         {
  674.             if(response)
  675.             {
  676.                 PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
  677.                 EDIT_DIALOG_Show(playerid, 2);
  678.             }
  679.             else
  680.             {
  681.                 PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
  682.                 EDIT_DIALOG_Show(playerid, 0);
  683.             }
  684.             return 1;
  685.         }
  686.         case 102:
  687.         {
  688.             if(!response)
  689.             {
  690.                 PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
  691.                 EDIT_DIALOG_Show(playerid, 1);
  692.             }
  693.             else
  694.             {
  695.                 PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
  696.             }
  697.             return 1;
  698.         }
  699.         case 103:
  700.         {
  701.             if(response)
  702.             {
  703.                 format(inputtext, 32, "%.2s", inputtext);
  704.                 EDIT_ACTION_Save(playerid, strval(inputtext), 1);
  705.                 if(EDIT_MAP_Unload(playerid, strval(inputtext)))
  706.                 {
  707.                     SendClientMessage(playerid, 0x99FF66FF, "Editor: Map successfully unloaded.");
  708.                 }
  709.             }
  710.             return 1;
  711.         }
  712.         case 104:
  713.         {
  714.             if(response)
  715.             {
  716.                 new
  717.                     map;
  718.                 map = EDIT_MAP_GetSlot(playerid);
  719.                 if(map == UOE_INVALID_ID)
  720.                 {
  721.                     return SendClientMessage(playerid, 0xCD5C5CFF, "Error: Too much maps loaded.");
  722.                 }
  723.                 new
  724.                     load,
  725.                     str[32];
  726.                 format(str, 32, "autosave-%s", EDIT_GetName(playerid));
  727.                 load = EDIT_MAP_Load(playerid, map, UOE_RECOVERY, str);
  728.                 if(load)
  729.                 {
  730.                     format(g_Str, 128, "Editor: %d objects successfully restored.", load);
  731.                     SendClientMessage(playerid, 0x99FF66FF, g_Str);
  732.                 }
  733.                 else
  734.                 {
  735.                     SendClientMessage(playerid, 0x99FF66FF, "Editor: No objects restored.");
  736.                 }
  737.             }
  738.             EDIT_MAP_EmptyRecovery(playerid, 1);
  739.             return 1;
  740.         }
  741.         case 105:
  742.         {
  743.             if(response)
  744.             {
  745.                 switch(listitem)
  746.                 {
  747.                     case 0:
  748.                     {
  749.                         if(!g_Config[g_ID[playerid]][e_Select])
  750.                         {
  751.                             g_Config[g_ID[playerid]][e_Select] = 1;
  752.                         }
  753.                         else
  754.                         {
  755.                             g_Config[g_ID[playerid]][e_Select] = 0;
  756.                         }
  757.                         EDIT_DIALOG_Show(playerid, 5);
  758.                     }
  759.                     case 1:
  760.                     {
  761.                         EDIT_DIALOG_Show(playerid, 6);
  762.                     }
  763.                     case 2:
  764.                     {
  765.                         EDIT_Cloudless(playerid, 0);
  766.                     }
  767.                 }
  768.             }
  769.             return 1;
  770.         }
  771.         case 106:
  772.         {
  773.             if(response)
  774.             {
  775.                 g_Config[playerid][e_Key_Action] = listitem;
  776.             }
  777.             EDIT_DIALOG_Show(playerid, 5);
  778.             return 1;
  779.         }
  780.     }
  781.     return 0;
  782. }
  783.  
  784. #if defined _inc_streamer
  785.  
  786. public OnPlayerSelectDynamicObject(playerid, objectid, modelid, Float:x, Float:y, Float:z)
  787. {
  788.     if(EDIT_OBJECT_IsValid(playerid, objectid))
  789.     {
  790.         if(GetTickCount() - g_Player[g_ID[playerid]][e_Delay] > 200)
  791.         {
  792.             if(g_Editor[g_ID[playerid]][objectid][e_EDIT][e_Lock])
  793.             {
  794.                 return SendClientMessage(playerid, 0xCD5C5CFF, "This object is locked.");
  795.             }
  796.             EDIT_OBJECT_SetActive(playerid, objectid);
  797.             g_Player[g_ID[playerid]][e_Active] = 0;
  798.             CancelEdit(playerid);
  799.         }
  800.     }
  801.     return 1;
  802. }
  803.  
  804. #else
  805.  
  806. public OnPlayerSelectObject(playerid, type, objectid, modelid, Float:fX, Float:fY, Float:fZ)
  807. {
  808.     if(type == SELECT_OBJECT_GLOBAL_OBJECT)
  809.     {
  810.         if(EDIT_OBJECT_IsValid(playerid, objectid))
  811.         {
  812.             if(GetTickCount() - g_Player[g_ID[playerid]][e_Delay] > 200)
  813.             {
  814.                 if(g_Editor[g_ID[playerid]][objectid][e_EDIT][e_Lock])
  815.                 {
  816.                     return SendClientMessage(playerid, 0xCD5C5CFF, "This object is locked.");
  817.                 }
  818.                 EDIT_OBJECT_SetActive(playerid, objectid);
  819.                 g_Player[g_ID[playerid]][e_Active] = 0;
  820.                 CancelEdit(playerid);
  821.             }
  822.         }
  823.     }
  824.     return 1;
  825. }
  826.  
  827. #endif
  828.  
  829. CMD:ecreate(user, params[])
  830. {
  831.     return cmd_eadd(user, params);
  832. }
  833.  
  834. CMD:eadd(user, params[])
  835. {
  836.     if(g_ID[user] != UOE_INVALID_ID)
  837.     {
  838.         if(g_Player[g_ID[user]][e_Mode][0])
  839.         {
  840.             new
  841.                 mID,
  842.                 info[24];
  843.             if(sscanf(params, "iS()[24]", mID, info))
  844.             {
  845.                 return SendClientMessage(user, 0x99FF66FF, "Usage: /eadd <model> <comment>");
  846.             }
  847.             if(g_Player[g_ID[user]][e_Active])
  848.             {
  849.                 g_Player[g_ID[user]][e_Active] = 0;
  850.                 CancelEdit(user);
  851.             }
  852.             new
  853.                 oID,
  854.                 Float:cam_x1,
  855.                 Float:cam_y1,
  856.                 Float:cam_z1,
  857.                 Float:cam_x2,
  858.                 Float:cam_y2,
  859.                 Float:cam_z2;
  860.             GetPlayerCameraPos(user, cam_x1, cam_y1, cam_z1);
  861.             GetPlayerCameraFrontVector(user, cam_x2, cam_y2, cam_z2);
  862.             cam_x1 = cam_x1 + cam_x2 * 20.0;
  863.             cam_y1 = cam_y1 + cam_y2 * 20.0;
  864.             cam_z1 = cam_z1 + cam_z2 * 20.0;
  865.             oID = EDIT_OBJECT_Create(user, ++g_Unique, mID, cam_x1, cam_y1, cam_z1, 0.0, 0.0, 0.0);
  866.             if(oID != UOE_INVALID_ID)
  867.             {
  868.                 EDIT_ACTION_Save(user, oID);
  869.                 g_Editor[g_ID[user]][oID][e_EDIT][e_MID] = mID;
  870.                 g_Editor[g_ID[user]][oID][e_EDIT][e_Info] = info;
  871.                 EDIT_3DTEXTLABEL_Create(user, oID);
  872.                 if(g_Config[g_ID[user]][e_Select])
  873.                 {
  874.                     EDIT_OBJECT_SetActive(user, oID);
  875.                 }
  876.             }
  877.             else
  878.             {
  879.                 SendClientMessage(user, 0xCD5C5CFF, "Unexpected error occurred.");
  880.             }
  881.         }
  882.         else
  883.         {
  884.             SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
  885.         }
  886.         return 1;
  887.     }
  888.     return 0;
  889. }
  890.  
  891. CMD:edestroy(user, params[])
  892. {
  893.     return cmd_edel(user, params);
  894. }
  895.  
  896. CMD:edelete(user, params[])
  897. {
  898.     return cmd_edel(user, params);
  899. }
  900.  
  901. CMD:edel(user, params[])
  902. {
  903.     if(g_ID[user] != UOE_INVALID_ID)
  904.     {
  905.         if(g_Player[g_ID[user]][e_Mode][0])
  906.         {
  907.             if(!strcmp(params, "/all", true, 2))
  908.             {
  909.                 new
  910.                     check;
  911.                 for(new i = 1; i < MAX_OBJECTS; ++i)
  912.                 {
  913.                     if(EDIT_OBJECT_IsValid(user, i))
  914.                     {
  915.                         check = 1;
  916.                         EDIT_OBJECT_Destroy(user, i);
  917.                     }
  918.                 }
  919.                 for(new i = 0; i <= 9; ++i)
  920.                 {
  921.                     g_File[g_ID[user]][i][0] = 0;
  922.                 }
  923.                 if(check)
  924.                 {
  925.                     PlayerPlaySound(user, 100008, 0.0, 0.0, 0.0);
  926.                 }
  927.                 EDIT_ACTION_ResetData(user, UOE_INVALID_ID);
  928.                 return 1;
  929.             }
  930.             new
  931.                 oID;
  932.             if(sscanf(params, "i", oID))
  933.             {
  934.                 oID = g_Player[g_ID[user]][e_OID];
  935.                 if(!EDIT_OBJECT_IsValid(user, oID))
  936.                 {
  937.                     return SendClientMessage(user, 0x99FF66FF, "Usage: /edel <object | /all>");
  938.                 }
  939.             }
  940.             else if(!EDIT_OBJECT_IsValid(user, oID))
  941.             {
  942.                 return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID.");
  943.             }
  944.             if(g_Editor[g_ID[user]][oID][e_EDIT][e_Lock])
  945.             {
  946.                 return SendClientMessage(user, 0xCD5C5CFF, "This object is locked.");
  947.             }
  948.             EDIT_ACTION_Save(user, oID);
  949.             EDIT_OBJECT_Destroy(user, oID);
  950.         }
  951.         else
  952.         {
  953.             SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
  954.         }
  955.         return 1;
  956.     }
  957.     return 0;
  958. }
  959.  
  960. CMD:eselect(user, params[])
  961. {
  962.     return cmd_esel(user, params);
  963. }
  964.  
  965. CMD:esel(user, params[])
  966. {
  967.     if(g_ID[user] != UOE_INVALID_ID)
  968.     {
  969.         if(g_Player[g_ID[user]][e_Mode][0])
  970.         {
  971.             new
  972.                 oID;
  973.             if(sscanf(params, "i", oID))
  974.             {
  975.                 g_Player[g_ID[user]][e_Active] = 1;
  976.                 EDIT_OBJECT_SetActive(user, UOE_INVALID_ID);
  977.                 SelectObject(user);
  978.                 return 1;
  979.             }
  980.             else if(!EDIT_OBJECT_IsValid(user, oID))
  981.             {
  982.                 return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID.");
  983.             }
  984.             if(g_Editor[g_ID[user]][oID][e_EDIT][e_Lock])
  985.             {
  986.                 return SendClientMessage(user, 0xCD5C5CFF, "This object is locked.");
  987.             }
  988.             if(g_Player[g_ID[user]][e_Active])
  989.             {
  990.                 g_Player[g_ID[user]][e_Active] = 0;
  991.                 CancelEdit(user);
  992.             }
  993.             EDIT_OBJECT_SetActive(user, oID);
  994.         }
  995.         else
  996.         {
  997.             SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
  998.         }
  999.         return 1;
  1000.     }
  1001.     return 0;
  1002. }
  1003.  
  1004. CMD:eplace(user, params[])
  1005. {
  1006.     return cmd_edesel(user, params);
  1007. }
  1008.  
  1009. CMD:edeselect(user, params[])
  1010. {
  1011.     return cmd_edesel(user, params);
  1012. }
  1013. CMD:edesel(user, params[])
  1014. {
  1015.     if(g_ID[user] != UOE_INVALID_ID)
  1016.     {
  1017.         if(g_Player[g_ID[user]][e_Mode][0])
  1018.         {
  1019.             new
  1020.                 slot;
  1021.             slot = g_Player[g_ID[user]][e_OID];
  1022.             if(EDIT_OBJECT_IsValid(user, slot))
  1023.             {
  1024.                 EDIT_OBJECT_SetActive(user, UOE_INVALID_ID);
  1025.             }
  1026.         }
  1027.         else
  1028.         {
  1029.             SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
  1030.         }
  1031.         return 1;
  1032.     }
  1033.     return 0;
  1034. }
  1035.  
  1036. CMD:ecopy(user, params[])
  1037. {
  1038.     if(g_ID[user] != UOE_INVALID_ID)
  1039.     {
  1040.         if(g_Player[g_ID[user]][e_Mode][0])
  1041.         {
  1042.             new
  1043.                 oID,
  1044.                 info[24];
  1045.             if(sscanf(params, "iS()[24]", oID, info))
  1046.             {
  1047.                 oID = g_Player[g_ID[user]][e_OID];
  1048.                 if(!EDIT_OBJECT_IsValid(user, oID))
  1049.                 {
  1050.                     return SendClientMessage(user, 0x99FF66FF, "Usage: /ecopy <object> <comment>");
  1051.                 }
  1052.                 else
  1053.                 {
  1054.                     sscanf(params, "S()[24]", info);
  1055.                 }
  1056.             }
  1057.             else if(!EDIT_OBJECT_IsValid(user, oID))
  1058.             {
  1059.                 return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID.");
  1060.             }
  1061.             if(g_Editor[g_ID[user]][oID][e_EDIT][e_Lock])
  1062.             {
  1063.                 return SendClientMessage(user, 0xCD5C5CFF, "This object is locked.");
  1064.             }
  1065.             if(g_Player[g_ID[user]][e_Active])
  1066.             {
  1067.                 g_Player[g_ID[user]][e_Active] = 0;
  1068.                 CancelEdit(user);
  1069.             }
  1070.             new
  1071.                 mID,
  1072.                 Float:float1[3],
  1073.                 Float:float2[3];
  1074.             EDIT_OBJECT_GetPos(user, oID, float1);
  1075.             EDIT_OBJECT_GetRot(user, oID, float2);
  1076.             mID = g_Editor[g_ID[user]][oID][e_EDIT][e_MID];
  1077.             oID = EDIT_OBJECT_Create(user, ++g_Unique, mID, float1[0], float1[1], float1[2], float2[0], float2[1], float2[2]);
  1078.             if(oID != UOE_INVALID_ID)
  1079.             {
  1080.                 EDIT_ACTION_Save(user, oID);
  1081.                 g_Editor[g_ID[user]][oID][e_EDIT][e_MID] = mID;
  1082.                 g_Editor[g_ID[user]][oID][e_EDIT][e_Info] = info;
  1083.                 EDIT_OBJECT_SetActive(user, oID);
  1084.             }
  1085.             else
  1086.             {
  1087.                 SendClientMessage(user, 0xCD5C5CFF, "Unexpected error occurred.");
  1088.             }
  1089.         }
  1090.         else
  1091.         {
  1092.             SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
  1093.         }
  1094.         return 1;
  1095.     }
  1096.     return 0;
  1097. }
  1098.  
  1099. CMD:emodel(user, params[])
  1100. {
  1101.     if(g_ID[user] != UOE_INVALID_ID)
  1102.     {
  1103.         if(g_Player[g_ID[user]][e_Mode][0])
  1104.         {
  1105.             new
  1106.                 oID,
  1107.                 mID;
  1108.             if(sscanf(params, "iI(-1)", oID, mID))
  1109.             {
  1110.                 return SendClientMessage(user, 0x99FF66FF, "Usage: /emodel <object> <model>");
  1111.             }
  1112.             if(oID && mID == -1)
  1113.             {
  1114.                 mID = oID;
  1115.                 oID = g_Player[g_ID[user]][e_OID];
  1116.                 if(!EDIT_OBJECT_IsValid(user, oID))
  1117.                 {
  1118.                     return SendClientMessage(user, 0x99FF66FF, "Usage: /emodel <object> <model>");
  1119.                 }
  1120.             }
  1121.             else if(!EDIT_OBJECT_IsValid(user, oID))
  1122.             {
  1123.                 return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID.");
  1124.             }
  1125.             if(g_Editor[g_ID[user]][oID][e_EDIT][e_Lock])
  1126.             {
  1127.                 return SendClientMessage(user, 0xCD5C5CFF, "This object is locked.");
  1128.             }
  1129.             if(g_Editor[g_ID[user]][oID][e_EDIT][e_MID] != mID)
  1130.             {
  1131.                 EDIT_ACTION_Save(user, oID);
  1132.                 EDIT_OBJECT_SetModel(user, oID, mID);
  1133.             }
  1134.         }
  1135.         else
  1136.         {
  1137.             SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
  1138.         }
  1139.         return 1;
  1140.     }
  1141.     return 0;
  1142. }
  1143.  
  1144. CMD:eloop(user, params[])
  1145. {
  1146.     if(g_ID[user] != UOE_INVALID_ID)
  1147.     {
  1148.         if(g_Player[g_ID[user]][e_Mode][0])
  1149.         {
  1150.             new
  1151.                 oID;
  1152.             oID = g_Player[g_ID[user]][e_OID];
  1153.             if(!EDIT_OBJECT_IsValid(user, oID))
  1154.             {
  1155.                 return SendClientMessage(user, 0xCD5C5CFF, "Select an object first using /esel command.");
  1156.             }
  1157.             new
  1158.                 loop,
  1159.                 sync_rot = -1,
  1160.                 Float:float1[3] = {-1000.0, -1000.0, -1000.0},
  1161.                 Float:float2[3] = {-1000.0, -1000.0, -1000.0};
  1162.             if(!strcmp(params, "/sync", true, 5))
  1163.             {
  1164.                 if(!g_Editor[g_ID[user]][oID][e_LOOP][e_SR])
  1165.                 {
  1166.                     g_Editor[g_ID[user]][oID][e_LOOP][e_SR] = 1;
  1167.                 }
  1168.                 else
  1169.                 {
  1170.                     g_Editor[g_ID[user]][oID][e_LOOP][e_SR] = 0;
  1171.                 }
  1172.                 loop = EDIT_LOOP_GetSLCount(user, oID);
  1173.             }
  1174.             else
  1175.             {
  1176.                 if(strcmp(params, "/del", true, 4))
  1177.                 {
  1178.                     if(sscanf(params, "iA<f>(-1000.0)[3]A<f>(-1000.0)[3]I(-1)", loop, float1, float2, sync_rot))
  1179.                     {
  1180.                         return SendClientMessage(user, 0x99FF66FF, "Usage: /eloop <amount | /sync | /del> <offset x> <offset y> <offset z> <rot x> <rot y> <rot z> <sync rot>");
  1181.                     }
  1182.                 }
  1183.             }
  1184.             EDIT_ACTION_Save(user, oID);
  1185.             EDIT_LOOP_SetMA(user, oID, 0);
  1186.             if(!EDIT_LOOP_Create(user, oID, loop, float1, float2, sync_rot))
  1187.             {
  1188.                 EDIT_ACTION_Undo(user);
  1189.             }
  1190.         }
  1191.         else
  1192.         {
  1193.             SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
  1194.         }
  1195.         return 1;
  1196.     }
  1197.     return 0;
  1198. }
  1199.  
  1200. CMD:eundo(user, params[])
  1201. {
  1202.     if(g_ID[user] != UOE_INVALID_ID)
  1203.     {
  1204.         if(g_Player[g_ID[user]][e_Mode][0])
  1205.         {
  1206.             new
  1207.                 amount;
  1208.             sscanf(params, "I(0)", amount);
  1209.             if(amount < 2)
  1210.             {
  1211.                 if(EDIT_ACTION_Undo(user))
  1212.                 {
  1213.                     SendClientMessage(user, 0x99FF66FF, "Editor: Last action has been undone.");
  1214.                 }
  1215.                 else
  1216.                 {
  1217.                     PlayerPlaySound(user, 1085, 0.0, 0.0, 0.0);
  1218.                 }
  1219.             }
  1220.             else
  1221.             {
  1222.                 new
  1223.                     undo;
  1224.                 for(undo = 0; undo < amount; ++undo)
  1225.                 {
  1226.                     if(!EDIT_ACTION_Undo(user))
  1227.                     {
  1228.                         PlayerPlaySound(user, 1085, 0.0, 0.0, 0.0);
  1229.                         break;
  1230.                     }
  1231.                 }
  1232.                 if(undo)
  1233.                 {
  1234.                     if(undo > 1)
  1235.                     {
  1236.                         format(g_Str, 64, "Editor: %d actions have been undone.", undo);
  1237.                         SendClientMessage(user, 0x99FF66FF, g_Str);
  1238.                     }
  1239.                     else
  1240.                     {
  1241.                         SendClientMessage(user, 0x99FF66FF, "Editor: Last action has been undone.");
  1242.                     }
  1243.                 }
  1244.             }
  1245.         }
  1246.         else
  1247.         {
  1248.             SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
  1249.         }
  1250.         return 1;
  1251.     }
  1252.     return 0;
  1253. }
  1254.  
  1255. CMD:etp(user, params[])
  1256. {
  1257.     return cmd_egoto(user, params);
  1258. }
  1259.  
  1260. CMD:eteleport(user, params[])
  1261. {
  1262.     return cmd_egoto(user, params);
  1263. }
  1264.  
  1265. CMD:egoto(user, params[])
  1266. {
  1267.     if(g_ID[user] != UOE_INVALID_ID)
  1268.     {
  1269.         new
  1270.             oID,
  1271.             str[32];
  1272.         if(sscanf(params, "s[32]", str))
  1273.         {
  1274.             oID = g_Player[g_ID[user]][e_OID];
  1275.             if(!EDIT_OBJECT_IsValid(user, oID))
  1276.             {
  1277.                 return SendClientMessage(user, 0x99FF66FF, "Usage: /egoto <object | map name>");
  1278.             }
  1279.         }
  1280.         else
  1281.         {
  1282.             oID = strval(str);
  1283.             if(!EDIT_OBJECT_IsValid(user, oID))
  1284.             {
  1285.                 oID = EDIT_MAP_GetFirstObject(user, str);
  1286.                 if(!oID)
  1287.                 {
  1288.                     return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID/map name.");
  1289.                 }
  1290.             }
  1291.         }
  1292.         new
  1293.             Float:float1[3];
  1294.         EDIT_OBJECT_GetPos(user, oID, float1);
  1295.         if(g_Player[g_ID[user]][e_Mode][0])
  1296.         {
  1297.             SetObjectPos(g_Player[g_ID[user]][e_Fly], float1[0], float1[1], float1[2] + 4.0);
  1298.         }
  1299.         else
  1300.         {
  1301.             if(!IsPlayerInAnyVehicle(user))
  1302.             {
  1303.                 SetPlayerPos(user, float1[0], float1[1], float1[2] + 4.0);
  1304.             }
  1305.             else
  1306.             {
  1307.                 SetVehiclePos(GetPlayerVehicleID(user), float1[0], float1[1], float1[2] + 4.0);
  1308.             }
  1309.         }
  1310.         #if defined _inc_streamer
  1311.             Streamer_Update(user);
  1312.         #endif
  1313.         return 1;
  1314.     }
  1315.     return 0;
  1316. }
  1317.  
  1318. CMD:eposition(user, params[])
  1319. {
  1320.     return cmd_epos(user, params);
  1321. }
  1322.  
  1323. CMD:epos(user, params[])
  1324. {
  1325.     if(g_ID[user] != UOE_INVALID_ID)
  1326.     {
  1327.         if(g_Player[g_ID[user]][e_Mode][0])
  1328.         {
  1329.             new
  1330.                 oID,
  1331.                 Float:pos_x,
  1332.                 Float:pos_y,
  1333.                 Float:pos_z;
  1334.             if(sscanf(params, "ifff", oID, pos_x, pos_y, pos_z))
  1335.             {
  1336.                 oID = g_Player[g_ID[user]][e_OID];
  1337.                 if(!EDIT_OBJECT_IsValid(user, oID) || sscanf(params, "fff", pos_x, pos_y, pos_z))
  1338.                 {
  1339.                     if(g_Player[g_ID[user]][e_Mode][1])
  1340.                     {
  1341.                         g_Player[g_ID[user]][e_Mode][1] = 0;
  1342.                         EDIT_TEXTDRAW_Update(user);
  1343.                     }
  1344.                     SendClientMessage(user, 0x99FF66FF, "Hint: /epos <object> <pos x> <pos y> <pos z>");
  1345.                     PlayerPlaySound(user, 1084, 0.0, 0.0, 0.0);
  1346.                     return 1;
  1347.                 }
  1348.             }
  1349.             else if(!EDIT_OBJECT_IsValid(user, oID))
  1350.             {
  1351.                 return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID.");
  1352.             }
  1353.             if(g_Editor[g_ID[user]][oID][e_EDIT][e_Lock])
  1354.             {
  1355.                 return SendClientMessage(user, 0xCD5C5CFF, "This object is locked.");
  1356.             }
  1357.             EDIT_ACTION_Save(user, oID);
  1358.             EDIT_ROAD_SetMA(user, oID, 0);
  1359.             EDIT_LOOP_SetMA(user, oID, 0);
  1360.             EDIT_OBJECT_SetPos(user, oID, pos_x, pos_y, pos_z);
  1361.             EDIT_LOOP_SetPos(user, oID);
  1362.             EDIT_ROAD_SetPos(user, oID);
  1363.         }
  1364.         else
  1365.         {
  1366.             SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
  1367.         }
  1368.         return 1;
  1369.     }
  1370.     return 0;
  1371. }
  1372.  
  1373. CMD:erotation(user, params[])
  1374. {
  1375.     return cmd_erot(user, params);
  1376. }
  1377.  
  1378. CMD:erot(user, params[])
  1379. {
  1380.     if(g_ID[user] != UOE_INVALID_ID)
  1381.     {
  1382.         if(g_Player[g_ID[user]][e_Mode][0])
  1383.         {
  1384.             new
  1385.                 oID,
  1386.                 Float:rot_x,
  1387.                 Float:rot_y,
  1388.                 Float:rot_z;
  1389.             if(sscanf(params, "ifff", oID, rot_x, rot_y, rot_z))
  1390.             {
  1391.                 oID = g_Player[g_ID[user]][e_OID];
  1392.                 if(!EDIT_OBJECT_IsValid(user, oID) || sscanf(params, "fff", rot_x, rot_y, rot_z))
  1393.                 {
  1394.                     if(!g_Player[g_ID[user]][e_Mode][1])
  1395.                     {
  1396.                         g_Player[g_ID[user]][e_Mode][1] = 1;
  1397.                         EDIT_TEXTDRAW_Update(user);
  1398.                     }
  1399.                     SendClientMessage(user, 0x99FF66FF, "Hint: /erot <object> <rot x> <rot y> <rot z>");
  1400.                     PlayerPlaySound(user, 1084, 0.0, 0.0, 0.0);
  1401.                     return 1;
  1402.                 }
  1403.             }
  1404.             else if(!EDIT_OBJECT_IsValid(user, oID))
  1405.             {
  1406.                 return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID.");
  1407.             }
  1408.             if(g_Editor[g_ID[user]][oID][e_EDIT][e_Lock])
  1409.             {
  1410.                 return SendClientMessage(user, 0xCD5C5CFF, "This object is locked.");
  1411.             }
  1412.             EDIT_ACTION_Save(user, oID);
  1413.             EDIT_ROAD_SetMA(user, oID, 0);
  1414.             EDIT_LOOP_SetMA(user, oID, 0);
  1415.             EDIT_OBJECT_SetRot(user, oID, rot_x, rot_y, rot_z);
  1416.             EDIT_LOOP_SetPos(user, oID);
  1417.             EDIT_ROAD_SetPos(user, oID);
  1418.         }
  1419.         else
  1420.         {
  1421.             SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
  1422.         }
  1423.         return 1;
  1424.     }
  1425.     return 0;
  1426. }
  1427.  
  1428. CMD:esnap(user, params[])
  1429. {
  1430.     if(g_ID[user] != UOE_INVALID_ID)
  1431.     {
  1432.         if(g_Player[g_ID[user]][e_Mode][0])
  1433.         {
  1434.             new
  1435.                 value;
  1436.             if(sscanf(params, "i", value))
  1437.             {
  1438.                 if(g_Player[g_ID[user]][e_Mode][2] != 2)
  1439.                 {
  1440.                     if(g_Player[g_ID[user]][e_Snap])
  1441.                     {
  1442.                         EDIT_AXIS_Hide(user);
  1443.                         g_Player[g_ID[user]][e_Mode][2] = 2;
  1444.                     }
  1445.                 }
  1446.                 else
  1447.                 {
  1448.                     g_Player[g_ID[user]][e_Mode][2] = 1;
  1449.                 }
  1450.                 SendClientMessage(user, 0x99FF66FF, "Hint: /esnap <value>");
  1451.                 PlayerPlaySound(user, 1084, 0.0, 0.0, 0.0);
  1452.             }
  1453.             else
  1454.             {
  1455.                 value = value % 720;
  1456.                 if(!value)
  1457.                 {
  1458.                     g_Player[g_ID[user]][e_Mode][2] = 1;
  1459.                 }
  1460.                 else
  1461.                 {
  1462.                     g_Player[g_ID[user]][e_Mode][2] = 2;
  1463.                 }
  1464.                 EDIT_AXIS_Hide(user);
  1465.                 g_Player[g_ID[user]][e_Snap] = value;
  1466.             }
  1467.             EDIT_TEXTDRAW_Update(user);
  1468.         }
  1469.         else
  1470.         {
  1471.             SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
  1472.         }
  1473.         return 1;
  1474.     }
  1475.     return 0;
  1476. }
  1477.  
  1478. CMD:elock(user, params[])
  1479. {
  1480.     if(g_ID[user] != UOE_INVALID_ID)
  1481.     {
  1482.         if(g_Player[g_ID[user]][e_Mode][0])
  1483.         {
  1484.             new
  1485.                 oID;
  1486.             if(sscanf(params, "i", oID))
  1487.             {
  1488.                 oID = g_Player[g_ID[user]][e_OID];
  1489.                 if(!EDIT_OBJECT_IsValid(user, oID))
  1490.                 {
  1491.                     return SendClientMessage(user, 0x99FF66FF, "Usage: /elock <object>");
  1492.                 }
  1493.             }
  1494.             else if(!EDIT_OBJECT_IsValid(user, oID))
  1495.             {
  1496.                 return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID.");
  1497.             }
  1498.             if(g_Editor[g_ID[user]][oID][e_EDIT][e_Lock])
  1499.             {
  1500.                 return SendClientMessage(user, 0xCD5C5CFF, "This object is already locked.");
  1501.             }
  1502.             EDIT_ACTION_Save(user, oID);
  1503.             EDIT_OBJECT_SetLocked(user, oID, 1);
  1504.         }
  1505.         else
  1506.         {
  1507.             SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
  1508.         }
  1509.         return 1;
  1510.     }
  1511.     return 0;
  1512. }
  1513.  
  1514. CMD:eunlock(user, params[])
  1515. {
  1516.     if(g_ID[user] != UOE_INVALID_ID)
  1517.     {
  1518.         if(g_Player[g_ID[user]][e_Mode][0])
  1519.         {
  1520.             new
  1521.                 oID;
  1522.             if(sscanf(params, "i", oID))
  1523.             {
  1524.                 return SendClientMessage(user, 0x99FF66FF, "Usage: /eunlock <object>");
  1525.             }
  1526.             if(!EDIT_OBJECT_IsValid(user, oID))
  1527.             {
  1528.                 return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID.");
  1529.             }
  1530.             if(!g_Editor[g_ID[user]][oID][e_EDIT][e_Lock])
  1531.             {
  1532.                 return SendClientMessage(user, 0xCD5C5CFF, "This object is not locked.");
  1533.             }
  1534.             EDIT_ACTION_Save(user, oID);
  1535.             EDIT_OBJECT_SetLocked(user, oID, 0);
  1536.         }
  1537.         else
  1538.         {
  1539.             SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
  1540.         }
  1541.         return 1;
  1542.     }
  1543.     return 0;
  1544. }
  1545.  
  1546. CMD:eattach(user, params[])
  1547. {
  1548.     return cmd_eatt(user, params);
  1549. }
  1550.  
  1551. CMD:eatt(user, params[])
  1552. {
  1553.     if(g_ID[user] != UOE_INVALID_ID)
  1554.     {
  1555.         if(g_Player[g_ID[user]][e_Mode][0])
  1556.         {
  1557.             new
  1558.                 road1,
  1559.                 road2;
  1560.             if(sscanf(params, "iI(-1)", road1, road2))
  1561.             {
  1562.                 return SendClientMessage(user, 0x99FF66FF, "Usage: /eatt <road> <to road>");
  1563.             }
  1564.             if(road1 && road2 == -1)
  1565.             {
  1566.                 road2 = road1;
  1567.                 road1 = g_Player[g_ID[user]][e_OID];
  1568.                 if(!EDIT_OBJECT_IsValid(user, road1))
  1569.                 {
  1570.                     return SendClientMessage(user, 0x99FF66FF, "Usage: /eatt <road> <to road>");
  1571.                 }
  1572.             }
  1573.             else if(!EDIT_OBJECT_IsValid(user, road1) || !EDIT_OBJECT_IsValid(user, road2))
  1574.             {
  1575.                 return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID.");
  1576.             }
  1577.             if(!EDIT_ROAD_IsValidModel(user, road1) || !EDIT_ROAD_IsValidModel(user, road2))
  1578.             {
  1579.                 return SendClientMessage(user, 0xCD5C5CFF, "This command supports only models between 18788 and 18803.");
  1580.             }
  1581.             if(!g_Editor[g_ID[user]][road1][e_ROAD][e_IDX] || !g_Editor[g_ID[user]][road2][e_ROAD][e_IDX])
  1582.             {
  1583.                 SendClientMessage(user, 0xCD5C5CFF, "This road model is not supported by the road attachment feature.");
  1584.                 SendClientMessage(user, 0xCD5C5CFF, "Supported models: 18788, 18789, 18791 - 18796, 18801 and 18803.");
  1585.                 return 1;
  1586.             }
  1587.             if(g_Editor[g_ID[user]][road1][e_EDIT][e_Lock] || g_Editor[g_ID[user]][road2][e_EDIT][e_Lock])
  1588.             {
  1589.                 return SendClientMessage(user, 0xCD5C5CFF, "This object is locked.");
  1590.             }
  1591.             if(g_Editor[g_ID[user]][road2][e_ROAD][e_SL] || g_Editor[g_ID[user]][road2][e_LOOP][e_SL])
  1592.             {
  1593.                 return SendClientMessage(user, 0xCD5C5CFF, "This road has another road attached to it.");
  1594.             }
  1595.             if(EDIT_ROAD_ScanSL(user, road1, road2))
  1596.             {
  1597.                 return SendClientMessage(user, 0xCD5C5CFF, "This road cannot be attached to any of its slave roads.");
  1598.             }
  1599.             if(road1 == road2)
  1600.             {
  1601.                 return SendClientMessage(user, 0xCD5C5CFF, "Road cannot be attached to itself.");
  1602.             }
  1603.             EDIT_ACTION_Save(user, road1);
  1604.             EDIT_ROAD_AttachFirst(user, road1, road2);
  1605.         }
  1606.         else
  1607.         {
  1608.             SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
  1609.         }
  1610.         return 1;
  1611.     }
  1612.     return 0;
  1613. }
  1614.  
  1615. CMD:espeed(user, params[])
  1616. {
  1617.     return cmd_evel(user, params);
  1618. }
  1619.  
  1620. CMD:evelocity(user, params[])
  1621. {
  1622.     return cmd_evel(user, params);
  1623. }
  1624.  
  1625. CMD:evel(user, params[])
  1626. {
  1627.     if(g_ID[user] != UOE_INVALID_ID)
  1628.     {
  1629.         if(g_Player[g_ID[user]][e_Mode][0])
  1630.         {
  1631.             new
  1632.                 Float:speed;
  1633.             if(sscanf(params, "f", speed))
  1634.             {
  1635.                 return SendClientMessage(user, 0x99FF66FF, "Usage: /evel <velocity>");
  1636.             }
  1637.             EDIT_Remainder(speed, 900.0);
  1638.             g_Player[g_ID[user]][e_Speed][1] = speed / 1000 * UOE_TIMER_INT;
  1639.             EDIT_TEXTDRAW_Update(user);
  1640.         }
  1641.         else
  1642.         {
  1643.             SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
  1644.         }
  1645.         return 1;
  1646.     }
  1647.     return 0;
  1648. }
  1649.  
  1650. CMD:eaxis(user, params[])
  1651. {
  1652.     if(g_ID[user] != UOE_INVALID_ID)
  1653.     {
  1654.         if(g_Player[g_ID[user]][e_Mode][0])
  1655.         {
  1656.             new
  1657.                 check,
  1658.                 Float:float1[3];
  1659.             if(sscanf(params, "a<f>[3]", float1))
  1660.             {
  1661.                 if(g_Axis[g_ID[user]][e_Axis][0])
  1662.                 {
  1663.                     SendClientMessage(user, 0x99FF66FF, "Editor: Axis feature disabled.");
  1664.                     EDIT_AXIS_Destroy(user);
  1665.                     return 1;
  1666.                 }
  1667.                 check = 1;
  1668.             }
  1669.             if(!g_Axis[g_ID[user]][e_Axis][0] || !check)
  1670.             {
  1671.                 if(g_Player[g_ID[user]][e_Mode][2])
  1672.                 {
  1673.                     return SendClientMessage(user, 0xCD5C5CFF, "Axis feature is not supported in world mode.");
  1674.                 }
  1675.                 if(!check)
  1676.                 {
  1677.                     g_Axis[g_ID[user]][e_O][0] = float1[0];
  1678.                     g_Axis[g_ID[user]][e_O][1] = float1[1];
  1679.                     g_Axis[g_ID[user]][e_O][2] = float1[2];
  1680.                 }
  1681.                 if(!g_Axis[g_ID[user]][e_Axis][0])
  1682.                 {
  1683.                     g_Axis[g_ID[user]][e_Axis][0] = CreateObject(1251, 0.0, 0.0, -20.0, 0.0, 0.0, 0.0);
  1684.                     SetObjectMaterialText(g_Axis[g_ID[user]][e_Axis][0], " ", 0, OBJECT_MATERIAL_SIZE_32x32, "Arial", 90, 1, 0, 0xFF0000, 0);
  1685.                     g_Axis[g_ID[user]][e_Axis][1] = CreateObject(1251, 0.0, 0.0, -20.0, 0.0, 0.0, 0.0);
  1686.                     SetObjectMaterialText(g_Axis[g_ID[user]][e_Axis][1], " ", 0, OBJECT_MATERIAL_SIZE_32x32, "Arial", 90, 1, 0, 0x00FF00, 0);
  1687.                     AttachObjectToObject(g_Axis[g_ID[user]][e_Axis][1], g_Axis[g_ID[user]][e_Axis][0], 0.0, 0.0, 0.0, 0.0, 0.0, 90.0, 1);
  1688.                     g_Axis[g_ID[user]][e_Axis][2] = CreateObject(1251, 0.0, 0.0, -20.0, 0.0, 0.0, 0.0);
  1689.                     SetObjectMaterialText(g_Axis[g_ID[user]][e_Axis][2], " ", 0, OBJECT_MATERIAL_SIZE_32x32, "Arial", 90, 1, 0, 0x0000FF, 0);
  1690.                     AttachObjectToObject(g_Axis[g_ID[user]][e_Axis][2], g_Axis[g_ID[user]][e_Axis][0], 0.0, 0.0, 0.0, 90.0, 90.0, 0.0, 1);
  1691.                     for(new i = 0; i < 3; ++i)
  1692.                     {
  1693.                         if(!IsValidObject(g_Axis[g_ID[user]][e_Axis][i]))
  1694.                         {
  1695.                             EDIT_AXIS_Destroy(user);
  1696.                             SendClientMessage(user, 0xCD5C5CFF, "Error: Not enough object slots available.");
  1697.                             return 1;
  1698.                         }
  1699.                     }
  1700.                     g_Axis[g_ID[user]][e_Axis][3] = CreatePlayerObject(user, 19362, 0.0, 0.0, -20.0, 0.0, 0.0, 0.0);
  1701.                     SetPlayerObjectMaterialText(user, g_Axis[g_ID[user]][e_Axis][3], "{F0F0F0}W", 0, OBJECT_MATERIAL_SIZE_128x128, "Arial", 32, 1, 0, 0, OBJECT_MATERIAL_TEXT_ALIGN_CENTER);
  1702.                     g_Axis[g_ID[user]][e_Axis][4] = CreatePlayerObject(user, 19362, 0.0, 0.0, -20.0, 0.0, 0.0, 0.0);
  1703.                     SetPlayerObjectMaterialText(user, g_Axis[g_ID[user]][e_Axis][4], "{F0F0F0}D", 0, OBJECT_MATERIAL_SIZE_128x128, "Arial", 32, 1, 0, 0, OBJECT_MATERIAL_TEXT_ALIGN_CENTER);
  1704.                     g_Axis[g_ID[user]][e_Axis][5] = CreatePlayerObject(user, 19362, 0.0, 0.0, -20.0, 0.0, 0.0, 0.0);
  1705.                     SetPlayerObjectMaterialText(user, g_Axis[g_ID[user]][e_Axis][5], "{F0F0F0}Shift + W", 0, OBJECT_MATERIAL_SIZE_128x128, "Arial", 32, 1, 0, 0, OBJECT_MATERIAL_TEXT_ALIGN_CENTER);
  1706.                     g_Axis[g_ID[user]][e_Axis][6] = CreatePlayerObject(user, 19362, 0.0, 0.0, -20.0, 0.0, 0.0, 0.0);
  1707.                     SetPlayerObjectMaterialText(user, g_Axis[g_ID[user]][e_Axis][6], "{F0F0F0}S", 0, OBJECT_MATERIAL_SIZE_128x128, "Arial", 32, 1, 0, 0, OBJECT_MATERIAL_TEXT_ALIGN_CENTER);
  1708.                     g_Axis[g_ID[user]][e_Axis][7] = CreatePlayerObject(user, 19362, 0.0, 0.0, -20.0, 0.0, 0.0, 0.0);
  1709.                     SetPlayerObjectMaterialText(user, g_Axis[g_ID[user]][e_Axis][7], "{F0F0F0}A", 0, OBJECT_MATERIAL_SIZE_128x128, "Arial", 32, 1, 0, 0, OBJECT_MATERIAL_TEXT_ALIGN_CENTER);
  1710.                     g_Axis[g_ID[user]][e_Axis][8] = CreatePlayerObject(user, 19362, 0.0, 0.0, -20.0, 0.0, 0.0, 0.0);
  1711.                     SetPlayerObjectMaterialText(user, g_Axis[g_ID[user]][e_Axis][8], "{F0F0F0}Shift + S", 0, OBJECT_MATERIAL_SIZE_128x128, "Arial", 32, 1, 0, 0, OBJECT_MATERIAL_TEXT_ALIGN_CENTER);
  1712.                     for(new i = 3; i < 9; ++i)
  1713.                     {
  1714.                         if(!IsValidPlayerObject(user, g_Axis[g_ID[user]][e_Axis][i]))
  1715.                         {
  1716.                             EDIT_AXIS_Destroy(user);
  1717.                             SendClientMessage(user, 0xCD5C5CFF, "Error: Not enough object slots available.");
  1718.                             return 1;
  1719.                         }
  1720.                     }
  1721.                     SendClientMessage(user, 0x99FF66FF, "Editor: Axis feature enabled.");
  1722.                     if(check)
  1723.                     {
  1724.                         SendClientMessage(user, 0x99FF66FF, "Hint: /eaxis <offset x> <offset y> <offset z>");
  1725.                         PlayerPlaySound(user, 1084, 0.0, 0.0, 0.0);
  1726.                     }
  1727.                 }
  1728.                 if(g_Player[g_ID[user]][e_OID] != UOE_INVALID_ID)
  1729.                 {
  1730.                     new
  1731.                         Float:float2[3];
  1732.                     EDIT_OBJECT_GetPos(user, g_Player[g_ID[user]][e_OID], float1);
  1733.                     EDIT_OBJECT_GetRot(user, g_Player[g_ID[user]][e_OID], float2);
  1734.                     EDIT_AXIS_Update(user, float1[0], float1[1], float1[2], float2[0], float2[1], float2[2]);
  1735.                     g_Axis[g_ID[user]][e_OID] = g_Player[g_ID[user]][e_OID];
  1736.                 }
  1737.             }
  1738.         }
  1739.         else
  1740.         {
  1741.             SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
  1742.         }
  1743.         return 1;
  1744.     }
  1745.     return 0;
  1746. }
  1747.  
  1748. CMD:ehover(user, params[])
  1749. {
  1750.     return cmd_efly(user, params);
  1751. }
  1752.  
  1753. CMD:efly(user, params[])
  1754. {
  1755.     #pragma unused params
  1756.     if(g_ID[user] != UOE_INVALID_ID)
  1757.     {
  1758.         EDIT_FLY_Switch(user);
  1759.         return 1;
  1760.     }
  1761.     return 0;
  1762. }
  1763.  
  1764. CMD:ehelp(user, params[])
  1765. {
  1766.     if(g_ID[user] != UOE_INVALID_ID)
  1767.     {
  1768.         new
  1769.             dialog;
  1770.         if(sscanf(params, "i", dialog))
  1771.         {
  1772.             EDIT_DIALOG_Show(user, 0);
  1773.         }
  1774.         else if(dialog == 1)
  1775.         {
  1776.             EDIT_DIALOG_Show(user, 1);
  1777.         }
  1778.         else if(dialog == 2)
  1779.         {
  1780.             EDIT_DIALOG_Show(user, 2);
  1781.         }
  1782.         else
  1783.         {
  1784.             EDIT_DIALOG_Show(user, 0);
  1785.         }
  1786.         return 1;
  1787.     }
  1788.     return 0;
  1789. }
  1790.  
  1791. CMD:esave(user, params[])
  1792. {
  1793.     if(g_ID[user] != UOE_INVALID_ID)
  1794.     {
  1795.         new
  1796.             str1[6],
  1797.             str2[32];
  1798.         if(sscanf(params, "s[6]s[32]", str1, str2))
  1799.         {
  1800.             return SendClientMessage(user, 0x99FF66FF, "Usage: /esave <map | /all> <map name>");
  1801.         }
  1802.         if(strlen(str2) > 14)
  1803.         {
  1804.             return SendClientMessage(user, 0xCD5C5CFF, "Error: Map name is too long (max. 14 characters).");
  1805.         }
  1806.         new
  1807.             slot;
  1808.         if(!strcmp(str1, "/all", true, 2) || strval(str1) < 0)
  1809.         {
  1810.             slot = UOE_INVALID_ID;
  1811.         }
  1812.         else
  1813.         {
  1814.             slot = strval(str1);
  1815.             if(slot < 0 || slot > 9)
  1816.             {
  1817.                 return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid map ID.");
  1818.             }
  1819.         }
  1820.         if(!fexist(UOE_PROJECTS) || !fexist(UOE_SAVES))
  1821.         {
  1822.             return SendClientMessage(user, 0xCD5C5CFF, "Error: One or more folders are missing.");
  1823.         }
  1824.         if(!EDIT_MAP_GetObjectCount(user, slot, 1))
  1825.         {
  1826.             return SendClientMessage(user, 0xCD5C5CFF, "Error: This map has no objects.");
  1827.         }
  1828.         if(EDIT_MAP_Exist(UOE_PROJECTS, str2, "uoe"))
  1829.         {
  1830.             SendClientMessage(user, 0x99FF66FF, "Editor: Overwriting the existing map file.");
  1831.         }
  1832.         new
  1833.             count;
  1834.         count = EDIT_MAP_Save(user, slot, UOE_PROJECTS, str2);
  1835.         if(count)
  1836.         {
  1837.             format(g_Str, 128, "Editor: %d objects saved to '%s.txt' file.", count, str2);
  1838.             SendClientMessage(user, 0x99FF66FF, g_Str);
  1839.         }
  1840.         else
  1841.         {
  1842.             SendClientMessage(user, 0xCD5C5CFF, "Unexpected error occurred.");
  1843.         }
  1844.         return 1;
  1845.     }
  1846.     return 0;
  1847. }
  1848.  
  1849. CMD:eload(user, params[])
  1850. {
  1851.     if(g_ID[user] != UOE_INVALID_ID)
  1852.     {
  1853.         new
  1854.             str[32];
  1855.         if(sscanf(params, "s[32]", str))
  1856.         {
  1857.             return SendClientMessage(user, 0x99FF66FF, "Usage: /eload <map name>");
  1858.         }
  1859.         if(EDIT_MAP_GetID(user, str) != UOE_INVALID_ID)
  1860.         {
  1861.             return SendClientMessage(user, 0xCD5C5CFF, "Error: A map with this name is already loaded.");
  1862.         }
  1863.         if(!fexist(UOE_PROJECTS) || !fexist(UOE_SAVES))
  1864.         {
  1865.             return SendClientMessage(user, 0xCD5C5CFF, "Error: One or more folders are missing.");
  1866.         }
  1867.         if(!EDIT_MAP_Exist(UOE_PROJECTS, str, "uoe"))
  1868.         {
  1869.             return SendClientMessage(user, 0xCD5C5CFF, "Error: This map doesn't exist.");
  1870.         }
  1871.         new
  1872.             slot;
  1873.         slot = EDIT_MAP_GetSlot(user);
  1874.         if(slot == UOE_INVALID_ID)
  1875.         {
  1876.             return SendClientMessage(user, 0xCD5C5CFF, "Error: Too much maps loaded.");
  1877.         }
  1878.         new
  1879.             count;
  1880.         count = EDIT_MAP_Load(user, slot, UOE_PROJECTS, str);
  1881.         if(count)
  1882.         {
  1883.             EDIT_ACTION_Save(user, slot, 2);
  1884.             format(g_File[g_ID[user]][slot], 32, "%s", str);
  1885.             format(g_Str, 64, "Editor: %d objects successfully loaded.", count);
  1886.             SendClientMessage(user, 0x99FF66FF, g_Str);
  1887.         }
  1888.         else
  1889.         {
  1890.             SendClientMessage(user, 0xCD5C5CFF, "Unexpected error occurred.");
  1891.             EDIT_MAP_Unload(user, slot);
  1892.         }
  1893.         return 1;
  1894.     }
  1895.     return 0;
  1896. }
  1897.  
  1898. CMD:emaps(user, params[])
  1899. {
  1900.     return cmd_eunload(user, params);
  1901. }
  1902.  
  1903. CMD:eunload(user, params[])
  1904. {
  1905.     if(g_ID[user] != UOE_INVALID_ID)
  1906.     {
  1907.         new
  1908.             str[32];
  1909.         if(sscanf(params, "s[32]", str))
  1910.         {
  1911.             if(!EDIT_DIALOG_Show(user, 3))
  1912.             {
  1913.                 SendClientMessage(user, 0x99FF66FF, "Editor: No maps are loaded.");
  1914.             }
  1915.             else
  1916.             {
  1917.                 SendClientMessage(user, 0x99FF66FF, "Hint: /eunload <map | map name>");
  1918.                 PlayerPlaySound(user, 1084, 0.0, 0.0, 0.0);
  1919.             }
  1920.             return 1;
  1921.         }
  1922.         new
  1923.             map;
  1924.         map = EDIT_MAP_GetID(user, str);
  1925.         if(EDIT_MAP_IsLoaded(user, map) || EDIT_MAP_IsLoaded(user, (map = strval(str))))
  1926.         {
  1927.             EDIT_ACTION_Save(user, map, 1);
  1928.             if(EDIT_MAP_Unload(user, map))
  1929.             {
  1930.                 SendClientMessage(user, 0x99FF66FF, "Editor: Map successfully unloaded.");
  1931.             }
  1932.         }
  1933.         else
  1934.         {
  1935.             SendClientMessage(user, 0xCD5C5CFF, "Error: This map is not loaded.");
  1936.         }
  1937.         return 1;
  1938.     }
  1939.     return 0;
  1940. }
  1941.  
  1942. CMD:eimport(user, params[])
  1943. {
  1944.     if(g_ID[user] != UOE_INVALID_ID)
  1945.     {
  1946.         new
  1947.             str[32],
  1948.             ext[10];
  1949.         if(sscanf(params, "s[32]S()[10]", str, ext))
  1950.         {
  1951.             return SendClientMessage(user, 0x99FF66FF, "Usage: /eimport <map name> <extension>");
  1952.         }
  1953.         if(EDIT_MAP_GetID(user, str) != UOE_INVALID_ID)
  1954.         {
  1955.             return SendClientMessage(user, 0xCD5C5CFF, "Error: A map with this name is already loaded.");
  1956.         }
  1957.         if(!fexist(UOE_IMPORT))
  1958.         {
  1959.             return SendClientMessage(user, 0xCD5C5CFF, "Error: One or more folders are missing.");
  1960.         }
  1961.         if(ext[0])
  1962.         {
  1963.             if(!EDIT_MAP_Exist(UOE_IMPORT, str, ext))
  1964.             {
  1965.                 return SendClientMessage(user, 0xCD5C5CFF, "Error: This map doesn't exist.");
  1966.             }
  1967.         }
  1968.         else
  1969.         {
  1970.             if(EDIT_MAP_Exist(UOE_IMPORT, str, "txt"))
  1971.             {
  1972.                 ext = "txt";
  1973.             }
  1974.             else if(EDIT_MAP_Exist(UOE_IMPORT, str, "pwn"))
  1975.             {
  1976.                 ext = "pwn";
  1977.             }
  1978.             else if(EDIT_MAP_Exist(UOE_IMPORT, str, "inc"))
  1979.             {
  1980.                 ext = "inc";
  1981.             }
  1982.             else
  1983.             {
  1984.                 new
  1985.                     pos;
  1986.                 pos = strfind(str, ".");
  1987.                 if(pos)
  1988.                 {
  1989.                     strmid(ext, str, pos + 1, strlen(str));
  1990.                     strdel(str, pos, strlen(str));
  1991.                 }
  1992.                 if(!EDIT_MAP_Exist(UOE_IMPORT, str, ext))
  1993.                 {
  1994.                     return SendClientMessage(user, 0xCD5C5CFF, "Error: This map doesn't exist.");
  1995.                 }
  1996.             }
  1997.         }
  1998.         new
  1999.             slot;
  2000.         slot = EDIT_MAP_GetSlot(user);
  2001.         if(slot == UOE_INVALID_ID)
  2002.         {
  2003.             return SendClientMessage(user, 0xCD5C5CFF, "Error: Too much maps loaded.");
  2004.         }
  2005.         new
  2006.             count;
  2007.         count = EDIT_MAP_Import(user, slot, UOE_IMPORT, str, ext);
  2008.         if(count)
  2009.         {
  2010.             EDIT_ACTION_Save(user, slot, 2);
  2011.             format(g_File[g_ID[user]][slot], 32, "%s", str);
  2012.             format(g_Str, 128, "Editor: %d objects successfully imported.", count);
  2013.             SendClientMessage(user, 0x99FF66FF, g_Str);
  2014.         }
  2015.         else
  2016.         {
  2017.             SendClientMessage(user, 0x99FF66FF, "Editor: No objects imported.");
  2018.         }
  2019.         return 1;
  2020.     }
  2021.     return 0;
  2022. }
  2023.  
  2024. CMD:esettings(user, params[])
  2025. {
  2026.     return cmd_econfig(user, params);
  2027. }
  2028.  
  2029. CMD:econfiguration(user, params[])
  2030. {
  2031.     return cmd_econfig(user, params);
  2032. }
  2033.  
  2034. CMD:econfig(user, params[])
  2035. {
  2036.     if(g_ID[user] != UOE_INVALID_ID)
  2037.     {
  2038.         EDIT_DIALOG_Show(user, 5);
  2039.         return 1;
  2040.     }
  2041.     return 0;
  2042. }
  2043.  
  2044. CMD:enrg(user, params[])
  2045. {
  2046.     #pragma unused params
  2047.     if(g_ID[user] != UOE_INVALID_ID)
  2048.     {
  2049.         if(!g_Player[g_ID[user]][e_Mode][0])
  2050.         {
  2051.             EDIT_VEHICLE_Spawn(user, 522, 0);
  2052.         }
  2053.         return 1;
  2054.     }
  2055.     return 0;
  2056. }
  2057.  
  2058. CMD:einf(user, params[])
  2059. {
  2060.     #pragma unused params
  2061.     if(g_ID[user] != UOE_INVALID_ID)
  2062.     {
  2063.         if(!g_Player[g_ID[user]][e_Mode][0])
  2064.         {
  2065.             EDIT_VEHICLE_Spawn(user, 411, 1);
  2066.         }
  2067.         return 1;
  2068.     }
  2069.     return 0;
  2070. }
  2071.  
  2072. CMD:ecloudless(user, params[])
  2073. {
  2074.     #pragma unused params
  2075.     if(g_ID[user] != UOE_INVALID_ID)
  2076.     {
  2077.         EDIT_Cloudless(user, 0);
  2078.         return 1;
  2079.     }
  2080.     return 0;
  2081. }
  2082.  
  2083. PUBLIC:EDIT_Cloudless(user, step)
  2084. {
  2085.     if(!step)
  2086.     {
  2087.         new
  2088.             Float:pos_x,
  2089.             Float:pos_y,
  2090.             Float:pos_z;
  2091.         GetPlayerPos(user, pos_x, pos_y, pos_z);
  2092.         if(2900.00 > pos_x > -2900.00 && 2900.00 > pos_y > -2900.00)
  2093.         {
  2094.             SetPlayerWeather(user, -117);
  2095.             SetTimerEx("EDIT_Cloudless", 100, 0, "ii", user, 1);
  2096.             SendClientMessage(user, 0x99FF66FF, "Note: Make sure you see at least one cloud in the sky.");
  2097.         }
  2098.         else
  2099.         {
  2100.             SendClientMessage(user, 0xCD5C5CFF, "Error: Unable to remove clouds. Go to San Andreas.");
  2101.         }
  2102.     }
  2103.     else
  2104.     {
  2105.         SetPlayerTime(user, 0, 30);
  2106.         SetPlayerWeather(user, 11);
  2107.     }
  2108.     return 1;
  2109. }
  2110.  
  2111. PUBLIC:EDIT_SpawnPlayer(user)
  2112. {
  2113.     if(IsPlayerConnected(user))
  2114.     {
  2115.         if(g_Player[g_ID[user]][e_Mode][0] == 2)
  2116.         {
  2117.             g_Player[g_ID[user]][e_Mode][0] = 0;
  2118.             SetPlayerFacingAngle(user, g_Player[g_ID[user]][e_Spawn][3]);
  2119.             SetPlayerPos(user, g_Player[g_ID[user]][e_Spawn][0], g_Player[g_ID[user]][e_Spawn][1], g_Player[g_ID[user]][e_Spawn][2]);
  2120.             SetCameraBehindPlayer(user);
  2121.         }
  2122.     }
  2123.     return 1;
  2124. }
  2125.  
  2126. PUBLIC:EDIT_Update(user, id)
  2127. {
  2128.     static
  2129.         keys,
  2130.         ud,
  2131.         lr;
  2132.     if(g_Player[id][e_Mode][0])
  2133.     {
  2134.         GetPlayerKeys(user, keys, ud, lr);
  2135.         if(keys & 8 && (ud || lr))
  2136.         {
  2137.             g_Player[id][e_Hold][2] = 1;
  2138.             EDIT_MoveCamera(user, keys, ud, lr);
  2139.             return 1;
  2140.         }
  2141.         else
  2142.         {
  2143.             if(g_Player[id][e_Hold][2])
  2144.             {
  2145.                 StopObject(g_Player[id][e_Fly]);
  2146.             }
  2147.         }
  2148.         if(!g_Player[id][e_Hold][2])
  2149.         {
  2150.             new
  2151.                 oID;
  2152.             oID = g_Player[id][e_OID];
  2153.             if(oID != UOE_INVALID_ID)
  2154.             {
  2155.                 if(!ud)
  2156.                 {
  2157.                     if(g_Player[id][e_Hold][0])
  2158.                     {
  2159.                         EDIT_ROAD_SetPos(user, oID);
  2160.                         EDIT_LOOP_SetPos(user, oID);
  2161.                         EDIT_3DTEXTLABEL_Update(user, oID);
  2162.                         g_Player[id][e_Hold][0] = 0;
  2163.                     }
  2164.                     g_Player[id][e_Hold][2] = 0;
  2165.                     g_Player[id][e_Hold][3] = 0;
  2166.                     g_Player[id][e_Time] = 0;
  2167.                 }
  2168.                 else if(ud > 0)
  2169.                 {
  2170.                     if(keys & 1024)
  2171.                     {
  2172.                         if(!g_Player[id][e_Hold][3])
  2173.                         {
  2174.                             EDIT_MODE_SetVelocity(user, ud);
  2175.                         }
  2176.                         g_Player[id][e_Hold][3] = 1;
  2177.                     }
  2178.                     else
  2179.                     {
  2180.                         if(!g_Player[id][e_Hold][0])
  2181.                         {
  2182.                             EDIT_ACTION_Save(user, oID);
  2183.                             EDIT_LOOP_SetMA(user, oID, 0);
  2184.                             EDIT_ROAD_SetMA(user, oID, 0);
  2185.                         }
  2186.                         if(g_Player[id][e_Mode][1])
  2187.                         {
  2188.                             if(keys & 32)
  2189.                             {
  2190.                                 if(keys & 128 || g_Player[id][e_Mode][2] == 2)
  2191.                                 {
  2192.                                     if(!g_Player[id][e_Hold][0])
  2193.                                     {
  2194.                                         EDIT_OBJECT_RotateZ(user, oID, -g_Player[id][e_Speed][1], -1);
  2195.                                     }
  2196.                                 }
  2197.                                 else
  2198.                                 {
  2199.                                     EDIT_OBJECT_RotateZ(user, oID, -g_Player[id][e_Speed][1]);
  2200.                                 }
  2201.                             }
  2202.                             else
  2203.                             {
  2204.                                 if(keys & 128 || g_Player[id][e_Mode][2] == 2)
  2205.                                 {
  2206.                                     if(!g_Player[id][e_Hold][0])
  2207.                                     {
  2208.                                         EDIT_OBJECT_RotateY(user, oID, -g_Player[id][e_Speed][1], -1);
  2209.                                     }
  2210.                                 }
  2211.                                 else
  2212.                                 {
  2213.                                     EDIT_OBJECT_RotateY(user, oID, -g_Player[id][e_Speed][1]);
  2214.                                 }
  2215.                             }
  2216.                         }
  2217.                         else
  2218.                         {
  2219.                             if(keys & 32)
  2220.                             {
  2221.                                 if(keys & 128 || g_Player[id][e_Mode][2] == 2)
  2222.                                 {
  2223.                                     if(!g_Player[id][e_Hold][0])
  2224.                                     {
  2225.                                         EDIT_OBJECT_MoveZ(user, oID, -g_Player[id][e_Speed][1], -1);
  2226.                                         EDIT_3DTEXTLABEL_Delete(user, oID);
  2227.                                         EDIT_3DTEXTLABEL_Create(user, oID);
  2228.                                     }
  2229.                                 }
  2230.                                 else
  2231.                                 {
  2232.                                     EDIT_OBJECT_MoveZ(user, oID, -g_Player[id][e_Speed][1]);
  2233.                                     EDIT_3DTEXTLABEL_Delete(user, oID);
  2234.                                 }
  2235.                             }
  2236.                             else
  2237.                             {
  2238.                                 if(keys & 128 ||  g_Player[id][e_Mode][2] == 2)
  2239.                                 {
  2240.                                     if(!g_Player[id][e_Hold][0])
  2241.                                     {
  2242.                                         EDIT_OBJECT_MoveY(user, oID, -g_Player[id][e_Speed][1], -1);
  2243.                                         EDIT_3DTEXTLABEL_Delete(user, oID);
  2244.                                         EDIT_3DTEXTLABEL_Create(user, oID);
  2245.                                     }
  2246.                                 }
  2247.                                 else
  2248.                                 {
  2249.                                     EDIT_OBJECT_MoveY(user, oID, -g_Player[id][e_Speed][1]);
  2250.                                     EDIT_3DTEXTLABEL_Delete(user, oID);
  2251.                                 }
  2252.                             }
  2253.                         }
  2254.                         g_Player[id][e_Hold][0] = 1;
  2255.                     }
  2256.                 }
  2257.                 else
  2258.                 {
  2259.                     if(keys & 1024)
  2260.                     {
  2261.                         if(!g_Player[id][e_Hold][3])
  2262.                         {
  2263.                             EDIT_MODE_SetVelocity(user, ud);
  2264.                         }
  2265.                         g_Player[id][e_Hold][3] = 1;
  2266.                     }
  2267.                     else
  2268.                     {
  2269.                         if(!g_Player[id][e_Hold][0])
  2270.                         {
  2271.                             EDIT_ACTION_Save(user, oID);
  2272.                             EDIT_LOOP_SetMA(user, oID, 0);
  2273.                             EDIT_ROAD_SetMA(user, oID, 0);
  2274.                         }
  2275.                         if(g_Player[id][e_Mode][1])
  2276.                         {
  2277.                             if(keys & 32)
  2278.                             {
  2279.                                 if(keys & 128 || g_Player[id][e_Mode][2] == 2)
  2280.                                 {
  2281.                                     if(!g_Player[id][e_Hold][0])
  2282.                                     {
  2283.                                         EDIT_OBJECT_RotateZ(user, oID, g_Player[id][e_Speed][1], 1);
  2284.                                     }
  2285.                                 }
  2286.                                 else
  2287.                                 {
  2288.                                     EDIT_OBJECT_RotateZ(user, oID, g_Player[id][e_Speed][1]);
  2289.                                 }
  2290.                             }
  2291.                             else
  2292.                             {
  2293.                                 if(keys & 128 || g_Player[id][e_Mode][2] == 2)
  2294.                                 {
  2295.                                     if(!g_Player[id][e_Hold][0])
  2296.                                     {
  2297.                                         EDIT_OBJECT_RotateY(user, oID, g_Player[id][e_Speed][1], 1);
  2298.                                     }
  2299.                                 }
  2300.                                 else
  2301.                                 {
  2302.                                     EDIT_OBJECT_RotateY(user, oID, g_Player[id][e_Speed][1]);
  2303.                                 }
  2304.                             }
  2305.                         }
  2306.                         else
  2307.                         {
  2308.                             if(keys & 32)
  2309.                             {
  2310.                                 if(keys & 128 || g_Player[id][e_Mode][2] == 2)
  2311.                                 {
  2312.                                     if(!g_Player[id][e_Hold][0])
  2313.                                     {
  2314.                                         EDIT_OBJECT_MoveZ(user, oID, g_Player[id][e_Speed][1], 1);
  2315.                                         EDIT_3DTEXTLABEL_Delete(user, oID);
  2316.                                         EDIT_3DTEXTLABEL_Create(user, oID);
  2317.                                     }
  2318.                                 }
  2319.                                 else
  2320.                                 {
  2321.                                     EDIT_OBJECT_MoveZ(user, oID, g_Player[id][e_Speed][1]);
  2322.                                     EDIT_3DTEXTLABEL_Delete(user, oID);
  2323.                                 }
  2324.                             }
  2325.                             else
  2326.                             {
  2327.                                 if(keys & 128 || g_Player[id][e_Mode][2] == 2)
  2328.                                 {
  2329.                                     if(!g_Player[id][e_Hold][0])
  2330.                                     {
  2331.                                         EDIT_OBJECT_MoveY(user, oID, g_Player[id][e_Speed][1], 1);
  2332.                                         EDIT_3DTEXTLABEL_Delete(user, oID);
  2333.                                         EDIT_3DTEXTLABEL_Create(user, oID);
  2334.                                     }
  2335.                                 }
  2336.                                 else
  2337.                                 {
  2338.                                     EDIT_OBJECT_MoveY(user, oID, g_Player[id][e_Speed][1]);
  2339.                                     EDIT_3DTEXTLABEL_Delete(user, oID);
  2340.                                 }
  2341.                             }
  2342.                         }
  2343.                         g_Player[id][e_Hold][0] = 1;
  2344.                     }
  2345.                 }
  2346.                 if(!lr)
  2347.                 {
  2348.                     if(g_Player[id][e_Hold][1])
  2349.                     {
  2350.                         EDIT_ROAD_SetPos(user, oID);
  2351.                         EDIT_LOOP_SetPos(user, oID);
  2352.                         EDIT_3DTEXTLABEL_Update(user, oID);
  2353.                         g_Player[id][e_Hold][1] = 0;
  2354.                     }
  2355.                 }
  2356.                 else if(lr > 0)
  2357.                 {
  2358.                     if(!g_Player[id][e_Hold][1])
  2359.                     {
  2360.                         EDIT_ACTION_Save(user, oID);
  2361.                         EDIT_LOOP_SetMA(user, oID, 0);
  2362.                         EDIT_ROAD_SetMA(user, oID, 0);
  2363.                     }
  2364.                     if(g_Player[id][e_Mode][1])
  2365.                     {
  2366.                         if(keys & 128 || g_Player[id][e_Mode][2] == 2)
  2367.                         {
  2368.                             if(!g_Player[id][e_Hold][1])
  2369.                             {
  2370.                                 EDIT_OBJECT_RotateX(user, oID, g_Player[id][e_Speed][1], 1);
  2371.                             }
  2372.                         }
  2373.                         else
  2374.                         {
  2375.                             EDIT_OBJECT_RotateX(user, oID, g_Player[id][e_Speed][1]);
  2376.                         }
  2377.                     }
  2378.                     else
  2379.                     {
  2380.                         if(keys & 128 || g_Player[id][e_Mode][2] == 2)
  2381.                         {
  2382.                             if(!g_Player[id][e_Hold][1])
  2383.                             {
  2384.                                 EDIT_OBJECT_MoveX(user, oID, g_Player[id][e_Speed][1], 1);
  2385.                                 EDIT_3DTEXTLABEL_Delete(user, oID);
  2386.                                 EDIT_3DTEXTLABEL_Create(user, oID);
  2387.                             }
  2388.                         }
  2389.                         else
  2390.                         {
  2391.                             EDIT_OBJECT_MoveX(user, oID, g_Player[id][e_Speed][1]);
  2392.                             EDIT_3DTEXTLABEL_Delete(user, oID);
  2393.                         }
  2394.                     }
  2395.                     g_Player[id][e_Hold][1] = 1;
  2396.                 }
  2397.                 else
  2398.                 {
  2399.                     if(!g_Player[id][e_Hold][1])
  2400.                     {
  2401.                         EDIT_ACTION_Save(user, oID);
  2402.                         EDIT_LOOP_SetMA(user, oID, 0);
  2403.                         EDIT_ROAD_SetMA(user, oID, 0);
  2404.                     }
  2405.                     if(g_Player[id][e_Mode][1])
  2406.                     {
  2407.                         if(keys & 128 || g_Player[id][e_Mode][2] == 2)
  2408.                         {
  2409.                             if(!g_Player[id][e_Hold][1])
  2410.                             {
  2411.                                 EDIT_OBJECT_RotateX(user, oID, -g_Player[id][e_Speed][1], -1);
  2412.                             }
  2413.                         }
  2414.                         else
  2415.                         {
  2416.                             EDIT_OBJECT_RotateX(user, oID, -g_Player[id][e_Speed][1]);
  2417.                         }
  2418.                     }
  2419.                     else
  2420.                     {
  2421.                         if(keys & 128 || g_Player[id][e_Mode][2] == 2)
  2422.                         {
  2423.                             if(!g_Player[id][e_Hold][1])
  2424.                             {
  2425.                                 EDIT_OBJECT_MoveX(user, oID, -g_Player[id][e_Speed][1], -1);
  2426.                                 EDIT_3DTEXTLABEL_Delete(user, oID);
  2427.                                 EDIT_3DTEXTLABEL_Create(user, oID);
  2428.                             }
  2429.                         }
  2430.                         else
  2431.                         {
  2432.                             EDIT_OBJECT_MoveX(user, oID, -g_Player[id][e_Speed][1]);
  2433.                             EDIT_3DTEXTLABEL_Delete(user, oID);
  2434.                         }
  2435.                     }
  2436.                     g_Player[id][e_Hold][1] = 1;
  2437.                 }
  2438.             }
  2439.         }
  2440.         else
  2441.         {
  2442.             if(!ud && !lr)
  2443.             {
  2444.                 g_Player[id][e_Hold][2] = 0;
  2445.                 g_Player[id][e_Time] = 0;
  2446.             }
  2447.         }
  2448.     }
  2449.     return 1;
  2450. }
  2451.  
  2452. PUBLIC:EDIT_AutoSave()
  2453. {
  2454.     for(new i = 0; i < UOE_MAX_ADMINS; ++i)
  2455.     {
  2456.         if(g_Player[i][e_PID] != UOE_INVALID_ID)
  2457.         {
  2458.             for(new x = 1; x < MAX_OBJECTS; ++x)
  2459.             {
  2460.                 if(g_Editor[i][x][e_EDIT][e_MID])
  2461.                 {
  2462.                     if(!EDIT_OID_IsValid(x))
  2463.                     {
  2464.                         EDIT_OBJECT_ResetData(g_Player[i][e_PID], x);
  2465.                     }
  2466.                 }
  2467.             }
  2468.             EDIT_MAP_AutoSave(g_Player[i][e_PID]);
  2469.         }
  2470.     }
  2471.     return 1;
  2472. }
  2473.  
  2474. EDIT_GetPosAndRot(Float:off[3], Float:rot[3], Float:id_pos[3], Float:id_rot[3])
  2475. {
  2476.     EDIT_ConvertValue(id_rot[0], id_rot[1], id_rot[2]);
  2477.     id_pos[0] = id_pos[0] + off[0] * cy * cz - off[0] * sx * sy * sz - off[1] * cx * sz + off[2] * sy * cz + off[2] * sx * cy * sz;
  2478.     id_pos[1] = id_pos[1] + off[0] * cy * sz + off[0] * sx * sy * cz + off[1] * cx * cz + off[2] * sy * sz - off[2] * sx * cy * cz;
  2479.     id_pos[2] = id_pos[2] - off[0] * cx * sy + off[1] * sx + off[2] * cx * cy;
  2480.     EDIT_ConvertValue(asin(cx * cy), atan2(sx, cx * sy) + rot[2], atan2(cy * cz * sx - sy * sz, cz * sy - cy * sx * -sz));
  2481.     EDIT_ConvertValue(asin(cx * sy), atan2(cx * cy, sx), atan2(cz * sx * sy - cy * sz, cy * cz + sx * sy * sz));
  2482.     EDIT_ConvertValue(atan2(sx, cx * cy) + rot[0], asin(cx * sy), atan2(cz * sx * sy + cy * sz, cy * cz - sx * sy * sz));
  2483.     id_rot[0] = asin(cy * sx), id_rot[1] = atan2(sy, cx * cy) + rot[1], id_rot[2] = atan2(cx * sz - cz * sx * sy, cx * cz + sx * sy * sz);
  2484.     return 1;
  2485. }
  2486.  
  2487. EDIT_ConvertValue(Float:rot_x, Float:rot_y, Float:rot_z)
  2488. {
  2489.     sx = floatsin(rot_x, degrees);
  2490.     sy = floatsin(rot_y, degrees);
  2491.     sz = floatsin(rot_z, degrees);
  2492.     cx = floatcos(rot_x, degrees);
  2493.     cy = floatcos(rot_y, degrees);
  2494.     cz = floatcos(rot_z, degrees);
  2495.     return 1;
  2496. }
  2497.  
  2498. EDIT_ModuloOperation(&Float:rot_x, &Float:rot_y, &Float:rot_z)
  2499. {
  2500.     EDIT_Remainder(rot_x, 360.0);
  2501.     EDIT_Remainder(rot_y, 360.0);
  2502.     EDIT_Remainder(rot_z, 360.0);
  2503.     return 1;
  2504. }
  2505.  
  2506. EDIT_Remainder(&Float:remainder, Float:value)
  2507. {
  2508.     if(remainder >= value)
  2509.     {
  2510.         while(remainder >= value)
  2511.         {
  2512.             remainder = remainder - value;
  2513.         }
  2514.     }
  2515.     else if(remainder < 0.0)
  2516.     {
  2517.         while(remainder < 0.0)
  2518.         {
  2519.             remainder = remainder + value;
  2520.         }
  2521.     }
  2522.     return 1;
  2523. }
  2524.  
  2525. EDIT_VEHICLE_Spawn(user, mid, component)
  2526. {
  2527.     if(g_Player[g_ID[user]][e_NRG])
  2528.     {
  2529.         DestroyVehicle(g_Player[g_ID[user]][e_NRG]);
  2530.         g_Player[g_ID[user]][e_NRG] = 0;
  2531.     }
  2532.     new
  2533.         Float:angle,
  2534.         Float:pos_x,
  2535.         Float:pos_y,
  2536.         Float:pos_z;
  2537.     GetPlayerFacingAngle(user, angle);
  2538.     GetPlayerPos(user, pos_x, pos_y, pos_z);
  2539.     g_Player[g_ID[user]][e_NRG] = CreateVehicle(mid, pos_x, pos_y, pos_z + 0.2, angle, -1, -1, -1);
  2540.     PutPlayerInVehicle(user, g_Player[g_ID[user]][e_NRG], 0);
  2541.     if(component)
  2542.     {
  2543.         AddVehicleComponent(g_Player[g_ID[user]][e_NRG], 1010);
  2544.     }
  2545.     return 1;
  2546. }
  2547.  
  2548. EDIT_VEHICLE_Destroy(user)
  2549. {
  2550.     if(g_Player[g_ID[user]][e_NRG])
  2551.     {
  2552.         DestroyVehicle(g_Player[g_ID[user]][e_NRG]);
  2553.         g_Player[g_ID[user]][e_NRG] = 0;
  2554.     }
  2555.     return 1;
  2556. }
  2557.  
  2558. EDIT_MoveCamera(user, keys, ud, lr)
  2559. {
  2560.     static
  2561.         time1,
  2562.         time2,
  2563.         Float:abs_z,
  2564.         Float:angle,
  2565.         Float:cam_x1,
  2566.         Float:cam_y1,
  2567.         Float:cam_z1,
  2568.         Float:cam_x2,
  2569.         Float:cam_y2,
  2570.         Float:cam_z2,
  2571.         Float:offset_x,
  2572.         Float:offset_y,
  2573.         Float:offset_z;
  2574.     GetPlayerCameraPos(user, cam_x1, cam_y1, cam_z1);
  2575.     GetPlayerCameraFrontVector(user, cam_x2, cam_y2, cam_z2);
  2576.     offset_x = (cam_x2 * 1000.0),
  2577.     offset_y = (cam_y2 * 1000.0),
  2578.     offset_z = (cam_z2 * 1000.0);
  2579.     if(lr < 0)
  2580.     {
  2581.         if(ud < 0)
  2582.         {
  2583.             abs_z = floatabs(offset_z);
  2584.             angle = -atan2(cam_y2, cam_x2);
  2585.             cam_x1 = cam_x1 + cam_x2 + (offset_x - offset_y) + (abs_z * floatsin(angle, degrees));
  2586.             cam_y1 = cam_y1 + cam_y2 + (offset_y + offset_x) + (abs_z * floatcos(angle, degrees));
  2587.             cam_z1 = cam_z1 + cam_z2 + offset_z;
  2588.         }
  2589.         else if(ud > 0)
  2590.         {
  2591.             abs_z = floatabs(offset_z);
  2592.             angle = -atan2(cam_y2, cam_x2);
  2593.             cam_x1 = cam_x1 + cam_x2 + (-offset_x - offset_y) + (abs_z * floatsin(angle, degrees));
  2594.             cam_y1 = cam_y1 + cam_y2 + (-offset_y + offset_x) + (abs_z * floatcos(angle, degrees));
  2595.             cam_z1 = cam_z1 + cam_z2 - offset_z;
  2596.         }
  2597.         else
  2598.         {
  2599.             cam_x1 = cam_x1 + cam_x2 - offset_y;
  2600.             cam_y1 = cam_y1 + cam_y2 + offset_x;
  2601.             cam_z1 = cam_z1 + cam_z2;
  2602.         }
  2603.     }
  2604.     else if(lr > 0)
  2605.     {
  2606.         if(ud < 0)
  2607.         {
  2608.             abs_z = floatabs(offset_z);
  2609.             angle = -atan2(cam_y2, cam_x2) + 180.0;
  2610.             cam_x1 = cam_x1 + cam_x2 + (offset_x + offset_y) + (abs_z * floatsin(angle, degrees));
  2611.             cam_y1 = cam_y1 + cam_y2 + (offset_y - offset_x) + (abs_z * floatcos(angle, degrees));
  2612.             cam_z1 = cam_z1 + cam_z2 + offset_z;
  2613.         }
  2614.         else if(ud > 0)
  2615.         {
  2616.             abs_z = floatabs(offset_z);
  2617.             angle = -atan2(cam_y2, cam_x2) + 180.0;
  2618.             cam_x1 = cam_x1 + cam_x2 + (-offset_x + offset_y) + (abs_z * floatsin(angle, degrees));
  2619.             cam_y1 = cam_y1 + cam_y2 + (-offset_y - offset_x) + (abs_z * floatcos(angle, degrees));
  2620.             cam_z1 = cam_z1 + cam_z2 - offset_z;
  2621.         }
  2622.         else
  2623.         {
  2624.             cam_x1 = cam_x1 + cam_x2 + offset_y;
  2625.             cam_y1 = cam_y1 + cam_y2 - offset_x;
  2626.             cam_z1 = cam_z1 + cam_z2;
  2627.         }
  2628.     }
  2629.     else if(ud < 0)
  2630.     {
  2631.         if(!(keys & 32))
  2632.         {
  2633.             cam_x1 = cam_x1 + cam_x2 + offset_x;
  2634.             cam_y1 = cam_y1 + cam_y2 + offset_y;
  2635.             cam_z1 = cam_z1 + cam_z2 + offset_z;
  2636.         }
  2637.         else
  2638.         {
  2639.             cam_z1 = cam_z1 + 1000.0;
  2640.         }
  2641.     }
  2642.     else if(ud > 0)
  2643.     {
  2644.         if(!(keys & 32))
  2645.         {
  2646.             cam_x1 = cam_x1 + cam_x2 - offset_x;
  2647.             cam_y1 = cam_y1 + cam_y2 - offset_y;
  2648.             cam_z1 = cam_z1 + cam_z2 - offset_z;
  2649.         }
  2650.         else
  2651.         {
  2652.             cam_z1 = cam_z1 - 1000.0;
  2653.         }
  2654.     }
  2655.     time1 = GetTickCount();
  2656.     if(g_Player[g_ID[user]][e_Time])
  2657.     {
  2658.         time2 = time1 - g_Player[g_ID[user]][e_Time];
  2659.         if(g_Player[g_ID[user]][e_Speed][0] < 500.0)
  2660.         {
  2661.             for(new i = 1; i != 200; ++i)
  2662.             {
  2663.                 if((20 * i) > time2)
  2664.                 {
  2665.                     if(i < 15)
  2666.                     {
  2667.                         g_Player[g_ID[user]][e_Speed][0] = 1.0 * i;
  2668.                     }
  2669.                     else if(i < 30)
  2670.                     {
  2671.                         g_Player[g_ID[user]][e_Speed][0] = 1.4 * i;
  2672.                     }
  2673.                     else if(i < 45)
  2674.                     {
  2675.                         g_Player[g_ID[user]][e_Speed][0] = 1.8 * i;
  2676.                     }
  2677.                     else if(i < 60)
  2678.                     {
  2679.                         g_Player[g_ID[user]][e_Speed][0] = 2.2 * i;
  2680.                     }
  2681.                     else
  2682.                     {
  2683.                         g_Player[g_ID[user]][e_Speed][0] = 2.6 * i;
  2684.                     }
  2685.                     break;
  2686.                 }
  2687.             }
  2688.         }
  2689.     }
  2690.     else
  2691.     {
  2692.         g_Player[g_ID[user]][e_Time] = time1;
  2693.         g_Player[g_ID[user]][e_Speed][0] = 1.0;
  2694.     }
  2695.     if(g_Axis[g_ID[user]][e_Axis][0])
  2696.     {
  2697.         if(g_Player[g_ID[user]][e_OID] != UOE_INVALID_ID)
  2698.         {
  2699.             new
  2700.                 Float:float1[3];
  2701.             EDIT_OBJECT_GetPos(user, g_Player[g_ID[user]][e_OID], float1);
  2702.             float1[0] = float1[0] + g_Axis[g_ID[user]][e_O][0];
  2703.             float1[1] = float1[1] + g_Axis[g_ID[user]][e_O][1];
  2704.             float1[2] = float1[2] + g_Axis[g_ID[user]][e_O][2];
  2705.             EDIT_AXIS_Rotate(user, float1[0], float1[1], float1[2]);
  2706.         }
  2707.     }
  2708.     MoveObject(g_Player[g_ID[user]][e_Fly], cam_x1, cam_y1, cam_z1, g_Player[g_ID[user]][e_Speed][0]);
  2709.     return 1;
  2710. }
  2711.  
  2712. EDIT_OBJECT_Create(user, uid, mid, Float:pos_x, Float:pos_y, Float:pos_z, Float:rot_x, Float:rot_y, Float:rot_z)
  2713. {
  2714.     new
  2715.         oID;
  2716.     oID = EDIT_OID_Create(mid, pos_x, pos_y, pos_z, rot_x, rot_y, rot_z, .DrawDistance = UOE_DRAW_DISTANCE);
  2717.     if(EDIT_OID_IsValid(oID))
  2718.     {
  2719.         #if defined _inc_streamer
  2720.             Streamer_Update(user);
  2721.             Streamer_SetFloatData(STREAMER_TYPE_OBJECT, oID, E_STREAMER_DRAW_DISTANCE, UOE_DRAW_DISTANCE);
  2722.         #endif
  2723.         if(g_Editor[g_ID[user]][oID][e_EDIT][e_UID])
  2724.         {
  2725.             EDIT_ACTION_ResetSlot(user, g_Editor[g_ID[user]][oID][e_EDIT][e_UID]);
  2726.         }
  2727.         g_Editor[g_ID[user]][oID][e_EDIT][e_Map] = 0;
  2728.         g_Editor[g_ID[user]][oID][e_EDIT][e_UID] = uid;
  2729.         g_Editor[g_ID[user]][oID][e_ROAD][e_IDX] = EDIT_ROAD_GetIndex(mid);
  2730.         return oID;
  2731.     }
  2732.     return UOE_INVALID_ID;
  2733. }
  2734.  
  2735. EDIT_OBJECT_Destroy(user, oid)
  2736. {
  2737.     if(EDIT_OBJECT_IsValid(user, oid))
  2738.     {
  2739.         EDIT_OBJECT_ResetData(user, oid);
  2740.         EDIT_OID_Destroy(oid);
  2741.         g_Editor[g_ID[user]][oid][e_EDIT][e_UID] = 0;
  2742.         return 1;
  2743.     }
  2744.     return 0;
  2745. }
  2746.  
  2747. EDIT_OBJECT_ResetData(user, oid)
  2748. {
  2749.     EDIT_ROAD_SetSL(user, oid, 0);
  2750.     EDIT_ROAD_SetMA(user, oid, 0);
  2751.     EDIT_LOOP_SetSL(user, oid, 0);
  2752.     EDIT_LOOP_SetMA(user, oid, 0);
  2753.     EDIT_3DTEXTLABEL_Delete(user, oid);
  2754.     g_Editor[g_ID[user]][oid][e_LOOP][e_O][0] = 0.0;
  2755.     g_Editor[g_ID[user]][oid][e_LOOP][e_O][1] = 0.0;
  2756.     g_Editor[g_ID[user]][oid][e_LOOP][e_O][2] = 0.0;
  2757.     g_Editor[g_ID[user]][oid][e_LOOP][e_R][0] = 0.0;
  2758.     g_Editor[g_ID[user]][oid][e_LOOP][e_R][1] = 0.0;
  2759.     g_Editor[g_ID[user]][oid][e_LOOP][e_R][2] = 0.0;
  2760.     if(g_Editor[g_ID[user]][oid][e_EDIT][e_Use])
  2761.     {
  2762.         EDIT_AXIS_Hide(user);
  2763.         g_Player[g_ID[user]][e_OID] = UOE_INVALID_ID;
  2764.         g_Editor[g_ID[user]][oid][e_EDIT][e_Use] = 0;
  2765.         EDIT_TEXTDRAW_Update(user);
  2766.     }
  2767.     g_Editor[g_ID[user]][oid][e_ROAD][e_IDX] = 0;
  2768.     g_Editor[g_ID[user]][oid][e_EDIT][e_MID] = 0;
  2769.     g_Editor[g_ID[user]][oid][e_EDIT][e_Map] = UOE_INVALID_ID;
  2770.     g_Editor[g_ID[user]][oid][e_EDIT][e_Lock] = 0;
  2771.     g_Editor[g_ID[user]][oid][e_EDIT][e_Info] = 0;
  2772.     return 1;
  2773. }
  2774.  
  2775. EDIT_OBJECT_IsValid(user, oid)
  2776. {
  2777.     if(EDIT_OID_IsValid(oid))
  2778.     {
  2779.         if(g_Editor[g_ID[user]][oid][e_EDIT][e_MID])
  2780.         {
  2781.             return 1;
  2782.         }
  2783.     }
  2784.     return 0;
  2785. }
  2786.  
  2787. EDIT_OBJECT_RotateX(user, oid, Float:rot_x, instant = 0)
  2788. {
  2789.     if(instant)
  2790.     {
  2791.         rot_x = rot_x * 1000 / UOE_TIMER_INT;
  2792.     }
  2793.     EDIT_OBJECT_GetRot(user, oid, g_Float1);
  2794.     if(!g_Player[g_ID[user]][e_Mode][2])
  2795.     {
  2796.         EDIT_ConvertValue(g_Float1[0], g_Float1[1], g_Float1[2]);
  2797.         EDIT_ConvertValue(atan2(sx, cx * cy) + rot_x, asin(cx * sy), atan2(cz * sx * sy + cy * sz, cy * cz - sx * sy * sz));
  2798.         EDIT_OBJECT_SetRot(user, oid, asin(cy * sx), atan2(sy, cx * cy), atan2(cx * sz - cz * sx * sy, cx * cz + sx * sy * sz));
  2799.     }
  2800.     else
  2801.     {
  2802.         if(g_Player[g_ID[user]][e_Mode][2] == 2)
  2803.         {
  2804.             rot_x = g_Player[g_ID[user]][e_Snap] * instant;
  2805.             g_Float1[0] = (floatround(g_Float1[0] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
  2806.         }
  2807.         EDIT_OBJECT_SetRot(user, oid, g_Float1[0] + rot_x, g_Float1[1], g_Float1[2]);
  2808.     }
  2809.     return 1;
  2810. }
  2811.  
  2812. EDIT_OBJECT_RotateY(user, oid, Float:rot_y, instant = 0)
  2813. {
  2814.     if(instant)
  2815.     {
  2816.         rot_y = rot_y * 1000 / UOE_TIMER_INT;
  2817.     }
  2818.     EDIT_OBJECT_GetRot(user, oid, g_Float1);
  2819.     if(g_Player[g_ID[user]][e_Mode][2] == 2)
  2820.     {
  2821.         rot_y = g_Player[g_ID[user]][e_Snap] * instant;
  2822.         g_Float1[1] = (floatround(g_Float1[1] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
  2823.     }
  2824.     EDIT_OBJECT_SetRot(user, oid, g_Float1[0], g_Float1[1] + rot_y, g_Float1[2]);
  2825.     return 1;
  2826. }
  2827.  
  2828. EDIT_OBJECT_RotateZ(user, oid, Float:rot_z, instant = 0)
  2829. {
  2830.     if(instant)
  2831.     {
  2832.         rot_z = rot_z * 1000 / UOE_TIMER_INT;
  2833.     }
  2834.     EDIT_OBJECT_GetRot(user, oid, g_Float1);
  2835.     if(!g_Player[g_ID[user]][e_Mode][2])
  2836.     {
  2837.         EDIT_ConvertValue(g_Float1[0], g_Float1[1], g_Float1[2]);
  2838.         EDIT_ConvertValue(asin(cx * cy), atan2(sx, cx * sy) + rot_z, atan2(cy * cz * sx - sy * sz, cz * sy - cy * sx * -sz));
  2839.         EDIT_OBJECT_SetRot(user, oid, asin(cx * sy), atan2(cx * cy, sx), atan2(cz * sx * sy - cy * sz, cy * cz + sx * sy * sz));
  2840.     }
  2841.     else
  2842.     {
  2843.         if(g_Player[g_ID[user]][e_Mode][2] == 2)
  2844.         {
  2845.             rot_z = g_Player[g_ID[user]][e_Snap] * instant;
  2846.             g_Float1[2] = (floatround(g_Float1[2] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
  2847.         }
  2848.         EDIT_OBJECT_SetRot(user, oid, g_Float1[0], g_Float1[1], g_Float1[2] + rot_z);
  2849.     }
  2850.     return 1;
  2851. }
  2852.  
  2853. EDIT_OBJECT_MoveX(user, oid, Float:offset, instant = 0)
  2854. {
  2855.     if(instant)
  2856.     {
  2857.         offset = offset * 1000 / UOE_TIMER_INT;
  2858.     }
  2859.     EDIT_OBJECT_GetPos(user, oid, g_Float1);
  2860.     if(!g_Player[g_ID[user]][e_Mode][2])
  2861.     {
  2862.         EDIT_OBJECT_GetRot(user, oid, g_Float2);
  2863.         EDIT_ConvertValue(g_Float2[0], g_Float2[1], g_Float2[2]);
  2864.         g_Float1[0] = g_Float1[0] + offset * cy * cz - offset * sx * sy * sz;
  2865.         g_Float1[1] = g_Float1[1] + offset * cy * sz + offset * sx * sy * cz;
  2866.         g_Float1[2] = g_Float1[2] - offset * cx * sy;
  2867.         if(g_Axis[g_ID[user]][e_Axis][0])
  2868.         {
  2869.             EDIT_AXIS_Update(user, g_Float1[0], g_Float1[1], g_Float1[2], g_Float2[0], g_Float2[1], g_Float2[2]);
  2870.         }
  2871.     }
  2872.     else
  2873.     {
  2874.         if(g_Player[g_ID[user]][e_Mode][2] == 2)
  2875.         {
  2876.             offset = g_Player[g_ID[user]][e_Snap] * instant;
  2877.             g_Float1[0] = (floatround(g_Float1[0] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
  2878.             g_Float1[1] = (floatround(g_Float1[1] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
  2879.             g_Float1[2] = (floatround(g_Float1[2] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
  2880.         }
  2881.         g_Float1[0] = g_Float1[0] + offset;
  2882.     }
  2883.     EDIT_OID_SetPos(oid, g_Float1[0], g_Float1[1], g_Float1[2]);
  2884.     return 1;
  2885. }
  2886.  
  2887. EDIT_OBJECT_MoveY(user, oid, Float:offset, instant = 0)
  2888. {
  2889.     if(instant)
  2890.     {
  2891.         offset = offset * 1000 / UOE_TIMER_INT;
  2892.     }
  2893.     EDIT_OBJECT_GetPos(user, oid, g_Float1);
  2894.     if(!g_Player[g_ID[user]][e_Mode][2])
  2895.     {
  2896.         EDIT_OBJECT_GetRot(user, oid, g_Float2);
  2897.         cx = floatcos(g_Float2[0], degrees);
  2898.         cz = floatcos(g_Float2[2], degrees);
  2899.         sx = floatsin(g_Float2[0], degrees);
  2900.         sz = floatsin(g_Float2[2], degrees);
  2901.         g_Float1[0] = g_Float1[0] - offset * cx * sz;
  2902.         g_Float1[1] = g_Float1[1] + offset * cx * cz;
  2903.         g_Float1[2] = g_Float1[2] + offset * sx;
  2904.         if(g_Axis[g_ID[user]][e_Axis][0])
  2905.         {
  2906.             EDIT_AXIS_Update(user, g_Float1[0], g_Float1[1], g_Float1[2], g_Float2[0], g_Float2[1], g_Float2[2]);
  2907.         }
  2908.     }
  2909.     else
  2910.     {
  2911.         if(g_Player[g_ID[user]][e_Mode][2] == 2)
  2912.         {
  2913.             offset = g_Player[g_ID[user]][e_Snap] * instant;
  2914.             g_Float1[0] = (floatround(g_Float1[0] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
  2915.             g_Float1[1] = (floatround(g_Float1[1] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
  2916.             g_Float1[2] = (floatround(g_Float1[2] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
  2917.         }
  2918.         g_Float1[1] = g_Float1[1] + offset;
  2919.     }
  2920.     EDIT_OID_SetPos(oid, g_Float1[0], g_Float1[1], g_Float1[2]);
  2921.     return 1;
  2922. }
  2923.  
  2924. EDIT_OBJECT_MoveZ(user, oid, Float:offset, instant = 0)
  2925. {
  2926.     if(instant)
  2927.     {
  2928.         offset = offset * 1000 / UOE_TIMER_INT;
  2929.     }
  2930.     EDIT_OBJECT_GetPos(user, oid, g_Float1);
  2931.     if(!g_Player[g_ID[user]][e_Mode][2])
  2932.     {
  2933.         EDIT_OBJECT_GetRot(user, oid, g_Float2);
  2934.         EDIT_ConvertValue(g_Float2[0], g_Float2[1], g_Float2[2]);
  2935.         g_Float1[0] = g_Float1[0] + offset * sy * cz + offset * sx * cy * sz;
  2936.         g_Float1[1] = g_Float1[1] + offset * sy * sz - offset * sx * cy * cz;
  2937.         g_Float1[2] = g_Float1[2] + offset * cx * cy;
  2938.         if(g_Axis[g_ID[user]][e_Axis][0])
  2939.         {
  2940.             EDIT_AXIS_Update(user, g_Float1[0], g_Float1[1], g_Float1[2], g_Float2[0], g_Float2[1], g_Float2[2]);
  2941.         }
  2942.     }
  2943.     else
  2944.     {
  2945.         if(g_Player[g_ID[user]][e_Mode][2] == 2)
  2946.         {
  2947.             offset = g_Player[g_ID[user]][e_Snap] * instant;
  2948.             g_Float1[0] = (floatround(g_Float1[0] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
  2949.             g_Float1[1] = (floatround(g_Float1[1] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
  2950.             g_Float1[2] = (floatround(g_Float1[2] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
  2951.         }
  2952.         g_Float1[2] = g_Float1[2] + offset;
  2953.     }
  2954.     EDIT_OID_SetPos(oid, g_Float1[0], g_Float1[1], g_Float1[2]);
  2955.     return 1;
  2956. }
  2957.  
  2958. EDIT_OBJECT_SetModel(user, oid, mid)
  2959. {
  2960.     new
  2961.         oID,
  2962.         uID,
  2963.         map,
  2964.         use,
  2965.         count_SL,
  2966.         sync_rot,
  2967.         road_MA,
  2968.         road_SL,
  2969.         Float:float1[3],
  2970.         Float:float2[3],
  2971.         Float:float3[3],
  2972.         Float:float4[3];
  2973.     EDIT_OBJECT_GetPos(user, oid, float1);
  2974.     EDIT_OBJECT_GetRot(user, oid, float2);
  2975.     if(g_Editor[g_ID[user]][oid][e_LOOP][e_SL])
  2976.     {
  2977.         float3[0] = g_Editor[g_ID[user]][oid][e_LOOP][e_O][0];
  2978.         float3[1] = g_Editor[g_ID[user]][oid][e_LOOP][e_O][1];
  2979.         float3[2] = g_Editor[g_ID[user]][oid][e_LOOP][e_O][2];
  2980.         float4[0] = g_Editor[g_ID[user]][oid][e_LOOP][e_R][0];
  2981.         float4[1] = g_Editor[g_ID[user]][oid][e_LOOP][e_R][1];
  2982.         float4[2] = g_Editor[g_ID[user]][oid][e_LOOP][e_R][2];
  2983.         count_SL = EDIT_LOOP_GetSLCount(user, oid);
  2984.         sync_rot = g_Editor[g_ID[user]][oid][e_LOOP][e_SR];
  2985.     }
  2986.     uID = g_Editor[g_ID[user]][oid][e_EDIT][e_UID];
  2987.     map = g_Editor[g_ID[user]][oid][e_EDIT][e_Map];
  2988.     use = g_Editor[g_ID[user]][oid][e_EDIT][e_Use];
  2989.     if(g_Editor[g_ID[user]][oid][e_ROAD][e_IDX])
  2990.     {
  2991.         road_MA = g_Editor[g_ID[user]][oid][e_ROAD][e_MA];
  2992.         road_SL = g_Editor[g_ID[user]][oid][e_ROAD][e_SL];
  2993.     }
  2994.     EDIT_LOOP_Destroy(user, oid);
  2995.     EDIT_OBJECT_Destroy(user, oid);
  2996.     oID = EDIT_OBJECT_Create(user, uID, mid, float1[0], float1[1], float1[2], float2[0], float2[1], float2[2]);
  2997.     g_Editor[g_ID[user]][oID][e_EDIT][e_Map] = map;
  2998.     g_Editor[g_ID[user]][oID][e_EDIT][e_MID] = mid;
  2999.     if(use)
  3000.     {
  3001.         if(g_Player[g_ID[user]][e_Active])
  3002.         {
  3003.             g_Player[g_ID[user]][e_Active] = 0;
  3004.             CancelEdit(user);
  3005.         }
  3006.         EDIT_OBJECT_SetActive(user, oID);
  3007.     }
  3008.     else
  3009.     {
  3010.         EDIT_3DTEXTLABEL_Create(user, oID);
  3011.     }
  3012.     if(count_SL)
  3013.     {
  3014.         EDIT_LOOP_Create(user, oID, count_SL, float3, float4, sync_rot);
  3015.     }
  3016.     if(g_Editor[g_ID[user]][oID][e_ROAD][e_IDX])
  3017.     {
  3018.         if(road_MA)
  3019.         {
  3020.             EDIT_ROAD_Attach(user, oID, road_MA);
  3021.         }
  3022.         EDIT_ROAD_SetSL(user, oID, road_SL);
  3023.         EDIT_ROAD_SetPos(user, oID);
  3024.     }
  3025.     return 1;
  3026. }
  3027.  
  3028. EDIT_OBJECT_SetPos(user, oid, Float:pos_x, Float:pos_y, Float:pos_z)
  3029. {
  3030.     if(EDIT_OBJECT_IsValid(user, oid))
  3031.     {
  3032.         EDIT_OID_SetPos(oid, pos_x, pos_y, pos_z);
  3033.         EDIT_3DTEXTLABEL_Delete(user, oid);
  3034.         EDIT_3DTEXTLABEL_Create(user, oid);
  3035.         if(!g_Player[g_ID[user]][e_Mode][2])
  3036.         {
  3037.             if(g_Axis[g_ID[user]][e_Axis][0])
  3038.             {
  3039.                 if(g_Axis[g_ID[user]][e_OID] == oid)
  3040.                 {
  3041.                     new
  3042.                         Float:float1[3];
  3043.                     EDIT_OBJECT_GetRot(user, oid, float1);
  3044.                     EDIT_AXIS_Update(user, pos_x, pos_y, pos_z, float1[0], float1[1], float1[2]);
  3045.                 }
  3046.             }
  3047.         }
  3048.     }
  3049.     return 1;
  3050. }
  3051.  
  3052. EDIT_OBJECT_SetRot(user, oid, Float:rot_x, Float:rot_y, Float:rot_z)
  3053. {
  3054.     if(EDIT_OBJECT_IsValid(user, oid))
  3055.     {
  3056.         EDIT_OID_SetRot(oid, rot_x, rot_y, rot_z);
  3057.         EDIT_3DTEXTLABEL_Update(user, oid);
  3058.         if(!g_Player[g_ID[user]][e_Mode][2])
  3059.         {
  3060.             if(g_Axis[g_ID[user]][e_Axis][0])
  3061.             {
  3062.                 if(g_Axis[g_ID[user]][e_OID] == oid)
  3063.                 {
  3064.                     new
  3065.                         Float:float1[3];
  3066.                     EDIT_OBJECT_GetPos(user, oid, float1);
  3067.                     EDIT_AXIS_Update(user, float1[0], float1[1], float1[2], rot_x, rot_y, rot_z);
  3068.                 }
  3069.             }
  3070.         }
  3071.     }
  3072.     return 1;
  3073. }
  3074.  
  3075. EDIT_OBJECT_GetPos(user, oid, Float:pos[3])
  3076. {
  3077.     if(EDIT_OBJECT_IsValid(user, oid))
  3078.     {
  3079.         EDIT_OID_GetPos(oid, pos[0], pos[1], pos[2]);
  3080.     }
  3081.     return 1;
  3082. }
  3083.  
  3084. EDIT_OBJECT_GetRot(user, oid, Float:rot[3])
  3085. {
  3086.     if(EDIT_OBJECT_IsValid(user, oid))
  3087.     {
  3088.         EDIT_OID_GetRot(oid, rot[0], rot[1], rot[2]);
  3089.         EDIT_ModuloOperation(rot[0], rot[1], rot[2]);
  3090.         if(g_Editor[g_ID[user]][oid][e_ROAD][e_IDX] != UOE_INVALID_ID)
  3091.         {
  3092.             if((!floatcmp(rot[0], 0.0) || !floatcmp(rot[0], 360.0))
  3093.             && (!floatcmp(rot[1], 0.0) || !floatcmp(rot[1], 360.0)))
  3094.             {
  3095.                 rot[1] = 0.000000001;
  3096.             }
  3097.         }
  3098.     }
  3099.     return 1;
  3100. }
  3101.  
  3102. EDIT_OBJECT_GetID(user, uid)
  3103. {
  3104.     if(uid)
  3105.     {
  3106.         for(new i = 1; i < MAX_OBJECTS; ++i)
  3107.         {
  3108.             if(g_Editor[g_ID[user]][i][e_EDIT][e_UID] == uid)
  3109.             {
  3110.                 if(!EDIT_OID_IsValid(i))
  3111.                 {
  3112.                     return UOE_INVALID_ID;
  3113.                 }
  3114.                 else
  3115.                 {
  3116.                     return i;
  3117.                 }
  3118.             }
  3119.         }
  3120.     }
  3121.     return 0;
  3122. }
  3123.  
  3124. EDIT_OBJECT_SetActive(user, oid)
  3125. {
  3126.     if(g_Player[g_ID[user]][e_OID] != oid)
  3127.     {
  3128.         if(oid == UOE_INVALID_ID)
  3129.         {
  3130.             EDIT_ROAD_SetPos(user, g_Player[g_ID[user]][e_OID]);
  3131.             EDIT_LOOP_SetPos(user, g_Player[g_ID[user]][e_OID]);
  3132.             g_Editor[g_ID[user]][g_Player[g_ID[user]][e_OID]][e_EDIT][e_Use] = 0;
  3133.             EDIT_3DTEXTLABEL_Update(user, g_Player[g_ID[user]][e_OID]);
  3134.             g_Player[g_ID[user]][e_OID] = UOE_INVALID_ID;
  3135.             if(!g_Player[g_ID[user]][e_Mode][2])
  3136.             {
  3137.                 EDIT_AXIS_Hide(user);
  3138.             }
  3139.         }
  3140.         else
  3141.         {
  3142.             if(g_Player[g_ID[user]][e_OID] != UOE_INVALID_ID)
  3143.             {
  3144.                 g_Editor[g_ID[user]][g_Player[g_ID[user]][e_OID]][e_EDIT][e_Use] = 0;
  3145.                 EDIT_3DTEXTLABEL_Update(user, g_Player[g_ID[user]][e_OID]);
  3146.             }
  3147.             g_Player[g_ID[user]][e_OID] = oid;
  3148.             if(!g_Editor[g_ID[user]][oid][e_EDIT][e_Use])
  3149.             {
  3150.                 g_Editor[g_ID[user]][oid][e_EDIT][e_Use] = 1;
  3151.                 EDIT_3DTEXTLABEL_Update(user, oid);
  3152.             }
  3153.             if(!g_Player[g_ID[user]][e_Mode][2])
  3154.             {
  3155.                 EDIT_AXIS_Show(user);
  3156.             }
  3157.         }
  3158.         EDIT_TEXTDRAW_Update(user);
  3159.     }
  3160.     return 1;
  3161. }
  3162.  
  3163. EDIT_OBJECT_SetLocked(user, oid, locked)
  3164. {
  3165.     if(locked != g_Editor[g_ID[user]][oid][e_EDIT][e_Lock])
  3166.     {
  3167.         if(locked)
  3168.         {
  3169.             if(g_Editor[g_ID[user]][oid][e_EDIT][e_Use])
  3170.             {
  3171.                 EDIT_OBJECT_SetActive(user, UOE_INVALID_ID);
  3172.             }
  3173.         }
  3174.         g_Editor[g_ID[user]][oid][e_EDIT][e_Lock] = locked;
  3175.         EDIT_3DTEXTLABEL_Delete(user, oid);
  3176.         EDIT_3DTEXTLABEL_Create(user, oid);
  3177.     }
  3178.     return 1;
  3179. }
  3180.  
  3181. EDIT_DIALOG_Show(user, dialog)
  3182. {
  3183.     static
  3184.         string[1160];
  3185.     switch(dialog)
  3186.     {
  3187.         case 0:
  3188.         {
  3189.             strcat(string, "{436EEE}" "ON FOOT" "\n" "\n" "{EEE9E9}" "Alt+F" "\t" "\t" "Enable fly mode" "\n" "N" "\t" "\t" "Spawn an NRG-500" "\n" "\n" "{436EEE}" "FLY MODE" "\n" "\n" "{EEE9E9}" "Alt+F" "\t" "\t" "Disable fly mode" "\n" "Space+WSAD" "\t" "Move camera around" "\n" "Num6/Num4" "\t" "Next/previous object model" "\n" "LMB" "\t" "\t" "Select/deselect an object" "\n" "Enter/F" "\t" "\t" "Action specified in /econfig" "\n");
  3190.             strcat(string, "Alt+C" "\t" "\t" "Toggle between local and world modes" "\n" "C" "\t" "\t" "Toggle between position and rotation editing" "\n" "\n" "{436EEE}" "POSITION EDITING" "\n" "\n" "{EEE9E9}" "RMB (hold)" "\t" "Instant position change" "\n" "Alt+W/S" "\t" "\t" "Increase/decrease movement speed" "\n" "WSAD" "\t" "\t" "Move object forward, back, left and right" "\n" "Shift+W/S" "\t" "Move object up and down" "\n" "\n");
  3191.             strcat(string, "{436EEE}" "ROTATION EDITING" "\n" "\n" "{EEE9E9}" "RMB (hold)" "\t" "Instant rotation change" "\n" "Alt+W/S" "\t" "\t" "Increase/decrease rotation speed" "\n" "WSAD" "\t" "\t" "Rotate object on Y and X axes" "\n" "Shift+W/S" "\t" "Rotate object on Z axis");
  3192.             ShowPlayerDialog(user, 100, DIALOG_STYLE_MSGBOX, "{EEE9E9}" "Keyboard shortcuts (default GTA SA keys)", string, "Next", "Cancel");
  3193.         }
  3194.         case 1:
  3195.         {
  3196.             strcat(string, "{436EEE}" "EADD" "\t" "\t" "\t" "\t" "EDEL" "\n" "{EEE9E9}" "Params - (model) " "{FFC125}" "(comment)" "\t" "{EEE9E9}" "Params - " "{FFC125}" "(object OR /all)" "\n" "{EEE9E9}" "Action - create an object" "\t" "Action - delete an object" "\n" "\n" "{436EEE}" "ESEL" "\t" "\t" "\t" "\t" "ECONFIG" "\n" "{EEE9E9}" "Params - " "{FFC125}" "(object)" "\t" "\t" "{EEE9E9}" "Params - none" "\n" "Action - select an object");
  3197.             strcat(string, "\t" "\t" "Action - open the config dialog" "\n" "\n" "{436EEE}" "ECOPY" "\t" "\t" "\t" "\t" "EMODEL" "\n" "{EEE9E9}" "Params - " "{FFC125}" "(object) (comment)" "\t" "{EEE9E9}" "Params - " "{FFC125}" "(object) " "{EEE9E9}" "(model)" "\n" "Action - copy an object" "\t" "\t" "Action - set an object's model" "\n" "\n" "{436EEE}" "ESAVE" "\t" "\t" "\t" "\t" "ELOAD" "\n" "{EEE9E9}" "Params - (map OR /all) (name)");
  3198.             strcat(string, "\t" "Params - (map name)" "\n" "Action - save objects to a file" "\t" "Action - load objects from a file" "\n" "\n" "{436EEE}" "EUNLOAD" "\t" "\t" "\t" "EUNDO" "\n" "{EEE9E9}" "Params - " "{FFC125}" "(map OR map name)" "\t" "{EEE9E9}" "Params - " "{FFC125}" "(amount)" "\n" "{EEE9E9}" "Action - unload a map" "\t" "\t" "Action - undo previous action(s)" "\n" "\n" "{436EEE}" "EIMPORT" "\t" "\t" "\t" "EGOTO" "\n");
  3199.             strcat(string, "{EEE9E9}" "Params - (map name) " "{FFC125}" "(ext)" "\t" "{EEE9E9}" "Params - " "{FFC125}" "(object OR map name)" "\n" "{EEE9E9}" "Action - import a map file" "\t" "Action - teleport to an object" "\n" "\n" "{EEE9E9}" "Note: parameters in " "{FFC125}" "orange" "{EEE9E9}" " are optional. In case where object" "\n" "is optional, if no parameter is given, the action is done to the" "\n" "selected object.");
  3200.             ShowPlayerDialog(user, 101, DIALOG_STYLE_MSGBOX, "{EEE9E9}" "Commands", string, "Next", "Previous");
  3201.         }
  3202.         case 2:
  3203.         {
  3204.             strcat(string, "{436EEE}" "EPOS" "\t" "\t" "\t" "\t" "EROT" "\n" "{EEE9E9}" "Params - " "{FFC125}" "(object) (position x 3)" "\t" "{EEE9E9}" "Params - " "{FFC125}" "(object) (rotation x 3)" "\n" "{EEE9E9}" "Action - set an object's position" "\t" "Action - set an object's rotation" "\n" "\n" "{436EEE}" "ELOCK" "\t" "\t" "\t" "\t" "EUNLOCK" "\n" "{EEE9E9}" "Params - " "{FFC125}" "(object)" "\t" "\t" "{EEE9E9}" "Params - (object)");
  3205.             strcat(string, "\n" "Action - disallow object editing" "\t" "Action - allow object editing" "\n" "\n" "{436EEE}" "ESNAP" "\t" "\t" "\t" "\t" "EVEL" "\n" "{EEE9E9}" "Params - " "{FFC125}" "(value)" "\t" "\t" "{EEE9E9}" "Params - (velocity) " "\n" "{EEE9E9}" "Action - set snap spacing/angle" "\t" "Action - set velocity" "\n" "\n" "{436EEE}" "EATT" "\t" "\t" "\t" "\t" "EFLY" "\n" "{EEE9E9}" "Params - " "{FFC125}" "(road) " "{EEE9E9}");
  3206.             strcat(string, "(to road)" "\t" "\t" "{EEE9E9}" "Params - " "none" "\n" "Action - attach road to road" "\t" "Action - enable/disable fly mode" "\n" "\n" "{436EEE}" "EAXIS" "\t" "\t" "\t" "\t" "ENRG" "\n" "{EEE9E9}" "Params - " "{FFC125}" "(offset x 3)" "\t" "\t" "{EEE9E9}" "Params - " "none" "\n" "{EEE9E9}" "Action - enable/disable axis" "\t" "Action - spawn an NRG-500" "\n" "\n" "{436EEE}" "ELOOP" "\n" "{EEE9E9}" );
  3207.             strcat(string, "Params - (amount OR /del) " "{FFC125}" "(offset x 3) (rotation x 3) (sync rot)" "\n" "{EEE9E9}" "Action - generate a loop from the selected object" "\n" "\n" "{EEE9E9}" "Note: parameters in " "{FFC125}" "orange " "{EEE9E9}" "are optional. In case where object" "\n" "is optional, if no parameter is given, the action is done to the" "\n" "selected object.");
  3208.             ShowPlayerDialog(user, 102, DIALOG_STYLE_MSGBOX, "{EEE9E9}" "Commands", string, "Cancel", "Previous");
  3209.         }
  3210.         case 3:
  3211.         {
  3212.             for(new i = 9; i != -1; --i)
  3213.             {
  3214.                 if(EDIT_MAP_IsLoaded(user, i))
  3215.                 {
  3216.                     format(g_Str, 64, "\n%02d - %s", i, g_File[g_ID[user]][i]);
  3217.                     strins(string, g_Str, 0);
  3218.                 }
  3219.             }
  3220.             if(!string[0])
  3221.             {
  3222.                 return 0;
  3223.             }
  3224.             ShowPlayerDialog(user, 103, DIALOG_STYLE_LIST, "{EEE9E9}" "Unload map", string, "Unload", "Cancel");
  3225.         }
  3226.         case 4:
  3227.         {
  3228.             ShowPlayerDialog(user, 104, DIALOG_STYLE_MSGBOX, "{EEE9E9}" "Map recovery", "\nWould you like to restore your last project?", "Restore", "Cancel");
  3229.         }
  3230.         case 5:
  3231.         {
  3232.             format(g_Str, 64, "\nAutomatically select created objects:\t\t%s", g_Config[g_ID[user]][e_Select] != 1 ? ("{CD5C5C}" "Disabled") : ("{99FF66}" "Enabled"));
  3233.             strcat(string, g_Str);
  3234.             format(g_Str, 64, "\nSelect action for the ENTER key:\t\tAction: %d", g_Config[g_ID[user]][e_Key_Action] + 1);
  3235.             strcat(string, g_Str);
  3236.             strcat(string, "\nRemove clouds from the sky forever");
  3237.             ShowPlayerDialog(user, 105, DIALOG_STYLE_LIST, "{EEE9E9}" "Configuration", string, "Select", "Cancel");
  3238.         }
  3239.         case 6:
  3240.         {
  3241.             strcat(string, "1. Attach road to road (18788-18803)\n" "2. Teleport the selected object to your location\n" "3. Teleport to the selected object\n" "4. Destroy the selected object\n" "5. Undo last action\n");
  3242.             ShowPlayerDialog(user, 106, DIALOG_STYLE_LIST, "{EEE9E9}" "Key action", string, "Select", "Back");
  3243.         }
  3244.     }
  3245.     string[0] = 0;
  3246.     return 1;
  3247. }
  3248.  
  3249. EDIT_3DTEXTLABEL_Create(user, oid)
  3250. {
  3251.     if(g_Player[g_ID[user]][e_Mode][0] == 1)
  3252.     {
  3253.         if(g_Player[g_ID[user]][e_3D][oid] == PlayerText3D:UOE_INVALID_ID)
  3254.         {
  3255.             EDIT_OBJECT_GetPos(user, oid, g_Float1);
  3256.             if(g_Editor[g_ID[user]][oid][e_EDIT][e_Use])
  3257.             {
  3258.                 EDIT_OBJECT_GetRot(user, oid, g_Float2);
  3259.                 format(g_Str, 160, "{66FF66}" "Object ID: %d  Model ID: %d\nPosX: %.4f  PosY: %.4f  PosZ: %.4f\nRotX: %.4f  RotY: %.4f  RotZ: %.4f", oid, g_Editor[g_ID[user]][oid][e_EDIT][e_MID], g_Float1[0], g_Float1[1], g_Float1[2], g_Float2[0], g_Float2[1], g_Float2[2]);
  3260.             }
  3261.             else if(g_Editor[g_ID[user]][oid][e_LOOP][e_MA])
  3262.             {
  3263.                 format(g_Str, 96, "{66FF66}" "Object ID: %d  Model ID: %d\n" "{E6E6E6}" "Attached to:  %d", oid, g_Editor[g_ID[user]][oid][e_EDIT][e_MID], g_Editor[g_ID[user]][oid][e_LOOP][e_MA]);
  3264.             }
  3265.             else if(g_Editor[g_ID[user]][oid][e_ROAD][e_MA])
  3266.             {
  3267.                 format(g_Str, 96, "{66FF66}" "Object ID: %d  Model ID: %d\n" "{E6E6E6}" "Attached to:  %d", oid, g_Editor[g_ID[user]][oid][e_EDIT][e_MID], g_Editor[g_ID[user]][oid][e_ROAD][e_MA]);
  3268.             }
  3269.             else
  3270.             {
  3271.                 format(g_Str, 96, "{66FF66}" "Object ID: %d  Model ID: %d", oid, g_Editor[g_ID[user]][oid][e_EDIT][e_MID]);
  3272.             }
  3273.             if(g_Editor[g_ID[user]][oid][e_EDIT][e_Lock])
  3274.             {
  3275.                 strins(g_Str, "{993333}" "Locked\n", 0);
  3276.             }
  3277.             if(g_Editor[g_ID[user]][oid][e_EDIT][e_Lock] && g_Editor[g_ID[user]][oid][e_LOOP][e_MA])
  3278.             {
  3279.                 g_Player[g_ID[user]][e_3D][oid] = CreatePlayer3DTextLabel(user, g_Str, 0, g_Float1[0], g_Float1[1], g_Float1[2], 100.0, .testLOS = 0);
  3280.             }
  3281.             else
  3282.             {
  3283.                 g_Player[g_ID[user]][e_3D][oid] = CreatePlayer3DTextLabel(user, g_Str, 0, g_Float1[0], g_Float1[1], g_Float1[2], 250.0, .testLOS = 0);
  3284.             }
  3285.         }
  3286.     }
  3287.     return 1;
  3288. }
  3289.  
  3290. EDIT_3DTEXTLABEL_Update(user, oid)
  3291. {
  3292.     if(g_Player[g_ID[user]][e_3D][oid] != PlayerText3D:UOE_INVALID_ID)
  3293.     {
  3294.         if(g_Editor[g_ID[user]][oid][e_EDIT][e_Use])
  3295.         {
  3296.             EDIT_OBJECT_GetPos(user, oid, g_Float1);
  3297.             EDIT_OBJECT_GetRot(user, oid, g_Float2);
  3298.             format(g_Str, 160, "{66FF66}" "Object ID: %d  Model ID: %d\nPosX: %.4f  PosY: %.4f  PosZ: %.4f\nRotX: %.4f  RotY: %.4f  RotZ: %.4f", oid, g_Editor[g_ID[user]][oid][e_EDIT][e_MID], g_Float1[0], g_Float1[1], g_Float1[2], g_Float2[0], g_Float2[1], g_Float2[2]);
  3299.         }
  3300.         else if(g_Editor[g_ID[user]][oid][e_LOOP][e_MA])
  3301.         {
  3302.             format(g_Str, 96, "{66FF66}" "Object ID: %d  Model ID: %d\n" "{E6E6E6}" "Attached to:  %d", oid, g_Editor[g_ID[user]][oid][e_EDIT][e_MID], g_Editor[g_ID[user]][oid][e_LOOP][e_MA]);
  3303.         }
  3304.         else if(g_Editor[g_ID[user]][oid][e_ROAD][e_MA])
  3305.         {
  3306.             format(g_Str, 96, "{66FF66}" "Object ID: %d  Model ID: %d\n" "{E6E6E6}" "Attached to:  %d", oid, g_Editor[g_ID[user]][oid][e_EDIT][e_MID], g_Editor[g_ID[user]][oid][e_ROAD][e_MA]);
  3307.         }
  3308.         else
  3309.         {
  3310.             format(g_Str, 96, "{66FF66}" "Object ID: %d  Model ID: %d", oid, g_Editor[g_ID[user]][oid][e_EDIT][e_MID]);
  3311.         }
  3312.         if(g_Editor[g_ID[user]][oid][e_EDIT][e_Lock])
  3313.         {
  3314.             strins(g_Str, "{993333}" "Locked\n", 0);
  3315.         }
  3316.         UpdatePlayer3DTextLabelText(user, g_Player[g_ID[user]][e_3D][oid], 0, g_Str);
  3317.     }
  3318.     else
  3319.     {
  3320.         EDIT_3DTEXTLABEL_Create(user, oid);
  3321.     }
  3322.     return 1;
  3323. }
  3324.  
  3325. EDIT_3DTEXTLABEL_Delete(user, oid)
  3326. {
  3327.     DeletePlayer3DTextLabel(user, g_Player[g_ID[user]][e_3D][oid]);
  3328.     g_Player[g_ID[user]][e_3D][oid] = PlayerText3D:UOE_INVALID_ID;
  3329.     return 1;
  3330. }
  3331.  
  3332. EDIT_3DTEXTLABEL_SetVisible(user, visible)
  3333. {
  3334.     if(!visible)
  3335.     {
  3336.         for(new i = 1; i < MAX_OBJECTS; ++i)
  3337.         {
  3338.             if(EDIT_OBJECT_IsValid(user, i))
  3339.             {
  3340.                 EDIT_3DTEXTLABEL_Delete(user, i);
  3341.             }
  3342.         }
  3343.     }
  3344.     else
  3345.     {
  3346.         for(new i = 1; i < MAX_OBJECTS; ++i)
  3347.         {
  3348.             if(EDIT_OBJECT_IsValid(user, i))
  3349.             {
  3350.                 EDIT_3DTEXTLABEL_Create(user, i);
  3351.             }
  3352.         }
  3353.     }
  3354.     return 1;
  3355. }
  3356.  
  3357. EDIT_ACTION_Save(user, id, extra = 0)
  3358. {
  3359.     if(!extra)
  3360.     {
  3361.         new
  3362.             Float:float1[3],
  3363.             Float:float2[3];
  3364.         EDIT_OBJECT_GetPos(user, id, float1);
  3365.         EDIT_OBJECT_GetRot(user, id, float2);
  3366.         g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_P][0] = float1[0];
  3367.         g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_P][1] = float1[1];
  3368.         g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_P][2] = float1[2];
  3369.         g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_R][0] = float2[0];
  3370.         g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_R][1] = float2[1];
  3371.         g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_R][2] = float2[2];
  3372.         g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_UID] = g_Editor[g_ID[user]][id][e_EDIT][e_UID];
  3373.         g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_MID] = g_Editor[g_ID[user]][id][e_EDIT][e_MID];
  3374.         g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_Map] = g_Editor[g_ID[user]][id][e_EDIT][e_Map];
  3375.         g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_Use] = g_Editor[g_ID[user]][id][e_EDIT][e_Use];
  3376.         g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_Lock] = g_Editor[g_ID[user]][id][e_EDIT][e_Lock];
  3377.         g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_Info] = g_Editor[g_ID[user]][id][e_EDIT][e_Info];
  3378.         g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_ROAD][e_SL] = g_Editor[g_ID[user]][g_Editor[g_ID[user]][id][e_ROAD][e_SL]][e_EDIT][e_UID];
  3379.         g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_ROAD][e_MA] = g_Editor[g_ID[user]][g_Editor[g_ID[user]][id][e_ROAD][e_MA]][e_EDIT][e_UID];
  3380.         g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_LOOP][e_SL] = g_Editor[g_ID[user]][g_Editor[g_ID[user]][id][e_LOOP][e_SL]][e_EDIT][e_UID];
  3381.         g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_LOOP][e_MA] = g_Editor[g_ID[user]][g_Editor[g_ID[user]][id][e_LOOP][e_MA]][e_EDIT][e_UID];
  3382.         if(g_Editor[g_ID[user]][id][e_LOOP][e_SL])
  3383.         {
  3384.             new
  3385.                 loop_SL;
  3386.             loop_SL = EDIT_LOOP_GetLastSL(user, id);
  3387.             g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_Count] = EDIT_LOOP_GetSLCount(user, id);
  3388.             g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_LOOP][e_O][0] = g_Editor[g_ID[user]][id][e_LOOP][e_O][0];
  3389.             g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_LOOP][e_O][1] = g_Editor[g_ID[user]][id][e_LOOP][e_O][1];
  3390.             g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_LOOP][e_O][2] = g_Editor[g_ID[user]][id][e_LOOP][e_O][2];
  3391.             g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_LOOP][e_R][0] = g_Editor[g_ID[user]][id][e_LOOP][e_R][0];
  3392.             g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_LOOP][e_R][1] = g_Editor[g_ID[user]][id][e_LOOP][e_R][1];
  3393.             g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_LOOP][e_R][2] = g_Editor[g_ID[user]][id][e_LOOP][e_R][2];
  3394.             g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_LOOP][e_SR] = g_Editor[g_ID[user]][id][e_LOOP][e_SR];
  3395.             if(loop_SL)
  3396.             {
  3397.                 g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_Extra2] = g_Editor[g_ID[user]][loop_SL][e_EDIT][e_UID];
  3398.                 g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_Extra1] = g_Editor[g_ID[user]][g_Editor[g_ID[user]][loop_SL][e_ROAD][e_SL]][e_EDIT][e_UID];
  3399.             }
  3400.         }
  3401.     }
  3402.     else
  3403.     {
  3404.         if(extra == 1)
  3405.         {
  3406.             new
  3407.                 str[24];
  3408.             EDIT_MAP_GetName(user, id, str);
  3409.             g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_Extra1] = -1;
  3410.             g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_UID] = 1;
  3411.             g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_Map] = id;
  3412.             g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_Info] = str;
  3413.             format(g_Str, 64, "action-%d%03d", g_ID[user], g_Undo[g_ID[user]]);
  3414.             EDIT_MAP_Save(user, id, UOE_RECOVERY, g_Str, 1);
  3415.         }
  3416.         else
  3417.         {
  3418.             g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_Extra1] = -2;
  3419.             g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_UID] = 1;
  3420.             g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_Map] = id;
  3421.         }
  3422.     }
  3423.     EDIT_ACTION_ResetData(user, g_Undo[g_ID[user]], 1);
  3424.     return 1;
  3425. }
  3426.  
  3427. EDIT_ACTION_Undo(user)
  3428. {
  3429.     new
  3430.         action;
  3431.     if(!g_Undo[g_ID[user]])
  3432.     {
  3433.         action = UOE_MAX_ACTIONS - 1;
  3434.     }
  3435.     else
  3436.     {
  3437.         action = g_Undo[g_ID[user]] - 1 % UOE_MAX_ACTIONS;
  3438.     }
  3439.     if(g_Action[g_ID[user]][action][e_EDIT][e_UID])
  3440.     {
  3441.         if(g_Action[g_ID[user]][action][e_Extra1] < 0)
  3442.         {
  3443.             if(g_Action[g_ID[user]][action][e_Extra1] == -1)
  3444.             {
  3445.                 new
  3446.                     map;
  3447.                 map = g_Action[g_ID[user]][action][e_EDIT][e_Map];
  3448.                 format(g_Str, 64, "action-%d%03d", g_ID[user], action);
  3449.                 if(!EDIT_MAP_Load(user, map, UOE_RECOVERY, g_Str, 1))
  3450.                 {
  3451.                     EDIT_ACTION_ResetData(user, UOE_INVALID_ID);
  3452.                     return 0;
  3453.                 }
  3454.                 format(g_File[g_ID[user]][map], 32, "%s", g_Action[g_ID[user]][action][e_EDIT][e_Info]);
  3455.             }
  3456.             else
  3457.             {
  3458.                 if(!EDIT_MAP_Unload(user, g_Action[g_ID[user]][action][e_EDIT][e_Map]))
  3459.                 {
  3460.                     EDIT_ACTION_ResetData(user, UOE_INVALID_ID);
  3461.                     return 0;
  3462.                 }
  3463.             }
  3464.         }
  3465.         else
  3466.         {
  3467.             new
  3468.                 oID;
  3469.             oID = EDIT_OBJECT_GetID(user, g_Action[g_ID[user]][action][e_EDIT][e_UID]);
  3470.             if(oID == UOE_INVALID_ID || g_Action[g_ID[user]][action][e_EDIT][e_UID] == UOE_INVALID_ID)
  3471.             {
  3472.                 EDIT_ACTION_ResetData(user, action);
  3473.                 return 0;
  3474.             }
  3475.             if(g_Editor[g_ID[user]][oID][e_EDIT][e_MID] != g_Action[g_ID[user]][action][e_EDIT][e_MID] || !oID)
  3476.             {
  3477.                 if(oID)
  3478.                 {
  3479.                     EDIT_LOOP_Destroy(user, oID);
  3480.                     EDIT_OBJECT_Destroy(user, oID);
  3481.                     oID = 0;
  3482.                 }
  3483.                 if(g_Action[g_ID[user]][action][e_EDIT][e_MID])
  3484.                 {
  3485.                     oID = EDIT_OBJECT_Create(user, g_Action[g_ID[user]][action][e_EDIT][e_UID], g_Action[g_ID[user]][action][e_EDIT][e_MID], g_Action[g_ID[user]][action][e_P][0], g_Action[g_ID[user]][action][e_P][1], g_Action[g_ID[user]][action][e_P][2], g_Action[g_ID[user]][action][e_R][0], g_Action[g_ID[user]][action][e_R][1], g_Action[g_ID[user]][action][e_R][2]);
  3486.                     if(oID == UOE_INVALID_ID)
  3487.                     {
  3488.                         EDIT_ACTION_ResetData(user, UOE_INVALID_ID);
  3489.                         return 0;
  3490.                     }
  3491.                     EDIT_LOOP_SetSL(user, oID, EDIT_OBJECT_GetID(user, g_Action[g_ID[user]][action][e_LOOP][e_SL]));
  3492.                     g_Editor[g_ID[user]][oID][e_EDIT][e_MID] = g_Action[g_ID[user]][action][e_EDIT][e_MID];
  3493.                     g_Editor[g_ID[user]][oID][e_EDIT][e_Map] = g_Action[g_ID[user]][action][e_EDIT][e_Map];
  3494.                     g_Editor[g_ID[user]][oID][e_EDIT][e_Info] = g_Action[g_ID[user]][action][e_EDIT][e_Info];
  3495.                     EDIT_3DTEXTLABEL_Create(user, oID);
  3496.                 }
  3497.             }
  3498.             if(oID)
  3499.             {
  3500.                 new
  3501.                     Float:float1[3],
  3502.                     Float:float2[3];
  3503.                 EDIT_OBJECT_GetPos(user, oID, float1);
  3504.                 if(floatcmp(g_Action[g_ID[user]][action][e_P][0], float1[0])
  3505.                 || floatcmp(g_Action[g_ID[user]][action][e_P][1], float1[1])
  3506.                 || floatcmp(g_Action[g_ID[user]][action][e_P][2], float1[2]))
  3507.                 {
  3508.                     EDIT_OBJECT_SetPos(user, oID, g_Action[g_ID[user]][action][e_P][0], g_Action[g_ID[user]][action][e_P][1], g_Action[g_ID[user]][action][e_P][2]);
  3509.                 }
  3510.                 EDIT_OBJECT_GetRot(user, oID, float2);
  3511.                 if(floatcmp(g_Action[g_ID[user]][action][e_R][0], float2[0])
  3512.                 || floatcmp(g_Action[g_ID[user]][action][e_R][1], float2[1])
  3513.                 || floatcmp(g_Action[g_ID[user]][action][e_R][2], float2[2]))
  3514.                 {
  3515.                     EDIT_OBJECT_SetRot(user, oID, g_Action[g_ID[user]][action][e_R][0], g_Action[g_ID[user]][action][e_R][1], g_Action[g_ID[user]][action][e_R][2]);
  3516.                 }
  3517.                 if(g_Action[g_ID[user]][action][e_EDIT][e_Use])
  3518.                 {
  3519.                     if(!g_Action[g_ID[user]][action][e_EDIT][e_Lock])
  3520.                     {
  3521.                         EDIT_OBJECT_SetActive(user, oID);
  3522.                     }
  3523.                 }
  3524.                 EDIT_OBJECT_SetLocked(user, oID, g_Action[g_ID[user]][action][e_EDIT][e_Lock]);
  3525.                 EDIT_LOOP_SetMA(user, oID, EDIT_OBJECT_GetID(user, g_Action[g_ID[user]][action][e_LOOP][e_MA]));
  3526.                 if(floatcmp(g_Action[g_ID[user]][action][e_LOOP][e_O][0], g_Editor[g_ID[user]][oID][e_LOOP][e_O][0])
  3527.                 || floatcmp(g_Action[g_ID[user]][action][e_LOOP][e_O][1], g_Editor[g_ID[user]][oID][e_LOOP][e_O][1])
  3528.                 || floatcmp(g_Action[g_ID[user]][action][e_LOOP][e_O][2], g_Editor[g_ID[user]][oID][e_LOOP][e_O][2])
  3529.                 || floatcmp(g_Action[g_ID[user]][action][e_LOOP][e_R][0], g_Editor[g_ID[user]][oID][e_LOOP][e_R][0])
  3530.                 || floatcmp(g_Action[g_ID[user]][action][e_LOOP][e_R][1], g_Editor[g_ID[user]][oID][e_LOOP][e_R][1])
  3531.                 || floatcmp(g_Action[g_ID[user]][action][e_LOOP][e_R][2], g_Editor[g_ID[user]][oID][e_LOOP][e_R][2])
  3532.                 || g_Action[g_ID[user]][action][e_LOOP][e_SR] != g_Editor[g_ID[user]][oID][e_LOOP][e_SR]
  3533.                 || g_Action[g_ID[user]][action][e_Count] != EDIT_LOOP_GetSLCount(user, oID))
  3534.                 {
  3535.                     float1[0] = g_Action[g_ID[user]][action][e_LOOP][e_O][0];
  3536.                     float1[1] = g_Action[g_ID[user]][action][e_LOOP][e_O][1];
  3537.                     float1[2] = g_Action[g_ID[user]][action][e_LOOP][e_O][2];
  3538.                     float2[0] = g_Action[g_ID[user]][action][e_LOOP][e_R][0];
  3539.                     float2[1] = g_Action[g_ID[user]][action][e_LOOP][e_R][1];
  3540.                     float2[2] = g_Action[g_ID[user]][action][e_LOOP][e_R][2];
  3541.                     g_Editor[g_ID[user]][oID][e_LOOP][e_SR] = g_Action[g_ID[user]][action][e_LOOP][e_SR];
  3542.                     if(!EDIT_LOOP_Create(user, oID, g_Action[g_ID[user]][action][e_Count], float1, float2, g_Action[g_ID[user]][action][e_LOOP][e_SR]))
  3543.                     {
  3544.                         EDIT_ACTION_ResetData(user, UOE_INVALID_ID);
  3545.                         return 0;
  3546.                     }
  3547.                     if(g_Action[g_ID[user]][action][e_Count])
  3548.                     {
  3549.                         new
  3550.                             loop_SL;
  3551.                         loop_SL = EDIT_LOOP_GetLastSL(user, oID);
  3552.                         g_Editor[g_ID[user]][loop_SL][e_EDIT][e_UID] = g_Action[g_ID[user]][action][e_Extra2];
  3553.                         EDIT_ROAD_SetSL(user, loop_SL, EDIT_OBJECT_GetID(user, g_Action[g_ID[user]][action][e_Extra1]));
  3554.                     }
  3555.                 }
  3556.                 else
  3557.                 {
  3558.                     EDIT_LOOP_SetPos(user, oID);
  3559.                 }
  3560.                 if(g_Editor[g_ID[user]][oID][e_ROAD][e_IDX])
  3561.                 {
  3562.                     EDIT_ROAD_SetSL(user, oID, EDIT_OBJECT_GetID(user, g_Action[g_ID[user]][action][e_ROAD][e_SL]));
  3563.                     EDIT_ROAD_SetMA(user, oID, EDIT_OBJECT_GetID(user, g_Action[g_ID[user]][action][e_ROAD][e_MA]));
  3564.                     EDIT_ROAD_SetPos(user, oID);
  3565.                 }
  3566.             }
  3567.         }
  3568.         g_Undo[g_ID[user]] = action;
  3569.         EDIT_ACTION_ResetData(user, action);
  3570.         return 1;
  3571.     }
  3572.     return 0;
  3573. }
  3574.  
  3575. EDIT_ACTION_ResetSlot(user, uid)
  3576. {
  3577.     for(new i = 0; i < UOE_MAX_ACTIONS; ++i)
  3578.     {
  3579.         if(g_Action[g_ID[user]][i][e_EDIT][e_UID] == uid)
  3580.         {
  3581.             EDIT_ACTION_ResetData(user, i);
  3582.             g_Action[g_ID[user]][i][e_EDIT][e_UID] = UOE_INVALID_ID;
  3583.         }
  3584.     }
  3585.     return 1;
  3586. }
  3587.  
  3588.  
  3589. EDIT_ACTION_ResetData(user, action, extra = 0)
  3590. {
  3591.     if(action != UOE_INVALID_ID)
  3592.     {
  3593.         if(extra)
  3594.         {
  3595.             if(extra == 1)
  3596.             {
  3597.                 action = action + 1;
  3598.                 if(action == UOE_MAX_ACTIONS)
  3599.                 {
  3600.                     action = 0;
  3601.                 }
  3602.             }
  3603.             else
  3604.             {
  3605.                 action = action - 1;
  3606.                 if(action < 0)
  3607.                 {
  3608.                     action = UOE_MAX_ACTIONS - 1;
  3609.                 }
  3610.             }
  3611.             g_Undo[g_ID[user]] = action;
  3612.         }
  3613.         g_Action[g_ID[user]][action][e_Count] = 0;
  3614.         g_Action[g_ID[user]][action][e_Extra1] = 0;
  3615.         g_Action[g_ID[user]][action][e_Extra2] = 0;
  3616.         g_Action[g_ID[user]][action][e_ROAD][e_MA] = 0;
  3617.         g_Action[g_ID[user]][action][e_ROAD][e_SL] = 0;
  3618.         g_Action[g_ID[user]][action][e_LOOP][e_MA] = 0;
  3619.         g_Action[g_ID[user]][action][e_LOOP][e_SL] = 0;
  3620.         g_Action[g_ID[user]][action][e_LOOP][e_SR] = 0;
  3621.         g_Action[g_ID[user]][action][e_EDIT][e_UID] = 0;
  3622.         g_Action[g_ID[user]][action][e_EDIT][e_MID] = 0;
  3623.         g_Action[g_ID[user]][action][e_EDIT][e_Map] = 0;
  3624.         g_Action[g_ID[user]][action][e_EDIT][e_Use] = 0;
  3625.         g_Action[g_ID[user]][action][e_EDIT][e_Lock] = 0;
  3626.         g_Action[g_ID[user]][action][e_EDIT][e_Info] = 0;
  3627.     }
  3628.     else
  3629.     {
  3630.         for(new i = 0; i < UOE_MAX_ACTIONS; ++i)
  3631.         {
  3632.             g_Action[g_ID[user]][i][e_Count] = 0;
  3633.             g_Action[g_ID[user]][i][e_Extra1] = 0;
  3634.             g_Action[g_ID[user]][i][e_Extra2] = 0;
  3635.             g_Action[g_ID[user]][i][e_ROAD][e_MA] = 0;
  3636.             g_Action[g_ID[user]][i][e_ROAD][e_SL] = 0;
  3637.             g_Action[g_ID[user]][i][e_LOOP][e_MA] = 0;
  3638.             g_Action[g_ID[user]][i][e_LOOP][e_SL] = 0;
  3639.             g_Action[g_ID[user]][i][e_LOOP][e_SR] = 0;
  3640.             g_Action[g_ID[user]][i][e_EDIT][e_UID] = 0;
  3641.             g_Action[g_ID[user]][i][e_EDIT][e_MID] = 0;
  3642.             g_Action[g_ID[user]][i][e_EDIT][e_Map] = 0;
  3643.             g_Action[g_ID[user]][i][e_EDIT][e_Use] = 0;
  3644.             g_Action[g_ID[user]][i][e_EDIT][e_Lock] = 0;
  3645.             g_Action[g_ID[user]][i][e_EDIT][e_Info] = 0;
  3646.         }
  3647.         EDIT_MAP_EmptyRecovery(user);
  3648.         g_Undo[g_ID[user]] = 0;
  3649.     }
  3650.     return 1;
  3651. }
  3652.  
  3653. EDIT_LOOP_Create(user, oid, count, Float:off[3], Float:rot[3], sync_rot = -1)
  3654. {
  3655.     EDIT_LOOP_Destroy(user, oid);
  3656.     if(count > 0)
  3657.     {
  3658.         new
  3659.             oID,
  3660.             mID,
  3661.             map,
  3662.             Float:pos_x,
  3663.             Float:pos_y,
  3664.             Float:pos_z,
  3665.             Float:rot_x,
  3666.             Float:rot_y,
  3667.             Float:rot_z,
  3668.             Float:float1[3],
  3669.             Float:float2[3],
  3670.             Float:float3[3],
  3671.             Float:float4[3];
  3672.         if(off[0] == -1000.0)
  3673.         {
  3674.             off[0] = g_Editor[g_ID[user]][oid][e_LOOP][e_O][0];
  3675.         }
  3676.         if(off[1] == -1000.0)
  3677.         {
  3678.             off[1] = g_Editor[g_ID[user]][oid][e_LOOP][e_O][1];
  3679.         }
  3680.         if(off[2] == -1000.0)
  3681.         {
  3682.             off[2] = g_Editor[g_ID[user]][oid][e_LOOP][e_O][2];
  3683.         }
  3684.         if(rot[0] == -1000.0)
  3685.         {
  3686.             rot[0] = g_Editor[g_ID[user]][oid][e_LOOP][e_R][0];
  3687.         }
  3688.         if(rot[1] == -1000.0)
  3689.         {
  3690.             rot[1] = g_Editor[g_ID[user]][oid][e_LOOP][e_R][1];
  3691.         }
  3692.         if(rot[2] == -1000.0)
  3693.         {
  3694.             rot[2] = g_Editor[g_ID[user]][oid][e_LOOP][e_R][2];
  3695.         }
  3696.         if(sync_rot == -1)
  3697.         {
  3698.             sync_rot = g_Editor[g_ID[user]][oid][e_LOOP][e_SR];
  3699.         }
  3700.         EDIT_OBJECT_GetPos(user, oid, float1);
  3701.         EDIT_OBJECT_GetRot(user, oid, float2);
  3702.         EDIT_ModuloOperation(rot[0], rot[1], rot[2]);
  3703.         mID = g_Editor[g_ID[user]][oid][e_EDIT][e_MID];
  3704.         map = g_Editor[g_ID[user]][oid][e_EDIT][e_Map];
  3705.         if(!sync_rot)
  3706.         {
  3707.             pos_x = float1[0];
  3708.             pos_y = float1[1];
  3709.             pos_z = float1[2];
  3710.             rot_x = float2[0];
  3711.             rot_y = float2[1];
  3712.             rot_z = float2[2];
  3713.         }
  3714.         for(new i = 0; i < count; ++i)
  3715.         {
  3716.             EDIT_GetPosAndRot(off, rot, float1, float2);
  3717.             if(sync_rot)
  3718.             {
  3719.                 rot_x = float2[0];
  3720.                 rot_y = float2[1];
  3721.                 rot_z = float2[2];
  3722.             }
  3723.             else
  3724.             {
  3725.                 EDIT_OBJECT_GetPos(user, oid, float3);
  3726.                 EDIT_GetPosAndRot(off, rot, float3, float4);
  3727.             }
  3728.             oID = EDIT_OBJECT_Create(user, ++g_Unique, mID, float1[0], float1[1], float1[2], rot_x, rot_y, rot_z);
  3729.             if(oID != UOE_INVALID_ID)
  3730.             {
  3731.                 if(sync_rot)
  3732.                 {
  3733.                     g_Editor[g_ID[user]][oid][e_LOOP][e_O][0] = off[0];
  3734.                     g_Editor[g_ID[user]][oid][e_LOOP][e_O][1] = off[1];
  3735.                     g_Editor[g_ID[user]][oid][e_LOOP][e_O][2] = off[2];
  3736.                 }
  3737.                 else
  3738.                 {
  3739.                     g_Editor[g_ID[user]][oid][e_LOOP][e_O][0] = float3[0] - pos_x;
  3740.                     g_Editor[g_ID[user]][oid][e_LOOP][e_O][1] = float3[1] - pos_y;
  3741.                     g_Editor[g_ID[user]][oid][e_LOOP][e_O][2] = float3[2] - pos_z;
  3742.                     pos_x = float1[0];
  3743.                     pos_y = float1[1];
  3744.                     pos_z = float1[2];
  3745.                 }
  3746.                 g_Editor[g_ID[user]][oid][e_LOOP][e_SL] = oID;
  3747.                 g_Editor[g_ID[user]][oid][e_LOOP][e_R][0] = rot[0];
  3748.                 g_Editor[g_ID[user]][oid][e_LOOP][e_R][1] = rot[1];
  3749.                 g_Editor[g_ID[user]][oid][e_LOOP][e_R][2] = rot[2];
  3750.                 g_Editor[g_ID[user]][oID][e_EDIT][e_MID] = mID;
  3751.                 g_Editor[g_ID[user]][oID][e_EDIT][e_Map] = map;
  3752.                 g_Editor[g_ID[user]][oID][e_LOOP][e_MA] = oid;
  3753.                 g_Editor[g_ID[user]][oid][e_LOOP][e_SR] = sync_rot;
  3754.                 if(i < count - 1)
  3755.                 {
  3756.                     g_Editor[g_ID[user]][oID][e_EDIT][e_Lock] = 1;
  3757.                 }
  3758.                 EDIT_3DTEXTLABEL_Create(user, oID);
  3759.                 oid = oID;
  3760.             }
  3761.             else
  3762.             {
  3763.                 return 0;
  3764.             }
  3765.         }
  3766.     }
  3767.     return 1;
  3768. }
  3769.  
  3770. EDIT_LOOP_SetPos(user, oid)
  3771. {
  3772.     if(g_Editor[g_ID[user]][oid][e_LOOP][e_SL])
  3773.     {
  3774.         new
  3775.             sync_rot,
  3776.             Float:sync_rot_x,
  3777.             Float:sync_rot_y,
  3778.             Float:sync_rot_z,
  3779.             Float:float1[3],
  3780.             Float:float2[3],
  3781.             Float:float3[3],
  3782.             Float:float4[3];
  3783.         EDIT_OBJECT_GetPos(user, oid, float3);
  3784.         EDIT_OBJECT_GetRot(user, oid, float4);
  3785.         float1[0] = g_Editor[g_ID[user]][oid][e_LOOP][e_O][0];
  3786.         float1[1] = g_Editor[g_ID[user]][oid][e_LOOP][e_O][1];
  3787.         float1[2] = g_Editor[g_ID[user]][oid][e_LOOP][e_O][2];
  3788.         float2[0] = g_Editor[g_ID[user]][oid][e_LOOP][e_R][0];
  3789.         float2[1] = g_Editor[g_ID[user]][oid][e_LOOP][e_R][1];
  3790.         float2[2] = g_Editor[g_ID[user]][oid][e_LOOP][e_R][2];
  3791.         sync_rot = g_Editor[g_ID[user]][oid][e_LOOP][e_SR];
  3792.         if(!sync_rot)
  3793.         {
  3794.             sync_rot_x = float4[0];
  3795.             sync_rot_y = float4[1];
  3796.             sync_rot_z = float4[2];
  3797.         }
  3798.         while(g_Editor[g_ID[user]][oid][e_LOOP][e_SL])
  3799.         {
  3800.             oid = g_Editor[g_ID[user]][oid][e_LOOP][e_SL];
  3801.             EDIT_GetPosAndRot(float1, float2, float3, float4);
  3802.             if(sync_rot)
  3803.             {
  3804.                 sync_rot_x = float4[0];
  3805.                 sync_rot_y = float4[1];
  3806.                 sync_rot_z = float4[2];
  3807.             }
  3808.             EDIT_OBJECT_SetPos(user, oid, float3[0], float3[1], float3[2]);
  3809.             EDIT_OBJECT_SetRot(user, oid, sync_rot_x, sync_rot_y, sync_rot_z);
  3810.             EDIT_ROAD_SetPos(user, oid);
  3811.         }
  3812.     }
  3813.     return 1;
  3814. }
  3815.  
  3816. EDIT_LOOP_GetSLCount(user, oid)
  3817. {
  3818.     new
  3819.         count;
  3820.     if(g_Editor[g_ID[user]][oid][e_LOOP][e_SL])
  3821.     {
  3822.         while(g_Editor[g_ID[user]][oid][e_LOOP][e_SL])
  3823.         {
  3824.             count = count + 1;
  3825.             oid = g_Editor[g_ID[user]][oid][e_LOOP][e_SL];
  3826.         }
  3827.     }
  3828.     return count;
  3829. }
  3830.  
  3831. EDIT_LOOP_Destroy(user, oid)
  3832. {
  3833.     if(g_Editor[g_ID[user]][oid][e_LOOP][e_SL])
  3834.     {
  3835.         new
  3836.             loop_SL;
  3837.         loop_SL = g_Editor[g_ID[user]][oid][e_LOOP][e_SL];
  3838.         g_Editor[g_ID[user]][oid][e_LOOP][e_SL] = 0;
  3839.         while(loop_SL)
  3840.         {
  3841.             oid = loop_SL;
  3842.             loop_SL = g_Editor[g_ID[user]][oid][e_LOOP][e_SL];
  3843.             EDIT_OBJECT_Destroy(user, oid);
  3844.         }
  3845.     }
  3846.     return 1;
  3847. }
  3848.  
  3849. EDIT_LOOP_SetMA(user, oid, master)
  3850. {
  3851.     if(g_Editor[g_ID[user]][oid][e_LOOP][e_MA] != master)
  3852.     {
  3853.         if(!master || master == UOE_INVALID_ID)
  3854.         {
  3855.             if(g_Editor[g_ID[user]][oid][e_LOOP][e_MA] > 0)
  3856.             {
  3857.                 master = g_Editor[g_ID[user]][oid][e_LOOP][e_MA];
  3858.                 g_Editor[g_ID[user]][master][e_LOOP][e_SL] = 0;
  3859.                 g_Editor[g_ID[user]][oid][e_LOOP][e_MA] = 0;
  3860.             }
  3861.         }
  3862.         else
  3863.         {
  3864.             if(g_Editor[g_ID[user]][oid][e_LOOP][e_MA])
  3865.             {
  3866.                 g_Editor[g_ID[user]][g_Editor[g_ID[user]][oid][e_LOOP][e_MA]][e_LOOP][e_SL] = 0;
  3867.             }
  3868.             if(g_Editor[g_ID[user]][master][e_LOOP][e_SL] != oid)
  3869.             {
  3870.                 if(g_Editor[g_ID[user]][master][e_LOOP][e_SL])
  3871.                 {
  3872.                     g_Editor[g_ID[user]][g_Editor[g_ID[user]][master][e_LOOP][e_SL]][e_LOOP][e_MA] = 0;
  3873.                 }
  3874.                 g_Editor[g_ID[user]][master][e_LOOP][e_SL] = oid;
  3875.             }
  3876.             g_Editor[g_ID[user]][oid][e_LOOP][e_MA] = master;
  3877.         }
  3878.         EDIT_3DTEXTLABEL_Delete(user, oid);
  3879.         EDIT_3DTEXTLABEL_Create(user, oid);
  3880.     }
  3881.     return 1;
  3882. }
  3883.  
  3884. EDIT_LOOP_SetSL(user, oid, slave)
  3885. {
  3886.     if(g_Editor[g_ID[user]][oid][e_LOOP][e_SL] != slave)
  3887.     {
  3888.         if(!slave || slave == UOE_INVALID_ID)
  3889.         {
  3890.             if(g_Editor[g_ID[user]][oid][e_LOOP][e_SL] > 0)
  3891.             {
  3892.                 g_Editor[g_ID[user]][g_Editor[g_ID[user]][oid][e_LOOP][e_SL]][e_LOOP][e_MA] = 0;
  3893.                 EDIT_3DTEXTLABEL_Update(user, g_Editor[g_ID[user]][oid][e_LOOP][e_SL]);
  3894.             }
  3895.             g_Editor[g_ID[user]][oid][e_LOOP][e_SL] = 0;
  3896.         }
  3897.         else
  3898.         {
  3899.             if(g_Editor[g_ID[user]][oid][e_LOOP][e_SL])
  3900.             {
  3901.                 g_Editor[g_ID[user]][g_Editor[g_ID[user]][oid][e_LOOP][e_SL]][e_LOOP][e_MA] = 0;
  3902.             }
  3903.             if(g_Editor[g_ID[user]][slave][e_LOOP][e_MA] != oid)
  3904.             {
  3905.                 if(g_Editor[g_ID[user]][slave][e_LOOP][e_MA])
  3906.                 {
  3907.                     g_Editor[g_ID[user]][g_Editor[g_ID[user]][slave][e_LOOP][e_MA]][e_LOOP][e_SL] = 0;
  3908.                 }
  3909.                 g_Editor[g_ID[user]][slave][e_LOOP][e_MA] = oid;
  3910.                 EDIT_3DTEXTLABEL_Delete(user, slave);
  3911.                 EDIT_3DTEXTLABEL_Create(user, slave);
  3912.             }
  3913.             g_Editor[g_ID[user]][oid][e_LOOP][e_SL] = slave;
  3914.         }
  3915.     }
  3916.     return 1;
  3917. }
  3918.  
  3919. EDIT_LOOP_GetLastSL(user, oid)
  3920. {
  3921.     if(g_Editor[g_ID[user]][oid][e_LOOP][e_SL])
  3922.     {
  3923.         while(g_Editor[g_ID[user]][oid][e_LOOP][e_SL])
  3924.         {
  3925.             oid = g_Editor[g_ID[user]][oid][e_LOOP][e_SL];
  3926.         }
  3927.         return oid;
  3928.     }
  3929.     return 0;
  3930. }
  3931.  
  3932. EDIT_ROAD_ScanSL(user, road, other)
  3933. {
  3934.     new
  3935.         loop_SL,
  3936.         road_SL;
  3937.     if(g_Editor[g_ID[user]][road][e_LOOP][e_SL])
  3938.     {
  3939.         loop_SL = road;
  3940.         while(g_Editor[g_ID[user]][loop_SL][e_LOOP][e_SL])
  3941.         {
  3942.             loop_SL = g_Editor[g_ID[user]][loop_SL][e_LOOP][e_SL];
  3943.             road_SL = g_Editor[g_ID[user]][loop_SL][e_ROAD][e_SL];
  3944.             if(road_SL)
  3945.             {
  3946.                 if(EDIT_ROAD_ScanSL(user, road_SL, other))
  3947.                 {
  3948.                     return 1;
  3949.                 }
  3950.             }
  3951.             if(loop_SL == other)
  3952.             {
  3953.                 return 1;
  3954.             }
  3955.         }
  3956.     }
  3957.     if(g_Editor[g_ID[user]][road][e_ROAD][e_SL])
  3958.     {
  3959.         road_SL = road;
  3960.         while(g_Editor[g_ID[user]][road_SL][e_ROAD][e_SL])
  3961.         {
  3962.             road_SL = g_Editor[g_ID[user]][road_SL][e_ROAD][e_SL];
  3963.             loop_SL = g_Editor[g_ID[user]][road_SL][e_LOOP][e_SL];
  3964.             if(loop_SL)
  3965.             {
  3966.                 if(EDIT_ROAD_ScanSL(user, loop_SL, other))
  3967.                 {
  3968.                     return 1;
  3969.                 }
  3970.             }
  3971.             if(road_SL == other)
  3972.             {
  3973.                 return 1;
  3974.             }
  3975.         }
  3976.     }
  3977.     return 0;
  3978. }
  3979.  
  3980. EDIT_ROAD_AttachFirst(user, oid1, oid2)
  3981. {
  3982.     EDIT_ROAD_Attach(user, oid1, oid2);
  3983.     EDIT_ROAD_SetPos(user, oid1);
  3984.     PlayerPlaySound(user, 1150, 0.0, 0.0, 0.0);
  3985.     GameTextForPlayer(user, "~n~~n~~n~~n~~n~~n~~n~~n~~g~attached!""Error: Unable to create the object required in fly mode.");
  3986.             }
  3987.         }
  3988.         else
  3989.         {
  3990.             SetObjectPos(g_Player[g_ID[user]][e_Fly], pos_x, pos_y, pos_z);
  3991.         }
  3992.         if(!g_Player[g_ID[user]][e_Timer])
  3993.         {
  3994.             g_Player[g_ID[user]][e_Timer] = SetTimerEx("EDIT_Update", UOE_TIMER_INT, 1, "ii", user, g_ID[user]);
  3995.         }
  3996.         g_Player[g_ID[user]][e_Mode][0] = 1;
  3997.         EDIT_3DTEXTLABEL_SetVisible(user, 1);
  3998.         EDIT_TEXTDRAW_Show(user);
  3999.         TogglePlayerSpectating(user, 1);
  4000.         AttachCameraToObject(user, g_Player[g_ID[user]][e_Fly]);
  4001.     }
  4002.     else
  4003.     {
  4004.         new
  4005.             Float:cam_x,
  4006.             Float:cam_y,
  4007.             Float:cam_z;
  4008.         g_Player[g_ID[user]][e_Mode][0] = 2;
  4009.         EDIT_3DTEXTLABEL_SetVisible(user, 0);
  4010.         EDIT_TEXTDRAW_Hide(user);
  4011.         EDIT_OBJECT_SetActive(user, UOE_INVALID_ID);
  4012.         GetPlayerCameraFrontVector(user, cam_x, cam_y, cam_z);
  4013.         GetPlayerCameraPos(user, g_Player[g_ID[user]][e_Spawn][0], g_Player[g_ID[user]][e_Spawn][1], g_Player[g_ID[user]][e_Spawn][2]);
  4014.         g_Player[g_ID[user]][e_Spawn][3] = atan2(cam_y, cam_x) + 270.0;
  4015.         TogglePlayerSpectating(user, 0);
  4016.         if(g_Player[g_ID[user]][e_Active])
  4017.         {
  4018.             g_Player[g_ID[user]][e_Active] = 0;
  4019.             CancelEdit(user);
  4020.         }
  4021.         if(g_Player[g_ID[user]][e_Timer])
  4022.         {
  4023.             KillTimer(g_Player[g_ID[user]][e_Timer]);
  4024.             g_Player[g_ID[user]][e_Timer] = 0;
  4025.         }
  4026.     }
  4027.     return 1;
  4028. }
  4029.  
  4030. EDIT_TEXTDRAW_Create(user)
  4031. {
  4032.     g_Player[g_ID[user]][e_Text] = CreatePlayerTextDraw(user, 3.0, 432.0, "_");
  4033.     PlayerTextDrawBackgroundColor(user, g_Player[g_ID[user]][e_Text], 255);
  4034.     PlayerTextDrawFont(user, g_Player[g_ID[user]][e_Text], 2);
  4035.     PlayerTextDrawColor(user, g_Player[g_ID[user]][e_Text], -1);
  4036.     PlayerTextDrawLetterSize(user, g_Player[g_ID[user]][e_Text], 0.36, 1.5);
  4037.     PlayerTextDrawSetProportional(user, g_Player[g_ID[user]][e_Text], 1);
  4038.     PlayerTextDrawAlignment(user, g_Player[g_ID[user]][e_Text], 0);
  4039.     PlayerTextDrawSetShadow(user, g_Player[g_ID[user]][e_Text], 0);
  4040.     PlayerTextDrawUseBox(user, g_Player[g_ID[user]][e_Text], 1);
  4041.     PlayerTextDrawBoxColor(user, g_Player[g_ID[user]][e_Text], 136);
  4042.     PlayerTextDrawTextSize(user, g_Player[g_ID[user]][e_Text], 640.0, 0.0);
  4043.     EDIT_TEXTDRAW_Update(user);
  4044.     return 1;
  4045. }
  4046.  
  4047. EDIT_TEXTDRAW_Destroy(user)
  4048. {
  4049.     PlayerTextDrawDestroy(user, g_Player[user][e_Text]);
  4050.     return 1;
  4051. }
  4052.  
  4053. EDIT_TEXTDRAW_Show(user)
  4054. {
  4055.     PlayerTextDrawShow(user, g_Player[g_ID[user]][e_Text]);
  4056.     return 1;
  4057. }
  4058.  
  4059. EDIT_TEXTDRAW_Hide(user)
  4060. {
  4061.     PlayerTextDrawHide(user, g_Player[g_ID[user]][e_Text]);
  4062.     return 1;
  4063. }
  4064.  
  4065. EDIT_TEXTDRAW_Update(user)
  4066. {
  4067.     new
  4068.         str[128];
  4069.     if(g_Player[g_ID[user]][e_OID] != UOE_INVALID_ID)
  4070.     {
  4071.         format(g_Str, 128, "   ~b~object: ~g~%03d", g_Player[g_ID[user]][e_OID]);
  4072.         strcat(str, g_Str);
  4073.     }
  4074.     else
  4075.     {
  4076.         strcat(str, "   ~b~object: ~w~none");
  4077.     }
  4078.     if(!g_Player[g_ID[user]][e_Mode][1])
  4079.     {
  4080.         format(g_Str, 128, "   ~b~editing: ~w~pos   ~b~speed: ~w~%.3f meters/s", g_Player[g_ID[user]][e_Speed][1] * 1000 / UOE_TIMER_INT * 1.000001);
  4081.         strcat(str, g_Str);
  4082.     }
  4083.     else
  4084.     {
  4085.         format(g_Str, 128, "   ~b~editing: ~w~rot   ~b~speed: ~w~%.3f degrees/s", g_Player[g_ID[user]][e_Speed][1] * 1000 / UOE_TIMER_INT * 1.000001);
  4086.         strcat(str, g_Str);
  4087.     }
  4088.     if(!g_Player[g_ID[user]][e_Mode][2])
  4089.     {
  4090.         strcat(str, "   ~b~mode: ~w~local");
  4091.     }
  4092.     else
  4093.     {
  4094.         if(g_Player[g_ID[user]][e_Mode][2] == 1)
  4095.         {
  4096.             strcat(str, "   ~b~mode: ~w~world");
  4097.         }
  4098.         else
  4099.         {
  4100.             format(g_Str, 128, "   ~b~mode: ~w~world snap ~g~(%d)", g_Player[g_ID[user]][e_Snap]);
  4101.             strcat(str, g_Str);
  4102.         }
  4103.     }
  4104.     PlayerTextDrawSetString(user, g_Player[g_ID[user]][e_Text], str);
  4105.     return 1;
  4106. }
  4107.  
  4108. EDIT_GetName(user)
  4109. {
  4110.     new
  4111.         name[24];
  4112.     GetPlayerName(user, name, 24);
  4113.     return name;
  4114. }
  4115.  
  4116. EDIT_MAP_AutoSave(user)
  4117. {
  4118.     if(EDIT_MAP_GetObjectCount(user, UOE_INVALID_ID, 1))
  4119.     {
  4120.         format(g_Str, 64, "autosave-%s", EDIT_GetName(user));
  4121.         EDIT_MAP_Save(user, UOE_INVALID_ID, UOE_RECOVERY, g_Str, 1);
  4122.     }
  4123.     return 1;
  4124. }
  4125.  
  4126. EDIT_MAP_RecoveryManager(user)
  4127. {
  4128.     format(g_Str, 64, "autosave-%s", EDIT_GetName(user));
  4129.     if(EDIT_MAP_Exist(UOE_RECOVERY, g_Str, "uoe"))
  4130.     {
  4131.         EDIT_DIALOG_Show(user, 4);
  4132.     }
  4133.     return 1;
  4134. }
  4135.  
  4136. EDIT_MAP_EmptyRecovery(user, extra = 0)
  4137. {
  4138.     if(!extra)
  4139.     {
  4140.         for(new i = 0; i < UOE_MAX_ACTIONS; ++i)
  4141.         {
  4142.             format(g_Str, 64, "%s" "action-%d%03d.uoe", UOE_RECOVERY, g_ID[user], i);
  4143.             if(fexist(g_Str))
  4144.             {
  4145.                 fremove(g_Str);
  4146.             }
  4147.         }
  4148.     }
  4149.     else
  4150.     {
  4151.         format(g_Str, 64, "%s" "autosave-%s.uoe", UOE_RECOVERY, EDIT_GetName(user));
  4152.         if(fexist(g_Str))
  4153.         {
  4154.             fremove(g_Str);
  4155.         }
  4156.     }
  4157.     return 1;
  4158. }
  4159.  
  4160. EDIT_MAP_Import(user, map, path[], name[], ext[])
  4161. {
  4162.     new
  4163.         str[64],
  4164.         File:file;
  4165.     format(str, 64, "%s" "%s.%s", path, name, ext);
  4166.     file = fopen(str, io_read);
  4167.     if(file)
  4168.     {
  4169.         new
  4170.             oID,
  4171.             mID,
  4172.             load,
  4173.             Float:pos_x,
  4174.             Float:pos_y,
  4175.             Float:pos_z,
  4176.             Float:rot_x,
  4177.             Float:rot_y,
  4178.             Float:rot_z;
  4179.         while(fread(file, g_Str))
  4180.         {
  4181.             if(!sscanf(g_Str, "'Object('P<(),>iffffff", mID, pos_x, pos_y, pos_z, rot_x, rot_y, rot_z))
  4182.             {
  4183.                 oID = EDIT_OBJECT_Create(user, ++g_Unique, mID, pos_x, pos_y, pos_z, rot_x, rot_y, rot_z);
  4184.                 if(oID != UOE_INVALID_ID)
  4185.                 {
  4186.                     load = load + 1;
  4187.                     g_Editor[g_ID[user]][oID][e_EDIT][e_MID] = mID;
  4188.                     g_Editor[g_ID[user]][oID][e_EDIT][e_Map] = map;
  4189.                     EDIT_3DTEXTLABEL_Create(user, oID);
  4190.                 }
  4191.                 else
  4192.                 {
  4193.                     fclose(file);
  4194.                     return 0;
  4195.                 }
  4196.             }
  4197.         }
  4198.         fclose(file);
  4199.         return load;
  4200.     }
  4201.     return 0;
  4202. }
  4203.  
  4204. EDIT_MAP_Save(user, map, path[], name[], extra = 0)
  4205. {
  4206.     if(fexist(path))
  4207.     {
  4208.         new
  4209.             str[64],
  4210.             File:file;
  4211.         format(str, 64, "%s" "%s.uoe", path, name);
  4212.         file = fopen(str, io_write);
  4213.         if(file)
  4214.         {
  4215.             new
  4216.                 Float:float1[3],
  4217.                 Float:float2[3];
  4218.             for(new i = 1; i < MAX_OBJECTS; ++i)
  4219.             {
  4220.                 if(g_Editor[g_ID[user]][i][e_EDIT][e_MID])
  4221.                 {
  4222.                     if(map == UOE_INVALID_ID || g_Editor[g_ID[user]][i][e_EDIT][e_Map] == map)
  4223.                     {
  4224.                         EDIT_OBJECT_GetPos(user, i, float1);
  4225.                         EDIT_OBJECT_GetRot(user, i, float2);
  4226.                         format(g_Str, 224, "%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%s\r\n",
  4227.                         g_Editor[g_ID[user]][i][e_EDIT][e_MID],
  4228.                         g_Editor[g_ID[user]][i][e_EDIT][e_UID],
  4229.                         float1[0], float1[1], float1[2],
  4230.                         float2[0], float2[1], float2[2],
  4231.                         g_Editor[g_ID[user]][i][e_LOOP][e_O][0],
  4232.                         g_Editor[g_ID[user]][i][e_LOOP][e_O][1],
  4233.                         g_Editor[g_ID[user]][i][e_LOOP][e_O][2],
  4234.                         g_Editor[g_ID[user]][i][e_LOOP][e_R][0],
  4235.                         g_Editor[g_ID[user]][i][e_LOOP][e_R][1],
  4236.                         g_Editor[g_ID[user]][i][e_LOOP][e_R][2],
  4237.                         g_Editor[g_ID[user]][i][e_LOOP][e_SR],
  4238.                         g_Editor[g_ID[user]][g_Editor[g_ID[user]][i][e_ROAD][e_MA]][e_EDIT][e_UID],
  4239.                         g_Editor[g_ID[user]][g_Editor[g_ID[user]][i][e_ROAD][e_SL]][e_EDIT][e_UID],
  4240.                         g_Editor[g_ID[user]][g_Editor[g_ID[user]][i][e_LOOP][e_MA]][e_EDIT][e_UID],
  4241.                         g_Editor[g_ID[user]][g_Editor[g_ID[user]][i][e_LOOP][e_SL]][e_EDIT][e_UID],
  4242.                         g_Editor[g_ID[user]][i][e_EDIT][e_Lock], g_Editor[g_ID[user]][i][e_EDIT][e_Info]);
  4243.                         fwrite(file, g_Str);
  4244.                     }
  4245.                 }
  4246.             }
  4247.             fclose(file);
  4248.         }
  4249.     }
  4250.     else
  4251.     {
  4252.         return 0;
  4253.     }
  4254.     if(!extra)
  4255.     {
  4256.         new
  4257.             str[64],
  4258.             File:file;
  4259.         format(str, 64, UOE_SAVES "%s.txt", name);
  4260.         file = fopen(str, io_write);
  4261.         if(file)
  4262.         {
  4263.             new
  4264.                 count,
  4265.                 Float:float1[3],
  4266.                 Float:float2[3];
  4267.             for(new i = 1; i < MAX_OBJECTS; ++i)
  4268.             {
  4269.                 if(g_Editor[g_ID[user]][i][e_EDIT][e_MID])
  4270.                 {
  4271.                     if(map == UOE_INVALID_ID || g_Editor[g_ID[user]][i][e_EDIT][e_Map] == map)
  4272.                     {
  4273.                         str[0] = 0;
  4274.                         count = count + 1;
  4275.                         EDIT_OBJECT_GetPos(user, i, float1);
  4276.                         EDIT_OBJECT_GetRot(user, i, float2);
  4277.                         if(g_Editor[g_ID[user]][i][e_EDIT][e_Info][0])
  4278.                         {
  4279.                             format(str, 64, " // %s", g_Editor[g_ID[user]][i][e_EDIT][e_Info]);
  4280.                         }
  4281.                         format(g_Str, 224, "CreateObject(%d, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f);%s\r\n", g_Editor[g_ID[user]][i][e_EDIT][e_MID], float1[0], float1[1], float1[2], float2[0], float2[1], float2[2], str);
  4282.                         fwrite(file, g_Str);
  4283.                     }
  4284.                 }
  4285.             }
  4286.             fclose(file);
  4287.             return count;
  4288.         }
  4289.         else
  4290.         {
  4291.             return 0;
  4292.         }
  4293.     }
  4294.     return 1;
  4295. }
  4296.  
  4297. EDIT_MAP_Load(user, map, path[], name[], extra = 0)
  4298. {
  4299.     new
  4300.         oID,
  4301.         get[20],
  4302.         str[64],
  4303.         File:file;
  4304.     format(str, 64, "%s" "%s.uoe", path, name);
  4305.     file = fopen(str, io_read);
  4306.     if(file)
  4307.     {
  4308.         if(!extra)
  4309.         {
  4310.             while(fread(file, g_Str))
  4311.             {
  4312.                 if(sscanf(g_Str, "p<|>a<x>[20]S()[32]", get, str))
  4313.                 {
  4314.                     fclose(file);
  4315.                     return 0;
  4316.                 }
  4317.                 oID = EDIT_OBJECT_Create(user, -get[1], get[0], Float:get[2], Float:get[3], Float:get[4], Float:get[5], Float:get[6], Float:get[7]);
  4318.                 if(oID != UOE_INVALID_ID)
  4319.                 {
  4320.                     g_Editor[g_ID[user]][oID][e_EDIT][e_Map] = map;
  4321.                     g_Editor[g_ID[user]][oID][e_EDIT][e_MID] = get[0];
  4322.                     g_Editor[g_ID[user]][oID][e_LOOP][e_O][0] = Float:get[8];
  4323.                     g_Editor[g_ID[user]][oID][e_LOOP][e_O][1] = Float:get[9];
  4324.                     g_Editor[g_ID[user]][oID][e_LOOP][e_O][2] = Float:get[10];
  4325.                     g_Editor[g_ID[user]][oID][e_LOOP][e_R][0] = Float:get[11];
  4326.                     g_Editor[g_ID[user]][oID][e_LOOP][e_R][1] = Float:get[12];
  4327.                     g_Editor[g_ID[user]][oID][e_LOOP][e_R][2] = Float:get[13];
  4328.                     g_Editor[g_ID[user]][oID][e_LOOP][e_SR] = get[14];
  4329.                     g_Editor[g_ID[user]][oID][e_ROAD][e_MA] = -get[15];
  4330.                     g_Editor[g_ID[user]][oID][e_ROAD][e_SL] = -get[16];
  4331.                     g_Editor[g_ID[user]][oID][e_LOOP][e_MA] = -get[17];
  4332.                     g_Editor[g_ID[user]][oID][e_LOOP][e_SL] = -get[18];
  4333.                     g_Editor[g_ID[user]][oID][e_EDIT][e_Lock] = get[19];
  4334.                     format(g_Editor[g_ID[user]][oID][e_EDIT][e_Info], 32, "%.*s", strlen(str) - 2, str);
  4335.                 }
  4336.                 else
  4337.                 {
  4338.                     fclose(file);
  4339.                     return 0;
  4340.                 }
  4341.             }
  4342.             fclose(file);
  4343.             for(new i = 1; i < MAX_OBJECTS; ++i)
  4344.             {
  4345.                 if(g_Editor[g_ID[user]][i][e_EDIT][e_MID])
  4346.                 {
  4347.                     if(g_Editor[g_ID[user]][i][e_EDIT][e_Map] == map)
  4348.                     {
  4349.                         g_Editor[g_ID[user]][i][e_ROAD][e_MA] = EDIT_OBJECT_GetID(user, g_Editor[g_ID[user]][i][e_ROAD][e_MA]);
  4350.                         g_Editor[g_ID[user]][i][e_ROAD][e_SL] = EDIT_OBJECT_GetID(user, g_Editor[g_ID[user]][i][e_ROAD][e_SL]);
  4351.                         g_Editor[g_ID[user]][i][e_LOOP][e_MA] = EDIT_OBJECT_GetID(user, g_Editor[g_ID[user]][i][e_LOOP][e_MA]);
  4352.                         g_Editor[g_ID[user]][i][e_LOOP][e_SL] = EDIT_OBJECT_GetID(user, g_Editor[g_ID[user]][i][e_LOOP][e_SL]);
  4353.                         EDIT_3DTEXTLABEL_Create(user, i);
  4354.                     }
  4355.                 }
  4356.             }
  4357.             new
  4358.                 count;
  4359.             for(new i = 1; i < MAX_OBJECTS; ++i)
  4360.             {
  4361.                 if(g_Editor[g_ID[user]][i][e_EDIT][e_MID])
  4362.                 {
  4363.                     if(g_Editor[g_ID[user]][i][e_EDIT][e_Map] == map)
  4364.                     {
  4365.                         count = count + 1;
  4366.                         g_Editor[g_ID[user]][i][e_EDIT][e_UID] = ++g_Unique;
  4367.                     }
  4368.                 }
  4369.             }
  4370.             if(count)
  4371.             {
  4372.                 format(g_File[g_ID[user]][map], 32, "%s", name);
  4373.             }
  4374.             return count;
  4375.         }
  4376.         else
  4377.         {
  4378.             while(fread(file, g_Str))
  4379.             {
  4380.                 if(sscanf(g_Str, "p<|>a<x>[20]S()[32]", get, str))
  4381.                 {
  4382.                     fclose(file);
  4383.                     return 0;
  4384.                 }
  4385.                 oID = EDIT_OBJECT_Create(user, get[1], get[0], Float:get[2], Float:get[3], Float:get[4], Float:get[5], Float:get[6], Float:get[7]);
  4386.                 if(oID != UOE_INVALID_ID)
  4387.                 {
  4388.                     g_Editor[g_ID[user]][oID][e_EDIT][e_Map] = map;
  4389.                     g_Editor[g_ID[user]][oID][e_EDIT][e_MID] = get[0];
  4390.                     g_Editor[g_ID[user]][oID][e_LOOP][e_O][0] = Float:get[8];
  4391.                     g_Editor[g_ID[user]][oID][e_LOOP][e_O][1] = Float:get[9];
  4392.                     g_Editor[g_ID[user]][oID][e_LOOP][e_O][2] = Float:get[10];
  4393.                     g_Editor[g_ID[user]][oID][e_LOOP][e_R][0] = Float:get[11];
  4394.                     g_Editor[g_ID[user]][oID][e_LOOP][e_R][1] = Float:get[12];
  4395.                     g_Editor[g_ID[user]][oID][e_LOOP][e_R][2] = Float:get[13];
  4396.                     g_Editor[g_ID[user]][oID][e_LOOP][e_SR] = get[14];
  4397.                     g_Editor[g_ID[user]][oID][e_ROAD][e_MA] = get[15];
  4398.                     g_Editor[g_ID[user]][oID][e_ROAD][e_SL] = get[16];
  4399.                     g_Editor[g_ID[user]][oID][e_LOOP][e_MA] = get[17];
  4400.                     g_Editor[g_ID[user]][oID][e_LOOP][e_SL] = get[18];
  4401.                     g_Editor[g_ID[user]][oID][e_EDIT][e_Lock] = get[19];
  4402.                     format(g_Editor[g_ID[user]][oID][e_EDIT][e_Info], 32, "%.*s", strlen(str) - 2, str);
  4403.                 }
  4404.                 else
  4405.                 {
  4406.                     fclose(file);
  4407.                     return 0;
  4408.                 }
  4409.             }
  4410.             fclose(file);
  4411.             for(new i = 1; i < MAX_OBJECTS; ++i)
  4412.             {
  4413.                 if(g_Editor[g_ID[user]][i][e_EDIT][e_MID])
  4414.                 {
  4415.                     if(g_Editor[g_ID[user]][i][e_EDIT][e_Map] == map)
  4416.                     {
  4417.                         new
  4418.                             road_MA,
  4419.                             road_SL;
  4420.                         road_MA = EDIT_OBJECT_GetID(user, g_Editor[g_ID[user]][i][e_ROAD][e_MA]),
  4421.                         road_SL = EDIT_OBJECT_GetID(user, g_Editor[g_ID[user]][i][e_ROAD][e_SL]);
  4422.                         g_Editor[g_ID[user]][i][e_ROAD][e_MA] = road_MA;
  4423.                         g_Editor[g_ID[user]][i][e_ROAD][e_SL] = road_SL;
  4424.                         if(EDIT_OBJECT_IsValid(user, road_MA))
  4425.                         {
  4426.                             if(g_Editor[g_ID[user]][road_MA][e_EDIT][e_Map] != map)
  4427.                             {
  4428.                                 g_Editor[g_ID[user]][road_MA][e_ROAD][e_SL] = i;
  4429.                             }
  4430.                         }
  4431.                         if(EDIT_OBJECT_IsValid(user, road_SL))
  4432.                         {
  4433.                             if(g_Editor[g_ID[user]][road_SL][e_EDIT][e_Map] != map)
  4434.                             {
  4435.                                 g_Editor[g_ID[user]][road_SL][e_ROAD][e_MA] = i;
  4436.                                 EDIT_3DTEXTLABEL_Update(user, road_SL);
  4437.                             }
  4438.                         }
  4439.                         g_Editor[g_ID[user]][i][e_LOOP][e_MA] = EDIT_OBJECT_GetID(user, g_Editor[g_ID[user]][i][e_LOOP][e_MA]);
  4440.                         g_Editor[g_ID[user]][i][e_LOOP][e_SL] = EDIT_OBJECT_GetID(user, g_Editor[g_ID[user]][i][e_LOOP][e_SL]);
  4441.                         EDIT_3DTEXTLABEL_Create(user, i);
  4442.                     }
  4443.                 }
  4444.             }
  4445.         }
  4446.         return 1;
  4447.     }
  4448.     return 0;
  4449. }
  4450.  
  4451. EDIT_MAP_Unload(user, map)
  4452. {
  4453.     if(map != UOE_INVALID_ID)
  4454.     {
  4455.         if(EDIT_MAP_IsLoaded(user, map))
  4456.         {
  4457.             new
  4458.                 count;
  4459.             for(new i = 1; i < MAX_OBJECTS; ++i)
  4460.             {
  4461.                 if(g_Editor[g_ID[user]][i][e_EDIT][e_Map] == map)
  4462.                 {
  4463.                     count = count + 1;
  4464.                     EDIT_OBJECT_Destroy(user, i);
  4465.                 }
  4466.             }
  4467.             g_File[g_ID[user]][map][0] = 0;
  4468.             return count;
  4469.         }
  4470.     }
  4471.     return 0;
  4472. }
  4473.  
  4474. EDIT_MAP_IsLoaded(user, map)
  4475. {
  4476.     if(1 <= map <= 9)
  4477.     {
  4478.         if(g_File[g_ID[user]][map][0])
  4479.         {
  4480.             return 1;
  4481.         }
  4482.     }
  4483.     return 0;
  4484. }
  4485.  
  4486. EDIT_MAP_GetSlot(user)
  4487. {
  4488.     for(new i = 1; i <= 9; ++i)
  4489.     {
  4490.         if(!g_File[g_ID[user]][i][0])
  4491.         {
  4492.             return i;
  4493.         }
  4494.     }
  4495.     return UOE_INVALID_ID;
  4496. }
  4497.  
  4498. EDIT_MAP_GetName(user, map, name[24])
  4499. {
  4500.     if(1 <= map <= 9)
  4501.     {
  4502.         if(g_File[g_ID[user]][map][0])
  4503.         {
  4504.             format(name, 24, g_File[g_ID[user]][map]);
  4505.         }
  4506.     }
  4507.     return 1;
  4508. }
  4509.  
  4510. EDIT_MAP_GetID(user, name[])
  4511. {
  4512.     for(new i = 1; i <= 9; ++i)
  4513.     {
  4514.         if(g_File[g_ID[user]][i][0])
  4515.         {
  4516.             if(!strcmp(g_File[g_ID[user]][i], name, true))
  4517.             {
  4518.                 return i;
  4519.             }
  4520.         }
  4521.     }
  4522.     return UOE_INVALID_ID;
  4523. }
  4524.  
  4525. EDIT_MAP_Exist(path[], name[], ext[])
  4526. {
  4527.     format(g_Str, 64, "%s" "%s.%s", path, name, ext);
  4528.     if(fexist(g_Str))
  4529.     {
  4530.         return 1;
  4531.     }
  4532.     return 0;
  4533. }
  4534.  
  4535. EDIT_MAP_GetFirstObject(user, name[])
  4536. {
  4537.     new
  4538.         map;
  4539.     map = EDIT_MAP_GetID(user, name);
  4540.     if(map != UOE_INVALID_ID)
  4541.     {
  4542.         for(new i = 1; i < MAX_OBJECTS; ++i)
  4543.         {
  4544.             if(g_Editor[g_ID[user]][i][e_EDIT][e_MID])
  4545.             {
  4546.                 if(g_Editor[g_ID[user]][i][e_EDIT][e_Map] == map)
  4547.                 {
  4548.                     return i;
  4549.                 }
  4550.             }
  4551.         }
  4552.     }
  4553.     return 0;
  4554. }
  4555.  
  4556. EDIT_MAP_GetObjectCount(user, map, first)
  4557. {
  4558.     new
  4559.         count;
  4560.     if(1 <= map <= 9 || map == UOE_INVALID_ID)
  4561.     {
  4562.         for(new i = 1; i < MAX_OBJECTS; ++i)
  4563.         {
  4564.             if(g_Editor[g_ID[user]][i][e_EDIT][e_MID])
  4565.             {
  4566.                 if(map == UOE_INVALID_ID || g_Editor[g_ID[user]][i][e_EDIT][e_Map] == map)
  4567.                 {
  4568.                     if(first)
  4569.                     {
  4570.                         return i;
  4571.                     }
  4572.                     count = count + 1;
  4573.                 }
  4574.             }
  4575.         }
  4576.     }
  4577.     return count;
  4578. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement