Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author:
- Stylock
- Changelog:
- 28-02-2015 (Update 3)
- * Added file import feature
- * Added snap to grid/snap to angle feature
- * Added in-game configuration dialog
- * Added support for Streamer plugin
- * Added rotation sync parameter to the loop feature
- * Overwriting an existing map file is now possible
- * Improved map file recovery feature
- * Improved fly mode camera mobility
- * Improved movement/rotation speed setting when altering with keys
- * Removed object model validity check due to SA-MP 0.3.7 objects
- * Fixed a bug that caused infinite recursion
- * Renamed normal mode to world mode
- * Minor improvements and bug fixes
- 08-07-2012 (Update 2)
- * Added new keyboard shortcuts
- * Fixed a bug with file loading
- * Minor bug fixes
- 16-06-2012 (Update 1)
- * Renamed world mode to normal mode
- * Corrected a mistake in the help dialog
- * Added a new project file and removed the old one
- * Fixed a bug in the undo feature causing objects to not get destroyed
- * Upgraded several commands to support optional parameters
- 13-06-2012
- * First release
- */
- #define FILTERSCRIPT
- #include <a_samp>
- #include <sscanf2>
- #include <zcmd>
- // Config
- #define UOE_MAX_ADMINS (2) // Max rcon admins allowed to create maps
- #define UOE_TIMER_INT (30) // Timer interval
- #define UOE_MAX_ACTIONS (300) // Max actions that can be undone in a row
- #define UOE_DRAW_DISTANCE (800) // Object draw distance
- // Invalid ID
- #define UOE_INVALID_ID (-1)
- // Directories
- #define UOE_IMPORT "maps\\import\\"
- #define UOE_RECOVERY "maps\\recovery\\"
- #define UOE_PROJECTS "maps\\projects\\"
- #define UOE_SAVES "maps\\saves\\"
- #tryinclude <streamer>
- #if !defined _inc_streamer
- #define EDIT_OID_IsValid \
- IsValidObject
- #define EDIT_OID_Create \
- CreateObject
- #define EDIT_OID_Destroy \
- DestroyObject
- #define EDIT_OID_SetPos \
- SetObjectPos
- #define EDIT_OID_SetRot \
- SetObjectRot
- #define EDIT_OID_GetPos \
- GetObjectPos
- #define EDIT_OID_GetRot \
- GetObjectRot
- #else
- #define EDIT_OID_IsValid \
- IsValidDynamicObject
- #define EDIT_OID_Create \
- CreateDynamicObject
- #define EDIT_OID_Destroy \
- DestroyDynamicObject
- #define EDIT_OID_SetPos \
- SetDynamicObjectPos
- #define EDIT_OID_SetRot \
- SetDynamicObjectRot
- #define EDIT_OID_GetPos \
- GetDynamicObjectPos
- #define EDIT_OID_GetRot \
- GetDynamicObjectRot
- #define DrawDistance streamdistance
- #endif
- #define PUBLIC:%1(%2) \
- forward %1(%2); \
- public %1(%2)
- // In-game config
- enum E_CONFIG
- {
- e_Select,
- e_Key_Action,
- };
- enum E_ROAD
- {
- e_IDX,
- e_SL,
- e_MA,
- };
- enum E_LOOP
- {
- e_SL,
- e_MA,
- e_SR,
- Float:e_O[3],
- Float:e_R[3]
- };
- enum E_EDIT
- {
- e_UID,
- e_MID,
- e_Map,
- e_Use,
- e_Lock,
- e_Info[24]
- };
- enum E_ACTION
- {
- e_Count,
- e_Extra1,
- e_Extra2,
- Float:e_P[3],
- Float:e_R[3],
- e_EDIT[E_EDIT],
- e_LOOP[E_LOOP],
- e_ROAD[E_ROAD]
- };
- enum E_EDITOR
- {
- e_EDIT[E_EDIT],
- e_LOOP[E_LOOP],
- e_ROAD[E_ROAD]
- };
- enum E_PLAYER
- {
- e_NRG,
- e_OID,
- e_PID,
- e_Fly,
- e_Snap,
- e_Time,
- e_Timer,
- e_Delay,
- e_Active,
- e_Hold[4],
- e_Mode[3],
- Float:e_Speed[2],
- Float:e_Spawn[4],
- PlayerText:e_Text,
- PlayerText3D:e_3D[MAX_OBJECTS]
- };
- enum E_AXIS
- {
- e_OID,
- e_Axis[9],
- Float:e_O[3]
- };
- new
- g_ID[MAX_PLAYERS],
- g_Undo[UOE_MAX_ADMINS],
- g_File[UOE_MAX_ADMINS][10][16],
- g_Axis[UOE_MAX_ADMINS][E_AXIS],
- g_Config[UOE_MAX_ADMINS][E_CONFIG],
- g_Player[UOE_MAX_ADMINS][E_PLAYER],
- g_Editor[UOE_MAX_ADMINS][MAX_OBJECTS][E_EDITOR],
- g_Action[UOE_MAX_ADMINS][UOE_MAX_ACTIONS][E_ACTION];
- new
- g_Update,
- g_Unique,
- g_Str[256],
- Float:g_Float1[3],
- Float:g_Float2[3],
- Float:sx,
- Float:sy,
- Float:sz,
- Float:cx,
- Float:cy,
- Float:cz;
- public OnFilterScriptInit()
- {
- for(new i = 0; i < UOE_MAX_ADMINS; ++i)
- {
- g_Axis[i][e_O][2] = 9.0;
- g_Config[i][e_Select] = 1;
- g_Player[i][e_Speed][0] = 1.0;
- g_Player[i][e_Speed][1] = 0.6;
- g_Player[i][e_Snap] = 10;
- g_Player[i][e_PID] = UOE_INVALID_ID;
- g_Player[i][e_OID] = UOE_INVALID_ID;
- for(new x = 0; x < MAX_OBJECTS; ++x)
- {
- g_Player[i][e_3D][x] = PlayerText3D:UOE_INVALID_ID;
- }
- }
- for(new i = 0; i < MAX_PLAYERS; ++i)
- {
- if(!IsPlayerAdmin(i))
- {
- g_ID[i] = UOE_INVALID_ID;
- }
- else
- {
- for(new x = 0; x < UOE_MAX_ADMINS; ++x)
- {
- if(g_Player[x][e_PID] == UOE_INVALID_ID)
- {
- g_ID[i] = x;
- g_Player[x][e_PID] = i;
- EDIT_TEXTDRAW_Create(i);
- EDIT_MAP_EmptyRecovery(i);
- EDIT_MAP_RecoveryManager(i);
- SendClientMessage(i, 0x2D74FDFF, "Universal Object Editor activated. Type /ehelp to get started.");
- break;
- }
- }
- }
- }
- g_Unique = 1;
- g_Update = SetTimer("EDIT_AutoSave", 1800000, 1);
- return 1;
- }
- public OnFilterScriptExit()
- {
- new
- pID;
- for(new i = 0; i < UOE_MAX_ADMINS; ++i)
- {
- pID = g_Player[i][e_PID];
- if(pID != UOE_INVALID_ID)
- {
- EDIT_MAP_AutoSave(pID);
- for(new x = 1; x < MAX_OBJECTS; ++x)
- {
- if(EDIT_OBJECT_IsValid(pID, x))
- {
- EDIT_OBJECT_Destroy(pID, x);
- }
- }
- if(g_Player[i][e_Active])
- {
- CancelEdit(pID);
- }
- if(g_Player[i][e_Mode][0])
- {
- TogglePlayerSpectating(pID, 0);
- }
- if(g_Player[i][e_Fly])
- {
- DestroyObject(g_Player[i][e_Fly]);
- }
- if(g_Player[i][e_Timer])
- {
- KillTimer(g_Player[i][e_Timer]);
- }
- EDIT_AXIS_Destroy(pID);
- EDIT_VEHICLE_Destroy(pID);
- EDIT_TEXTDRAW_Destroy(pID);
- EDIT_MAP_EmptyRecovery(pID);
- }
- }
- KillTimer(g_Update);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(g_ID[playerid] != UOE_INVALID_ID)
- {
- EDIT_MAP_AutoSave(playerid);
- for(new i = 1; i < MAX_OBJECTS; ++i)
- {
- if(EDIT_OBJECT_IsValid(playerid, i))
- {
- EDIT_OBJECT_Destroy(playerid, i);
- }
- g_Player[g_ID[playerid]][e_3D][i] = PlayerText3D:UOE_INVALID_ID;
- }
- for(new i = 0; i <= 9; ++i)
- {
- g_File[g_ID[playerid]][i][0] = 0;
- }
- if(g_Player[g_ID[playerid]][e_Timer])
- {
- KillTimer(g_Player[g_ID[playerid]][e_Timer]);
- g_Player[g_ID[playerid]][e_Timer] = 0;
- }
- EDIT_AXIS_Destroy(playerid);
- EDIT_VEHICLE_Destroy(playerid);
- EDIT_TEXTDRAW_Destroy(playerid);
- EDIT_ACTION_ResetData(playerid, UOE_INVALID_ID);
- DestroyObject(g_Player[g_ID[playerid]][e_Fly]);
- g_Player[g_ID[playerid]][e_PID] = UOE_INVALID_ID;
- g_Player[g_ID[playerid]][e_OID] = UOE_INVALID_ID;
- g_Player[g_ID[playerid]][e_Snap] = 10;
- g_Player[g_ID[playerid]][e_Speed][0] = 1.0;
- g_Player[g_ID[playerid]][e_Speed][1] = 0.6;
- g_Player[g_ID[playerid]][e_Mode][0] = 0;
- g_Player[g_ID[playerid]][e_Mode][1] = 0;
- g_Player[g_ID[playerid]][e_Mode][2] = 0;
- g_Player[g_ID[playerid]][e_Active] = 0;
- g_Axis[g_ID[playerid]][e_O][0] = 0.0;
- g_Axis[g_ID[playerid]][e_O][1] = 0.0;
- g_Axis[g_ID[playerid]][e_O][2] = 9.0;
- g_ID[playerid] = UOE_INVALID_ID;
- }
- return 1;
- }
- public OnPlayerRequestClass(playerid)
- {
- if(g_ID[playerid] != UOE_INVALID_ID)
- {
- if(g_Player[g_ID[playerid]][e_Active])
- {
- g_Player[g_ID[playerid]][e_Active] = 0;
- CancelEdit(playerid);
- }
- EDIT_OBJECT_SetActive(playerid, UOE_INVALID_ID);
- }
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(g_ID[playerid] != UOE_INVALID_ID)
- {
- if(g_Player[g_ID[playerid]][e_Mode][0])
- {
- SpawnPlayer(playerid);
- }
- if(g_Player[g_ID[playerid]][e_Active])
- {
- g_Player[g_ID[playerid]][e_Active] = 0;
- CancelEdit(playerid);
- }
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- if(g_ID[playerid] != UOE_INVALID_ID)
- {
- if(g_Player[g_ID[playerid]][e_Mode][0])
- {
- if(g_Player[g_ID[playerid]][e_Mode][0] == 2)
- {
- SetTimerEx("EDIT_SpawnPlayer", 1000, 0, "i", playerid);
- GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~g~prepare to teleport...", 1000, 3);
- }
- else
- {
- if(EDIT_OID_IsValid(g_Player[g_ID[playerid]][e_Fly]))
- {
- TogglePlayerSpectating(playerid, 1);
- AttachCameraToObject(playerid, g_Player[g_ID[playerid]][e_Fly]);
- }
- }
- }
- if(g_Player[g_ID[playerid]][e_Active])
- {
- g_Player[g_ID[playerid]][e_Active] = 0;
- CancelEdit(playerid);
- }
- }
- return 0;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- if(success)
- {
- new
- ip_addr[16];
- for(new i = 0; i < MAX_PLAYERS; ++i)
- {
- if(IsPlayerConnected(i) && !IsPlayerNPC(i))
- {
- if(g_ID[i] == UOE_INVALID_ID)
- {
- GetPlayerIp(i, ip_addr, 16);
- if(!strcmp(ip, ip_addr, false))
- {
- for(new x = 0; x < UOE_MAX_ADMINS; ++x)
- {
- if(g_Player[x][e_PID] == UOE_INVALID_ID)
- {
- g_ID[i] = x;
- g_Player[x][e_PID] = i;
- EDIT_TEXTDRAW_Create(i);
- EDIT_MAP_EmptyRecovery(i);
- EDIT_MAP_RecoveryManager(i);
- SendClientMessage(i, 0x2D74FDFF, "Universal Object Editor activated. Type /ehelp to get started.");
- SetPlayerWeather(i, 11);
- SetPlayerTime(i, 0, 30);
- return 1;
- }
- }
- }
- }
- }
- }
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(g_ID[playerid] != UOE_INVALID_ID)
- {
- if((newkeys - oldkeys) == 16)
- {
- if(!IsPlayerInAnyVehicle(playerid))
- {
- if(newkeys & 1024)
- {
- EDIT_FLY_Switch(playerid);
- return 1;
- }
- }
- else
- {
- if(newkeys & 4)
- {
- EDIT_FLY_Switch(playerid);
- return 1;
- }
- }
- }
- if(!g_Player[g_ID[playerid]][e_Mode][0])
- {
- if((newkeys - oldkeys) == 131072)
- {
- if(!g_Player[g_ID[playerid]][e_Mode][0])
- {
- EDIT_VEHICLE_Spawn(playerid, 522, 0);
- return 1;
- }
- }
- }
- else
- {
- if((newkeys - oldkeys) == 16384)
- {
- new
- oID;
- oID = g_Player[g_ID[playerid]][e_OID];
- if(EDIT_OBJECT_IsValid(playerid, oID))
- {
- EDIT_ACTION_Save(playerid, oID);
- EDIT_OBJECT_SetModel(playerid, oID, g_Editor[g_ID[playerid]][oID][e_EDIT][e_MID] + 1);
- return 1;
- }
- }
- if((newkeys - oldkeys) == 8192)
- {
- new
- oID;
- oID = g_Player[g_ID[playerid]][e_OID];
- if(EDIT_OBJECT_IsValid(playerid, oID))
- {
- EDIT_ACTION_Save(playerid, oID);
- EDIT_OBJECT_SetModel(playerid, oID, g_Editor[g_ID[playerid]][oID][e_EDIT][e_MID] - 1);
- return 1;
- }
- }
- if((newkeys - oldkeys) == 4)
- {
- new
- oID;
- oID = g_Player[g_ID[playerid]][e_OID];
- if(!EDIT_OBJECT_IsValid(playerid, oID))
- {
- g_Player[g_ID[playerid]][e_Active] = 1;
- g_Player[g_ID[playerid]][e_Hold][0] = 0;
- g_Player[g_ID[playerid]][e_Hold][1] = 0;
- g_Player[g_ID[playerid]][e_Delay] = GetTickCount();
- SelectObject(playerid);
- }
- EDIT_OBJECT_SetActive(playerid, UOE_INVALID_ID);
- return 1;
- }
- if((newkeys - oldkeys) == 2)
- {
- if(newkeys & 1024)
- {
- if(!g_Player[g_ID[playerid]][e_Mode][2])
- {
- EDIT_AXIS_Hide(playerid);
- g_Player[g_ID[playerid]][e_Mode][2] = 1;
- }
- else
- {
- if(g_Player[g_ID[playerid]][e_Mode][2] == 1)
- {
- if(g_Player[g_ID[playerid]][e_Snap])
- {
- EDIT_AXIS_Hide(playerid);
- g_Player[g_ID[playerid]][e_Mode][2] = 2;
- }
- else
- {
- EDIT_AXIS_Show(playerid);
- g_Player[g_ID[playerid]][e_Mode][2] = 0;
- }
- }
- else
- {
- EDIT_AXIS_Show(playerid);
- g_Player[g_ID[playerid]][e_Mode][2] = 0;
- }
- }
- }
- else
- {
- if(!g_Player[g_ID[playerid]][e_Mode][1])
- {
- g_Player[g_ID[playerid]][e_Mode][1] = 1;
- }
- else
- {
- g_Player[g_ID[playerid]][e_Mode][1] = 0;
- }
- }
- PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
- EDIT_TEXTDRAW_Update(playerid);
- return 1;
- }
- if((newkeys - oldkeys) == 16)
- {
- switch(g_Config[g_ID[playerid]][e_Key_Action])
- {
- case 0:
- {
- new
- oID;
- oID = g_Player[g_ID[playerid]][e_OID];
- if(EDIT_OBJECT_IsValid(playerid, oID))
- {
- if(EDIT_ROAD_IsValidModel(playerid, oID))
- {
- new
- road;
- road = EDIT_ROAD_GetNearest(playerid, oID);
- if(road)
- {
- if(!g_Editor[g_ID[playerid]][oID][e_ROAD][e_IDX])
- {
- SendClientMessage(playerid, 0xCD5C5CFF, "This road model is not supported by the road attachment feature.");
- }
- else
- {
- EDIT_ACTION_Save(playerid, oID);
- EDIT_ROAD_AttachFirst(playerid, oID, road);
- }
- }
- else
- {
- SendClientMessage(playerid, 0xCD5C5CFF, "No roads found nearby.");
- }
- }
- }
- }
- case 1:
- {
- new
- oID;
- oID = g_Player[g_ID[playerid]][e_OID];
- if(EDIT_OBJECT_IsValid(playerid, oID))
- {
- new
- Float:cam_x1,
- Float:cam_y1,
- Float:cam_z1,
- Float:cam_x2,
- Float:cam_y2,
- Float:cam_z2;
- EDIT_ACTION_Save(playerid, oID, 0);
- EDIT_LOOP_SetMA(playerid, oID, 0);
- EDIT_ROAD_SetMA(playerid, oID, 0);
- GetPlayerCameraPos(playerid, cam_x1, cam_y1, cam_z1);
- GetPlayerCameraFrontVector(playerid, cam_x2, cam_y2, cam_z2);
- cam_x1 = cam_x1 + cam_x2 * 20.0;
- cam_y1 = cam_y1 + cam_y2 * 20.0;
- cam_z1 = cam_z1 + cam_z2 * 20.0;
- EDIT_OBJECT_SetPos(playerid, oID, cam_x1, cam_y1, cam_z1);
- EDIT_ROAD_SetPos(playerid, oID);
- EDIT_LOOP_SetPos(playerid, oID);
- PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
- }
- }
- case 2:
- {
- new
- oID;
- oID = g_Player[g_ID[playerid]][e_OID];
- if(EDIT_OBJECT_IsValid(playerid, oID))
- {
- new
- Float:float1[3];
- EDIT_OBJECT_GetPos(playerid, oID, float1);
- if(g_Player[g_ID[playerid]][e_Mode][0])
- {
- SetObjectPos(g_Player[g_ID[playerid]][e_Fly], float1[0], float1[1], float1[2] + 4.0);
- }
- }
- }
- case 3:
- {
- new
- oID;
- oID = g_Player[g_ID[playerid]][e_OID];
- if(EDIT_OBJECT_IsValid(playerid, oID))
- {
- EDIT_ACTION_Save(playerid, oID);
- EDIT_OBJECT_Destroy(playerid, oID);
- }
- }
- case 4:
- {
- if(EDIT_ACTION_Undo(playerid))
- {
- SendClientMessage(playerid, 0x99FF66FF, "Editor: Last action has been undone.");
- }
- else
- {
- PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
- }
- }
- }
- return 1;
- }
- }
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case 100:
- {
- if(response)
- {
- PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
- EDIT_DIALOG_Show(playerid, 1);
- }
- else
- {
- PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
- }
- return 1;
- }
- case 101:
- {
- if(response)
- {
- PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
- EDIT_DIALOG_Show(playerid, 2);
- }
- else
- {
- PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
- EDIT_DIALOG_Show(playerid, 0);
- }
- return 1;
- }
- case 102:
- {
- if(!response)
- {
- PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
- EDIT_DIALOG_Show(playerid, 1);
- }
- else
- {
- PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
- }
- return 1;
- }
- case 103:
- {
- if(response)
- {
- format(inputtext, 32, "%.2s", inputtext);
- EDIT_ACTION_Save(playerid, strval(inputtext), 1);
- if(EDIT_MAP_Unload(playerid, strval(inputtext)))
- {
- SendClientMessage(playerid, 0x99FF66FF, "Editor: Map successfully unloaded.");
- }
- }
- return 1;
- }
- case 104:
- {
- if(response)
- {
- new
- map;
- map = EDIT_MAP_GetSlot(playerid);
- if(map == UOE_INVALID_ID)
- {
- return SendClientMessage(playerid, 0xCD5C5CFF, "Error: Too much maps loaded.");
- }
- new
- load,
- str[32];
- format(str, 32, "autosave-%s", EDIT_GetName(playerid));
- load = EDIT_MAP_Load(playerid, map, UOE_RECOVERY, str);
- if(load)
- {
- format(g_Str, 128, "Editor: %d objects successfully restored.", load);
- SendClientMessage(playerid, 0x99FF66FF, g_Str);
- }
- else
- {
- SendClientMessage(playerid, 0x99FF66FF, "Editor: No objects restored.");
- }
- }
- EDIT_MAP_EmptyRecovery(playerid, 1);
- return 1;
- }
- case 105:
- {
- if(response)
- {
- switch(listitem)
- {
- case 0:
- {
- if(!g_Config[g_ID[playerid]][e_Select])
- {
- g_Config[g_ID[playerid]][e_Select] = 1;
- }
- else
- {
- g_Config[g_ID[playerid]][e_Select] = 0;
- }
- EDIT_DIALOG_Show(playerid, 5);
- }
- case 1:
- {
- EDIT_DIALOG_Show(playerid, 6);
- }
- case 2:
- {
- EDIT_Cloudless(playerid, 0);
- }
- }
- }
- return 1;
- }
- case 106:
- {
- if(response)
- {
- g_Config[playerid][e_Key_Action] = listitem;
- }
- EDIT_DIALOG_Show(playerid, 5);
- return 1;
- }
- }
- return 0;
- }
- #if defined _inc_streamer
- public OnPlayerSelectDynamicObject(playerid, objectid, modelid, Float:x, Float:y, Float:z)
- {
- if(EDIT_OBJECT_IsValid(playerid, objectid))
- {
- if(GetTickCount() - g_Player[g_ID[playerid]][e_Delay] > 200)
- {
- if(g_Editor[g_ID[playerid]][objectid][e_EDIT][e_Lock])
- {
- return SendClientMessage(playerid, 0xCD5C5CFF, "This object is locked.");
- }
- EDIT_OBJECT_SetActive(playerid, objectid);
- g_Player[g_ID[playerid]][e_Active] = 0;
- CancelEdit(playerid);
- }
- }
- return 1;
- }
- #else
- public OnPlayerSelectObject(playerid, type, objectid, modelid, Float:fX, Float:fY, Float:fZ)
- {
- if(type == SELECT_OBJECT_GLOBAL_OBJECT)
- {
- if(EDIT_OBJECT_IsValid(playerid, objectid))
- {
- if(GetTickCount() - g_Player[g_ID[playerid]][e_Delay] > 200)
- {
- if(g_Editor[g_ID[playerid]][objectid][e_EDIT][e_Lock])
- {
- return SendClientMessage(playerid, 0xCD5C5CFF, "This object is locked.");
- }
- EDIT_OBJECT_SetActive(playerid, objectid);
- g_Player[g_ID[playerid]][e_Active] = 0;
- CancelEdit(playerid);
- }
- }
- }
- return 1;
- }
- #endif
- CMD:ecreate(user, params[])
- {
- return cmd_eadd(user, params);
- }
- CMD:eadd(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- if(g_Player[g_ID[user]][e_Mode][0])
- {
- new
- mID,
- info[24];
- if(sscanf(params, "iS()[24]", mID, info))
- {
- return SendClientMessage(user, 0x99FF66FF, "Usage: /eadd <model> <comment>");
- }
- if(g_Player[g_ID[user]][e_Active])
- {
- g_Player[g_ID[user]][e_Active] = 0;
- CancelEdit(user);
- }
- new
- oID,
- Float:cam_x1,
- Float:cam_y1,
- Float:cam_z1,
- Float:cam_x2,
- Float:cam_y2,
- Float:cam_z2;
- GetPlayerCameraPos(user, cam_x1, cam_y1, cam_z1);
- GetPlayerCameraFrontVector(user, cam_x2, cam_y2, cam_z2);
- cam_x1 = cam_x1 + cam_x2 * 20.0;
- cam_y1 = cam_y1 + cam_y2 * 20.0;
- cam_z1 = cam_z1 + cam_z2 * 20.0;
- oID = EDIT_OBJECT_Create(user, ++g_Unique, mID, cam_x1, cam_y1, cam_z1, 0.0, 0.0, 0.0);
- if(oID != UOE_INVALID_ID)
- {
- EDIT_ACTION_Save(user, oID);
- g_Editor[g_ID[user]][oID][e_EDIT][e_MID] = mID;
- g_Editor[g_ID[user]][oID][e_EDIT][e_Info] = info;
- EDIT_3DTEXTLABEL_Create(user, oID);
- if(g_Config[g_ID[user]][e_Select])
- {
- EDIT_OBJECT_SetActive(user, oID);
- }
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "Unexpected error occurred.");
- }
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
- }
- return 1;
- }
- return 0;
- }
- CMD:edestroy(user, params[])
- {
- return cmd_edel(user, params);
- }
- CMD:edelete(user, params[])
- {
- return cmd_edel(user, params);
- }
- CMD:edel(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- if(g_Player[g_ID[user]][e_Mode][0])
- {
- if(!strcmp(params, "/all", true, 2))
- {
- new
- check;
- for(new i = 1; i < MAX_OBJECTS; ++i)
- {
- if(EDIT_OBJECT_IsValid(user, i))
- {
- check = 1;
- EDIT_OBJECT_Destroy(user, i);
- }
- }
- for(new i = 0; i <= 9; ++i)
- {
- g_File[g_ID[user]][i][0] = 0;
- }
- if(check)
- {
- PlayerPlaySound(user, 100008, 0.0, 0.0, 0.0);
- }
- EDIT_ACTION_ResetData(user, UOE_INVALID_ID);
- return 1;
- }
- new
- oID;
- if(sscanf(params, "i", oID))
- {
- oID = g_Player[g_ID[user]][e_OID];
- if(!EDIT_OBJECT_IsValid(user, oID))
- {
- return SendClientMessage(user, 0x99FF66FF, "Usage: /edel <object | /all>");
- }
- }
- else if(!EDIT_OBJECT_IsValid(user, oID))
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID.");
- }
- if(g_Editor[g_ID[user]][oID][e_EDIT][e_Lock])
- {
- return SendClientMessage(user, 0xCD5C5CFF, "This object is locked.");
- }
- EDIT_ACTION_Save(user, oID);
- EDIT_OBJECT_Destroy(user, oID);
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
- }
- return 1;
- }
- return 0;
- }
- CMD:eselect(user, params[])
- {
- return cmd_esel(user, params);
- }
- CMD:esel(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- if(g_Player[g_ID[user]][e_Mode][0])
- {
- new
- oID;
- if(sscanf(params, "i", oID))
- {
- g_Player[g_ID[user]][e_Active] = 1;
- EDIT_OBJECT_SetActive(user, UOE_INVALID_ID);
- SelectObject(user);
- return 1;
- }
- else if(!EDIT_OBJECT_IsValid(user, oID))
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID.");
- }
- if(g_Editor[g_ID[user]][oID][e_EDIT][e_Lock])
- {
- return SendClientMessage(user, 0xCD5C5CFF, "This object is locked.");
- }
- if(g_Player[g_ID[user]][e_Active])
- {
- g_Player[g_ID[user]][e_Active] = 0;
- CancelEdit(user);
- }
- EDIT_OBJECT_SetActive(user, oID);
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
- }
- return 1;
- }
- return 0;
- }
- CMD:eplace(user, params[])
- {
- return cmd_edesel(user, params);
- }
- CMD:edeselect(user, params[])
- {
- return cmd_edesel(user, params);
- }
- CMD:edesel(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- if(g_Player[g_ID[user]][e_Mode][0])
- {
- new
- slot;
- slot = g_Player[g_ID[user]][e_OID];
- if(EDIT_OBJECT_IsValid(user, slot))
- {
- EDIT_OBJECT_SetActive(user, UOE_INVALID_ID);
- }
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
- }
- return 1;
- }
- return 0;
- }
- CMD:ecopy(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- if(g_Player[g_ID[user]][e_Mode][0])
- {
- new
- oID,
- info[24];
- if(sscanf(params, "iS()[24]", oID, info))
- {
- oID = g_Player[g_ID[user]][e_OID];
- if(!EDIT_OBJECT_IsValid(user, oID))
- {
- return SendClientMessage(user, 0x99FF66FF, "Usage: /ecopy <object> <comment>");
- }
- else
- {
- sscanf(params, "S()[24]", info);
- }
- }
- else if(!EDIT_OBJECT_IsValid(user, oID))
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID.");
- }
- if(g_Editor[g_ID[user]][oID][e_EDIT][e_Lock])
- {
- return SendClientMessage(user, 0xCD5C5CFF, "This object is locked.");
- }
- if(g_Player[g_ID[user]][e_Active])
- {
- g_Player[g_ID[user]][e_Active] = 0;
- CancelEdit(user);
- }
- new
- mID,
- Float:float1[3],
- Float:float2[3];
- EDIT_OBJECT_GetPos(user, oID, float1);
- EDIT_OBJECT_GetRot(user, oID, float2);
- mID = g_Editor[g_ID[user]][oID][e_EDIT][e_MID];
- oID = EDIT_OBJECT_Create(user, ++g_Unique, mID, float1[0], float1[1], float1[2], float2[0], float2[1], float2[2]);
- if(oID != UOE_INVALID_ID)
- {
- EDIT_ACTION_Save(user, oID);
- g_Editor[g_ID[user]][oID][e_EDIT][e_MID] = mID;
- g_Editor[g_ID[user]][oID][e_EDIT][e_Info] = info;
- EDIT_OBJECT_SetActive(user, oID);
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "Unexpected error occurred.");
- }
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
- }
- return 1;
- }
- return 0;
- }
- CMD:emodel(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- if(g_Player[g_ID[user]][e_Mode][0])
- {
- new
- oID,
- mID;
- if(sscanf(params, "iI(-1)", oID, mID))
- {
- return SendClientMessage(user, 0x99FF66FF, "Usage: /emodel <object> <model>");
- }
- if(oID && mID == -1)
- {
- mID = oID;
- oID = g_Player[g_ID[user]][e_OID];
- if(!EDIT_OBJECT_IsValid(user, oID))
- {
- return SendClientMessage(user, 0x99FF66FF, "Usage: /emodel <object> <model>");
- }
- }
- else if(!EDIT_OBJECT_IsValid(user, oID))
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID.");
- }
- if(g_Editor[g_ID[user]][oID][e_EDIT][e_Lock])
- {
- return SendClientMessage(user, 0xCD5C5CFF, "This object is locked.");
- }
- if(g_Editor[g_ID[user]][oID][e_EDIT][e_MID] != mID)
- {
- EDIT_ACTION_Save(user, oID);
- EDIT_OBJECT_SetModel(user, oID, mID);
- }
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
- }
- return 1;
- }
- return 0;
- }
- CMD:eloop(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- if(g_Player[g_ID[user]][e_Mode][0])
- {
- new
- oID;
- oID = g_Player[g_ID[user]][e_OID];
- if(!EDIT_OBJECT_IsValid(user, oID))
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Select an object first using /esel command.");
- }
- new
- loop,
- sync_rot = -1,
- Float:float1[3] = {-1000.0, -1000.0, -1000.0},
- Float:float2[3] = {-1000.0, -1000.0, -1000.0};
- if(!strcmp(params, "/sync", true, 5))
- {
- if(!g_Editor[g_ID[user]][oID][e_LOOP][e_SR])
- {
- g_Editor[g_ID[user]][oID][e_LOOP][e_SR] = 1;
- }
- else
- {
- g_Editor[g_ID[user]][oID][e_LOOP][e_SR] = 0;
- }
- loop = EDIT_LOOP_GetSLCount(user, oID);
- }
- else
- {
- if(strcmp(params, "/del", true, 4))
- {
- if(sscanf(params, "iA<f>(-1000.0)[3]A<f>(-1000.0)[3]I(-1)", loop, float1, float2, sync_rot))
- {
- return SendClientMessage(user, 0x99FF66FF, "Usage: /eloop <amount | /sync | /del> <offset x> <offset y> <offset z> <rot x> <rot y> <rot z> <sync rot>");
- }
- }
- }
- EDIT_ACTION_Save(user, oID);
- EDIT_LOOP_SetMA(user, oID, 0);
- if(!EDIT_LOOP_Create(user, oID, loop, float1, float2, sync_rot))
- {
- EDIT_ACTION_Undo(user);
- }
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
- }
- return 1;
- }
- return 0;
- }
- CMD:eundo(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- if(g_Player[g_ID[user]][e_Mode][0])
- {
- new
- amount;
- sscanf(params, "I(0)", amount);
- if(amount < 2)
- {
- if(EDIT_ACTION_Undo(user))
- {
- SendClientMessage(user, 0x99FF66FF, "Editor: Last action has been undone.");
- }
- else
- {
- PlayerPlaySound(user, 1085, 0.0, 0.0, 0.0);
- }
- }
- else
- {
- new
- undo;
- for(undo = 0; undo < amount; ++undo)
- {
- if(!EDIT_ACTION_Undo(user))
- {
- PlayerPlaySound(user, 1085, 0.0, 0.0, 0.0);
- break;
- }
- }
- if(undo)
- {
- if(undo > 1)
- {
- format(g_Str, 64, "Editor: %d actions have been undone.", undo);
- SendClientMessage(user, 0x99FF66FF, g_Str);
- }
- else
- {
- SendClientMessage(user, 0x99FF66FF, "Editor: Last action has been undone.");
- }
- }
- }
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
- }
- return 1;
- }
- return 0;
- }
- CMD:etp(user, params[])
- {
- return cmd_egoto(user, params);
- }
- CMD:eteleport(user, params[])
- {
- return cmd_egoto(user, params);
- }
- CMD:egoto(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- new
- oID,
- str[32];
- if(sscanf(params, "s[32]", str))
- {
- oID = g_Player[g_ID[user]][e_OID];
- if(!EDIT_OBJECT_IsValid(user, oID))
- {
- return SendClientMessage(user, 0x99FF66FF, "Usage: /egoto <object | map name>");
- }
- }
- else
- {
- oID = strval(str);
- if(!EDIT_OBJECT_IsValid(user, oID))
- {
- oID = EDIT_MAP_GetFirstObject(user, str);
- if(!oID)
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID/map name.");
- }
- }
- }
- new
- Float:float1[3];
- EDIT_OBJECT_GetPos(user, oID, float1);
- if(g_Player[g_ID[user]][e_Mode][0])
- {
- SetObjectPos(g_Player[g_ID[user]][e_Fly], float1[0], float1[1], float1[2] + 4.0);
- }
- else
- {
- if(!IsPlayerInAnyVehicle(user))
- {
- SetPlayerPos(user, float1[0], float1[1], float1[2] + 4.0);
- }
- else
- {
- SetVehiclePos(GetPlayerVehicleID(user), float1[0], float1[1], float1[2] + 4.0);
- }
- }
- #if defined _inc_streamer
- Streamer_Update(user);
- #endif
- return 1;
- }
- return 0;
- }
- CMD:eposition(user, params[])
- {
- return cmd_epos(user, params);
- }
- CMD:epos(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- if(g_Player[g_ID[user]][e_Mode][0])
- {
- new
- oID,
- Float:pos_x,
- Float:pos_y,
- Float:pos_z;
- if(sscanf(params, "ifff", oID, pos_x, pos_y, pos_z))
- {
- oID = g_Player[g_ID[user]][e_OID];
- if(!EDIT_OBJECT_IsValid(user, oID) || sscanf(params, "fff", pos_x, pos_y, pos_z))
- {
- if(g_Player[g_ID[user]][e_Mode][1])
- {
- g_Player[g_ID[user]][e_Mode][1] = 0;
- EDIT_TEXTDRAW_Update(user);
- }
- SendClientMessage(user, 0x99FF66FF, "Hint: /epos <object> <pos x> <pos y> <pos z>");
- PlayerPlaySound(user, 1084, 0.0, 0.0, 0.0);
- return 1;
- }
- }
- else if(!EDIT_OBJECT_IsValid(user, oID))
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID.");
- }
- if(g_Editor[g_ID[user]][oID][e_EDIT][e_Lock])
- {
- return SendClientMessage(user, 0xCD5C5CFF, "This object is locked.");
- }
- EDIT_ACTION_Save(user, oID);
- EDIT_ROAD_SetMA(user, oID, 0);
- EDIT_LOOP_SetMA(user, oID, 0);
- EDIT_OBJECT_SetPos(user, oID, pos_x, pos_y, pos_z);
- EDIT_LOOP_SetPos(user, oID);
- EDIT_ROAD_SetPos(user, oID);
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
- }
- return 1;
- }
- return 0;
- }
- CMD:erotation(user, params[])
- {
- return cmd_erot(user, params);
- }
- CMD:erot(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- if(g_Player[g_ID[user]][e_Mode][0])
- {
- new
- oID,
- Float:rot_x,
- Float:rot_y,
- Float:rot_z;
- if(sscanf(params, "ifff", oID, rot_x, rot_y, rot_z))
- {
- oID = g_Player[g_ID[user]][e_OID];
- if(!EDIT_OBJECT_IsValid(user, oID) || sscanf(params, "fff", rot_x, rot_y, rot_z))
- {
- if(!g_Player[g_ID[user]][e_Mode][1])
- {
- g_Player[g_ID[user]][e_Mode][1] = 1;
- EDIT_TEXTDRAW_Update(user);
- }
- SendClientMessage(user, 0x99FF66FF, "Hint: /erot <object> <rot x> <rot y> <rot z>");
- PlayerPlaySound(user, 1084, 0.0, 0.0, 0.0);
- return 1;
- }
- }
- else if(!EDIT_OBJECT_IsValid(user, oID))
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID.");
- }
- if(g_Editor[g_ID[user]][oID][e_EDIT][e_Lock])
- {
- return SendClientMessage(user, 0xCD5C5CFF, "This object is locked.");
- }
- EDIT_ACTION_Save(user, oID);
- EDIT_ROAD_SetMA(user, oID, 0);
- EDIT_LOOP_SetMA(user, oID, 0);
- EDIT_OBJECT_SetRot(user, oID, rot_x, rot_y, rot_z);
- EDIT_LOOP_SetPos(user, oID);
- EDIT_ROAD_SetPos(user, oID);
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
- }
- return 1;
- }
- return 0;
- }
- CMD:esnap(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- if(g_Player[g_ID[user]][e_Mode][0])
- {
- new
- value;
- if(sscanf(params, "i", value))
- {
- if(g_Player[g_ID[user]][e_Mode][2] != 2)
- {
- if(g_Player[g_ID[user]][e_Snap])
- {
- EDIT_AXIS_Hide(user);
- g_Player[g_ID[user]][e_Mode][2] = 2;
- }
- }
- else
- {
- g_Player[g_ID[user]][e_Mode][2] = 1;
- }
- SendClientMessage(user, 0x99FF66FF, "Hint: /esnap <value>");
- PlayerPlaySound(user, 1084, 0.0, 0.0, 0.0);
- }
- else
- {
- value = value % 720;
- if(!value)
- {
- g_Player[g_ID[user]][e_Mode][2] = 1;
- }
- else
- {
- g_Player[g_ID[user]][e_Mode][2] = 2;
- }
- EDIT_AXIS_Hide(user);
- g_Player[g_ID[user]][e_Snap] = value;
- }
- EDIT_TEXTDRAW_Update(user);
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
- }
- return 1;
- }
- return 0;
- }
- CMD:elock(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- if(g_Player[g_ID[user]][e_Mode][0])
- {
- new
- oID;
- if(sscanf(params, "i", oID))
- {
- oID = g_Player[g_ID[user]][e_OID];
- if(!EDIT_OBJECT_IsValid(user, oID))
- {
- return SendClientMessage(user, 0x99FF66FF, "Usage: /elock <object>");
- }
- }
- else if(!EDIT_OBJECT_IsValid(user, oID))
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID.");
- }
- if(g_Editor[g_ID[user]][oID][e_EDIT][e_Lock])
- {
- return SendClientMessage(user, 0xCD5C5CFF, "This object is already locked.");
- }
- EDIT_ACTION_Save(user, oID);
- EDIT_OBJECT_SetLocked(user, oID, 1);
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
- }
- return 1;
- }
- return 0;
- }
- CMD:eunlock(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- if(g_Player[g_ID[user]][e_Mode][0])
- {
- new
- oID;
- if(sscanf(params, "i", oID))
- {
- return SendClientMessage(user, 0x99FF66FF, "Usage: /eunlock <object>");
- }
- if(!EDIT_OBJECT_IsValid(user, oID))
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID.");
- }
- if(!g_Editor[g_ID[user]][oID][e_EDIT][e_Lock])
- {
- return SendClientMessage(user, 0xCD5C5CFF, "This object is not locked.");
- }
- EDIT_ACTION_Save(user, oID);
- EDIT_OBJECT_SetLocked(user, oID, 0);
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
- }
- return 1;
- }
- return 0;
- }
- CMD:eattach(user, params[])
- {
- return cmd_eatt(user, params);
- }
- CMD:eatt(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- if(g_Player[g_ID[user]][e_Mode][0])
- {
- new
- road1,
- road2;
- if(sscanf(params, "iI(-1)", road1, road2))
- {
- return SendClientMessage(user, 0x99FF66FF, "Usage: /eatt <road> <to road>");
- }
- if(road1 && road2 == -1)
- {
- road2 = road1;
- road1 = g_Player[g_ID[user]][e_OID];
- if(!EDIT_OBJECT_IsValid(user, road1))
- {
- return SendClientMessage(user, 0x99FF66FF, "Usage: /eatt <road> <to road>");
- }
- }
- else if(!EDIT_OBJECT_IsValid(user, road1) || !EDIT_OBJECT_IsValid(user, road2))
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid object ID.");
- }
- if(!EDIT_ROAD_IsValidModel(user, road1) || !EDIT_ROAD_IsValidModel(user, road2))
- {
- return SendClientMessage(user, 0xCD5C5CFF, "This command supports only models between 18788 and 18803.");
- }
- if(!g_Editor[g_ID[user]][road1][e_ROAD][e_IDX] || !g_Editor[g_ID[user]][road2][e_ROAD][e_IDX])
- {
- SendClientMessage(user, 0xCD5C5CFF, "This road model is not supported by the road attachment feature.");
- SendClientMessage(user, 0xCD5C5CFF, "Supported models: 18788, 18789, 18791 - 18796, 18801 and 18803.");
- return 1;
- }
- if(g_Editor[g_ID[user]][road1][e_EDIT][e_Lock] || g_Editor[g_ID[user]][road2][e_EDIT][e_Lock])
- {
- return SendClientMessage(user, 0xCD5C5CFF, "This object is locked.");
- }
- if(g_Editor[g_ID[user]][road2][e_ROAD][e_SL] || g_Editor[g_ID[user]][road2][e_LOOP][e_SL])
- {
- return SendClientMessage(user, 0xCD5C5CFF, "This road has another road attached to it.");
- }
- if(EDIT_ROAD_ScanSL(user, road1, road2))
- {
- return SendClientMessage(user, 0xCD5C5CFF, "This road cannot be attached to any of its slave roads.");
- }
- if(road1 == road2)
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Road cannot be attached to itself.");
- }
- EDIT_ACTION_Save(user, road1);
- EDIT_ROAD_AttachFirst(user, road1, road2);
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
- }
- return 1;
- }
- return 0;
- }
- CMD:espeed(user, params[])
- {
- return cmd_evel(user, params);
- }
- CMD:evelocity(user, params[])
- {
- return cmd_evel(user, params);
- }
- CMD:evel(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- if(g_Player[g_ID[user]][e_Mode][0])
- {
- new
- Float:speed;
- if(sscanf(params, "f", speed))
- {
- return SendClientMessage(user, 0x99FF66FF, "Usage: /evel <velocity>");
- }
- EDIT_Remainder(speed, 900.0);
- g_Player[g_ID[user]][e_Speed][1] = speed / 1000 * UOE_TIMER_INT;
- EDIT_TEXTDRAW_Update(user);
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
- }
- return 1;
- }
- return 0;
- }
- CMD:eaxis(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- if(g_Player[g_ID[user]][e_Mode][0])
- {
- new
- check,
- Float:float1[3];
- if(sscanf(params, "a<f>[3]", float1))
- {
- if(g_Axis[g_ID[user]][e_Axis][0])
- {
- SendClientMessage(user, 0x99FF66FF, "Editor: Axis feature disabled.");
- EDIT_AXIS_Destroy(user);
- return 1;
- }
- check = 1;
- }
- if(!g_Axis[g_ID[user]][e_Axis][0] || !check)
- {
- if(g_Player[g_ID[user]][e_Mode][2])
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Axis feature is not supported in world mode.");
- }
- if(!check)
- {
- g_Axis[g_ID[user]][e_O][0] = float1[0];
- g_Axis[g_ID[user]][e_O][1] = float1[1];
- g_Axis[g_ID[user]][e_O][2] = float1[2];
- }
- if(!g_Axis[g_ID[user]][e_Axis][0])
- {
- g_Axis[g_ID[user]][e_Axis][0] = CreateObject(1251, 0.0, 0.0, -20.0, 0.0, 0.0, 0.0);
- SetObjectMaterialText(g_Axis[g_ID[user]][e_Axis][0], " ", 0, OBJECT_MATERIAL_SIZE_32x32, "Arial", 90, 1, 0, 0xFF0000, 0);
- g_Axis[g_ID[user]][e_Axis][1] = CreateObject(1251, 0.0, 0.0, -20.0, 0.0, 0.0, 0.0);
- SetObjectMaterialText(g_Axis[g_ID[user]][e_Axis][1], " ", 0, OBJECT_MATERIAL_SIZE_32x32, "Arial", 90, 1, 0, 0x00FF00, 0);
- 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);
- g_Axis[g_ID[user]][e_Axis][2] = CreateObject(1251, 0.0, 0.0, -20.0, 0.0, 0.0, 0.0);
- SetObjectMaterialText(g_Axis[g_ID[user]][e_Axis][2], " ", 0, OBJECT_MATERIAL_SIZE_32x32, "Arial", 90, 1, 0, 0x0000FF, 0);
- 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);
- for(new i = 0; i < 3; ++i)
- {
- if(!IsValidObject(g_Axis[g_ID[user]][e_Axis][i]))
- {
- EDIT_AXIS_Destroy(user);
- SendClientMessage(user, 0xCD5C5CFF, "Error: Not enough object slots available.");
- return 1;
- }
- }
- g_Axis[g_ID[user]][e_Axis][3] = CreatePlayerObject(user, 19362, 0.0, 0.0, -20.0, 0.0, 0.0, 0.0);
- 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);
- g_Axis[g_ID[user]][e_Axis][4] = CreatePlayerObject(user, 19362, 0.0, 0.0, -20.0, 0.0, 0.0, 0.0);
- 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);
- g_Axis[g_ID[user]][e_Axis][5] = CreatePlayerObject(user, 19362, 0.0, 0.0, -20.0, 0.0, 0.0, 0.0);
- 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);
- g_Axis[g_ID[user]][e_Axis][6] = CreatePlayerObject(user, 19362, 0.0, 0.0, -20.0, 0.0, 0.0, 0.0);
- 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);
- g_Axis[g_ID[user]][e_Axis][7] = CreatePlayerObject(user, 19362, 0.0, 0.0, -20.0, 0.0, 0.0, 0.0);
- 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);
- g_Axis[g_ID[user]][e_Axis][8] = CreatePlayerObject(user, 19362, 0.0, 0.0, -20.0, 0.0, 0.0, 0.0);
- 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);
- for(new i = 3; i < 9; ++i)
- {
- if(!IsValidPlayerObject(user, g_Axis[g_ID[user]][e_Axis][i]))
- {
- EDIT_AXIS_Destroy(user);
- SendClientMessage(user, 0xCD5C5CFF, "Error: Not enough object slots available.");
- return 1;
- }
- }
- SendClientMessage(user, 0x99FF66FF, "Editor: Axis feature enabled.");
- if(check)
- {
- SendClientMessage(user, 0x99FF66FF, "Hint: /eaxis <offset x> <offset y> <offset z>");
- PlayerPlaySound(user, 1084, 0.0, 0.0, 0.0);
- }
- }
- if(g_Player[g_ID[user]][e_OID] != UOE_INVALID_ID)
- {
- new
- Float:float2[3];
- EDIT_OBJECT_GetPos(user, g_Player[g_ID[user]][e_OID], float1);
- EDIT_OBJECT_GetRot(user, g_Player[g_ID[user]][e_OID], float2);
- EDIT_AXIS_Update(user, float1[0], float1[1], float1[2], float2[0], float2[1], float2[2]);
- g_Axis[g_ID[user]][e_OID] = g_Player[g_ID[user]][e_OID];
- }
- }
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "This command is only available in fly mode.");
- }
- return 1;
- }
- return 0;
- }
- CMD:ehover(user, params[])
- {
- return cmd_efly(user, params);
- }
- CMD:efly(user, params[])
- {
- #pragma unused params
- if(g_ID[user] != UOE_INVALID_ID)
- {
- EDIT_FLY_Switch(user);
- return 1;
- }
- return 0;
- }
- CMD:ehelp(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- new
- dialog;
- if(sscanf(params, "i", dialog))
- {
- EDIT_DIALOG_Show(user, 0);
- }
- else if(dialog == 1)
- {
- EDIT_DIALOG_Show(user, 1);
- }
- else if(dialog == 2)
- {
- EDIT_DIALOG_Show(user, 2);
- }
- else
- {
- EDIT_DIALOG_Show(user, 0);
- }
- return 1;
- }
- return 0;
- }
- CMD:esave(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- new
- str1[6],
- str2[32];
- if(sscanf(params, "s[6]s[32]", str1, str2))
- {
- return SendClientMessage(user, 0x99FF66FF, "Usage: /esave <map | /all> <map name>");
- }
- if(strlen(str2) > 14)
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: Map name is too long (max. 14 characters).");
- }
- new
- slot;
- if(!strcmp(str1, "/all", true, 2) || strval(str1) < 0)
- {
- slot = UOE_INVALID_ID;
- }
- else
- {
- slot = strval(str1);
- if(slot < 0 || slot > 9)
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: Invalid map ID.");
- }
- }
- if(!fexist(UOE_PROJECTS) || !fexist(UOE_SAVES))
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: One or more folders are missing.");
- }
- if(!EDIT_MAP_GetObjectCount(user, slot, 1))
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: This map has no objects.");
- }
- if(EDIT_MAP_Exist(UOE_PROJECTS, str2, "uoe"))
- {
- SendClientMessage(user, 0x99FF66FF, "Editor: Overwriting the existing map file.");
- }
- new
- count;
- count = EDIT_MAP_Save(user, slot, UOE_PROJECTS, str2);
- if(count)
- {
- format(g_Str, 128, "Editor: %d objects saved to '%s.txt' file.", count, str2);
- SendClientMessage(user, 0x99FF66FF, g_Str);
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "Unexpected error occurred.");
- }
- return 1;
- }
- return 0;
- }
- CMD:eload(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- new
- str[32];
- if(sscanf(params, "s[32]", str))
- {
- return SendClientMessage(user, 0x99FF66FF, "Usage: /eload <map name>");
- }
- if(EDIT_MAP_GetID(user, str) != UOE_INVALID_ID)
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: A map with this name is already loaded.");
- }
- if(!fexist(UOE_PROJECTS) || !fexist(UOE_SAVES))
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: One or more folders are missing.");
- }
- if(!EDIT_MAP_Exist(UOE_PROJECTS, str, "uoe"))
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: This map doesn't exist.");
- }
- new
- slot;
- slot = EDIT_MAP_GetSlot(user);
- if(slot == UOE_INVALID_ID)
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: Too much maps loaded.");
- }
- new
- count;
- count = EDIT_MAP_Load(user, slot, UOE_PROJECTS, str);
- if(count)
- {
- EDIT_ACTION_Save(user, slot, 2);
- format(g_File[g_ID[user]][slot], 32, "%s", str);
- format(g_Str, 64, "Editor: %d objects successfully loaded.", count);
- SendClientMessage(user, 0x99FF66FF, g_Str);
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "Unexpected error occurred.");
- EDIT_MAP_Unload(user, slot);
- }
- return 1;
- }
- return 0;
- }
- CMD:emaps(user, params[])
- {
- return cmd_eunload(user, params);
- }
- CMD:eunload(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- new
- str[32];
- if(sscanf(params, "s[32]", str))
- {
- if(!EDIT_DIALOG_Show(user, 3))
- {
- SendClientMessage(user, 0x99FF66FF, "Editor: No maps are loaded.");
- }
- else
- {
- SendClientMessage(user, 0x99FF66FF, "Hint: /eunload <map | map name>");
- PlayerPlaySound(user, 1084, 0.0, 0.0, 0.0);
- }
- return 1;
- }
- new
- map;
- map = EDIT_MAP_GetID(user, str);
- if(EDIT_MAP_IsLoaded(user, map) || EDIT_MAP_IsLoaded(user, (map = strval(str))))
- {
- EDIT_ACTION_Save(user, map, 1);
- if(EDIT_MAP_Unload(user, map))
- {
- SendClientMessage(user, 0x99FF66FF, "Editor: Map successfully unloaded.");
- }
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "Error: This map is not loaded.");
- }
- return 1;
- }
- return 0;
- }
- CMD:eimport(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- new
- str[32],
- ext[10];
- if(sscanf(params, "s[32]S()[10]", str, ext))
- {
- return SendClientMessage(user, 0x99FF66FF, "Usage: /eimport <map name> <extension>");
- }
- if(EDIT_MAP_GetID(user, str) != UOE_INVALID_ID)
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: A map with this name is already loaded.");
- }
- if(!fexist(UOE_IMPORT))
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: One or more folders are missing.");
- }
- if(ext[0])
- {
- if(!EDIT_MAP_Exist(UOE_IMPORT, str, ext))
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: This map doesn't exist.");
- }
- }
- else
- {
- if(EDIT_MAP_Exist(UOE_IMPORT, str, "txt"))
- {
- ext = "txt";
- }
- else if(EDIT_MAP_Exist(UOE_IMPORT, str, "pwn"))
- {
- ext = "pwn";
- }
- else if(EDIT_MAP_Exist(UOE_IMPORT, str, "inc"))
- {
- ext = "inc";
- }
- else
- {
- new
- pos;
- pos = strfind(str, ".");
- if(pos)
- {
- strmid(ext, str, pos + 1, strlen(str));
- strdel(str, pos, strlen(str));
- }
- if(!EDIT_MAP_Exist(UOE_IMPORT, str, ext))
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: This map doesn't exist.");
- }
- }
- }
- new
- slot;
- slot = EDIT_MAP_GetSlot(user);
- if(slot == UOE_INVALID_ID)
- {
- return SendClientMessage(user, 0xCD5C5CFF, "Error: Too much maps loaded.");
- }
- new
- count;
- count = EDIT_MAP_Import(user, slot, UOE_IMPORT, str, ext);
- if(count)
- {
- EDIT_ACTION_Save(user, slot, 2);
- format(g_File[g_ID[user]][slot], 32, "%s", str);
- format(g_Str, 128, "Editor: %d objects successfully imported.", count);
- SendClientMessage(user, 0x99FF66FF, g_Str);
- }
- else
- {
- SendClientMessage(user, 0x99FF66FF, "Editor: No objects imported.");
- }
- return 1;
- }
- return 0;
- }
- CMD:esettings(user, params[])
- {
- return cmd_econfig(user, params);
- }
- CMD:econfiguration(user, params[])
- {
- return cmd_econfig(user, params);
- }
- CMD:econfig(user, params[])
- {
- if(g_ID[user] != UOE_INVALID_ID)
- {
- EDIT_DIALOG_Show(user, 5);
- return 1;
- }
- return 0;
- }
- CMD:enrg(user, params[])
- {
- #pragma unused params
- if(g_ID[user] != UOE_INVALID_ID)
- {
- if(!g_Player[g_ID[user]][e_Mode][0])
- {
- EDIT_VEHICLE_Spawn(user, 522, 0);
- }
- return 1;
- }
- return 0;
- }
- CMD:einf(user, params[])
- {
- #pragma unused params
- if(g_ID[user] != UOE_INVALID_ID)
- {
- if(!g_Player[g_ID[user]][e_Mode][0])
- {
- EDIT_VEHICLE_Spawn(user, 411, 1);
- }
- return 1;
- }
- return 0;
- }
- CMD:ecloudless(user, params[])
- {
- #pragma unused params
- if(g_ID[user] != UOE_INVALID_ID)
- {
- EDIT_Cloudless(user, 0);
- return 1;
- }
- return 0;
- }
- PUBLIC:EDIT_Cloudless(user, step)
- {
- if(!step)
- {
- new
- Float:pos_x,
- Float:pos_y,
- Float:pos_z;
- GetPlayerPos(user, pos_x, pos_y, pos_z);
- if(2900.00 > pos_x > -2900.00 && 2900.00 > pos_y > -2900.00)
- {
- SetPlayerWeather(user, -117);
- SetTimerEx("EDIT_Cloudless", 100, 0, "ii", user, 1);
- SendClientMessage(user, 0x99FF66FF, "Note: Make sure you see at least one cloud in the sky.");
- }
- else
- {
- SendClientMessage(user, 0xCD5C5CFF, "Error: Unable to remove clouds. Go to San Andreas.");
- }
- }
- else
- {
- SetPlayerTime(user, 0, 30);
- SetPlayerWeather(user, 11);
- }
- return 1;
- }
- PUBLIC:EDIT_SpawnPlayer(user)
- {
- if(IsPlayerConnected(user))
- {
- if(g_Player[g_ID[user]][e_Mode][0] == 2)
- {
- g_Player[g_ID[user]][e_Mode][0] = 0;
- SetPlayerFacingAngle(user, g_Player[g_ID[user]][e_Spawn][3]);
- 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]);
- SetCameraBehindPlayer(user);
- }
- }
- return 1;
- }
- PUBLIC:EDIT_Update(user, id)
- {
- static
- keys,
- ud,
- lr;
- if(g_Player[id][e_Mode][0])
- {
- GetPlayerKeys(user, keys, ud, lr);
- if(keys & 8 && (ud || lr))
- {
- g_Player[id][e_Hold][2] = 1;
- EDIT_MoveCamera(user, keys, ud, lr);
- return 1;
- }
- else
- {
- if(g_Player[id][e_Hold][2])
- {
- StopObject(g_Player[id][e_Fly]);
- }
- }
- if(!g_Player[id][e_Hold][2])
- {
- new
- oID;
- oID = g_Player[id][e_OID];
- if(oID != UOE_INVALID_ID)
- {
- if(!ud)
- {
- if(g_Player[id][e_Hold][0])
- {
- EDIT_ROAD_SetPos(user, oID);
- EDIT_LOOP_SetPos(user, oID);
- EDIT_3DTEXTLABEL_Update(user, oID);
- g_Player[id][e_Hold][0] = 0;
- }
- g_Player[id][e_Hold][2] = 0;
- g_Player[id][e_Hold][3] = 0;
- g_Player[id][e_Time] = 0;
- }
- else if(ud > 0)
- {
- if(keys & 1024)
- {
- if(!g_Player[id][e_Hold][3])
- {
- EDIT_MODE_SetVelocity(user, ud);
- }
- g_Player[id][e_Hold][3] = 1;
- }
- else
- {
- if(!g_Player[id][e_Hold][0])
- {
- EDIT_ACTION_Save(user, oID);
- EDIT_LOOP_SetMA(user, oID, 0);
- EDIT_ROAD_SetMA(user, oID, 0);
- }
- if(g_Player[id][e_Mode][1])
- {
- if(keys & 32)
- {
- if(keys & 128 || g_Player[id][e_Mode][2] == 2)
- {
- if(!g_Player[id][e_Hold][0])
- {
- EDIT_OBJECT_RotateZ(user, oID, -g_Player[id][e_Speed][1], -1);
- }
- }
- else
- {
- EDIT_OBJECT_RotateZ(user, oID, -g_Player[id][e_Speed][1]);
- }
- }
- else
- {
- if(keys & 128 || g_Player[id][e_Mode][2] == 2)
- {
- if(!g_Player[id][e_Hold][0])
- {
- EDIT_OBJECT_RotateY(user, oID, -g_Player[id][e_Speed][1], -1);
- }
- }
- else
- {
- EDIT_OBJECT_RotateY(user, oID, -g_Player[id][e_Speed][1]);
- }
- }
- }
- else
- {
- if(keys & 32)
- {
- if(keys & 128 || g_Player[id][e_Mode][2] == 2)
- {
- if(!g_Player[id][e_Hold][0])
- {
- EDIT_OBJECT_MoveZ(user, oID, -g_Player[id][e_Speed][1], -1);
- EDIT_3DTEXTLABEL_Delete(user, oID);
- EDIT_3DTEXTLABEL_Create(user, oID);
- }
- }
- else
- {
- EDIT_OBJECT_MoveZ(user, oID, -g_Player[id][e_Speed][1]);
- EDIT_3DTEXTLABEL_Delete(user, oID);
- }
- }
- else
- {
- if(keys & 128 || g_Player[id][e_Mode][2] == 2)
- {
- if(!g_Player[id][e_Hold][0])
- {
- EDIT_OBJECT_MoveY(user, oID, -g_Player[id][e_Speed][1], -1);
- EDIT_3DTEXTLABEL_Delete(user, oID);
- EDIT_3DTEXTLABEL_Create(user, oID);
- }
- }
- else
- {
- EDIT_OBJECT_MoveY(user, oID, -g_Player[id][e_Speed][1]);
- EDIT_3DTEXTLABEL_Delete(user, oID);
- }
- }
- }
- g_Player[id][e_Hold][0] = 1;
- }
- }
- else
- {
- if(keys & 1024)
- {
- if(!g_Player[id][e_Hold][3])
- {
- EDIT_MODE_SetVelocity(user, ud);
- }
- g_Player[id][e_Hold][3] = 1;
- }
- else
- {
- if(!g_Player[id][e_Hold][0])
- {
- EDIT_ACTION_Save(user, oID);
- EDIT_LOOP_SetMA(user, oID, 0);
- EDIT_ROAD_SetMA(user, oID, 0);
- }
- if(g_Player[id][e_Mode][1])
- {
- if(keys & 32)
- {
- if(keys & 128 || g_Player[id][e_Mode][2] == 2)
- {
- if(!g_Player[id][e_Hold][0])
- {
- EDIT_OBJECT_RotateZ(user, oID, g_Player[id][e_Speed][1], 1);
- }
- }
- else
- {
- EDIT_OBJECT_RotateZ(user, oID, g_Player[id][e_Speed][1]);
- }
- }
- else
- {
- if(keys & 128 || g_Player[id][e_Mode][2] == 2)
- {
- if(!g_Player[id][e_Hold][0])
- {
- EDIT_OBJECT_RotateY(user, oID, g_Player[id][e_Speed][1], 1);
- }
- }
- else
- {
- EDIT_OBJECT_RotateY(user, oID, g_Player[id][e_Speed][1]);
- }
- }
- }
- else
- {
- if(keys & 32)
- {
- if(keys & 128 || g_Player[id][e_Mode][2] == 2)
- {
- if(!g_Player[id][e_Hold][0])
- {
- EDIT_OBJECT_MoveZ(user, oID, g_Player[id][e_Speed][1], 1);
- EDIT_3DTEXTLABEL_Delete(user, oID);
- EDIT_3DTEXTLABEL_Create(user, oID);
- }
- }
- else
- {
- EDIT_OBJECT_MoveZ(user, oID, g_Player[id][e_Speed][1]);
- EDIT_3DTEXTLABEL_Delete(user, oID);
- }
- }
- else
- {
- if(keys & 128 || g_Player[id][e_Mode][2] == 2)
- {
- if(!g_Player[id][e_Hold][0])
- {
- EDIT_OBJECT_MoveY(user, oID, g_Player[id][e_Speed][1], 1);
- EDIT_3DTEXTLABEL_Delete(user, oID);
- EDIT_3DTEXTLABEL_Create(user, oID);
- }
- }
- else
- {
- EDIT_OBJECT_MoveY(user, oID, g_Player[id][e_Speed][1]);
- EDIT_3DTEXTLABEL_Delete(user, oID);
- }
- }
- }
- g_Player[id][e_Hold][0] = 1;
- }
- }
- if(!lr)
- {
- if(g_Player[id][e_Hold][1])
- {
- EDIT_ROAD_SetPos(user, oID);
- EDIT_LOOP_SetPos(user, oID);
- EDIT_3DTEXTLABEL_Update(user, oID);
- g_Player[id][e_Hold][1] = 0;
- }
- }
- else if(lr > 0)
- {
- if(!g_Player[id][e_Hold][1])
- {
- EDIT_ACTION_Save(user, oID);
- EDIT_LOOP_SetMA(user, oID, 0);
- EDIT_ROAD_SetMA(user, oID, 0);
- }
- if(g_Player[id][e_Mode][1])
- {
- if(keys & 128 || g_Player[id][e_Mode][2] == 2)
- {
- if(!g_Player[id][e_Hold][1])
- {
- EDIT_OBJECT_RotateX(user, oID, g_Player[id][e_Speed][1], 1);
- }
- }
- else
- {
- EDIT_OBJECT_RotateX(user, oID, g_Player[id][e_Speed][1]);
- }
- }
- else
- {
- if(keys & 128 || g_Player[id][e_Mode][2] == 2)
- {
- if(!g_Player[id][e_Hold][1])
- {
- EDIT_OBJECT_MoveX(user, oID, g_Player[id][e_Speed][1], 1);
- EDIT_3DTEXTLABEL_Delete(user, oID);
- EDIT_3DTEXTLABEL_Create(user, oID);
- }
- }
- else
- {
- EDIT_OBJECT_MoveX(user, oID, g_Player[id][e_Speed][1]);
- EDIT_3DTEXTLABEL_Delete(user, oID);
- }
- }
- g_Player[id][e_Hold][1] = 1;
- }
- else
- {
- if(!g_Player[id][e_Hold][1])
- {
- EDIT_ACTION_Save(user, oID);
- EDIT_LOOP_SetMA(user, oID, 0);
- EDIT_ROAD_SetMA(user, oID, 0);
- }
- if(g_Player[id][e_Mode][1])
- {
- if(keys & 128 || g_Player[id][e_Mode][2] == 2)
- {
- if(!g_Player[id][e_Hold][1])
- {
- EDIT_OBJECT_RotateX(user, oID, -g_Player[id][e_Speed][1], -1);
- }
- }
- else
- {
- EDIT_OBJECT_RotateX(user, oID, -g_Player[id][e_Speed][1]);
- }
- }
- else
- {
- if(keys & 128 || g_Player[id][e_Mode][2] == 2)
- {
- if(!g_Player[id][e_Hold][1])
- {
- EDIT_OBJECT_MoveX(user, oID, -g_Player[id][e_Speed][1], -1);
- EDIT_3DTEXTLABEL_Delete(user, oID);
- EDIT_3DTEXTLABEL_Create(user, oID);
- }
- }
- else
- {
- EDIT_OBJECT_MoveX(user, oID, -g_Player[id][e_Speed][1]);
- EDIT_3DTEXTLABEL_Delete(user, oID);
- }
- }
- g_Player[id][e_Hold][1] = 1;
- }
- }
- }
- else
- {
- if(!ud && !lr)
- {
- g_Player[id][e_Hold][2] = 0;
- g_Player[id][e_Time] = 0;
- }
- }
- }
- return 1;
- }
- PUBLIC:EDIT_AutoSave()
- {
- for(new i = 0; i < UOE_MAX_ADMINS; ++i)
- {
- if(g_Player[i][e_PID] != UOE_INVALID_ID)
- {
- for(new x = 1; x < MAX_OBJECTS; ++x)
- {
- if(g_Editor[i][x][e_EDIT][e_MID])
- {
- if(!EDIT_OID_IsValid(x))
- {
- EDIT_OBJECT_ResetData(g_Player[i][e_PID], x);
- }
- }
- }
- EDIT_MAP_AutoSave(g_Player[i][e_PID]);
- }
- }
- return 1;
- }
- EDIT_GetPosAndRot(Float:off[3], Float:rot[3], Float:id_pos[3], Float:id_rot[3])
- {
- EDIT_ConvertValue(id_rot[0], id_rot[1], id_rot[2]);
- 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;
- 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;
- id_pos[2] = id_pos[2] - off[0] * cx * sy + off[1] * sx + off[2] * cx * cy;
- EDIT_ConvertValue(asin(cx * cy), atan2(sx, cx * sy) + rot[2], atan2(cy * cz * sx - sy * sz, cz * sy - cy * sx * -sz));
- EDIT_ConvertValue(asin(cx * sy), atan2(cx * cy, sx), atan2(cz * sx * sy - cy * sz, cy * cz + sx * sy * sz));
- EDIT_ConvertValue(atan2(sx, cx * cy) + rot[0], asin(cx * sy), atan2(cz * sx * sy + cy * sz, cy * cz - sx * sy * sz));
- 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);
- return 1;
- }
- EDIT_ConvertValue(Float:rot_x, Float:rot_y, Float:rot_z)
- {
- sx = floatsin(rot_x, degrees);
- sy = floatsin(rot_y, degrees);
- sz = floatsin(rot_z, degrees);
- cx = floatcos(rot_x, degrees);
- cy = floatcos(rot_y, degrees);
- cz = floatcos(rot_z, degrees);
- return 1;
- }
- EDIT_ModuloOperation(&Float:rot_x, &Float:rot_y, &Float:rot_z)
- {
- EDIT_Remainder(rot_x, 360.0);
- EDIT_Remainder(rot_y, 360.0);
- EDIT_Remainder(rot_z, 360.0);
- return 1;
- }
- EDIT_Remainder(&Float:remainder, Float:value)
- {
- if(remainder >= value)
- {
- while(remainder >= value)
- {
- remainder = remainder - value;
- }
- }
- else if(remainder < 0.0)
- {
- while(remainder < 0.0)
- {
- remainder = remainder + value;
- }
- }
- return 1;
- }
- EDIT_VEHICLE_Spawn(user, mid, component)
- {
- if(g_Player[g_ID[user]][e_NRG])
- {
- DestroyVehicle(g_Player[g_ID[user]][e_NRG]);
- g_Player[g_ID[user]][e_NRG] = 0;
- }
- new
- Float:angle,
- Float:pos_x,
- Float:pos_y,
- Float:pos_z;
- GetPlayerFacingAngle(user, angle);
- GetPlayerPos(user, pos_x, pos_y, pos_z);
- g_Player[g_ID[user]][e_NRG] = CreateVehicle(mid, pos_x, pos_y, pos_z + 0.2, angle, -1, -1, -1);
- PutPlayerInVehicle(user, g_Player[g_ID[user]][e_NRG], 0);
- if(component)
- {
- AddVehicleComponent(g_Player[g_ID[user]][e_NRG], 1010);
- }
- return 1;
- }
- EDIT_VEHICLE_Destroy(user)
- {
- if(g_Player[g_ID[user]][e_NRG])
- {
- DestroyVehicle(g_Player[g_ID[user]][e_NRG]);
- g_Player[g_ID[user]][e_NRG] = 0;
- }
- return 1;
- }
- EDIT_MoveCamera(user, keys, ud, lr)
- {
- static
- time1,
- time2,
- Float:abs_z,
- Float:angle,
- Float:cam_x1,
- Float:cam_y1,
- Float:cam_z1,
- Float:cam_x2,
- Float:cam_y2,
- Float:cam_z2,
- Float:offset_x,
- Float:offset_y,
- Float:offset_z;
- GetPlayerCameraPos(user, cam_x1, cam_y1, cam_z1);
- GetPlayerCameraFrontVector(user, cam_x2, cam_y2, cam_z2);
- offset_x = (cam_x2 * 1000.0),
- offset_y = (cam_y2 * 1000.0),
- offset_z = (cam_z2 * 1000.0);
- if(lr < 0)
- {
- if(ud < 0)
- {
- abs_z = floatabs(offset_z);
- angle = -atan2(cam_y2, cam_x2);
- cam_x1 = cam_x1 + cam_x2 + (offset_x - offset_y) + (abs_z * floatsin(angle, degrees));
- cam_y1 = cam_y1 + cam_y2 + (offset_y + offset_x) + (abs_z * floatcos(angle, degrees));
- cam_z1 = cam_z1 + cam_z2 + offset_z;
- }
- else if(ud > 0)
- {
- abs_z = floatabs(offset_z);
- angle = -atan2(cam_y2, cam_x2);
- cam_x1 = cam_x1 + cam_x2 + (-offset_x - offset_y) + (abs_z * floatsin(angle, degrees));
- cam_y1 = cam_y1 + cam_y2 + (-offset_y + offset_x) + (abs_z * floatcos(angle, degrees));
- cam_z1 = cam_z1 + cam_z2 - offset_z;
- }
- else
- {
- cam_x1 = cam_x1 + cam_x2 - offset_y;
- cam_y1 = cam_y1 + cam_y2 + offset_x;
- cam_z1 = cam_z1 + cam_z2;
- }
- }
- else if(lr > 0)
- {
- if(ud < 0)
- {
- abs_z = floatabs(offset_z);
- angle = -atan2(cam_y2, cam_x2) + 180.0;
- cam_x1 = cam_x1 + cam_x2 + (offset_x + offset_y) + (abs_z * floatsin(angle, degrees));
- cam_y1 = cam_y1 + cam_y2 + (offset_y - offset_x) + (abs_z * floatcos(angle, degrees));
- cam_z1 = cam_z1 + cam_z2 + offset_z;
- }
- else if(ud > 0)
- {
- abs_z = floatabs(offset_z);
- angle = -atan2(cam_y2, cam_x2) + 180.0;
- cam_x1 = cam_x1 + cam_x2 + (-offset_x + offset_y) + (abs_z * floatsin(angle, degrees));
- cam_y1 = cam_y1 + cam_y2 + (-offset_y - offset_x) + (abs_z * floatcos(angle, degrees));
- cam_z1 = cam_z1 + cam_z2 - offset_z;
- }
- else
- {
- cam_x1 = cam_x1 + cam_x2 + offset_y;
- cam_y1 = cam_y1 + cam_y2 - offset_x;
- cam_z1 = cam_z1 + cam_z2;
- }
- }
- else if(ud < 0)
- {
- if(!(keys & 32))
- {
- cam_x1 = cam_x1 + cam_x2 + offset_x;
- cam_y1 = cam_y1 + cam_y2 + offset_y;
- cam_z1 = cam_z1 + cam_z2 + offset_z;
- }
- else
- {
- cam_z1 = cam_z1 + 1000.0;
- }
- }
- else if(ud > 0)
- {
- if(!(keys & 32))
- {
- cam_x1 = cam_x1 + cam_x2 - offset_x;
- cam_y1 = cam_y1 + cam_y2 - offset_y;
- cam_z1 = cam_z1 + cam_z2 - offset_z;
- }
- else
- {
- cam_z1 = cam_z1 - 1000.0;
- }
- }
- time1 = GetTickCount();
- if(g_Player[g_ID[user]][e_Time])
- {
- time2 = time1 - g_Player[g_ID[user]][e_Time];
- if(g_Player[g_ID[user]][e_Speed][0] < 500.0)
- {
- for(new i = 1; i != 200; ++i)
- {
- if((20 * i) > time2)
- {
- if(i < 15)
- {
- g_Player[g_ID[user]][e_Speed][0] = 1.0 * i;
- }
- else if(i < 30)
- {
- g_Player[g_ID[user]][e_Speed][0] = 1.4 * i;
- }
- else if(i < 45)
- {
- g_Player[g_ID[user]][e_Speed][0] = 1.8 * i;
- }
- else if(i < 60)
- {
- g_Player[g_ID[user]][e_Speed][0] = 2.2 * i;
- }
- else
- {
- g_Player[g_ID[user]][e_Speed][0] = 2.6 * i;
- }
- break;
- }
- }
- }
- }
- else
- {
- g_Player[g_ID[user]][e_Time] = time1;
- g_Player[g_ID[user]][e_Speed][0] = 1.0;
- }
- if(g_Axis[g_ID[user]][e_Axis][0])
- {
- if(g_Player[g_ID[user]][e_OID] != UOE_INVALID_ID)
- {
- new
- Float:float1[3];
- EDIT_OBJECT_GetPos(user, g_Player[g_ID[user]][e_OID], float1);
- float1[0] = float1[0] + g_Axis[g_ID[user]][e_O][0];
- float1[1] = float1[1] + g_Axis[g_ID[user]][e_O][1];
- float1[2] = float1[2] + g_Axis[g_ID[user]][e_O][2];
- EDIT_AXIS_Rotate(user, float1[0], float1[1], float1[2]);
- }
- }
- MoveObject(g_Player[g_ID[user]][e_Fly], cam_x1, cam_y1, cam_z1, g_Player[g_ID[user]][e_Speed][0]);
- return 1;
- }
- EDIT_OBJECT_Create(user, uid, mid, Float:pos_x, Float:pos_y, Float:pos_z, Float:rot_x, Float:rot_y, Float:rot_z)
- {
- new
- oID;
- oID = EDIT_OID_Create(mid, pos_x, pos_y, pos_z, rot_x, rot_y, rot_z, .DrawDistance = UOE_DRAW_DISTANCE);
- if(EDIT_OID_IsValid(oID))
- {
- #if defined _inc_streamer
- Streamer_Update(user);
- Streamer_SetFloatData(STREAMER_TYPE_OBJECT, oID, E_STREAMER_DRAW_DISTANCE, UOE_DRAW_DISTANCE);
- #endif
- if(g_Editor[g_ID[user]][oID][e_EDIT][e_UID])
- {
- EDIT_ACTION_ResetSlot(user, g_Editor[g_ID[user]][oID][e_EDIT][e_UID]);
- }
- g_Editor[g_ID[user]][oID][e_EDIT][e_Map] = 0;
- g_Editor[g_ID[user]][oID][e_EDIT][e_UID] = uid;
- g_Editor[g_ID[user]][oID][e_ROAD][e_IDX] = EDIT_ROAD_GetIndex(mid);
- return oID;
- }
- return UOE_INVALID_ID;
- }
- EDIT_OBJECT_Destroy(user, oid)
- {
- if(EDIT_OBJECT_IsValid(user, oid))
- {
- EDIT_OBJECT_ResetData(user, oid);
- EDIT_OID_Destroy(oid);
- g_Editor[g_ID[user]][oid][e_EDIT][e_UID] = 0;
- return 1;
- }
- return 0;
- }
- EDIT_OBJECT_ResetData(user, oid)
- {
- EDIT_ROAD_SetSL(user, oid, 0);
- EDIT_ROAD_SetMA(user, oid, 0);
- EDIT_LOOP_SetSL(user, oid, 0);
- EDIT_LOOP_SetMA(user, oid, 0);
- EDIT_3DTEXTLABEL_Delete(user, oid);
- g_Editor[g_ID[user]][oid][e_LOOP][e_O][0] = 0.0;
- g_Editor[g_ID[user]][oid][e_LOOP][e_O][1] = 0.0;
- g_Editor[g_ID[user]][oid][e_LOOP][e_O][2] = 0.0;
- g_Editor[g_ID[user]][oid][e_LOOP][e_R][0] = 0.0;
- g_Editor[g_ID[user]][oid][e_LOOP][e_R][1] = 0.0;
- g_Editor[g_ID[user]][oid][e_LOOP][e_R][2] = 0.0;
- if(g_Editor[g_ID[user]][oid][e_EDIT][e_Use])
- {
- EDIT_AXIS_Hide(user);
- g_Player[g_ID[user]][e_OID] = UOE_INVALID_ID;
- g_Editor[g_ID[user]][oid][e_EDIT][e_Use] = 0;
- EDIT_TEXTDRAW_Update(user);
- }
- g_Editor[g_ID[user]][oid][e_ROAD][e_IDX] = 0;
- g_Editor[g_ID[user]][oid][e_EDIT][e_MID] = 0;
- g_Editor[g_ID[user]][oid][e_EDIT][e_Map] = UOE_INVALID_ID;
- g_Editor[g_ID[user]][oid][e_EDIT][e_Lock] = 0;
- g_Editor[g_ID[user]][oid][e_EDIT][e_Info] = 0;
- return 1;
- }
- EDIT_OBJECT_IsValid(user, oid)
- {
- if(EDIT_OID_IsValid(oid))
- {
- if(g_Editor[g_ID[user]][oid][e_EDIT][e_MID])
- {
- return 1;
- }
- }
- return 0;
- }
- EDIT_OBJECT_RotateX(user, oid, Float:rot_x, instant = 0)
- {
- if(instant)
- {
- rot_x = rot_x * 1000 / UOE_TIMER_INT;
- }
- EDIT_OBJECT_GetRot(user, oid, g_Float1);
- if(!g_Player[g_ID[user]][e_Mode][2])
- {
- EDIT_ConvertValue(g_Float1[0], g_Float1[1], g_Float1[2]);
- EDIT_ConvertValue(atan2(sx, cx * cy) + rot_x, asin(cx * sy), atan2(cz * sx * sy + cy * sz, cy * cz - sx * sy * sz));
- EDIT_OBJECT_SetRot(user, oid, asin(cy * sx), atan2(sy, cx * cy), atan2(cx * sz - cz * sx * sy, cx * cz + sx * sy * sz));
- }
- else
- {
- if(g_Player[g_ID[user]][e_Mode][2] == 2)
- {
- rot_x = g_Player[g_ID[user]][e_Snap] * instant;
- g_Float1[0] = (floatround(g_Float1[0] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
- }
- EDIT_OBJECT_SetRot(user, oid, g_Float1[0] + rot_x, g_Float1[1], g_Float1[2]);
- }
- return 1;
- }
- EDIT_OBJECT_RotateY(user, oid, Float:rot_y, instant = 0)
- {
- if(instant)
- {
- rot_y = rot_y * 1000 / UOE_TIMER_INT;
- }
- EDIT_OBJECT_GetRot(user, oid, g_Float1);
- if(g_Player[g_ID[user]][e_Mode][2] == 2)
- {
- rot_y = g_Player[g_ID[user]][e_Snap] * instant;
- g_Float1[1] = (floatround(g_Float1[1] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
- }
- EDIT_OBJECT_SetRot(user, oid, g_Float1[0], g_Float1[1] + rot_y, g_Float1[2]);
- return 1;
- }
- EDIT_OBJECT_RotateZ(user, oid, Float:rot_z, instant = 0)
- {
- if(instant)
- {
- rot_z = rot_z * 1000 / UOE_TIMER_INT;
- }
- EDIT_OBJECT_GetRot(user, oid, g_Float1);
- if(!g_Player[g_ID[user]][e_Mode][2])
- {
- EDIT_ConvertValue(g_Float1[0], g_Float1[1], g_Float1[2]);
- EDIT_ConvertValue(asin(cx * cy), atan2(sx, cx * sy) + rot_z, atan2(cy * cz * sx - sy * sz, cz * sy - cy * sx * -sz));
- EDIT_OBJECT_SetRot(user, oid, asin(cx * sy), atan2(cx * cy, sx), atan2(cz * sx * sy - cy * sz, cy * cz + sx * sy * sz));
- }
- else
- {
- if(g_Player[g_ID[user]][e_Mode][2] == 2)
- {
- rot_z = g_Player[g_ID[user]][e_Snap] * instant;
- g_Float1[2] = (floatround(g_Float1[2] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
- }
- EDIT_OBJECT_SetRot(user, oid, g_Float1[0], g_Float1[1], g_Float1[2] + rot_z);
- }
- return 1;
- }
- EDIT_OBJECT_MoveX(user, oid, Float:offset, instant = 0)
- {
- if(instant)
- {
- offset = offset * 1000 / UOE_TIMER_INT;
- }
- EDIT_OBJECT_GetPos(user, oid, g_Float1);
- if(!g_Player[g_ID[user]][e_Mode][2])
- {
- EDIT_OBJECT_GetRot(user, oid, g_Float2);
- EDIT_ConvertValue(g_Float2[0], g_Float2[1], g_Float2[2]);
- g_Float1[0] = g_Float1[0] + offset * cy * cz - offset * sx * sy * sz;
- g_Float1[1] = g_Float1[1] + offset * cy * sz + offset * sx * sy * cz;
- g_Float1[2] = g_Float1[2] - offset * cx * sy;
- if(g_Axis[g_ID[user]][e_Axis][0])
- {
- EDIT_AXIS_Update(user, g_Float1[0], g_Float1[1], g_Float1[2], g_Float2[0], g_Float2[1], g_Float2[2]);
- }
- }
- else
- {
- if(g_Player[g_ID[user]][e_Mode][2] == 2)
- {
- offset = g_Player[g_ID[user]][e_Snap] * instant;
- g_Float1[0] = (floatround(g_Float1[0] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
- g_Float1[1] = (floatround(g_Float1[1] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
- g_Float1[2] = (floatround(g_Float1[2] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
- }
- g_Float1[0] = g_Float1[0] + offset;
- }
- EDIT_OID_SetPos(oid, g_Float1[0], g_Float1[1], g_Float1[2]);
- return 1;
- }
- EDIT_OBJECT_MoveY(user, oid, Float:offset, instant = 0)
- {
- if(instant)
- {
- offset = offset * 1000 / UOE_TIMER_INT;
- }
- EDIT_OBJECT_GetPos(user, oid, g_Float1);
- if(!g_Player[g_ID[user]][e_Mode][2])
- {
- EDIT_OBJECT_GetRot(user, oid, g_Float2);
- cx = floatcos(g_Float2[0], degrees);
- cz = floatcos(g_Float2[2], degrees);
- sx = floatsin(g_Float2[0], degrees);
- sz = floatsin(g_Float2[2], degrees);
- g_Float1[0] = g_Float1[0] - offset * cx * sz;
- g_Float1[1] = g_Float1[1] + offset * cx * cz;
- g_Float1[2] = g_Float1[2] + offset * sx;
- if(g_Axis[g_ID[user]][e_Axis][0])
- {
- EDIT_AXIS_Update(user, g_Float1[0], g_Float1[1], g_Float1[2], g_Float2[0], g_Float2[1], g_Float2[2]);
- }
- }
- else
- {
- if(g_Player[g_ID[user]][e_Mode][2] == 2)
- {
- offset = g_Player[g_ID[user]][e_Snap] * instant;
- g_Float1[0] = (floatround(g_Float1[0] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
- g_Float1[1] = (floatround(g_Float1[1] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
- g_Float1[2] = (floatround(g_Float1[2] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
- }
- g_Float1[1] = g_Float1[1] + offset;
- }
- EDIT_OID_SetPos(oid, g_Float1[0], g_Float1[1], g_Float1[2]);
- return 1;
- }
- EDIT_OBJECT_MoveZ(user, oid, Float:offset, instant = 0)
- {
- if(instant)
- {
- offset = offset * 1000 / UOE_TIMER_INT;
- }
- EDIT_OBJECT_GetPos(user, oid, g_Float1);
- if(!g_Player[g_ID[user]][e_Mode][2])
- {
- EDIT_OBJECT_GetRot(user, oid, g_Float2);
- EDIT_ConvertValue(g_Float2[0], g_Float2[1], g_Float2[2]);
- g_Float1[0] = g_Float1[0] + offset * sy * cz + offset * sx * cy * sz;
- g_Float1[1] = g_Float1[1] + offset * sy * sz - offset * sx * cy * cz;
- g_Float1[2] = g_Float1[2] + offset * cx * cy;
- if(g_Axis[g_ID[user]][e_Axis][0])
- {
- EDIT_AXIS_Update(user, g_Float1[0], g_Float1[1], g_Float1[2], g_Float2[0], g_Float2[1], g_Float2[2]);
- }
- }
- else
- {
- if(g_Player[g_ID[user]][e_Mode][2] == 2)
- {
- offset = g_Player[g_ID[user]][e_Snap] * instant;
- g_Float1[0] = (floatround(g_Float1[0] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
- g_Float1[1] = (floatround(g_Float1[1] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
- g_Float1[2] = (floatround(g_Float1[2] / g_Player[g_ID[user]][e_Snap]) * g_Player[g_ID[user]][e_Snap]);
- }
- g_Float1[2] = g_Float1[2] + offset;
- }
- EDIT_OID_SetPos(oid, g_Float1[0], g_Float1[1], g_Float1[2]);
- return 1;
- }
- EDIT_OBJECT_SetModel(user, oid, mid)
- {
- new
- oID,
- uID,
- map,
- use,
- count_SL,
- sync_rot,
- road_MA,
- road_SL,
- Float:float1[3],
- Float:float2[3],
- Float:float3[3],
- Float:float4[3];
- EDIT_OBJECT_GetPos(user, oid, float1);
- EDIT_OBJECT_GetRot(user, oid, float2);
- if(g_Editor[g_ID[user]][oid][e_LOOP][e_SL])
- {
- float3[0] = g_Editor[g_ID[user]][oid][e_LOOP][e_O][0];
- float3[1] = g_Editor[g_ID[user]][oid][e_LOOP][e_O][1];
- float3[2] = g_Editor[g_ID[user]][oid][e_LOOP][e_O][2];
- float4[0] = g_Editor[g_ID[user]][oid][e_LOOP][e_R][0];
- float4[1] = g_Editor[g_ID[user]][oid][e_LOOP][e_R][1];
- float4[2] = g_Editor[g_ID[user]][oid][e_LOOP][e_R][2];
- count_SL = EDIT_LOOP_GetSLCount(user, oid);
- sync_rot = g_Editor[g_ID[user]][oid][e_LOOP][e_SR];
- }
- uID = g_Editor[g_ID[user]][oid][e_EDIT][e_UID];
- map = g_Editor[g_ID[user]][oid][e_EDIT][e_Map];
- use = g_Editor[g_ID[user]][oid][e_EDIT][e_Use];
- if(g_Editor[g_ID[user]][oid][e_ROAD][e_IDX])
- {
- road_MA = g_Editor[g_ID[user]][oid][e_ROAD][e_MA];
- road_SL = g_Editor[g_ID[user]][oid][e_ROAD][e_SL];
- }
- EDIT_LOOP_Destroy(user, oid);
- EDIT_OBJECT_Destroy(user, oid);
- oID = EDIT_OBJECT_Create(user, uID, mid, float1[0], float1[1], float1[2], float2[0], float2[1], float2[2]);
- g_Editor[g_ID[user]][oID][e_EDIT][e_Map] = map;
- g_Editor[g_ID[user]][oID][e_EDIT][e_MID] = mid;
- if(use)
- {
- if(g_Player[g_ID[user]][e_Active])
- {
- g_Player[g_ID[user]][e_Active] = 0;
- CancelEdit(user);
- }
- EDIT_OBJECT_SetActive(user, oID);
- }
- else
- {
- EDIT_3DTEXTLABEL_Create(user, oID);
- }
- if(count_SL)
- {
- EDIT_LOOP_Create(user, oID, count_SL, float3, float4, sync_rot);
- }
- if(g_Editor[g_ID[user]][oID][e_ROAD][e_IDX])
- {
- if(road_MA)
- {
- EDIT_ROAD_Attach(user, oID, road_MA);
- }
- EDIT_ROAD_SetSL(user, oID, road_SL);
- EDIT_ROAD_SetPos(user, oID);
- }
- return 1;
- }
- EDIT_OBJECT_SetPos(user, oid, Float:pos_x, Float:pos_y, Float:pos_z)
- {
- if(EDIT_OBJECT_IsValid(user, oid))
- {
- EDIT_OID_SetPos(oid, pos_x, pos_y, pos_z);
- EDIT_3DTEXTLABEL_Delete(user, oid);
- EDIT_3DTEXTLABEL_Create(user, oid);
- if(!g_Player[g_ID[user]][e_Mode][2])
- {
- if(g_Axis[g_ID[user]][e_Axis][0])
- {
- if(g_Axis[g_ID[user]][e_OID] == oid)
- {
- new
- Float:float1[3];
- EDIT_OBJECT_GetRot(user, oid, float1);
- EDIT_AXIS_Update(user, pos_x, pos_y, pos_z, float1[0], float1[1], float1[2]);
- }
- }
- }
- }
- return 1;
- }
- EDIT_OBJECT_SetRot(user, oid, Float:rot_x, Float:rot_y, Float:rot_z)
- {
- if(EDIT_OBJECT_IsValid(user, oid))
- {
- EDIT_OID_SetRot(oid, rot_x, rot_y, rot_z);
- EDIT_3DTEXTLABEL_Update(user, oid);
- if(!g_Player[g_ID[user]][e_Mode][2])
- {
- if(g_Axis[g_ID[user]][e_Axis][0])
- {
- if(g_Axis[g_ID[user]][e_OID] == oid)
- {
- new
- Float:float1[3];
- EDIT_OBJECT_GetPos(user, oid, float1);
- EDIT_AXIS_Update(user, float1[0], float1[1], float1[2], rot_x, rot_y, rot_z);
- }
- }
- }
- }
- return 1;
- }
- EDIT_OBJECT_GetPos(user, oid, Float:pos[3])
- {
- if(EDIT_OBJECT_IsValid(user, oid))
- {
- EDIT_OID_GetPos(oid, pos[0], pos[1], pos[2]);
- }
- return 1;
- }
- EDIT_OBJECT_GetRot(user, oid, Float:rot[3])
- {
- if(EDIT_OBJECT_IsValid(user, oid))
- {
- EDIT_OID_GetRot(oid, rot[0], rot[1], rot[2]);
- EDIT_ModuloOperation(rot[0], rot[1], rot[2]);
- if(g_Editor[g_ID[user]][oid][e_ROAD][e_IDX] != UOE_INVALID_ID)
- {
- if((!floatcmp(rot[0], 0.0) || !floatcmp(rot[0], 360.0))
- && (!floatcmp(rot[1], 0.0) || !floatcmp(rot[1], 360.0)))
- {
- rot[1] = 0.000000001;
- }
- }
- }
- return 1;
- }
- EDIT_OBJECT_GetID(user, uid)
- {
- if(uid)
- {
- for(new i = 1; i < MAX_OBJECTS; ++i)
- {
- if(g_Editor[g_ID[user]][i][e_EDIT][e_UID] == uid)
- {
- if(!EDIT_OID_IsValid(i))
- {
- return UOE_INVALID_ID;
- }
- else
- {
- return i;
- }
- }
- }
- }
- return 0;
- }
- EDIT_OBJECT_SetActive(user, oid)
- {
- if(g_Player[g_ID[user]][e_OID] != oid)
- {
- if(oid == UOE_INVALID_ID)
- {
- EDIT_ROAD_SetPos(user, g_Player[g_ID[user]][e_OID]);
- EDIT_LOOP_SetPos(user, g_Player[g_ID[user]][e_OID]);
- g_Editor[g_ID[user]][g_Player[g_ID[user]][e_OID]][e_EDIT][e_Use] = 0;
- EDIT_3DTEXTLABEL_Update(user, g_Player[g_ID[user]][e_OID]);
- g_Player[g_ID[user]][e_OID] = UOE_INVALID_ID;
- if(!g_Player[g_ID[user]][e_Mode][2])
- {
- EDIT_AXIS_Hide(user);
- }
- }
- else
- {
- if(g_Player[g_ID[user]][e_OID] != UOE_INVALID_ID)
- {
- g_Editor[g_ID[user]][g_Player[g_ID[user]][e_OID]][e_EDIT][e_Use] = 0;
- EDIT_3DTEXTLABEL_Update(user, g_Player[g_ID[user]][e_OID]);
- }
- g_Player[g_ID[user]][e_OID] = oid;
- if(!g_Editor[g_ID[user]][oid][e_EDIT][e_Use])
- {
- g_Editor[g_ID[user]][oid][e_EDIT][e_Use] = 1;
- EDIT_3DTEXTLABEL_Update(user, oid);
- }
- if(!g_Player[g_ID[user]][e_Mode][2])
- {
- EDIT_AXIS_Show(user);
- }
- }
- EDIT_TEXTDRAW_Update(user);
- }
- return 1;
- }
- EDIT_OBJECT_SetLocked(user, oid, locked)
- {
- if(locked != g_Editor[g_ID[user]][oid][e_EDIT][e_Lock])
- {
- if(locked)
- {
- if(g_Editor[g_ID[user]][oid][e_EDIT][e_Use])
- {
- EDIT_OBJECT_SetActive(user, UOE_INVALID_ID);
- }
- }
- g_Editor[g_ID[user]][oid][e_EDIT][e_Lock] = locked;
- EDIT_3DTEXTLABEL_Delete(user, oid);
- EDIT_3DTEXTLABEL_Create(user, oid);
- }
- return 1;
- }
- EDIT_DIALOG_Show(user, dialog)
- {
- static
- string[1160];
- switch(dialog)
- {
- case 0:
- {
- 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");
- 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");
- 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");
- ShowPlayerDialog(user, 100, DIALOG_STYLE_MSGBOX, "{EEE9E9}" "Keyboard shortcuts (default GTA SA keys)", string, "Next", "Cancel");
- }
- case 1:
- {
- 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");
- 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)");
- 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");
- 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.");
- ShowPlayerDialog(user, 101, DIALOG_STYLE_MSGBOX, "{EEE9E9}" "Commands", string, "Next", "Previous");
- }
- case 2:
- {
- 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)");
- 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}");
- 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}" );
- 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.");
- ShowPlayerDialog(user, 102, DIALOG_STYLE_MSGBOX, "{EEE9E9}" "Commands", string, "Cancel", "Previous");
- }
- case 3:
- {
- for(new i = 9; i != -1; --i)
- {
- if(EDIT_MAP_IsLoaded(user, i))
- {
- format(g_Str, 64, "\n%02d - %s", i, g_File[g_ID[user]][i]);
- strins(string, g_Str, 0);
- }
- }
- if(!string[0])
- {
- return 0;
- }
- ShowPlayerDialog(user, 103, DIALOG_STYLE_LIST, "{EEE9E9}" "Unload map", string, "Unload", "Cancel");
- }
- case 4:
- {
- ShowPlayerDialog(user, 104, DIALOG_STYLE_MSGBOX, "{EEE9E9}" "Map recovery", "\nWould you like to restore your last project?", "Restore", "Cancel");
- }
- case 5:
- {
- format(g_Str, 64, "\nAutomatically select created objects:\t\t%s", g_Config[g_ID[user]][e_Select] != 1 ? ("{CD5C5C}" "Disabled") : ("{99FF66}" "Enabled"));
- strcat(string, g_Str);
- format(g_Str, 64, "\nSelect action for the ENTER key:\t\tAction: %d", g_Config[g_ID[user]][e_Key_Action] + 1);
- strcat(string, g_Str);
- strcat(string, "\nRemove clouds from the sky forever");
- ShowPlayerDialog(user, 105, DIALOG_STYLE_LIST, "{EEE9E9}" "Configuration", string, "Select", "Cancel");
- }
- case 6:
- {
- 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");
- ShowPlayerDialog(user, 106, DIALOG_STYLE_LIST, "{EEE9E9}" "Key action", string, "Select", "Back");
- }
- }
- string[0] = 0;
- return 1;
- }
- EDIT_3DTEXTLABEL_Create(user, oid)
- {
- if(g_Player[g_ID[user]][e_Mode][0] == 1)
- {
- if(g_Player[g_ID[user]][e_3D][oid] == PlayerText3D:UOE_INVALID_ID)
- {
- EDIT_OBJECT_GetPos(user, oid, g_Float1);
- if(g_Editor[g_ID[user]][oid][e_EDIT][e_Use])
- {
- EDIT_OBJECT_GetRot(user, oid, g_Float2);
- 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]);
- }
- else if(g_Editor[g_ID[user]][oid][e_LOOP][e_MA])
- {
- 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]);
- }
- else if(g_Editor[g_ID[user]][oid][e_ROAD][e_MA])
- {
- 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]);
- }
- else
- {
- format(g_Str, 96, "{66FF66}" "Object ID: %d Model ID: %d", oid, g_Editor[g_ID[user]][oid][e_EDIT][e_MID]);
- }
- if(g_Editor[g_ID[user]][oid][e_EDIT][e_Lock])
- {
- strins(g_Str, "{993333}" "Locked\n", 0);
- }
- if(g_Editor[g_ID[user]][oid][e_EDIT][e_Lock] && g_Editor[g_ID[user]][oid][e_LOOP][e_MA])
- {
- 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);
- }
- else
- {
- 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);
- }
- }
- }
- return 1;
- }
- EDIT_3DTEXTLABEL_Update(user, oid)
- {
- if(g_Player[g_ID[user]][e_3D][oid] != PlayerText3D:UOE_INVALID_ID)
- {
- if(g_Editor[g_ID[user]][oid][e_EDIT][e_Use])
- {
- EDIT_OBJECT_GetPos(user, oid, g_Float1);
- EDIT_OBJECT_GetRot(user, oid, g_Float2);
- 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]);
- }
- else if(g_Editor[g_ID[user]][oid][e_LOOP][e_MA])
- {
- 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]);
- }
- else if(g_Editor[g_ID[user]][oid][e_ROAD][e_MA])
- {
- 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]);
- }
- else
- {
- format(g_Str, 96, "{66FF66}" "Object ID: %d Model ID: %d", oid, g_Editor[g_ID[user]][oid][e_EDIT][e_MID]);
- }
- if(g_Editor[g_ID[user]][oid][e_EDIT][e_Lock])
- {
- strins(g_Str, "{993333}" "Locked\n", 0);
- }
- UpdatePlayer3DTextLabelText(user, g_Player[g_ID[user]][e_3D][oid], 0, g_Str);
- }
- else
- {
- EDIT_3DTEXTLABEL_Create(user, oid);
- }
- return 1;
- }
- EDIT_3DTEXTLABEL_Delete(user, oid)
- {
- DeletePlayer3DTextLabel(user, g_Player[g_ID[user]][e_3D][oid]);
- g_Player[g_ID[user]][e_3D][oid] = PlayerText3D:UOE_INVALID_ID;
- return 1;
- }
- EDIT_3DTEXTLABEL_SetVisible(user, visible)
- {
- if(!visible)
- {
- for(new i = 1; i < MAX_OBJECTS; ++i)
- {
- if(EDIT_OBJECT_IsValid(user, i))
- {
- EDIT_3DTEXTLABEL_Delete(user, i);
- }
- }
- }
- else
- {
- for(new i = 1; i < MAX_OBJECTS; ++i)
- {
- if(EDIT_OBJECT_IsValid(user, i))
- {
- EDIT_3DTEXTLABEL_Create(user, i);
- }
- }
- }
- return 1;
- }
- EDIT_ACTION_Save(user, id, extra = 0)
- {
- if(!extra)
- {
- new
- Float:float1[3],
- Float:float2[3];
- EDIT_OBJECT_GetPos(user, id, float1);
- EDIT_OBJECT_GetRot(user, id, float2);
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_P][0] = float1[0];
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_P][1] = float1[1];
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_P][2] = float1[2];
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_R][0] = float2[0];
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_R][1] = float2[1];
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_R][2] = float2[2];
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_UID] = g_Editor[g_ID[user]][id][e_EDIT][e_UID];
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_MID] = g_Editor[g_ID[user]][id][e_EDIT][e_MID];
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_Map] = g_Editor[g_ID[user]][id][e_EDIT][e_Map];
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_Use] = g_Editor[g_ID[user]][id][e_EDIT][e_Use];
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_Lock] = g_Editor[g_ID[user]][id][e_EDIT][e_Lock];
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_Info] = g_Editor[g_ID[user]][id][e_EDIT][e_Info];
- 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];
- 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];
- 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];
- 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];
- if(g_Editor[g_ID[user]][id][e_LOOP][e_SL])
- {
- new
- loop_SL;
- loop_SL = EDIT_LOOP_GetLastSL(user, id);
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_Count] = EDIT_LOOP_GetSLCount(user, id);
- 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];
- 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];
- 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];
- 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];
- 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];
- 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];
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_LOOP][e_SR] = g_Editor[g_ID[user]][id][e_LOOP][e_SR];
- if(loop_SL)
- {
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_Extra2] = g_Editor[g_ID[user]][loop_SL][e_EDIT][e_UID];
- 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];
- }
- }
- }
- else
- {
- if(extra == 1)
- {
- new
- str[24];
- EDIT_MAP_GetName(user, id, str);
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_Extra1] = -1;
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_UID] = 1;
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_Map] = id;
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_Info] = str;
- format(g_Str, 64, "action-%d%03d", g_ID[user], g_Undo[g_ID[user]]);
- EDIT_MAP_Save(user, id, UOE_RECOVERY, g_Str, 1);
- }
- else
- {
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_Extra1] = -2;
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_UID] = 1;
- g_Action[g_ID[user]][g_Undo[g_ID[user]]][e_EDIT][e_Map] = id;
- }
- }
- EDIT_ACTION_ResetData(user, g_Undo[g_ID[user]], 1);
- return 1;
- }
- EDIT_ACTION_Undo(user)
- {
- new
- action;
- if(!g_Undo[g_ID[user]])
- {
- action = UOE_MAX_ACTIONS - 1;
- }
- else
- {
- action = g_Undo[g_ID[user]] - 1 % UOE_MAX_ACTIONS;
- }
- if(g_Action[g_ID[user]][action][e_EDIT][e_UID])
- {
- if(g_Action[g_ID[user]][action][e_Extra1] < 0)
- {
- if(g_Action[g_ID[user]][action][e_Extra1] == -1)
- {
- new
- map;
- map = g_Action[g_ID[user]][action][e_EDIT][e_Map];
- format(g_Str, 64, "action-%d%03d", g_ID[user], action);
- if(!EDIT_MAP_Load(user, map, UOE_RECOVERY, g_Str, 1))
- {
- EDIT_ACTION_ResetData(user, UOE_INVALID_ID);
- return 0;
- }
- format(g_File[g_ID[user]][map], 32, "%s", g_Action[g_ID[user]][action][e_EDIT][e_Info]);
- }
- else
- {
- if(!EDIT_MAP_Unload(user, g_Action[g_ID[user]][action][e_EDIT][e_Map]))
- {
- EDIT_ACTION_ResetData(user, UOE_INVALID_ID);
- return 0;
- }
- }
- }
- else
- {
- new
- oID;
- oID = EDIT_OBJECT_GetID(user, g_Action[g_ID[user]][action][e_EDIT][e_UID]);
- if(oID == UOE_INVALID_ID || g_Action[g_ID[user]][action][e_EDIT][e_UID] == UOE_INVALID_ID)
- {
- EDIT_ACTION_ResetData(user, action);
- return 0;
- }
- if(g_Editor[g_ID[user]][oID][e_EDIT][e_MID] != g_Action[g_ID[user]][action][e_EDIT][e_MID] || !oID)
- {
- if(oID)
- {
- EDIT_LOOP_Destroy(user, oID);
- EDIT_OBJECT_Destroy(user, oID);
- oID = 0;
- }
- if(g_Action[g_ID[user]][action][e_EDIT][e_MID])
- {
- 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]);
- if(oID == UOE_INVALID_ID)
- {
- EDIT_ACTION_ResetData(user, UOE_INVALID_ID);
- return 0;
- }
- EDIT_LOOP_SetSL(user, oID, EDIT_OBJECT_GetID(user, g_Action[g_ID[user]][action][e_LOOP][e_SL]));
- g_Editor[g_ID[user]][oID][e_EDIT][e_MID] = g_Action[g_ID[user]][action][e_EDIT][e_MID];
- g_Editor[g_ID[user]][oID][e_EDIT][e_Map] = g_Action[g_ID[user]][action][e_EDIT][e_Map];
- g_Editor[g_ID[user]][oID][e_EDIT][e_Info] = g_Action[g_ID[user]][action][e_EDIT][e_Info];
- EDIT_3DTEXTLABEL_Create(user, oID);
- }
- }
- if(oID)
- {
- new
- Float:float1[3],
- Float:float2[3];
- EDIT_OBJECT_GetPos(user, oID, float1);
- if(floatcmp(g_Action[g_ID[user]][action][e_P][0], float1[0])
- || floatcmp(g_Action[g_ID[user]][action][e_P][1], float1[1])
- || floatcmp(g_Action[g_ID[user]][action][e_P][2], float1[2]))
- {
- 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]);
- }
- EDIT_OBJECT_GetRot(user, oID, float2);
- if(floatcmp(g_Action[g_ID[user]][action][e_R][0], float2[0])
- || floatcmp(g_Action[g_ID[user]][action][e_R][1], float2[1])
- || floatcmp(g_Action[g_ID[user]][action][e_R][2], float2[2]))
- {
- 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]);
- }
- if(g_Action[g_ID[user]][action][e_EDIT][e_Use])
- {
- if(!g_Action[g_ID[user]][action][e_EDIT][e_Lock])
- {
- EDIT_OBJECT_SetActive(user, oID);
- }
- }
- EDIT_OBJECT_SetLocked(user, oID, g_Action[g_ID[user]][action][e_EDIT][e_Lock]);
- EDIT_LOOP_SetMA(user, oID, EDIT_OBJECT_GetID(user, g_Action[g_ID[user]][action][e_LOOP][e_MA]));
- if(floatcmp(g_Action[g_ID[user]][action][e_LOOP][e_O][0], g_Editor[g_ID[user]][oID][e_LOOP][e_O][0])
- || floatcmp(g_Action[g_ID[user]][action][e_LOOP][e_O][1], g_Editor[g_ID[user]][oID][e_LOOP][e_O][1])
- || floatcmp(g_Action[g_ID[user]][action][e_LOOP][e_O][2], g_Editor[g_ID[user]][oID][e_LOOP][e_O][2])
- || floatcmp(g_Action[g_ID[user]][action][e_LOOP][e_R][0], g_Editor[g_ID[user]][oID][e_LOOP][e_R][0])
- || floatcmp(g_Action[g_ID[user]][action][e_LOOP][e_R][1], g_Editor[g_ID[user]][oID][e_LOOP][e_R][1])
- || floatcmp(g_Action[g_ID[user]][action][e_LOOP][e_R][2], g_Editor[g_ID[user]][oID][e_LOOP][e_R][2])
- || g_Action[g_ID[user]][action][e_LOOP][e_SR] != g_Editor[g_ID[user]][oID][e_LOOP][e_SR]
- || g_Action[g_ID[user]][action][e_Count] != EDIT_LOOP_GetSLCount(user, oID))
- {
- float1[0] = g_Action[g_ID[user]][action][e_LOOP][e_O][0];
- float1[1] = g_Action[g_ID[user]][action][e_LOOP][e_O][1];
- float1[2] = g_Action[g_ID[user]][action][e_LOOP][e_O][2];
- float2[0] = g_Action[g_ID[user]][action][e_LOOP][e_R][0];
- float2[1] = g_Action[g_ID[user]][action][e_LOOP][e_R][1];
- float2[2] = g_Action[g_ID[user]][action][e_LOOP][e_R][2];
- g_Editor[g_ID[user]][oID][e_LOOP][e_SR] = g_Action[g_ID[user]][action][e_LOOP][e_SR];
- 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]))
- {
- EDIT_ACTION_ResetData(user, UOE_INVALID_ID);
- return 0;
- }
- if(g_Action[g_ID[user]][action][e_Count])
- {
- new
- loop_SL;
- loop_SL = EDIT_LOOP_GetLastSL(user, oID);
- g_Editor[g_ID[user]][loop_SL][e_EDIT][e_UID] = g_Action[g_ID[user]][action][e_Extra2];
- EDIT_ROAD_SetSL(user, loop_SL, EDIT_OBJECT_GetID(user, g_Action[g_ID[user]][action][e_Extra1]));
- }
- }
- else
- {
- EDIT_LOOP_SetPos(user, oID);
- }
- if(g_Editor[g_ID[user]][oID][e_ROAD][e_IDX])
- {
- EDIT_ROAD_SetSL(user, oID, EDIT_OBJECT_GetID(user, g_Action[g_ID[user]][action][e_ROAD][e_SL]));
- EDIT_ROAD_SetMA(user, oID, EDIT_OBJECT_GetID(user, g_Action[g_ID[user]][action][e_ROAD][e_MA]));
- EDIT_ROAD_SetPos(user, oID);
- }
- }
- }
- g_Undo[g_ID[user]] = action;
- EDIT_ACTION_ResetData(user, action);
- return 1;
- }
- return 0;
- }
- EDIT_ACTION_ResetSlot(user, uid)
- {
- for(new i = 0; i < UOE_MAX_ACTIONS; ++i)
- {
- if(g_Action[g_ID[user]][i][e_EDIT][e_UID] == uid)
- {
- EDIT_ACTION_ResetData(user, i);
- g_Action[g_ID[user]][i][e_EDIT][e_UID] = UOE_INVALID_ID;
- }
- }
- return 1;
- }
- EDIT_ACTION_ResetData(user, action, extra = 0)
- {
- if(action != UOE_INVALID_ID)
- {
- if(extra)
- {
- if(extra == 1)
- {
- action = action + 1;
- if(action == UOE_MAX_ACTIONS)
- {
- action = 0;
- }
- }
- else
- {
- action = action - 1;
- if(action < 0)
- {
- action = UOE_MAX_ACTIONS - 1;
- }
- }
- g_Undo[g_ID[user]] = action;
- }
- g_Action[g_ID[user]][action][e_Count] = 0;
- g_Action[g_ID[user]][action][e_Extra1] = 0;
- g_Action[g_ID[user]][action][e_Extra2] = 0;
- g_Action[g_ID[user]][action][e_ROAD][e_MA] = 0;
- g_Action[g_ID[user]][action][e_ROAD][e_SL] = 0;
- g_Action[g_ID[user]][action][e_LOOP][e_MA] = 0;
- g_Action[g_ID[user]][action][e_LOOP][e_SL] = 0;
- g_Action[g_ID[user]][action][e_LOOP][e_SR] = 0;
- g_Action[g_ID[user]][action][e_EDIT][e_UID] = 0;
- g_Action[g_ID[user]][action][e_EDIT][e_MID] = 0;
- g_Action[g_ID[user]][action][e_EDIT][e_Map] = 0;
- g_Action[g_ID[user]][action][e_EDIT][e_Use] = 0;
- g_Action[g_ID[user]][action][e_EDIT][e_Lock] = 0;
- g_Action[g_ID[user]][action][e_EDIT][e_Info] = 0;
- }
- else
- {
- for(new i = 0; i < UOE_MAX_ACTIONS; ++i)
- {
- g_Action[g_ID[user]][i][e_Count] = 0;
- g_Action[g_ID[user]][i][e_Extra1] = 0;
- g_Action[g_ID[user]][i][e_Extra2] = 0;
- g_Action[g_ID[user]][i][e_ROAD][e_MA] = 0;
- g_Action[g_ID[user]][i][e_ROAD][e_SL] = 0;
- g_Action[g_ID[user]][i][e_LOOP][e_MA] = 0;
- g_Action[g_ID[user]][i][e_LOOP][e_SL] = 0;
- g_Action[g_ID[user]][i][e_LOOP][e_SR] = 0;
- g_Action[g_ID[user]][i][e_EDIT][e_UID] = 0;
- g_Action[g_ID[user]][i][e_EDIT][e_MID] = 0;
- g_Action[g_ID[user]][i][e_EDIT][e_Map] = 0;
- g_Action[g_ID[user]][i][e_EDIT][e_Use] = 0;
- g_Action[g_ID[user]][i][e_EDIT][e_Lock] = 0;
- g_Action[g_ID[user]][i][e_EDIT][e_Info] = 0;
- }
- EDIT_MAP_EmptyRecovery(user);
- g_Undo[g_ID[user]] = 0;
- }
- return 1;
- }
- EDIT_LOOP_Create(user, oid, count, Float:off[3], Float:rot[3], sync_rot = -1)
- {
- EDIT_LOOP_Destroy(user, oid);
- if(count > 0)
- {
- new
- oID,
- mID,
- map,
- Float:pos_x,
- Float:pos_y,
- Float:pos_z,
- Float:rot_x,
- Float:rot_y,
- Float:rot_z,
- Float:float1[3],
- Float:float2[3],
- Float:float3[3],
- Float:float4[3];
- if(off[0] == -1000.0)
- {
- off[0] = g_Editor[g_ID[user]][oid][e_LOOP][e_O][0];
- }
- if(off[1] == -1000.0)
- {
- off[1] = g_Editor[g_ID[user]][oid][e_LOOP][e_O][1];
- }
- if(off[2] == -1000.0)
- {
- off[2] = g_Editor[g_ID[user]][oid][e_LOOP][e_O][2];
- }
- if(rot[0] == -1000.0)
- {
- rot[0] = g_Editor[g_ID[user]][oid][e_LOOP][e_R][0];
- }
- if(rot[1] == -1000.0)
- {
- rot[1] = g_Editor[g_ID[user]][oid][e_LOOP][e_R][1];
- }
- if(rot[2] == -1000.0)
- {
- rot[2] = g_Editor[g_ID[user]][oid][e_LOOP][e_R][2];
- }
- if(sync_rot == -1)
- {
- sync_rot = g_Editor[g_ID[user]][oid][e_LOOP][e_SR];
- }
- EDIT_OBJECT_GetPos(user, oid, float1);
- EDIT_OBJECT_GetRot(user, oid, float2);
- EDIT_ModuloOperation(rot[0], rot[1], rot[2]);
- mID = g_Editor[g_ID[user]][oid][e_EDIT][e_MID];
- map = g_Editor[g_ID[user]][oid][e_EDIT][e_Map];
- if(!sync_rot)
- {
- pos_x = float1[0];
- pos_y = float1[1];
- pos_z = float1[2];
- rot_x = float2[0];
- rot_y = float2[1];
- rot_z = float2[2];
- }
- for(new i = 0; i < count; ++i)
- {
- EDIT_GetPosAndRot(off, rot, float1, float2);
- if(sync_rot)
- {
- rot_x = float2[0];
- rot_y = float2[1];
- rot_z = float2[2];
- }
- else
- {
- EDIT_OBJECT_GetPos(user, oid, float3);
- EDIT_GetPosAndRot(off, rot, float3, float4);
- }
- oID = EDIT_OBJECT_Create(user, ++g_Unique, mID, float1[0], float1[1], float1[2], rot_x, rot_y, rot_z);
- if(oID != UOE_INVALID_ID)
- {
- if(sync_rot)
- {
- g_Editor[g_ID[user]][oid][e_LOOP][e_O][0] = off[0];
- g_Editor[g_ID[user]][oid][e_LOOP][e_O][1] = off[1];
- g_Editor[g_ID[user]][oid][e_LOOP][e_O][2] = off[2];
- }
- else
- {
- g_Editor[g_ID[user]][oid][e_LOOP][e_O][0] = float3[0] - pos_x;
- g_Editor[g_ID[user]][oid][e_LOOP][e_O][1] = float3[1] - pos_y;
- g_Editor[g_ID[user]][oid][e_LOOP][e_O][2] = float3[2] - pos_z;
- pos_x = float1[0];
- pos_y = float1[1];
- pos_z = float1[2];
- }
- g_Editor[g_ID[user]][oid][e_LOOP][e_SL] = oID;
- g_Editor[g_ID[user]][oid][e_LOOP][e_R][0] = rot[0];
- g_Editor[g_ID[user]][oid][e_LOOP][e_R][1] = rot[1];
- g_Editor[g_ID[user]][oid][e_LOOP][e_R][2] = rot[2];
- g_Editor[g_ID[user]][oID][e_EDIT][e_MID] = mID;
- g_Editor[g_ID[user]][oID][e_EDIT][e_Map] = map;
- g_Editor[g_ID[user]][oID][e_LOOP][e_MA] = oid;
- g_Editor[g_ID[user]][oid][e_LOOP][e_SR] = sync_rot;
- if(i < count - 1)
- {
- g_Editor[g_ID[user]][oID][e_EDIT][e_Lock] = 1;
- }
- EDIT_3DTEXTLABEL_Create(user, oID);
- oid = oID;
- }
- else
- {
- return 0;
- }
- }
- }
- return 1;
- }
- EDIT_LOOP_SetPos(user, oid)
- {
- if(g_Editor[g_ID[user]][oid][e_LOOP][e_SL])
- {
- new
- sync_rot,
- Float:sync_rot_x,
- Float:sync_rot_y,
- Float:sync_rot_z,
- Float:float1[3],
- Float:float2[3],
- Float:float3[3],
- Float:float4[3];
- EDIT_OBJECT_GetPos(user, oid, float3);
- EDIT_OBJECT_GetRot(user, oid, float4);
- float1[0] = g_Editor[g_ID[user]][oid][e_LOOP][e_O][0];
- float1[1] = g_Editor[g_ID[user]][oid][e_LOOP][e_O][1];
- float1[2] = g_Editor[g_ID[user]][oid][e_LOOP][e_O][2];
- float2[0] = g_Editor[g_ID[user]][oid][e_LOOP][e_R][0];
- float2[1] = g_Editor[g_ID[user]][oid][e_LOOP][e_R][1];
- float2[2] = g_Editor[g_ID[user]][oid][e_LOOP][e_R][2];
- sync_rot = g_Editor[g_ID[user]][oid][e_LOOP][e_SR];
- if(!sync_rot)
- {
- sync_rot_x = float4[0];
- sync_rot_y = float4[1];
- sync_rot_z = float4[2];
- }
- while(g_Editor[g_ID[user]][oid][e_LOOP][e_SL])
- {
- oid = g_Editor[g_ID[user]][oid][e_LOOP][e_SL];
- EDIT_GetPosAndRot(float1, float2, float3, float4);
- if(sync_rot)
- {
- sync_rot_x = float4[0];
- sync_rot_y = float4[1];
- sync_rot_z = float4[2];
- }
- EDIT_OBJECT_SetPos(user, oid, float3[0], float3[1], float3[2]);
- EDIT_OBJECT_SetRot(user, oid, sync_rot_x, sync_rot_y, sync_rot_z);
- EDIT_ROAD_SetPos(user, oid);
- }
- }
- return 1;
- }
- EDIT_LOOP_GetSLCount(user, oid)
- {
- new
- count;
- if(g_Editor[g_ID[user]][oid][e_LOOP][e_SL])
- {
- while(g_Editor[g_ID[user]][oid][e_LOOP][e_SL])
- {
- count = count + 1;
- oid = g_Editor[g_ID[user]][oid][e_LOOP][e_SL];
- }
- }
- return count;
- }
- EDIT_LOOP_Destroy(user, oid)
- {
- if(g_Editor[g_ID[user]][oid][e_LOOP][e_SL])
- {
- new
- loop_SL;
- loop_SL = g_Editor[g_ID[user]][oid][e_LOOP][e_SL];
- g_Editor[g_ID[user]][oid][e_LOOP][e_SL] = 0;
- while(loop_SL)
- {
- oid = loop_SL;
- loop_SL = g_Editor[g_ID[user]][oid][e_LOOP][e_SL];
- EDIT_OBJECT_Destroy(user, oid);
- }
- }
- return 1;
- }
- EDIT_LOOP_SetMA(user, oid, master)
- {
- if(g_Editor[g_ID[user]][oid][e_LOOP][e_MA] != master)
- {
- if(!master || master == UOE_INVALID_ID)
- {
- if(g_Editor[g_ID[user]][oid][e_LOOP][e_MA] > 0)
- {
- master = g_Editor[g_ID[user]][oid][e_LOOP][e_MA];
- g_Editor[g_ID[user]][master][e_LOOP][e_SL] = 0;
- g_Editor[g_ID[user]][oid][e_LOOP][e_MA] = 0;
- }
- }
- else
- {
- if(g_Editor[g_ID[user]][oid][e_LOOP][e_MA])
- {
- g_Editor[g_ID[user]][g_Editor[g_ID[user]][oid][e_LOOP][e_MA]][e_LOOP][e_SL] = 0;
- }
- if(g_Editor[g_ID[user]][master][e_LOOP][e_SL] != oid)
- {
- if(g_Editor[g_ID[user]][master][e_LOOP][e_SL])
- {
- g_Editor[g_ID[user]][g_Editor[g_ID[user]][master][e_LOOP][e_SL]][e_LOOP][e_MA] = 0;
- }
- g_Editor[g_ID[user]][master][e_LOOP][e_SL] = oid;
- }
- g_Editor[g_ID[user]][oid][e_LOOP][e_MA] = master;
- }
- EDIT_3DTEXTLABEL_Delete(user, oid);
- EDIT_3DTEXTLABEL_Create(user, oid);
- }
- return 1;
- }
- EDIT_LOOP_SetSL(user, oid, slave)
- {
- if(g_Editor[g_ID[user]][oid][e_LOOP][e_SL] != slave)
- {
- if(!slave || slave == UOE_INVALID_ID)
- {
- if(g_Editor[g_ID[user]][oid][e_LOOP][e_SL] > 0)
- {
- g_Editor[g_ID[user]][g_Editor[g_ID[user]][oid][e_LOOP][e_SL]][e_LOOP][e_MA] = 0;
- EDIT_3DTEXTLABEL_Update(user, g_Editor[g_ID[user]][oid][e_LOOP][e_SL]);
- }
- g_Editor[g_ID[user]][oid][e_LOOP][e_SL] = 0;
- }
- else
- {
- if(g_Editor[g_ID[user]][oid][e_LOOP][e_SL])
- {
- g_Editor[g_ID[user]][g_Editor[g_ID[user]][oid][e_LOOP][e_SL]][e_LOOP][e_MA] = 0;
- }
- if(g_Editor[g_ID[user]][slave][e_LOOP][e_MA] != oid)
- {
- if(g_Editor[g_ID[user]][slave][e_LOOP][e_MA])
- {
- g_Editor[g_ID[user]][g_Editor[g_ID[user]][slave][e_LOOP][e_MA]][e_LOOP][e_SL] = 0;
- }
- g_Editor[g_ID[user]][slave][e_LOOP][e_MA] = oid;
- EDIT_3DTEXTLABEL_Delete(user, slave);
- EDIT_3DTEXTLABEL_Create(user, slave);
- }
- g_Editor[g_ID[user]][oid][e_LOOP][e_SL] = slave;
- }
- }
- return 1;
- }
- EDIT_LOOP_GetLastSL(user, oid)
- {
- if(g_Editor[g_ID[user]][oid][e_LOOP][e_SL])
- {
- while(g_Editor[g_ID[user]][oid][e_LOOP][e_SL])
- {
- oid = g_Editor[g_ID[user]][oid][e_LOOP][e_SL];
- }
- return oid;
- }
- return 0;
- }
- EDIT_ROAD_ScanSL(user, road, other)
- {
- new
- loop_SL,
- road_SL;
- if(g_Editor[g_ID[user]][road][e_LOOP][e_SL])
- {
- loop_SL = road;
- while(g_Editor[g_ID[user]][loop_SL][e_LOOP][e_SL])
- {
- loop_SL = g_Editor[g_ID[user]][loop_SL][e_LOOP][e_SL];
- road_SL = g_Editor[g_ID[user]][loop_SL][e_ROAD][e_SL];
- if(road_SL)
- {
- if(EDIT_ROAD_ScanSL(user, road_SL, other))
- {
- return 1;
- }
- }
- if(loop_SL == other)
- {
- return 1;
- }
- }
- }
- if(g_Editor[g_ID[user]][road][e_ROAD][e_SL])
- {
- road_SL = road;
- while(g_Editor[g_ID[user]][road_SL][e_ROAD][e_SL])
- {
- road_SL = g_Editor[g_ID[user]][road_SL][e_ROAD][e_SL];
- loop_SL = g_Editor[g_ID[user]][road_SL][e_LOOP][e_SL];
- if(loop_SL)
- {
- if(EDIT_ROAD_ScanSL(user, loop_SL, other))
- {
- return 1;
- }
- }
- if(road_SL == other)
- {
- return 1;
- }
- }
- }
- return 0;
- }
- EDIT_ROAD_AttachFirst(user, oid1, oid2)
- {
- EDIT_ROAD_Attach(user, oid1, oid2);
- EDIT_ROAD_SetPos(user, oid1);
- PlayerPlaySound(user, 1150, 0.0, 0.0, 0.0);
- GameTextForPlayer(user, "~n~~n~~n~~n~~n~~n~~n~~n~~g~attached!""Error: Unable to create the object required in fly mode.");
- }
- }
- else
- {
- SetObjectPos(g_Player[g_ID[user]][e_Fly], pos_x, pos_y, pos_z);
- }
- if(!g_Player[g_ID[user]][e_Timer])
- {
- g_Player[g_ID[user]][e_Timer] = SetTimerEx("EDIT_Update", UOE_TIMER_INT, 1, "ii", user, g_ID[user]);
- }
- g_Player[g_ID[user]][e_Mode][0] = 1;
- EDIT_3DTEXTLABEL_SetVisible(user, 1);
- EDIT_TEXTDRAW_Show(user);
- TogglePlayerSpectating(user, 1);
- AttachCameraToObject(user, g_Player[g_ID[user]][e_Fly]);
- }
- else
- {
- new
- Float:cam_x,
- Float:cam_y,
- Float:cam_z;
- g_Player[g_ID[user]][e_Mode][0] = 2;
- EDIT_3DTEXTLABEL_SetVisible(user, 0);
- EDIT_TEXTDRAW_Hide(user);
- EDIT_OBJECT_SetActive(user, UOE_INVALID_ID);
- GetPlayerCameraFrontVector(user, cam_x, cam_y, cam_z);
- 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]);
- g_Player[g_ID[user]][e_Spawn][3] = atan2(cam_y, cam_x) + 270.0;
- TogglePlayerSpectating(user, 0);
- if(g_Player[g_ID[user]][e_Active])
- {
- g_Player[g_ID[user]][e_Active] = 0;
- CancelEdit(user);
- }
- if(g_Player[g_ID[user]][e_Timer])
- {
- KillTimer(g_Player[g_ID[user]][e_Timer]);
- g_Player[g_ID[user]][e_Timer] = 0;
- }
- }
- return 1;
- }
- EDIT_TEXTDRAW_Create(user)
- {
- g_Player[g_ID[user]][e_Text] = CreatePlayerTextDraw(user, 3.0, 432.0, "_");
- PlayerTextDrawBackgroundColor(user, g_Player[g_ID[user]][e_Text], 255);
- PlayerTextDrawFont(user, g_Player[g_ID[user]][e_Text], 2);
- PlayerTextDrawColor(user, g_Player[g_ID[user]][e_Text], -1);
- PlayerTextDrawLetterSize(user, g_Player[g_ID[user]][e_Text], 0.36, 1.5);
- PlayerTextDrawSetProportional(user, g_Player[g_ID[user]][e_Text], 1);
- PlayerTextDrawAlignment(user, g_Player[g_ID[user]][e_Text], 0);
- PlayerTextDrawSetShadow(user, g_Player[g_ID[user]][e_Text], 0);
- PlayerTextDrawUseBox(user, g_Player[g_ID[user]][e_Text], 1);
- PlayerTextDrawBoxColor(user, g_Player[g_ID[user]][e_Text], 136);
- PlayerTextDrawTextSize(user, g_Player[g_ID[user]][e_Text], 640.0, 0.0);
- EDIT_TEXTDRAW_Update(user);
- return 1;
- }
- EDIT_TEXTDRAW_Destroy(user)
- {
- PlayerTextDrawDestroy(user, g_Player[user][e_Text]);
- return 1;
- }
- EDIT_TEXTDRAW_Show(user)
- {
- PlayerTextDrawShow(user, g_Player[g_ID[user]][e_Text]);
- return 1;
- }
- EDIT_TEXTDRAW_Hide(user)
- {
- PlayerTextDrawHide(user, g_Player[g_ID[user]][e_Text]);
- return 1;
- }
- EDIT_TEXTDRAW_Update(user)
- {
- new
- str[128];
- if(g_Player[g_ID[user]][e_OID] != UOE_INVALID_ID)
- {
- format(g_Str, 128, " ~b~object: ~g~%03d", g_Player[g_ID[user]][e_OID]);
- strcat(str, g_Str);
- }
- else
- {
- strcat(str, " ~b~object: ~w~none");
- }
- if(!g_Player[g_ID[user]][e_Mode][1])
- {
- 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);
- strcat(str, g_Str);
- }
- else
- {
- 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);
- strcat(str, g_Str);
- }
- if(!g_Player[g_ID[user]][e_Mode][2])
- {
- strcat(str, " ~b~mode: ~w~local");
- }
- else
- {
- if(g_Player[g_ID[user]][e_Mode][2] == 1)
- {
- strcat(str, " ~b~mode: ~w~world");
- }
- else
- {
- format(g_Str, 128, " ~b~mode: ~w~world snap ~g~(%d)", g_Player[g_ID[user]][e_Snap]);
- strcat(str, g_Str);
- }
- }
- PlayerTextDrawSetString(user, g_Player[g_ID[user]][e_Text], str);
- return 1;
- }
- EDIT_GetName(user)
- {
- new
- name[24];
- GetPlayerName(user, name, 24);
- return name;
- }
- EDIT_MAP_AutoSave(user)
- {
- if(EDIT_MAP_GetObjectCount(user, UOE_INVALID_ID, 1))
- {
- format(g_Str, 64, "autosave-%s", EDIT_GetName(user));
- EDIT_MAP_Save(user, UOE_INVALID_ID, UOE_RECOVERY, g_Str, 1);
- }
- return 1;
- }
- EDIT_MAP_RecoveryManager(user)
- {
- format(g_Str, 64, "autosave-%s", EDIT_GetName(user));
- if(EDIT_MAP_Exist(UOE_RECOVERY, g_Str, "uoe"))
- {
- EDIT_DIALOG_Show(user, 4);
- }
- return 1;
- }
- EDIT_MAP_EmptyRecovery(user, extra = 0)
- {
- if(!extra)
- {
- for(new i = 0; i < UOE_MAX_ACTIONS; ++i)
- {
- format(g_Str, 64, "%s" "action-%d%03d.uoe", UOE_RECOVERY, g_ID[user], i);
- if(fexist(g_Str))
- {
- fremove(g_Str);
- }
- }
- }
- else
- {
- format(g_Str, 64, "%s" "autosave-%s.uoe", UOE_RECOVERY, EDIT_GetName(user));
- if(fexist(g_Str))
- {
- fremove(g_Str);
- }
- }
- return 1;
- }
- EDIT_MAP_Import(user, map, path[], name[], ext[])
- {
- new
- str[64],
- File:file;
- format(str, 64, "%s" "%s.%s", path, name, ext);
- file = fopen(str, io_read);
- if(file)
- {
- new
- oID,
- mID,
- load,
- Float:pos_x,
- Float:pos_y,
- Float:pos_z,
- Float:rot_x,
- Float:rot_y,
- Float:rot_z;
- while(fread(file, g_Str))
- {
- if(!sscanf(g_Str, "'Object('P<(),>iffffff", mID, pos_x, pos_y, pos_z, rot_x, rot_y, rot_z))
- {
- oID = EDIT_OBJECT_Create(user, ++g_Unique, mID, pos_x, pos_y, pos_z, rot_x, rot_y, rot_z);
- if(oID != UOE_INVALID_ID)
- {
- load = load + 1;
- g_Editor[g_ID[user]][oID][e_EDIT][e_MID] = mID;
- g_Editor[g_ID[user]][oID][e_EDIT][e_Map] = map;
- EDIT_3DTEXTLABEL_Create(user, oID);
- }
- else
- {
- fclose(file);
- return 0;
- }
- }
- }
- fclose(file);
- return load;
- }
- return 0;
- }
- EDIT_MAP_Save(user, map, path[], name[], extra = 0)
- {
- if(fexist(path))
- {
- new
- str[64],
- File:file;
- format(str, 64, "%s" "%s.uoe", path, name);
- file = fopen(str, io_write);
- if(file)
- {
- new
- Float:float1[3],
- Float:float2[3];
- for(new i = 1; i < MAX_OBJECTS; ++i)
- {
- if(g_Editor[g_ID[user]][i][e_EDIT][e_MID])
- {
- if(map == UOE_INVALID_ID || g_Editor[g_ID[user]][i][e_EDIT][e_Map] == map)
- {
- EDIT_OBJECT_GetPos(user, i, float1);
- EDIT_OBJECT_GetRot(user, i, float2);
- 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",
- g_Editor[g_ID[user]][i][e_EDIT][e_MID],
- g_Editor[g_ID[user]][i][e_EDIT][e_UID],
- float1[0], float1[1], float1[2],
- float2[0], float2[1], float2[2],
- g_Editor[g_ID[user]][i][e_LOOP][e_O][0],
- g_Editor[g_ID[user]][i][e_LOOP][e_O][1],
- g_Editor[g_ID[user]][i][e_LOOP][e_O][2],
- g_Editor[g_ID[user]][i][e_LOOP][e_R][0],
- g_Editor[g_ID[user]][i][e_LOOP][e_R][1],
- g_Editor[g_ID[user]][i][e_LOOP][e_R][2],
- g_Editor[g_ID[user]][i][e_LOOP][e_SR],
- g_Editor[g_ID[user]][g_Editor[g_ID[user]][i][e_ROAD][e_MA]][e_EDIT][e_UID],
- g_Editor[g_ID[user]][g_Editor[g_ID[user]][i][e_ROAD][e_SL]][e_EDIT][e_UID],
- g_Editor[g_ID[user]][g_Editor[g_ID[user]][i][e_LOOP][e_MA]][e_EDIT][e_UID],
- g_Editor[g_ID[user]][g_Editor[g_ID[user]][i][e_LOOP][e_SL]][e_EDIT][e_UID],
- g_Editor[g_ID[user]][i][e_EDIT][e_Lock], g_Editor[g_ID[user]][i][e_EDIT][e_Info]);
- fwrite(file, g_Str);
- }
- }
- }
- fclose(file);
- }
- }
- else
- {
- return 0;
- }
- if(!extra)
- {
- new
- str[64],
- File:file;
- format(str, 64, UOE_SAVES "%s.txt", name);
- file = fopen(str, io_write);
- if(file)
- {
- new
- count,
- Float:float1[3],
- Float:float2[3];
- for(new i = 1; i < MAX_OBJECTS; ++i)
- {
- if(g_Editor[g_ID[user]][i][e_EDIT][e_MID])
- {
- if(map == UOE_INVALID_ID || g_Editor[g_ID[user]][i][e_EDIT][e_Map] == map)
- {
- str[0] = 0;
- count = count + 1;
- EDIT_OBJECT_GetPos(user, i, float1);
- EDIT_OBJECT_GetRot(user, i, float2);
- if(g_Editor[g_ID[user]][i][e_EDIT][e_Info][0])
- {
- format(str, 64, " // %s", g_Editor[g_ID[user]][i][e_EDIT][e_Info]);
- }
- 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);
- fwrite(file, g_Str);
- }
- }
- }
- fclose(file);
- return count;
- }
- else
- {
- return 0;
- }
- }
- return 1;
- }
- EDIT_MAP_Load(user, map, path[], name[], extra = 0)
- {
- new
- oID,
- get[20],
- str[64],
- File:file;
- format(str, 64, "%s" "%s.uoe", path, name);
- file = fopen(str, io_read);
- if(file)
- {
- if(!extra)
- {
- while(fread(file, g_Str))
- {
- if(sscanf(g_Str, "p<|>a<x>[20]S()[32]", get, str))
- {
- fclose(file);
- return 0;
- }
- 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]);
- if(oID != UOE_INVALID_ID)
- {
- g_Editor[g_ID[user]][oID][e_EDIT][e_Map] = map;
- g_Editor[g_ID[user]][oID][e_EDIT][e_MID] = get[0];
- g_Editor[g_ID[user]][oID][e_LOOP][e_O][0] = Float:get[8];
- g_Editor[g_ID[user]][oID][e_LOOP][e_O][1] = Float:get[9];
- g_Editor[g_ID[user]][oID][e_LOOP][e_O][2] = Float:get[10];
- g_Editor[g_ID[user]][oID][e_LOOP][e_R][0] = Float:get[11];
- g_Editor[g_ID[user]][oID][e_LOOP][e_R][1] = Float:get[12];
- g_Editor[g_ID[user]][oID][e_LOOP][e_R][2] = Float:get[13];
- g_Editor[g_ID[user]][oID][e_LOOP][e_SR] = get[14];
- g_Editor[g_ID[user]][oID][e_ROAD][e_MA] = -get[15];
- g_Editor[g_ID[user]][oID][e_ROAD][e_SL] = -get[16];
- g_Editor[g_ID[user]][oID][e_LOOP][e_MA] = -get[17];
- g_Editor[g_ID[user]][oID][e_LOOP][e_SL] = -get[18];
- g_Editor[g_ID[user]][oID][e_EDIT][e_Lock] = get[19];
- format(g_Editor[g_ID[user]][oID][e_EDIT][e_Info], 32, "%.*s", strlen(str) - 2, str);
- }
- else
- {
- fclose(file);
- return 0;
- }
- }
- fclose(file);
- for(new i = 1; i < MAX_OBJECTS; ++i)
- {
- if(g_Editor[g_ID[user]][i][e_EDIT][e_MID])
- {
- if(g_Editor[g_ID[user]][i][e_EDIT][e_Map] == map)
- {
- g_Editor[g_ID[user]][i][e_ROAD][e_MA] = EDIT_OBJECT_GetID(user, g_Editor[g_ID[user]][i][e_ROAD][e_MA]);
- g_Editor[g_ID[user]][i][e_ROAD][e_SL] = EDIT_OBJECT_GetID(user, g_Editor[g_ID[user]][i][e_ROAD][e_SL]);
- g_Editor[g_ID[user]][i][e_LOOP][e_MA] = EDIT_OBJECT_GetID(user, g_Editor[g_ID[user]][i][e_LOOP][e_MA]);
- g_Editor[g_ID[user]][i][e_LOOP][e_SL] = EDIT_OBJECT_GetID(user, g_Editor[g_ID[user]][i][e_LOOP][e_SL]);
- EDIT_3DTEXTLABEL_Create(user, i);
- }
- }
- }
- new
- count;
- for(new i = 1; i < MAX_OBJECTS; ++i)
- {
- if(g_Editor[g_ID[user]][i][e_EDIT][e_MID])
- {
- if(g_Editor[g_ID[user]][i][e_EDIT][e_Map] == map)
- {
- count = count + 1;
- g_Editor[g_ID[user]][i][e_EDIT][e_UID] = ++g_Unique;
- }
- }
- }
- if(count)
- {
- format(g_File[g_ID[user]][map], 32, "%s", name);
- }
- return count;
- }
- else
- {
- while(fread(file, g_Str))
- {
- if(sscanf(g_Str, "p<|>a<x>[20]S()[32]", get, str))
- {
- fclose(file);
- return 0;
- }
- 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]);
- if(oID != UOE_INVALID_ID)
- {
- g_Editor[g_ID[user]][oID][e_EDIT][e_Map] = map;
- g_Editor[g_ID[user]][oID][e_EDIT][e_MID] = get[0];
- g_Editor[g_ID[user]][oID][e_LOOP][e_O][0] = Float:get[8];
- g_Editor[g_ID[user]][oID][e_LOOP][e_O][1] = Float:get[9];
- g_Editor[g_ID[user]][oID][e_LOOP][e_O][2] = Float:get[10];
- g_Editor[g_ID[user]][oID][e_LOOP][e_R][0] = Float:get[11];
- g_Editor[g_ID[user]][oID][e_LOOP][e_R][1] = Float:get[12];
- g_Editor[g_ID[user]][oID][e_LOOP][e_R][2] = Float:get[13];
- g_Editor[g_ID[user]][oID][e_LOOP][e_SR] = get[14];
- g_Editor[g_ID[user]][oID][e_ROAD][e_MA] = get[15];
- g_Editor[g_ID[user]][oID][e_ROAD][e_SL] = get[16];
- g_Editor[g_ID[user]][oID][e_LOOP][e_MA] = get[17];
- g_Editor[g_ID[user]][oID][e_LOOP][e_SL] = get[18];
- g_Editor[g_ID[user]][oID][e_EDIT][e_Lock] = get[19];
- format(g_Editor[g_ID[user]][oID][e_EDIT][e_Info], 32, "%.*s", strlen(str) - 2, str);
- }
- else
- {
- fclose(file);
- return 0;
- }
- }
- fclose(file);
- for(new i = 1; i < MAX_OBJECTS; ++i)
- {
- if(g_Editor[g_ID[user]][i][e_EDIT][e_MID])
- {
- if(g_Editor[g_ID[user]][i][e_EDIT][e_Map] == map)
- {
- new
- road_MA,
- road_SL;
- road_MA = EDIT_OBJECT_GetID(user, g_Editor[g_ID[user]][i][e_ROAD][e_MA]),
- road_SL = EDIT_OBJECT_GetID(user, g_Editor[g_ID[user]][i][e_ROAD][e_SL]);
- g_Editor[g_ID[user]][i][e_ROAD][e_MA] = road_MA;
- g_Editor[g_ID[user]][i][e_ROAD][e_SL] = road_SL;
- if(EDIT_OBJECT_IsValid(user, road_MA))
- {
- if(g_Editor[g_ID[user]][road_MA][e_EDIT][e_Map] != map)
- {
- g_Editor[g_ID[user]][road_MA][e_ROAD][e_SL] = i;
- }
- }
- if(EDIT_OBJECT_IsValid(user, road_SL))
- {
- if(g_Editor[g_ID[user]][road_SL][e_EDIT][e_Map] != map)
- {
- g_Editor[g_ID[user]][road_SL][e_ROAD][e_MA] = i;
- EDIT_3DTEXTLABEL_Update(user, road_SL);
- }
- }
- g_Editor[g_ID[user]][i][e_LOOP][e_MA] = EDIT_OBJECT_GetID(user, g_Editor[g_ID[user]][i][e_LOOP][e_MA]);
- g_Editor[g_ID[user]][i][e_LOOP][e_SL] = EDIT_OBJECT_GetID(user, g_Editor[g_ID[user]][i][e_LOOP][e_SL]);
- EDIT_3DTEXTLABEL_Create(user, i);
- }
- }
- }
- }
- return 1;
- }
- return 0;
- }
- EDIT_MAP_Unload(user, map)
- {
- if(map != UOE_INVALID_ID)
- {
- if(EDIT_MAP_IsLoaded(user, map))
- {
- new
- count;
- for(new i = 1; i < MAX_OBJECTS; ++i)
- {
- if(g_Editor[g_ID[user]][i][e_EDIT][e_Map] == map)
- {
- count = count + 1;
- EDIT_OBJECT_Destroy(user, i);
- }
- }
- g_File[g_ID[user]][map][0] = 0;
- return count;
- }
- }
- return 0;
- }
- EDIT_MAP_IsLoaded(user, map)
- {
- if(1 <= map <= 9)
- {
- if(g_File[g_ID[user]][map][0])
- {
- return 1;
- }
- }
- return 0;
- }
- EDIT_MAP_GetSlot(user)
- {
- for(new i = 1; i <= 9; ++i)
- {
- if(!g_File[g_ID[user]][i][0])
- {
- return i;
- }
- }
- return UOE_INVALID_ID;
- }
- EDIT_MAP_GetName(user, map, name[24])
- {
- if(1 <= map <= 9)
- {
- if(g_File[g_ID[user]][map][0])
- {
- format(name, 24, g_File[g_ID[user]][map]);
- }
- }
- return 1;
- }
- EDIT_MAP_GetID(user, name[])
- {
- for(new i = 1; i <= 9; ++i)
- {
- if(g_File[g_ID[user]][i][0])
- {
- if(!strcmp(g_File[g_ID[user]][i], name, true))
- {
- return i;
- }
- }
- }
- return UOE_INVALID_ID;
- }
- EDIT_MAP_Exist(path[], name[], ext[])
- {
- format(g_Str, 64, "%s" "%s.%s", path, name, ext);
- if(fexist(g_Str))
- {
- return 1;
- }
- return 0;
- }
- EDIT_MAP_GetFirstObject(user, name[])
- {
- new
- map;
- map = EDIT_MAP_GetID(user, name);
- if(map != UOE_INVALID_ID)
- {
- for(new i = 1; i < MAX_OBJECTS; ++i)
- {
- if(g_Editor[g_ID[user]][i][e_EDIT][e_MID])
- {
- if(g_Editor[g_ID[user]][i][e_EDIT][e_Map] == map)
- {
- return i;
- }
- }
- }
- }
- return 0;
- }
- EDIT_MAP_GetObjectCount(user, map, first)
- {
- new
- count;
- if(1 <= map <= 9 || map == UOE_INVALID_ID)
- {
- for(new i = 1; i < MAX_OBJECTS; ++i)
- {
- if(g_Editor[g_ID[user]][i][e_EDIT][e_MID])
- {
- if(map == UOE_INVALID_ID || g_Editor[g_ID[user]][i][e_EDIT][e_Map] == map)
- {
- if(first)
- {
- return i;
- }
- count = count + 1;
- }
- }
- }
- }
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement