Robo_N1X

[SA:MP 0.3e+] Player Attached Object Editor 0.3

Mar 25th, 2014
2,286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //  A Recommended Update to v0.4 is Available - http://pastebin.com/JvsDU2Uz  //
  3. ////////////////////////////////////////////////////////////////////////////////
  4. //                          ATTACHED OBJECT EDITOR                            //
  5. //                                by Robo_N1X                                 //
  6. //                              -Version: 0.3-                                //
  7. // ========================================================================== //
  8. // Note: This filterscript works in SA:MP 0.3e or upper                       //
  9. // License note:                                                              //
  10. // * You may not remove any credits that is written in the credits dialog or  //
  11. //   other user interface element on this script!                             //
  12. // * You may modify this script without removing any credits                  //
  13. // * You may copy the content(s) of this script without removing any credits  //
  14. // * You may use this script for non-commercial only                          //
  15. // Credits & Thanks to: SA-MP Team, h02/Scott, Zeex, Y_Less, and whoever      //
  16. // helped or made some useful functions or codes used in this filter-script!  //
  17. // Original thread: http://forum.sa-mp.com/showthread.php?t=416138            //
  18. ////////////////////////////////////////////////////////////////////////////////
  19. #define FILTERSCRIPT                            // This is a filterscript, don't remove!
  20. #include <a_samp>                               // 0.3e+ - Credits to: SA-MP team
  21. #include <zcmd>                                 // 0.3.1 - Credits to: Zeex
  22. #include <sscanf2>                              // 2.8.1 - Credits to: Y_Less
  23. #define MAX_ATTACHED_OBJECT_BONES       18      // Don't edit unless there is change on SA:MP feature with it.
  24. #define MAX_ATTACHED_OBJECT_OFFSET      300.0   // Max attached object offset, set around 0.0 to 3000.0
  25. #define MIN_ATTACHED_OBJECT_OFFSET      -300.0  // Min attached object offset, set around 0.0 to -3000.0
  26. #define MAX_ATTACHED_OBJECT_ROTATION    360.0   // Max attached object rotation, 360.0 is default
  27. #define MIN_ATTACHED_OBJECT_ROTATION    -360.0  // Min attached object rotation, -360.0 default
  28. #define MAX_ATTACHED_OBJECT_SIZE        100.0   // Max attached object size, set around 0 to 1000.0
  29. #define MIN_ATTACHED_OBJECT_SIZE        -100.0  // Min attached object size, set around 0 to -1000.0
  30. #define AOE_VERSION     "0.3 - March, 2014"     // Version, don't edit if not necessary!
  31. #define PAO_FILENAME    "%s_pao.txt"            // Player attached object file (%s = name) located in '\scriptfiles' folder by default
  32. #define AOE_CantEdit(%0) GetPVarInt(%0, "PAO_EAO") != 0 || GetPlayerState(%0) == PLAYER_STATE_WASTED || GetPlayerState(%0) == PLAYER_STATE_SPECTATING // Do not edit this!
  33. #define AOE_HexFormat(%0) %0 >>> 16, %0 & 0xFFFF // printf %x fix for hex, format: 0x%04x%04x - Credits to: Y_Less
  34. #define COLOR_WHITE     (0xFFFFFFFF)
  35. #define COLOR_RED       (0xFF3333FF)
  36. #define COLOR_MAGENTA   (0xFF33CCFF)
  37. #define COLOR_BLUE      (0x3366FFFF)
  38. #define COLOR_CYAN      (0x66FFCCFF)
  39. #define COLOR_GREEN     (0x00CC00FF)
  40. #define COLOR_YELLOW    (0xFFFF33FF)
  41. // =============================================================================
  42. new AOE_STR[128];
  43. new PlayerName[MAX_PLAYER_NAME+1];
  44. enum // Dialog ID enumeration
  45. {
  46.     E_AOED = 400,
  47.     E_AOED_HELP,
  48.     E_AOED_ABOUT,
  49.     E_AOED_CREATE_MODEL,
  50.     E_AOED_CREATE_BONE,
  51.     E_AOED_CREATE_SLOT,
  52.     E_AOED_CREATE_REPLACE,
  53.     E_AOED_CREATE_EDIT,
  54.     E_AOED_EDIT_SLOT,
  55.     E_AOED_REMOVE_SLOT,
  56.     E_AOED_REMOVEALL,
  57.     E_AOED_STATS_SLOT,
  58.     E_AOED_STATS,
  59.     E_AOED_DUPLICATE_SLOT1,
  60.     E_AOED_DUPLICATE_SLOT2,
  61.     E_AOED_DUPLICATE_REPLACE,
  62.     E_AOED_SET_SLOT1,
  63.     E_AOED_SET_SLOT2,
  64.     E_AOED_SET_SLOT_REPLACE,
  65.     E_AOED_SET_MODEL_SLOT,
  66.     E_AOED_SET_MODEL,
  67.     E_AOED_SET_BONE_SLOT,
  68.     E_AOED_SET_BONE,
  69.     E_AOED_SAVE,
  70.     E_AOED_SAVE_SLOT,
  71.     E_AOED_SAVE_REPLACE,
  72.     E_AOED_SAVE2,
  73.     E_AOED_SAVE2_REPLACE,
  74.     E_AOED_LOAD,
  75.     E_AOED_LOAD_SLOT,
  76.     E_AOED_LOAD_REPLACE,
  77.     E_AOED_LOAD2,
  78. }
  79. enum E_ATTACHED_OBJECT
  80. {
  81.     AO_STATUS = 0,
  82.     AO_MODEL_ID, AO_BONE_ID,
  83.     Float:AO_X, Float:AO_Y, Float:AO_Z,
  84.     Float:AO_RX, Float:AO_RY, Float:AO_RZ,
  85.     Float:AO_SX, Float:AO_SY, Float:AO_SZ,
  86.     AO_MC1, AO_MC2
  87. }
  88. new PAO[MAX_PLAYERS][MAX_PLAYER_ATTACHED_OBJECTS][E_ATTACHED_OBJECT];
  89. new AttachedObjectBones[MAX_ATTACHED_OBJECT_BONES][15+1] =
  90. {
  91.     {"Spine"}, {"Head"}, {"Left upper arm"}, {"Right upper arm"}, {"Left hand"}, {"Right hand"},
  92.     {"Left thigh"}, {"Right thigh"}, {"Left foot"}, {"Right foot"}, {"Right calf"}, {"Left calf"},
  93.     {"Left forearm"}, {"Right forearm"}, {"Left clavicle"}, {"Right clavicle"}, {"Neck"}, {"Jaw"}
  94. };
  95. // =============================================================================
  96. public OnFilterScriptInit()
  97. {
  98.     print("  [FilterScript] Loading Attached Object Editor...");
  99.     new j = GetMaxPlayers();
  100.     if(j > MAX_PLAYERS)
  101.     {
  102.         printf("  [FS:AOE] \"maxplayers\" (%d) > \"MAX_PLAYERS\" (%d)\n  >> Preferring \"MAX_PLAYERS\" for loop...", j, MAX_PLAYERS);
  103.         j = MAX_PLAYERS;
  104.     }
  105.     for(new i = 0; i < j; i++)
  106.     {
  107.         for(new x = 0; x < MAX_PLAYER_ATTACHED_OBJECTS; x++)
  108.         {
  109.             if(IsPlayerAttachedObjectSlotUsed(i, x)) PAO[i][x][AO_STATUS] = 1;
  110.             else AOE_UnsetValues(i, x);
  111.         }
  112.     }
  113.     print("  [FilterScript] Attached Object Editor for SA:MP 0.3e+ has been loaded!\n  * Current version: " #AOE_VERSION);
  114.     printf("  * Player attached objects count: %d", GetAttachedObjectsCount());
  115.     return 1;
  116. }
  117.  
  118. public OnFilterScriptExit()
  119. {
  120.     printf("  [FilterScript] Unloading Attached Object Editor...\n  * Player attached objects count: %d", GetAttachedObjectsCount());
  121.     new j = GetMaxPlayers();
  122.     if(j > MAX_PLAYERS) j = MAX_PLAYERS;
  123.     for(new i = 0; i < j; i++) if(IsPlayerConnected(i)) AOE_UnsetVars(i);
  124.     print("  [FilterScript] Attached Object Editor for SA:MP 0.3e+ has been unloaded!");
  125.     return 1;
  126. }
  127.  
  128. public OnPlayerConnect(playerid)
  129. {
  130.     for(new i = 0; i < MAX_PLAYER_ATTACHED_OBJECTS; i++)
  131.     {
  132.         if(IsPlayerAttachedObjectSlotUsed(playerid, i)) PAO[playerid][i][AO_STATUS] = 1;
  133.         else RemovePlayerAttachedObject(playerid, i), AOE_UnsetValues(playerid, i);
  134.     }
  135.     return 1;
  136. }
  137.  
  138. public OnPlayerSpawn(playerid)
  139. {
  140.     new slots = 0;
  141.     for(new i = 0; i < MAX_PLAYER_ATTACHED_OBJECTS; i++)
  142.     {
  143.         if(PAO[playerid][i][AO_STATUS] == 1)
  144.         {
  145.             RestorePlayerAttachedObject(playerid, i);
  146.             slots++;
  147.         }
  148.     }
  149.     if(0 < slots <= MAX_PLAYER_ATTACHED_OBJECTS)
  150.     {
  151.         format(AOE_STR, sizeof(AOE_STR), "* Automatically restored your attached object(s) [Total: %d]!", slots);
  152.         SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  153.     }
  154.     return 1;
  155. }
  156. // -----------------------------------------------------------------------------
  157. CMD:attachedobjecteditor(playerid, params[])
  158. {
  159.     #pragma unused params
  160.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  161.     else AOE_ShowPlayerDialog(playerid, 0, E_AOED, "Attached Object Editor", "Select", "Close");
  162.     return 1;
  163. }
  164.  
  165. CMD:aoe(playerid, params[]) return cmd_attachedobjecteditor(playerid, params);
  166.  
  167. CMD:removeattachedobjects(playerid, params[])
  168. {
  169.     #pragma unused params
  170.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  171.     else if(!GetPlayerAttachedObjectsCount(playerid))
  172.     {
  173.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  174.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  175.     }
  176.     else AOE_ShowPlayerDialog(playerid, 10, E_AOED_REMOVEALL, "Remove All Attached Object(s)", "Yes", "Cancel");
  177.     return 1;
  178. }
  179.  
  180. CMD:raos(playerid, params[]) return cmd_removeattachedobjects(playerid, params);
  181.  
  182. CMD:undeleteattachedobject(playerid, params[])
  183. {
  184.     #pragma unused params
  185.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  186.     else if(GetPlayerAttachedObjectsCount(playerid) == MAX_PLAYER_ATTACHED_OBJECTS)
  187.     {
  188.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't have more attached objects [Limit exceeded]!");
  189.         SendClientMessage(playerid, COLOR_YELLOW, "* You can only hold "#MAX_PLAYER_ATTACHED_OBJECTS" attached object(s) at a time!");
  190.         GameTextForPlayer(playerid, "~r~~h~Too many attached objects!", 3000, 3);
  191.     }
  192.     else
  193.     {
  194.         if(GetPVarType(playerid, "PAO_LAOR"))
  195.         {
  196.             new slot = GetPVarInt(playerid, "PAO_LAOR");
  197.             if(IsValidPlayerAttachedObject(playerid, slot))
  198.             {
  199.                 if(IsPlayerAttachedObjectSlotUsed(playerid, slot))
  200.                 {
  201.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you can't restore your last attached object as you had an attached object in that slot already (%d)!", slot);
  202.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  203.                     GameTextForPlayer(playerid, "~r~~h~Cannot restore attached object!", 3000, 3);
  204.                 }
  205.                 else
  206.                 {
  207.                     RestorePlayerAttachedObject(playerid, slot);
  208.                     format(AOE_STR, sizeof(AOE_STR), "* You've restored your attaced object from slot/index number %d [Model: %d - Bone: %s (%d)]!", slot, PAO[playerid][slot][AO_MODEL_ID],
  209.                     GetAttachedObjectBoneName(PAO[playerid][slot][AO_BONE_ID]), PAO[playerid][slot][AO_BONE_ID]);
  210.                     SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  211.                     format(AOE_STR, sizeof(AOE_STR), "~g~Restored your attached object~n~~w~index/number: %d~n~Model: %d - Bone: %d", slot, PAO[playerid][slot][AO_MODEL_ID], PAO[playerid][slot][AO_BONE_ID]);
  212.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  213.                 }
  214.             }
  215.             else
  216.             {
  217.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you can't restore your last attached object from slot/index number %d as it's not valid!", slot);
  218.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  219.                 GameTextForPlayer(playerid, "~r~~h~Cannot restore attached object!", 3000, 3);
  220.             }
  221.         }
  222.         else
  223.         {
  224.             SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object to restore!");
  225.             GameTextForPlayer(playerid, "~r~~h~No attached object can be restored!", 3000, 3);
  226.         }
  227.     }
  228.     return 1;
  229. }
  230.  
  231. CMD:udao(playerid, params[]) return cmd_undeleteattachedobject(playerid, params);
  232.  
  233. CMD:totalattachedobjects(playerid, params[])
  234. {
  235.     #pragma unused params
  236.     SendClientMessage(playerid, COLOR_MAGENTA, "----------------------------------------------------------------------------------------------------");
  237.     format(AOE_STR, sizeof(AOE_STR), "-- Total attached object(s) attached on you: %d", GetPlayerAttachedObjectsCount(playerid));
  238.     SendClientMessage(playerid, COLOR_CYAN, AOE_STR);
  239.     format(AOE_STR, sizeof(AOE_STR), "-- Total of all attached object(s) in server: %d", GetAttachedObjectsCount());
  240.     SendClientMessage(playerid, COLOR_CYAN, AOE_STR);
  241.     SendClientMessage(playerid, COLOR_MAGENTA, "----------------------------------------------------------------------------------------------------");
  242.     return 1;
  243. }
  244.  
  245. CMD:taos(playerid, params[]) return cmd_totalattachedobjects(playerid, params);
  246.  
  247. CMD:createattachedobject(playerid, params[])
  248. {
  249.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  250.     else if(GetPlayerAttachedObjectsCount(playerid) == MAX_PLAYER_ATTACHED_OBJECTS)
  251.     {
  252.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't have more attached object(s) [Limit exceeded]!");
  253.         SendClientMessage(playerid, COLOR_YELLOW, "* You can only hold "#MAX_PLAYER_ATTACHED_OBJECTS" attached object(s) at a time!");
  254.         GameTextForPlayer(playerid, "~r~~h~Too many attached objects!", 3000, 3);
  255.     }
  256.     else
  257.     {
  258.         new slot, model = -1, bone[15+1];
  259.         if(sscanf(params, "dD(-1)S()[16]", slot, model, bone)) AOE_ShowPlayerDialog(playerid, 5, E_AOED_CREATE_SLOT, "Create Attached Object", "Select", "Cancel");
  260.         else
  261.         {
  262.             if(IsValidAttachedObjectSlot(slot))
  263.             {
  264.                 SetPVarInt(playerid, "PAO_CAOI", slot);
  265.                 if(IsPlayerAttachedObjectSlotUsed(playerid, slot)) AOE_ShowPlayerDialog(playerid, 8, E_AOED_CREATE_REPLACE, "Create Attached Object (Replace)", "Yes", "Back");
  266.                 else
  267.                 {
  268.                     if(model == -1) AOE_ShowPlayerDialog(playerid, 3, E_AOED_CREATE_MODEL, "Create Attached Object", "Enter", "Sel Index");
  269.                     else
  270.                     {
  271.                         if(IsValidObjectModel(model))
  272.                         {
  273.                             SetPVarInt(playerid, "PAO_CAOM", model);
  274.                             if(strlen(bone))
  275.                             {
  276.                                 if(IsValidAttachedObjectBoneName(bone))
  277.                                 {
  278.                                     new boneid = GetAttachedObjectBone(bone);
  279.                                     SetPVarInt(playerid, "PAO_CAOB", boneid);
  280.                                     CreatePlayerAttachedObject(playerid, slot, model, boneid);
  281.                                     format(AOE_STR, sizeof(AOE_STR), "* Created attached object model %d at slot/index number %d [Bone: %s (%d)]!", model, slot, GetAttachedObjectBoneName(boneid), boneid);
  282.                                     SendClientMessage(playerid, COLOR_BLUE, AOE_STR);
  283.                                     format(AOE_STR, sizeof(AOE_STR), "~b~Created attached object~n~~w~index/number: %d~n~Model: %d - Bone: %d", slot, model, boneid);
  284.                                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  285.                                     AOE_ShowPlayerDialog(playerid, 9, E_AOED_CREATE_EDIT, "Create Attached Object (Edit)", "Edit", "Skip");
  286.                                 }
  287.                                 else
  288.                                 {
  289.                                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object bone number/id [%s]!", bone);
  290.                                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  291.                                     GameTextForPlayer(playerid, "~r~~h~Invalid attached object bone!", 3000, 3);
  292.                                 }
  293.                             }
  294.                             else AOE_ShowPlayerDialog(playerid, 4, E_AOED_CREATE_BONE, "Create Attached Object", "Select", "Sel Model");
  295.                         }
  296.                         else
  297.                         {
  298.                             format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid object model number/id [%d]!", model);
  299.                             SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  300.                             GameTextForPlayer(playerid, "~r~~h~Invalid object model!", 3000, 3);
  301.                         }
  302.                     }
  303.                 }
  304.             }
  305.             else
  306.             {
  307.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  308.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  309.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  310.             }
  311.         }
  312.     }
  313.     return 1;
  314. }
  315.  
  316. CMD:cao(playerid, params[]) return cmd_createattachedobject(playerid, params);
  317.  
  318. CMD:editattachedobject(playerid, params[])
  319. {
  320.     if(GetPVarInt(playerid, "PAO_EAO") == 1) CancelEdit(playerid);
  321.     else if(GetPlayerState(playerid) == PLAYER_STATE_WASTED || GetPlayerState(playerid) == PLAYER_STATE_SPECTATING)
  322.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  323.     else if(!GetPlayerAttachedObjectsCount(playerid))
  324.     {
  325.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  326.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  327.     }
  328.     else
  329.     {
  330.         new slot;
  331.         if(sscanf(params, "d", slot)) AOE_ShowPlayerDialog(playerid, 6, E_AOED_EDIT_SLOT, "Edit Attached Object", "Edit/Create", "Cancel");
  332.         else
  333.         {
  334.             if(IsValidAttachedObjectSlot(slot))
  335.             {
  336.                 if(IsPlayerAttachedObjectSlotUsed(playerid, slot))
  337.                 {
  338.                     EditAttachedObject(playerid, slot);
  339.                     SetPVarInt(playerid, "PAO_EAO", 1);
  340.                     PAO[playerid][slot][AO_STATUS] = 2;
  341.                     format(AOE_STR, sizeof(AOE_STR), "* You're now editing your attached object from slot/index number %d!", slot);
  342.                     SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  343.                     format(AOE_STR, sizeof(AOE_STR), "~g~Editing your attached object~n~~w~index/number: %d", slot);
  344.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  345.                     if(IsValidPlayerAttachedObject(playerid, slot) != 1) SendClientMessage(playerid, COLOR_RED, "Warning: This attached object has unknown data, please save it first to refresh the data!");
  346.                     if(IsPlayerInAnyVehicle(playerid))  SendClientMessage(playerid, COLOR_YELLOW, "** Hint: Use {FFFFFF}~k~~VEHICLE_ACCELERATE~{FFFF33} key to look around");
  347.                     else SendClientMessage(playerid, COLOR_YELLOW, "** Hint: Use {FFFFFF}~k~~PED_SPRINT~{FFFF33} key to look around");
  348.                     if(PAO[playerid][slot][AO_BONE_ID] == 2) SendClientMessage(playerid, COLOR_YELLOW, "** Hint: Type {FFFFFF}/HEADMOVE{FFFF33} to toggle player head movement");
  349.                 }
  350.                 else
  351.                 {
  352.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you don't have attached object at slot/index number %d!", slot);
  353.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  354.                     format(AOE_STR, sizeof(AOE_STR), "~r~~h~You have no attached object~n~~w~index/number: %d", slot);
  355.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  356.                 }
  357.             }
  358.             else
  359.             {
  360.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  361.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  362.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  363.             }
  364.         }
  365.     }
  366.     return 1;
  367. }
  368.  
  369. CMD:eao(playerid, params[]) return cmd_editattachedobject(playerid, params);
  370.  
  371. CMD:removeattachedobject(playerid, params[])
  372. {
  373.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  374.     else if(!GetPlayerAttachedObjectsCount(playerid))
  375.     {
  376.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  377.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  378.     }
  379.     else
  380.     {
  381.         new slot;
  382.         if(sscanf(params, "d", slot)) AOE_ShowPlayerDialog(playerid, 6, E_AOED_REMOVE_SLOT, "Remove Attached Object", "Remove", "Cancel");
  383.         else
  384.         {
  385.             if(IsValidAttachedObjectSlot(slot))
  386.             {
  387.                 if(IsPlayerAttachedObjectSlotUsed(playerid, slot))
  388.                 {
  389.                     if(IsValidPlayerAttachedObject(playerid, slot)) format(AOE_STR, sizeof(AOE_STR), "* You've removed your attached object from slot/index number %d! (/udao to undelete)", slot);
  390.                     else format(AOE_STR, sizeof(AOE_STR), "* You've removed your attached object from slot/index number %d", slot);
  391.                     RemovePlayerAttachedObjectEx(playerid, slot);
  392.                     SendClientMessage(playerid, COLOR_RED, AOE_STR);
  393.                     format(AOE_STR, sizeof(AOE_STR), "~r~Removed your attached object~n~~w~index/number: %d", slot);
  394.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  395.                 }
  396.                 else
  397.                 {
  398.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you don't have attached object at slot/index number %d!", slot);
  399.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  400.                     format(AOE_STR, sizeof(AOE_STR), "~r~~h~You have no attached object~n~~w~index/number: %d", slot);
  401.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  402.                 }
  403.             }
  404.             else
  405.             {
  406.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  407.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  408.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  409.             }
  410.         }
  411.     }
  412.     return 1;
  413. }
  414.  
  415. CMD:rao(playerid, params[]) return cmd_removeattachedobject(playerid, params);
  416.  
  417. CMD:refreshattachedobject(playerid, params[])
  418. {
  419.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  420.     else if(GetPlayerAttachedObjectsCount(playerid) == MAX_PLAYER_ATTACHED_OBJECTS)
  421.     {
  422.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't have more attached object(s) [Limit exceeded]!");
  423.         SendClientMessage(playerid, COLOR_YELLOW, "* You can only hold "#MAX_PLAYER_ATTACHED_OBJECTS" attached object(s) at a time!");
  424.         GameTextForPlayer(playerid, "~r~~h~Too many attached objects!", 3000, 3);
  425.     }
  426.     else
  427.     {
  428.         new targetid, slot;
  429.         if(sscanf(params, "ud", targetid, slot))
  430.         {
  431.             SendClientMessage(playerid, COLOR_MAGENTA, "* Usage: /refreshattachedobject <PlayerName/ID> <AttachedObjectSlot>");
  432.             SendClientMessage(playerid, COLOR_WHITE, "** Allows you to load another player's attached object from specified slot");
  433.             SendClientMessage(playerid, COLOR_WHITE, "** Note: if you have an attached object on specified slot already, it will be replaced!");
  434.         }
  435.         else
  436.         {
  437.             if(targetid == playerid) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't refresh your own attached object!");
  438.             else
  439.             {
  440.                 if(IsPlayerConnected(targetid))
  441.                 {
  442.                     if(IsPlayerAttachedObjectSlotUsed(targetid, slot))
  443.                     {
  444.                         RefreshPlayerAttachedObject(targetid, playerid, slot);
  445.                         GetPlayerName(targetid, PlayerName, sizeof(PlayerName));
  446.                         format(AOE_STR, sizeof(AOE_STR), "* You've refershed %s (ID:%d)'s attached object from slot/index number %d [Model: %d - Bone: %s (%d)]!",
  447.                         PlayerName, targetid, slot, PAO[targetid][slot][AO_MODEL_ID], GetAttachedObjectBoneName(PAO[targetid][slot][AO_BONE_ID]), PAO[targetid][slot][AO_BONE_ID]);
  448.                         SendClientMessage(playerid, COLOR_BLUE, AOE_STR);
  449.                         format(AOE_STR, sizeof(AOE_STR), "~p~~h~Refreshed %s's attached object", PlayerName);
  450.                         GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  451.                         GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
  452.                         format(AOE_STR, sizeof(AOE_STR), "* %s (ID:%d) has refreshed your attached object from slot/index number %d [Model: %d - Bone: %s (%d)]!",
  453.                         PlayerName, playerid, slot, PAO[targetid][slot][AO_MODEL_ID], GetAttachedObjectBoneName(PAO[targetid][slot][AO_BONE_ID]), PAO[targetid][slot][AO_BONE_ID]);
  454.                         SendClientMessage(targetid, COLOR_BLUE, AOE_STR);
  455.                         format(AOE_STR, sizeof(AOE_STR), "~p~~h~%s has refreshed your attached object", PlayerName);
  456.                         GameTextForPlayer(targetid, AOE_STR, 5000, 3);
  457.                     }
  458.                     else
  459.                     {
  460.                         format(AOE_STR, sizeof(AOE_STR), "* Sorry, %s (ID:%d) has no attached object in slot/index number %d!", PlayerName, targetid, slot);
  461.                         SendClientMessage(playerid, COLOR_WHITE, AOE_STR);
  462.                     }
  463.                 }
  464.                 else
  465.                 {
  466.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, player %d is not connected!", targetid);
  467.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  468.                 }
  469.             }
  470.         }
  471.     }
  472.     return 1;
  473. }
  474.  
  475. CMD:rpao(playerid, params[]) return cmd_refreshattachedobject(playerid, params);
  476.  
  477. CMD:saveattachedobject(playerid, params[])
  478. {
  479.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  480.     else if(!GetPlayerAttachedObjectsCount(playerid))
  481.     {
  482.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  483.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  484.     }
  485.     else
  486.     {
  487.         new slot, filename[32+1], comment[64+1];
  488.         if(sscanf(params,"dS()[25]S()[65]", slot, filename, comment)) AOE_ShowPlayerDialog(playerid, 6, E_AOED_SAVE_SLOT, "Save Attached Object", "Select", "Cancel");
  489.         else
  490.         {
  491.             if(IsValidAttachedObjectSlot(slot))
  492.             {
  493.                 if(IsPlayerAttachedObjectSlotUsed(playerid, slot))
  494.                 {
  495.                     SetPVarInt(playerid, "PAO_SAOI", slot);
  496.                     if(strlen(filename))
  497.                     {
  498.                         if(IsValidFileName(filename))
  499.                         {
  500.                             SetPVarString(playerid, "PAO_SAON", filename);
  501.                             format(filename, sizeof(filename), PAO_FILENAME, filename);
  502.                             if(fexist(filename))
  503.                             {
  504.                                 if(IsPlayerAdmin(playerid)) AOE_ShowPlayerDialog(playerid, 16, E_AOED_SAVE_REPLACE, "Save Attached Object", "Yes", "Cancel");
  505.                                 else
  506.                                 {
  507.                                     strdel(filename, strlen(filename) - (strlen(PAO_FILENAME) -2), sizeof(filename));
  508.                                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, attached object file \"%s\" already exists!", filename);
  509.                                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  510.                                     GameTextForPlayer(playerid, "~r~~h~File already exists!", 3000, 3);
  511.                                 }
  512.                             }
  513.                             else
  514.                             {
  515.                                 new filelen;
  516.                                 SendClientMessage(playerid, COLOR_WHITE, "* Saving attached object file, please wait...");
  517.                                 if(AOE_SavePlayerAttachedObject(playerid, filename, slot, comment, filelen))
  518.                                 {
  519.                                     format(AOE_STR, sizeof(AOE_STR), "** Your attached object from index %d has been saved as \"%s\" (Model: %d - Bone: %d - %d bytes)!",
  520.                                     slot, filename, PAO[playerid][slot][AO_MODEL_ID], PAO[playerid][slot][AO_BONE_ID], filelen);
  521.                                     SendClientMessage(playerid, COLOR_BLUE, AOE_STR);
  522.                                 }
  523.                                 else
  524.                                 {
  525.                                     SendClientMessage(playerid, COLOR_RED, "* Error: Invalid attached object data, save canceled");
  526.                                     GameTextForPlayer(playerid, "~r~~h~Invalid attached object data!", 3000, 3);
  527.                                 }
  528.                             }
  529.                         }
  530.                         else
  531.                         {
  532.                             strdel(filename, strlen(filename) - (strlen(PAO_FILENAME) -2), sizeof(filename));
  533.                             format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid file name [%s]!", filename);
  534.                             SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  535.                             SendClientMessage(playerid, COLOR_YELLOW, "** Valid length is greater than or equal to 1 and less than or equal to 24 characters.");
  536.                             SendClientMessage(playerid, COLOR_YELLOW, "** Valid characters are: A to Z or a to z, 0 to 9 and @, $, (, ), [, ], _, =, .");
  537.                             GameTextForPlayer(playerid, "~r~~h~Invalid file name!", 3000, 3);
  538.                         }
  539.                     }
  540.                     else AOE_ShowPlayerDialog(playerid, 13, E_AOED_SAVE, "Save Attached Object", "Save", "Sel Idx");
  541.                 }
  542.                 else
  543.                 {
  544.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you don't have attached object at slot/index number %d!", slot);
  545.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  546.                     format(AOE_STR, sizeof(AOE_STR), "~r~~h~You have no attached object~n~~w~index/number: %d", slot);
  547.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  548.                 }
  549.             }
  550.             else
  551.             {
  552.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  553.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  554.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  555.             }
  556.         }
  557.     }
  558.     return 1;
  559. }
  560.  
  561. CMD:sao(playerid, params[]) return cmd_saveattachedobject(playerid, params);
  562.  
  563. CMD:saveattachedobjects(playerid, params[])
  564. {
  565.     new PAON = GetPlayerAttachedObjectsCount(playerid);
  566.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  567.     else if(!PAON)
  568.     {
  569.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  570.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  571.     }
  572.     else if(PAON == 1)
  573.     {
  574.         SendClientMessage(playerid, COLOR_CYAN, "* You only have one attached object, redirecting you to use single save command instead...");
  575.         cmd_saveattachedobject(playerid, "");
  576.     }
  577.     else
  578.     {
  579.         new filename[32+1], comment[64+1];
  580.         if(sscanf(params, "s[25]S()[65]", filename)) AOE_ShowPlayerDialog(playerid, 13, E_AOED_SAVE2, "Save Attached Object(s) Set", "Save", "Cancel");
  581.         else
  582.         {
  583.             if(IsValidFileName(filename))
  584.             {
  585.                 SetPVarString(playerid, "PAO_SAON", filename);
  586.                 format(filename, sizeof(filename), PAO_FILENAME, filename);
  587.                 if(fexist(filename))
  588.                 {
  589.                     if(IsPlayerAdmin(playerid)) AOE_ShowPlayerDialog(playerid, 16, E_AOED_SAVE2_REPLACE, "Save Attached Object(s) Set", "Save", "Cancel");
  590.                     else
  591.                      {
  592.                         strdel(filename, strlen(filename) - (strlen(PAO_FILENAME) -2), sizeof(filename));
  593.                         format(AOE_STR, sizeof(AOE_STR), "* Sorry, attached object(s) set file \"%s\" already exists!", filename);
  594.                         SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  595.                         GameTextForPlayer(playerid, "~r~~h~File already exists!", 3000, 3);
  596.                     }
  597.                 }
  598.                 else
  599.                 {
  600.                     new slots, filelen;
  601.                     SendClientMessage(playerid, COLOR_WHITE, "* Saving attached object(s) set file, please wait...");
  602.                     slots = AOE_SavePlayerAttachedObject(playerid, filename, MAX_PLAYER_ATTACHED_OBJECTS, comment, filelen);
  603.                     if(slots)
  604.                     {
  605.                         format(AOE_STR, sizeof(AOE_STR), "** Your attached object set has been saved as \"%s\" (Total: %d - %d bytes)!", filename, slots, filelen);
  606.                         SendClientMessage(playerid, COLOR_BLUE, AOE_STR);
  607.                     }
  608.                     else SendClientMessage(playerid, COLOR_RED, "** Error: file saving was canceled because there were no valid attached object!");
  609.                 }
  610.             }
  611.             else
  612.             {
  613.                 strdel(filename, strlen(filename) - (strlen(PAO_FILENAME) -2), sizeof(filename));
  614.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid file name [%s]!", filename);
  615.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  616.                 SendClientMessage(playerid, COLOR_YELLOW, "** Valid length is greater than or equal to 1 and less than or equal to 24 characters.");
  617.                 SendClientMessage(playerid, COLOR_YELLOW, "** Valid characters are: A to Z or a to z, 0 to 9 and @, $, (, ), [, ], _, =, .");
  618.                 GameTextForPlayer(playerid, "~r~~h~Invalid file name!", 3000, 3);
  619.             }
  620.         }
  621.     }
  622.     return 1;
  623. }
  624.  
  625. CMD:saos(playerid, params[]) return cmd_saveattachedobjects(playerid, params);
  626.  
  627. CMD:loadattachedobject(playerid, params[])
  628. {
  629.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  630.     else if(GetPlayerAttachedObjectsCount(playerid) == MAX_PLAYER_ATTACHED_OBJECTS)
  631.     {
  632.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't have more attached object(s) [Limit exceeded]!");
  633.         SendClientMessage(playerid, COLOR_YELLOW, "* You can only hold "#MAX_PLAYER_ATTACHED_OBJECTS" attached objects at a time!");
  634.         GameTextForPlayer(playerid, "~r~~h~Too many attached objects!", 3000, 3);
  635.     }
  636.     else
  637.     {
  638.         new filename[32+1], slot = -1;
  639.         if(sscanf(params, "s[25]D(-1)", filename, slot)) AOE_ShowPlayerDialog(playerid, 14, E_AOED_LOAD, "Load Attached Object", "Enter", "Cancel");
  640.         else
  641.         {
  642.             if(IsValidFileName(filename))
  643.             {
  644.                 SetPVarString(playerid, "PAO_LAON", filename);
  645.                 format(filename, sizeof(filename), PAO_FILENAME, filename);
  646.                 if(fexist(filename))
  647.                 {
  648.                     if(slot == -1)
  649.                     {
  650.                         SendClientMessage(playerid, COLOR_WHITE, "* Load Attached Object: Please specify attached object index...");
  651.                         ShowPlayerDialog(playerid, E_AOED_LOAD_SLOT, DIALOG_STYLE_INPUT, "Load Attached Object", "Enter the index number of attached object in the file:", "Load", "Sel File");
  652.                     }
  653.                     else
  654.                     {
  655.                         if(IsValidAttachedObjectSlot(slot))
  656.                         {
  657.                             SetPVarInt(playerid, "PAO_LAOI", slot);
  658.                             if(IsPlayerAttachedObjectSlotUsed(playerid, slot)) AOE_ShowPlayerDialog(playerid, 15, E_AOED_LOAD_REPLACE, "Load & Replace Attached Object", "Yes", "Cancel");
  659.                             else
  660.                             {
  661.                                 new comment[64+1];
  662.                                 SendClientMessage(playerid, COLOR_WHITE, "* Loading attached object file, please wait...");
  663.                                 if(AOE_LoadPlayerAttachedObject(playerid, filename, slot, comment, sizeof(comment)))
  664.                                 {
  665.                                     format(AOE_STR, sizeof(AOE_STR), "** You've loaded attached object from file \"%s\" from slot index/number %d!", filename, slot);
  666.                                     SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  667.                                     format(AOE_STR, sizeof(AOE_STR), "** Comment: %s", comment);
  668.                                     SendClientMessage(playerid, COLOR_WHITE, AOE_STR);
  669.                                 }
  670.                                 else
  671.                                 {
  672.                                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, there is no valid attached object data found in the file \"%s\" from slot %d!", filename, slot);
  673.                                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  674.                                     PAO[playerid][slot][AO_STATUS] = 0;
  675.                                     GameTextForPlayer(playerid, "~r~~h~Attached object data not found!", 3000, 3);
  676.                                 }
  677.                             }
  678.                         }
  679.                         else
  680.                         {
  681.                             format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  682.                             SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  683.                             GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  684.                         }
  685.                     }
  686.                 }
  687.                 else
  688.                 {
  689.                     strdel(filename, strlen(filename) - (strlen(PAO_FILENAME) -2), sizeof(filename));
  690.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, attached object file \"%s\" does not exist!", filename);
  691.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  692.                     GameTextForPlayer(playerid, "~r~~h~File does not exist!", 3000, 3);
  693.                 }
  694.             }
  695.             else
  696.             {
  697.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid file name [%s]!", filename);
  698.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  699.                 SendClientMessage(playerid, COLOR_YELLOW, "** Valid length is greater than or equal to 1 and less than or equal to 24 characters.");
  700.                 SendClientMessage(playerid, COLOR_YELLOW, "** Valid characters are: A to Z or a to z, 0 to 9 and @, $, (, ), [, ], _, =, .");
  701.                 GameTextForPlayer(playerid, "~r~~h~Invalid file name!", 3000, 3);
  702.             }
  703.         }
  704.     }
  705.     return 1;
  706. }
  707.  
  708. CMD:lao(playerid, params[]) return cmd_loadattachedobject(playerid, params);
  709.  
  710. CMD:loadattachedobjects(playerid, params[])
  711. {
  712.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command when editing an attached object!");
  713.     else if(GetPlayerAttachedObjectsCount(playerid) == MAX_PLAYER_ATTACHED_OBJECTS)
  714.     {
  715.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't have more attached object(s) [Limit exceeded]!");
  716.         SendClientMessage(playerid, COLOR_YELLOW, "* You can only hold "#MAX_PLAYER_ATTACHED_OBJECTS" attached objects at a time!");
  717.         GameTextForPlayer(playerid, "~r~~h~Too many attached objects!", 3000, 3);
  718.     }
  719.     else
  720.     {
  721.         new filename[32+1];
  722.         if(sscanf(params, "s[25]", filename)) AOE_ShowPlayerDialog(playerid, 14, E_AOED_LOAD2, "Load Attached Object(s) Set", "Load", "Cancel");
  723.         else
  724.         {
  725.             if(IsValidFileName(filename))
  726.             {
  727.                 format(filename, sizeof(filename), PAO_FILENAME, filename);
  728.                 if(fexist(filename))
  729.                 {
  730.                     new slots = 0, comment[64+1];
  731.                     SendClientMessage(playerid, COLOR_WHITE, "* Loading attached object(s) set file, please wait...");
  732.                     slots = AOE_LoadPlayerAttachedObject(playerid, filename, MAX_PLAYER_ATTACHED_OBJECTS, comment, sizeof(comment));
  733.                     if(slots)
  734.                     {
  735.                         format(AOE_STR, sizeof(AOE_STR), "** You've loaded attached object(s) set from file \"%s\" (Total: %d)!", filename, slots);
  736.                         SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  737.                         format(AOE_STR, sizeof(AOE_STR), "** Comment: %s", comment);
  738.                         SendClientMessage(playerid, COLOR_WHITE, AOE_STR);
  739.                     }
  740.                     else
  741.                     {
  742.                         format(AOE_STR, sizeof(AOE_STR), "* Sorry, there is no valid attached object data found in the file \"%s\"!", filename);
  743.                         SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  744.                         GameTextForPlayer(playerid, "~r~~h~Attached object data not found!", 3000, 3);
  745.                     }
  746.                 }
  747.                 else
  748.                 {
  749.                     strdel(filename, strlen(filename) - (strlen(PAO_FILENAME) -2), sizeof(filename));
  750.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, attached object file \"%s\" does not exist!", filename);
  751.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  752.                     GameTextForPlayer(playerid, "~r~~h~File does not exist!", 3000, 3);
  753.                 }
  754.             }
  755.             else
  756.             {
  757.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid file name [%s]!", filename);
  758.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  759.                 SendClientMessage(playerid, COLOR_YELLOW, "** Valid length is greater than or equal to 1 and less than or equal to 24 characters.");
  760.                 SendClientMessage(playerid, COLOR_YELLOW, "** Valid characters are: A to Z or a to z, 0 to 9 and @, $, (, ), [, ], _, =, .");
  761.                 GameTextForPlayer(playerid, "~r~~h~Invalid file name!", 3000, 3);
  762.             }
  763.         }
  764.     }
  765.     return 1;
  766. }
  767.  
  768. CMD:laos(playerid, params[]) return cmd_loadattachedobjects(playerid, params);
  769.  
  770. CMD:deleteattachedobjectfile(playerid, params[])
  771. {
  772.     if(IsPlayerAdmin(playerid))
  773.     {
  774.         new filename[32+1];
  775.         if(sscanf(params, "s[25]", filename))
  776.         {
  777.             SendClientMessage(playerid, COLOR_MAGENTA, "* Usage: /deleteattachedobjectfile <AttachedObjectFile>");
  778.             SendClientMessage(playerid, COLOR_WHITE, "** Allows an admin to DELETE an existing attached object file PERMANENTLY");
  779.             SendClientMessage(playerid, COLOR_WHITE, "** This command doesn't require you to type the format of the file");
  780.         }
  781.         else
  782.         {
  783.             if(IsValidFileName(filename))
  784.             {
  785.                 format(filename, sizeof(filename), PAO_FILENAME, filename);
  786.                 if(fexist(filename))
  787.                 {
  788.                     if(fremove(filename)) format(AOE_STR, sizeof(AOE_STR), "* You've deleted attached object file \"{CCFFFF}%s{%06x}\"!", filename, COLOR_RED >>> 8);
  789.                     else format(AOE_STR, sizeof(AOE_STR), "* Failed to delete attached object file \"{CCFFFF}%s{%06x}\"", filename, COLOR_RED >>> 8);
  790.                     SendClientMessage(playerid, COLOR_RED, AOE_STR);
  791.                 }
  792.                 else
  793.                 {
  794.                     strdel(filename, strlen(filename) - (strlen(PAO_FILENAME) -2), sizeof(filename));
  795.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, attached object file \"%s\" does not exist!", filename);
  796.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  797.                     GameTextForPlayer(playerid, "~r~~h~File does not exist!", 3000, 3);
  798.                 }
  799.             }
  800.             else
  801.             {
  802.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid file name [%s]!", filename);
  803.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  804.                 SendClientMessage(playerid, COLOR_YELLOW, "** Valid length is greater than or equal to 1 and less than or equal to 24 characters.");
  805.                 SendClientMessage(playerid, COLOR_YELLOW, "** Valid characters are: A to Z or a to z, 0 to 9 and @, $, (, ), [, ], _, =, .");
  806.                 GameTextForPlayer(playerid, "~r~~h~Invalid file name!", 3000, 3);
  807.             }
  808.         }
  809.     }
  810.     else SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, only Admin can delete player attached object file!");
  811.     return 1;
  812. }
  813.  
  814. CMD:daof(playerid, params[]) return cmd_deleteattachedobjectfile(playerid, params);
  815.  
  816. CMD:attachedobjectstats(playerid, params[])
  817. {
  818.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  819.     else    {
  820.         new slot, targetid = -1;
  821.         if(sscanf(params, "dU(-1)", slot, targetid))
  822.         {
  823.             if(targetid == -1 && GetPlayerAttachedObjectsCount(playerid) >= 1)
  824.                 AOE_ShowPlayerDialog(playerid, 6, E_AOED_STATS_SLOT, "Attached Object Stats", "Select", "Cancel");
  825.             else
  826.             {
  827.                 SendClientMessage(playerid, COLOR_MAGENTA, "* Usage: /attachedobjectstats <AttachedObjectSlot> <Optional:Player>");
  828.                 SendClientMessage(playerid, COLOR_WHITE, "** Allows you to view a player's attached object's stats");
  829.                 SendClientMessage(playerid, COLOR_WHITE, "** If you don't specify the player, then it will show yours.");
  830.             }
  831.         }
  832.         else
  833.         {
  834.             SetPVarInt(playerid, "PAO_AOSI", slot);
  835.             if(IsValidAttachedObjectSlot(slot))
  836.             {
  837.                 if(targetid == -1) targetid = playerid;
  838.                 if(IsPlayerConnected(targetid))
  839.                 {
  840.                     SetPVarInt(playerid, "PAO_AOSU", targetid);
  841.                     GetPlayerName(targetid, PlayerName, sizeof(PlayerName));
  842.                     if(GetPlayerAttachedObjectsCount(targetid))
  843.                     {
  844.                         if(IsPlayerAttachedObjectSlotUsed(targetid, slot))
  845.                         {
  846.                             if(targetid == playerid) format(AOE_STR, sizeof(AOE_STR), "Your Attached Object Stats (%d)", slot);
  847.                             else format(AOE_STR, sizeof(AOE_STR), "%s's Attached Object Stats (%d)", PlayerName, slot);
  848.                             AOE_ShowPlayerDialog(playerid, 7, E_AOED_STATS, AOE_STR, "Print", "Close");
  849.                         }
  850.                         else
  851.                         {
  852.                             if(targetid == playerid) format(AOE_STR, sizeof(AOE_STR), "* Sorry, you have no attached object at slot/index number %d!", slot);
  853.                             else format(AOE_STR, sizeof(AOE_STR), "* Sorry, %s has no attached object at slot/index number %d!", PlayerName, slot);
  854.                             SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  855.                             format(AOE_STR, sizeof(AOE_STR), "~r~~h~Unknown attached object~n~~w~index/number: %d", slot);
  856.                             GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  857.                         }
  858.                     }
  859.                     else
  860.                     {
  861.                         if(targetid == playerid)
  862.                         {
  863.                             SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you have no attached object!");
  864.                             GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  865.                         }
  866.                         else
  867.                         {
  868.                             format(AOE_STR, sizeof(AOE_STR), "* Sorry, %s has no attached object!", PlayerName);
  869.                             SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  870.                             format(AOE_STR, sizeof(AOE_STR), "~r~~h~%s has no attached object", PlayerName);
  871.                             GameTextForPlayer(playerid, AOE_STR, 3000, 3);
  872.                         }
  873.                     }
  874.                 }
  875.                 else
  876.                 {
  877.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, player %d is not connected!", targetid);
  878.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  879.                 }
  880.             }
  881.             else
  882.             {
  883.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  884.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  885.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  886.             }
  887.         }
  888.     }
  889.     return 1;
  890. }
  891.  
  892. CMD:aos(playerid, params[]) return cmd_attachedobjectstats(playerid, params);
  893.  
  894. CMD:duplicateattachedobject(playerid, params[])
  895. {
  896.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  897.     else if(!GetPlayerAttachedObjectsCount(playerid))
  898.     {
  899.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  900.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  901.     }
  902.     else
  903.     {
  904.         new fromslot, asslot = -1; // This is "as slot"
  905.         if(sscanf(params, "dD(-1)", fromslot, asslot)) AOE_ShowPlayerDialog(playerid, 6, E_AOED_DUPLICATE_SLOT1, "Duplicate Attached Object Index (1)", "Select", "Cancel");
  906.         else
  907.         {
  908.             if(IsValidAttachedObjectSlot(fromslot))
  909.             {
  910.                 SetPVarInt(playerid, "PAO_DAOI1", fromslot);
  911.                 if(IsPlayerAttachedObjectSlotUsed(playerid, fromslot))
  912.                 {
  913.                     if(asslot == -1) AOE_ShowPlayerDialog(playerid, 5, E_AOED_DUPLICATE_SLOT2, "Duplicate Attached Object Index (2)", "Select", "Sel Idx1");
  914.                     else
  915.                     {
  916.                         if(IsValidAttachedObjectSlot(asslot))
  917.                         {
  918.                             SetPVarInt(playerid, "PAO_DAOI2", asslot);
  919.                             if(fromslot == asslot)
  920.                             {
  921.                                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you can't duplicate your attached object from slot/index number %d to the same slot (%d) as it's already there?!!", fromslot, asslot);
  922.                                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  923.                                 GameTextForPlayer(playerid, "~y~DOH!", 2500, 3);
  924.                             }
  925.                             else
  926.                             {
  927.                                 if(IsPlayerAttachedObjectSlotUsed(playerid, asslot)) AOE_ShowPlayerDialog(playerid, 11, E_AOED_DUPLICATE_REPLACE, "Duplicate Attached Object (Replace)", "Yes", "Sel Idx2");
  928.                                 else
  929.                                 {
  930.                                     DuplicatePlayerAttachedObject(playerid, fromslot, asslot);
  931.                                     format(AOE_STR, sizeof(AOE_STR), "* Duplicated your attached object from slot/index number %d to %d!", fromslot, asslot);
  932.                                     SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  933.                                     format(AOE_STR, sizeof(AOE_STR), "~g~Attached object duplicated~n~~w~index/number:~n~%d to %d", fromslot, asslot);
  934.                                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  935.                                 }
  936.                             }
  937.                         }
  938.                         else
  939.                         {
  940.                             format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index (2) number [%d]!", asslot);
  941.                             SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  942.                             GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  943.                         }
  944.                     }
  945.                 }
  946.                 else
  947.                 {
  948.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you don't have attached object at slot/index number %d!", fromslot);
  949.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  950.                     format(AOE_STR, sizeof(AOE_STR), "~r~~h~You have no attached object~n~~w~index/number: %d", fromslot);
  951.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  952.                 }
  953.             }
  954.             else
  955.             {
  956.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index (1) number [%d]!", fromslot);
  957.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  958.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  959.             }
  960.         }
  961.     }
  962.     return 1;
  963. }
  964.  
  965. CMD:dao(playerid, params[]) return cmd_duplicateattachedobject(playerid, params);
  966.  
  967. CMD:setattachedobjectindex(playerid, params[])
  968. {
  969.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  970.     else if(!GetPlayerAttachedObjectsCount(playerid))
  971.     {
  972.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  973.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  974.     }
  975.     else
  976.     {
  977.         new slot, newslot = -1;
  978.         if(sscanf(params, "dD(-1)", slot, newslot)) AOE_ShowPlayerDialog(playerid, 6, E_AOED_SET_SLOT1, "Set Attached Object Index (1)", "Select", "Cancel");
  979.         else
  980.         {
  981.             if(IsValidAttachedObjectSlot(slot))
  982.             {
  983.                 if(IsPlayerAttachedObjectSlotUsed(playerid, slot))
  984.                 {
  985.                     SetPVarInt(playerid, "PAO_SAOI1", slot);
  986.                     if(newslot == -1) AOE_ShowPlayerDialog(playerid, 5, E_AOED_SET_SLOT2, "Set Attached Object Index (2)", "Select", "Sel Idx1");
  987.                     else
  988.                     {
  989.                         if(IsValidAttachedObjectSlot(newslot))
  990.                         {
  991.                             if(slot == newslot)
  992.                             {
  993.                                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you can't move your attached object from slot/index number %d to the same slot (%d) as it's already there?!!", slot, newslot);
  994.                                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  995.                                 GameTextForPlayer(playerid, "~y~DOH!", 2500, 3);
  996.                             }
  997.                             else
  998.                             {
  999.                                 SetPVarInt(playerid, "PAO_SAOI2", newslot);
  1000.                                 if(IsPlayerAttachedObjectSlotUsed(playerid, newslot)) AOE_ShowPlayerDialog(playerid, 12, E_AOED_SET_SLOT_REPLACE, "Set Attached Object Index (Replace)", "Yes", "Sel Idx2");
  1001.                                 else
  1002.                                 {
  1003.                                     MovePlayerAttachedObjectIndex(playerid, slot, newslot);
  1004.                                     format(AOE_STR, sizeof(AOE_STR), "* Moved your attached object from slot/index number %d to %d!", slot, newslot);
  1005.                                     SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  1006.                                     format(AOE_STR, sizeof(AOE_STR), "~g~Attached object moved~n~~w~index/number:~n~%d to %d", slot, newslot);
  1007.                                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1008.                                 }
  1009.                             }
  1010.                         }
  1011.                         else
  1012.                         {
  1013.                             format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", newslot);
  1014.                             SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1015.                             GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  1016.                         }
  1017.                     }
  1018.                 }
  1019.                 else
  1020.                 {
  1021.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you don't have attached object at slot/index number %d!", slot);
  1022.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1023.                     format(AOE_STR, sizeof(AOE_STR), "~r~~h~You have no attached object~n~~w~index/number: %d", slot);
  1024.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1025.                 }
  1026.             }
  1027.             else
  1028.             {
  1029.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  1030.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1031.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  1032.             }
  1033.         }
  1034.     }
  1035.     return 1;
  1036. }
  1037.  
  1038. CMD:setattachedobjectslot(playerid, params[]) return cmd_setattachedobjectindex(playerid, params);
  1039.  
  1040. CMD:saoi(playerid, params[]) return cmd_setattachedobjectindex(playerid, params);
  1041.  
  1042. CMD:setattachedobjectmodel(playerid, params[])
  1043. {
  1044.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  1045.     else if(!GetPlayerAttachedObjectsCount(playerid))
  1046.     {
  1047.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  1048.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  1049.     }
  1050.     else
  1051.     {
  1052.         new slot, newmodel = -1;
  1053.         if(sscanf(params, "dD(-1)", slot, newmodel)) AOE_ShowPlayerDialog(playerid, 6, E_AOED_SET_MODEL_SLOT, "Set Attached Object Model", "Select", "Cancel");
  1054.         else
  1055.         {
  1056.             if(IsValidAttachedObjectSlot(slot))
  1057.             {
  1058.                 if(IsPlayerAttachedObjectSlotUsed(playerid, slot))
  1059.                 {
  1060.                     SetPVarInt(playerid, "PAO_SAOMI", slot);
  1061.                     if(newmodel == -1) AOE_ShowPlayerDialog(playerid, 3, E_AOED_SET_MODEL, "Set Attached Object Model", "Enter", "Sel Idx");
  1062.                     else
  1063.                     {
  1064.                         if(IsValidObjectModel(newmodel))
  1065.                         {
  1066.                             if(newmodel == PAO[playerid][slot][AO_MODEL_ID])
  1067.                             {
  1068.                                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you can't change this attached object (SID:%d) model from %d to the same model (%d)!!", slot, PAO[playerid][slot][AO_MODEL_ID], newmodel);
  1069.                                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1070.                                 GameTextForPlayer(playerid, "~y~DOH!", 2500, 3);
  1071.                             }
  1072.                             else
  1073.                             {
  1074.                                 UpdatePlayerAttachedObject(playerid, slot, newmodel, PAO[playerid][slot][AO_BONE_ID]);
  1075.                                 format(AOE_STR, sizeof(AOE_STR), "* Updated your attached object model to %d at slot/index number %d!", newmodel, slot);
  1076.                                 SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  1077.                                 format(AOE_STR, sizeof(AOE_STR), "~g~Attached object model updated~n~~w~%d (SID:%d)", newmodel, slot);
  1078.                                 GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1079.                             }
  1080.                         }
  1081.                         else
  1082.                         {
  1083.                             format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid object model number/id [%d]!", newmodel);
  1084.                             SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1085.                             GameTextForPlayer(playerid, "~r~~h~Invalid object model!", 3000, 3);
  1086.                         }
  1087.                     }
  1088.                 }
  1089.                 else
  1090.                 {
  1091.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you don't have attached object at slot/index number %d!", slot);
  1092.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1093.                     format(AOE_STR, sizeof(AOE_STR), "~r~~h~You have no attached object~n~~w~index/number: %d", slot);
  1094.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1095.                 }
  1096.                
  1097.             }
  1098.             else
  1099.             {
  1100.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  1101.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1102.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  1103.             }
  1104.         }
  1105.     }
  1106.     return 1;
  1107. }
  1108.  
  1109. CMD:saom(playerid, params[]) return cmd_setattachedobjectmodel(playerid, params);
  1110.  
  1111. CMD:setattachedobjectbone(playerid, params[])
  1112. {
  1113.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  1114.     else if(!GetPlayerAttachedObjectsCount(playerid))
  1115.     {
  1116.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  1117.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  1118.     }
  1119.     else
  1120.     {
  1121.         new slot, newbone[15+1];
  1122.         if(sscanf(params, "dS()[16]", slot, newbone)) AOE_ShowPlayerDialog(playerid, 6, E_AOED_SET_BONE_SLOT, "Set Attached Object Bone", "Select", "Cancel");
  1123.         else
  1124.         {
  1125.             if(IsValidAttachedObjectSlot(slot))
  1126.             {
  1127.                 if(IsPlayerAttachedObjectSlotUsed(playerid, slot))
  1128.                 {
  1129.                     SetPVarInt(playerid, "PAO_SAOBI", slot);
  1130.                     if(strlen(newbone))
  1131.                     {
  1132.                         if(IsValidAttachedObjectBoneName(newbone))
  1133.                         {
  1134.                             new newboneid = GetAttachedObjectBone(newbone);
  1135.                             if(newboneid == PAO[playerid][slot][AO_BONE_ID])
  1136.                             {
  1137.                                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you can't change this attached object (SID:%d) bone from %s to the same bone (%d)!!", slot, newbone, PAO[playerid][slot][AO_BONE_ID]);
  1138.                                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1139.                                 GameTextForPlayer(playerid, "~y~DOH!", 2500, 3);
  1140.                             }
  1141.                             else
  1142.                             {
  1143.                                 UpdatePlayerAttachedObject(playerid, slot, PAO[playerid][slot][AO_MODEL_ID], newboneid);
  1144.                                 format(AOE_STR, sizeof(AOE_STR), "* Updated your attached object bone to %d (%s) at slot/index number %d!", newboneid, newbone, slot);
  1145.                                 SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  1146.                                 format(AOE_STR, sizeof(AOE_STR), "~g~Attached object bone updated~n~~w~%d (SID:%d)", newboneid, slot);
  1147.                                 GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1148.                             }
  1149.                         }
  1150.                         else
  1151.                         {
  1152.                             format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object bone [%s]!", newbone);
  1153.                             SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1154.                             GameTextForPlayer(playerid, "~r~~h~Invalid attached object bone!", 3000, 3);
  1155.                         }
  1156.                     }
  1157.                     else AOE_ShowPlayerDialog(playerid, 4, E_AOED_SET_BONE, "Set Attached Object", "Set", "Sel Idx");
  1158.                 }
  1159.                 else
  1160.                 {
  1161.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you don't have attached object at slot/index number %d!", slot);
  1162.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1163.                     format(AOE_STR, sizeof(AOE_STR), "~r~~h~You have no attached object~n~~w~index/number: %d", slot);
  1164.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1165.                 }
  1166.             }
  1167.             else
  1168.             {
  1169.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  1170.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1171.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  1172.             }
  1173.         }
  1174.     }
  1175.     return 1;
  1176. }
  1177.  
  1178. CMD:saob(playerid, params[]) return cmd_setattachedobjectbone(playerid, params);
  1179.  
  1180. CMD:setattachedobjectoffsetx(playerid, params[])
  1181. {
  1182.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  1183.     else if(!GetPlayerAttachedObjectsCount(playerid))
  1184.     {
  1185.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  1186.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  1187.     }
  1188.     else
  1189.     {
  1190.         new slot, Float:newoffsetx;
  1191.         if(sscanf(params, "df", slot, newoffsetx))
  1192.         {
  1193.             SendClientMessage(playerid, COLOR_MAGENTA, "* Usage: /setattachedobjectoffsetx <AttachedObjectSlot> <Float:OffsetX>");
  1194.             SendClientMessage(playerid, COLOR_WHITE, "** Allows you to set your attached object position (OffsetX) with specified parameters");
  1195.         }
  1196.         else
  1197.         {
  1198.             if(IsValidAttachedObjectSlot(slot))
  1199.             {
  1200.                 if(IsPlayerAttachedObjectSlotUsed(playerid, slot))
  1201.                 {
  1202.                     if(MIN_ATTACHED_OBJECT_OFFSET <= newoffsetx <= MAX_ATTACHED_OBJECT_OFFSET)
  1203.                     {
  1204.                         UpdatePlayerAttachedObjectEx(playerid, slot, PAO[playerid][slot][AO_MODEL_ID], PAO[playerid][slot][AO_BONE_ID], newoffsetx, PAO[playerid][slot][AO_Y], PAO[playerid][slot][AO_Z],
  1205.                         PAO[playerid][slot][AO_RX], PAO[playerid][slot][AO_RY], PAO[playerid][slot][AO_RZ], PAO[playerid][slot][AO_SX], PAO[playerid][slot][AO_SY], PAO[playerid][slot][AO_SZ], PAO[playerid][slot][AO_MC1], PAO[playerid][slot][AO_MC2]);
  1206.                         format(AOE_STR, sizeof(AOE_STR), "* Updated your attached object position (OffsetX) to %.2f at slot/index number %d!", newoffsetx, slot);
  1207.                         SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  1208.                         GameTextForPlayer(playerid, "~g~Attached object position updated!", 3000, 3);
  1209.                     }
  1210.                     else
  1211.                     {
  1212.                         format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object offset(X) value [%.f]!", newoffsetx);
  1213.                         SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1214.                         SendClientMessage(playerid, COLOR_YELLOW, "** Allowed float (OffsetX) value is larger than "#MIN_ATTACHED_OBJECT_OFFSET" and less than "#MAX_ATTACHED_OBJECT_OFFSET);
  1215.                         GameTextForPlayer(playerid, "~r~~h~Invalid attached object offset value!", 3000, 3);
  1216.                     }
  1217.                 }
  1218.                 else
  1219.                 {
  1220.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you don't have attached object at slot/index number %d!", slot);
  1221.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1222.                     format(AOE_STR, sizeof(AOE_STR), "~r~~h~You have no attached object~n~~w~index/number: %d", slot);
  1223.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1224.                 }
  1225.             }
  1226.             else
  1227.             {
  1228.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  1229.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1230.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  1231.             }
  1232.         }
  1233.     }
  1234.     return 1;
  1235. }
  1236.  
  1237. CMD:saoox(playerid, params[]) return cmd_setattachedobjectoffsetx(playerid, params);
  1238.  
  1239. CMD:setattachedobjectoffsety(playerid, params[])
  1240. {
  1241.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  1242.     else if(!GetPlayerAttachedObjectsCount(playerid))
  1243.     {
  1244.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  1245.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  1246.     }
  1247.     else
  1248.     {
  1249.         new slot, Float:newoffsety;
  1250.         if(sscanf(params, "df", slot, newoffsety))
  1251.         {
  1252.             SendClientMessage(playerid, COLOR_MAGENTA, "* Usage: /setattachedobjectoffsety <AttachedObjectSlot> <Float:OffsetY>");
  1253.             SendClientMessage(playerid, COLOR_WHITE, "** Allows you to set your attached object position (OffsetY) with specified parameters");
  1254.         }
  1255.         else
  1256.         {
  1257.             if(IsValidAttachedObjectSlot(slot))
  1258.             {
  1259.                 if(IsPlayerAttachedObjectSlotUsed(playerid, slot))
  1260.                 {
  1261.                     if(MIN_ATTACHED_OBJECT_OFFSET <= newoffsety <= MAX_ATTACHED_OBJECT_OFFSET)
  1262.                     {
  1263.                         UpdatePlayerAttachedObjectEx(playerid, slot, PAO[playerid][slot][AO_MODEL_ID], PAO[playerid][slot][AO_BONE_ID], PAO[playerid][slot][AO_X], newoffsety, PAO[playerid][slot][AO_Z],
  1264.                         PAO[playerid][slot][AO_RX], PAO[playerid][slot][AO_RY], PAO[playerid][slot][AO_RZ], PAO[playerid][slot][AO_SX], PAO[playerid][slot][AO_SY], PAO[playerid][slot][AO_SZ], PAO[playerid][slot][AO_MC1], PAO[playerid][slot][AO_MC2]);
  1265.                         format(AOE_STR, sizeof(AOE_STR), "* Updated your attached object position (OffsetY) to %.2f at slot/index number %d!", newoffsety, slot);
  1266.                         SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  1267.                         GameTextForPlayer(playerid, "~g~Attached object position updated!", 3000, 3);
  1268.                     }
  1269.                     else
  1270.                     {
  1271.                         format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object offset(Y) value [%.f]!", newoffsety);
  1272.                         SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1273.                         SendClientMessage(playerid, COLOR_YELLOW, "** Allowed float (OffsetY) value is larger than "#MIN_ATTACHED_OBJECT_OFFSET" and less than "#MAX_ATTACHED_OBJECT_OFFSET);
  1274.                         GameTextForPlayer(playerid, "~r~~h~Invalid attached object offset value!", 3000, 3);
  1275.                     }
  1276.                 }
  1277.                 else
  1278.                 {
  1279.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you don't have attached object at slot/index number %d!", slot);
  1280.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1281.                     format(AOE_STR, sizeof(AOE_STR), "~r~~h~You have no attached object~n~~w~index/number: %d", slot);
  1282.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1283.                 }
  1284.             }
  1285.             else
  1286.             {
  1287.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  1288.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1289.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  1290.             }
  1291.         }
  1292.     }
  1293.     return 1;
  1294. }
  1295.  
  1296. CMD:saooy(playerid, params[]) return cmd_setattachedobjectoffsety(playerid, params);
  1297.  
  1298. CMD:setattachedobjectoffsetz(playerid, params[])
  1299. {
  1300.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  1301.     else if(!GetPlayerAttachedObjectsCount(playerid))
  1302.     {
  1303.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  1304.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  1305.     }
  1306.     else
  1307.     {
  1308.         new slot, Float:newoffsetz;
  1309.         if(sscanf(params, "df", slot, newoffsetz))
  1310.         {
  1311.             SendClientMessage(playerid, COLOR_MAGENTA, "* Usage: /setattachedobjectoffsetz <AttachedObjectSlot> <Float:OffsetZ>");
  1312.             SendClientMessage(playerid, COLOR_WHITE, "** Allows you to set your attached object position (OffsetZ) with specified parameters");
  1313.         }
  1314.         else
  1315.         {
  1316.             if(IsValidAttachedObjectSlot(slot))
  1317.             {
  1318.                 if(IsPlayerAttachedObjectSlotUsed(playerid, slot))
  1319.                 {
  1320.                     if(MIN_ATTACHED_OBJECT_OFFSET <= newoffsetz <= MAX_ATTACHED_OBJECT_OFFSET)
  1321.                     {
  1322.                         UpdatePlayerAttachedObjectEx(playerid, slot, PAO[playerid][slot][AO_MODEL_ID], PAO[playerid][slot][AO_BONE_ID], PAO[playerid][slot][AO_X], PAO[playerid][slot][AO_Y], newoffsetz,
  1323.                         PAO[playerid][slot][AO_RX], PAO[playerid][slot][AO_RY], PAO[playerid][slot][AO_RZ], PAO[playerid][slot][AO_SX], PAO[playerid][slot][AO_SY], PAO[playerid][slot][AO_SZ], PAO[playerid][slot][AO_MC1], PAO[playerid][slot][AO_MC2]);
  1324.                         format(AOE_STR, sizeof(AOE_STR), "* Updated your attached object position (OffsetZ) to %.2f at slot/index number %d!", newoffsetz, slot);
  1325.                         SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  1326.                         GameTextForPlayer(playerid, "~g~Attached object position updated!", 3000, 3);
  1327.                     }
  1328.                     else
  1329.                     {
  1330.                         format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object offset(Z) value [%.f]!", newoffsetz);
  1331.                         SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1332.                         SendClientMessage(playerid, COLOR_YELLOW, "** Allowed float (OffsetZ) value is larger than "#MIN_ATTACHED_OBJECT_OFFSET" and less than "#MAX_ATTACHED_OBJECT_OFFSET);
  1333.                         GameTextForPlayer(playerid, "~r~~h~Invalid attached object offset value!", 3000, 3);
  1334.                     }
  1335.                 }
  1336.                 else
  1337.                 {
  1338.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you don't have attached object at slot/index number %d!", slot);
  1339.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1340.                     format(AOE_STR, sizeof(AOE_STR), "~r~~h~You have no attached object~n~~w~index/number: %d", slot);
  1341.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1342.                 }
  1343.             }
  1344.             else
  1345.             {
  1346.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  1347.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1348.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  1349.             }
  1350.         }
  1351.     }
  1352.     return 1;
  1353. }
  1354.  
  1355. CMD:saooz(playerid, params[]) return cmd_setattachedobjectoffsetz(playerid, params);
  1356.  
  1357. CMD:setattachedobjectrotx(playerid, params[])
  1358. {
  1359.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  1360.     else if(!GetPlayerAttachedObjectsCount(playerid))
  1361.     {
  1362.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  1363.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  1364.     }
  1365.     else
  1366.     {
  1367.         new slot, Float:newrotx;
  1368.         if(sscanf(params, "df", slot, newrotx))
  1369.         {
  1370.             SendClientMessage(playerid, COLOR_MAGENTA, "* Usage: /setattachedobjectrotx <AttachedObjectSlot> <Float:RotX>");
  1371.             SendClientMessage(playerid, COLOR_WHITE, "** Allows you to set your attached object rotation (RotX) with specified parameters");
  1372.         }
  1373.         else
  1374.         {
  1375.             if(IsValidAttachedObjectSlot(slot))
  1376.             {
  1377.                 if(IsPlayerAttachedObjectSlotUsed(playerid, slot))
  1378.                 {
  1379.                     if(MIN_ATTACHED_OBJECT_ROTATION <= newrotx <= MAX_ATTACHED_OBJECT_ROTATION)
  1380.                     {
  1381.                         UpdatePlayerAttachedObjectEx(playerid, slot, PAO[playerid][slot][AO_MODEL_ID], PAO[playerid][slot][AO_BONE_ID], PAO[playerid][slot][AO_X], PAO[playerid][slot][AO_Y], PAO[playerid][slot][AO_Z],
  1382.                         newrotx, PAO[playerid][slot][AO_RY], PAO[playerid][slot][AO_RZ], PAO[playerid][slot][AO_SX], PAO[playerid][slot][AO_SY], PAO[playerid][slot][AO_SZ], PAO[playerid][slot][AO_MC1], PAO[playerid][slot][AO_MC2]);
  1383.                         format(AOE_STR, sizeof(AOE_STR), "* Updated your attached object rotation (RotX) to %.2f at slot/index number %d!", newrotx, slot);
  1384.                         SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  1385.                         GameTextForPlayer(playerid, "~g~Attached object rotation updated!", 3000, 3);
  1386.                     }
  1387.                     else
  1388.                     {
  1389.                         format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object rotation(X) value [%.f]!", newrotx);
  1390.                         SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1391.                         SendClientMessage(playerid, COLOR_YELLOW, "** Allowed float (RotX) value is larger than "#MIN_ATTACHED_OBJECT_ROTATION" and less than "#MAX_ATTACHED_OBJECT_ROTATION);
  1392.                         GameTextForPlayer(playerid, "~r~~h~Invalid attached object rotation value!", 3000, 3);
  1393.                     }
  1394.                 }
  1395.                 else
  1396.                 {
  1397.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you don't have attached object at slot/index number %d!", slot);
  1398.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1399.                     format(AOE_STR, sizeof(AOE_STR), "~r~~h~You have no attached object~n~~w~index/number: %d", slot);
  1400.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1401.                 }
  1402.             }
  1403.             else
  1404.             {
  1405.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  1406.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1407.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  1408.             }
  1409.         }
  1410.     }
  1411.     return 1;
  1412. }
  1413.  
  1414. CMD:saorx(playerid, params[]) return cmd_setattachedobjectrotx(playerid, params);
  1415.  
  1416. CMD:setattachedobjectroty(playerid, params[])
  1417. {
  1418.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  1419.     else if(!GetPlayerAttachedObjectsCount(playerid))
  1420.     {
  1421.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  1422.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  1423.     }
  1424.     else
  1425.     {
  1426.         new slot, Float:newroty;
  1427.         if(sscanf(params, "df", slot, newroty))
  1428.         {
  1429.             SendClientMessage(playerid, COLOR_MAGENTA, "* Usage: /setattachedobjectroty <AttachedObjectSlot> <Float:RotY>");
  1430.             SendClientMessage(playerid, COLOR_WHITE, "** Allows you to set your attached object rotation (RotY) with specified parameters");
  1431.         }
  1432.         else
  1433.         {
  1434.             if(IsValidAttachedObjectSlot(slot))
  1435.             {
  1436.                 if(IsPlayerAttachedObjectSlotUsed(playerid, slot))
  1437.                 {
  1438.                     if(MIN_ATTACHED_OBJECT_ROTATION <= newroty <= MAX_ATTACHED_OBJECT_ROTATION)
  1439.                     {
  1440.                         UpdatePlayerAttachedObjectEx(playerid, slot, PAO[playerid][slot][AO_MODEL_ID], PAO[playerid][slot][AO_BONE_ID], PAO[playerid][slot][AO_X], PAO[playerid][slot][AO_Y], PAO[playerid][slot][AO_Z],
  1441.                         PAO[playerid][slot][AO_RX], newroty, PAO[playerid][slot][AO_RZ], PAO[playerid][slot][AO_SX], PAO[playerid][slot][AO_SY], PAO[playerid][slot][AO_SZ], PAO[playerid][slot][AO_MC1], PAO[playerid][slot][AO_MC2]);
  1442.                         format(AOE_STR, sizeof(AOE_STR), "* Updated your attached object rotation (RotY) to %.2f at slot/index number %d!", newroty, slot);
  1443.                         SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  1444.                         GameTextForPlayer(playerid, "~g~Attached object rotation updated!", 3000, 3);
  1445.                     }
  1446.                     else
  1447.                     {
  1448.                         format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object rotation(Y) value [%.f]!", newroty);
  1449.                         SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1450.                         SendClientMessage(playerid, COLOR_YELLOW, "** Allowed float (RotY) value is larger than "#MIN_ATTACHED_OBJECT_ROTATION" and less than "#MAX_ATTACHED_OBJECT_ROTATION);
  1451.                         GameTextForPlayer(playerid, "~r~~h~Invalid attached object rotation value!", 3000, 3);
  1452.                     }
  1453.                 }
  1454.                 else
  1455.                 {
  1456.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you don't have attached object at slot/index number %d!", slot);
  1457.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1458.                     format(AOE_STR, sizeof(AOE_STR), "~r~~h~You have no attached object~n~~w~index/number: %d", slot);
  1459.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1460.                 }
  1461.             }
  1462.             else
  1463.             {
  1464.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  1465.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1466.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  1467.             }
  1468.         }
  1469.     }
  1470.     return 1;
  1471. }
  1472.  
  1473. CMD:saory(playerid, params[]) return cmd_setattachedobjectroty(playerid, params);
  1474.  
  1475. CMD:setattachedobjectrotz(playerid, params[])
  1476. {
  1477.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  1478.     else if(!GetPlayerAttachedObjectsCount(playerid))
  1479.     {
  1480.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  1481.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  1482.     }
  1483.     else
  1484.     {
  1485.         new slot, Float:newrotz;
  1486.         if(sscanf(params, "df", slot, newrotz))
  1487.         {
  1488.             SendClientMessage(playerid, COLOR_MAGENTA, "* Usage: /setattachedobjectrotz <AttachedObjectSlot> <Float:RotZ>");
  1489.             SendClientMessage(playerid, COLOR_WHITE, "** Allows you to set your attached object rotation (RotZ) with specified parameters");
  1490.         }
  1491.         else
  1492.         {
  1493.             if(IsValidAttachedObjectSlot(slot))
  1494.             {
  1495.                 if(IsPlayerAttachedObjectSlotUsed(playerid, slot))
  1496.                 {
  1497.                     if(MIN_ATTACHED_OBJECT_ROTATION <= newrotz <= MAX_ATTACHED_OBJECT_ROTATION)
  1498.                     {
  1499.                         UpdatePlayerAttachedObjectEx(playerid, slot, PAO[playerid][slot][AO_MODEL_ID], PAO[playerid][slot][AO_BONE_ID], PAO[playerid][slot][AO_X], PAO[playerid][slot][AO_Y], PAO[playerid][slot][AO_Z],
  1500.                         PAO[playerid][slot][AO_RX], PAO[playerid][slot][AO_RY], newrotz, PAO[playerid][slot][AO_SX], PAO[playerid][slot][AO_SY], PAO[playerid][slot][AO_SZ], PAO[playerid][slot][AO_MC1], PAO[playerid][slot][AO_MC2]);
  1501.                         format(AOE_STR, sizeof(AOE_STR), "* Updated your attached object rotation (RotZ) to %.2f at slot/index number %d!", newrotz, slot);
  1502.                         SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  1503.                         GameTextForPlayer(playerid, "~g~Attached object rotation updated!", 3000, 3);
  1504.                     }
  1505.                     else
  1506.                     {
  1507.                         format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object rotation(Z) value [%.f]!", newrotz);
  1508.                         SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1509.                         SendClientMessage(playerid, COLOR_YELLOW, "** Allowed float (RotZ) value is larger than "#MIN_ATTACHED_OBJECT_ROTATION" and less than "#MAX_ATTACHED_OBJECT_ROTATION);
  1510.                         GameTextForPlayer(playerid, "~r~~h~Invalid attached object rotation value!", 3000, 3);
  1511.                     }
  1512.                 }
  1513.                 else
  1514.                 {
  1515.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you don't have attached object at slot/index number %d!", slot);
  1516.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1517.                     format(AOE_STR, sizeof(AOE_STR), "~r~~h~You have no attached object~n~~w~index/number: %d", slot);
  1518.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1519.                 }
  1520.             }
  1521.             else
  1522.             {
  1523.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  1524.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1525.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  1526.             }
  1527.         }
  1528.     }
  1529.     return 1;
  1530. }
  1531.  
  1532. CMD:saorz(playerid, params[]) return cmd_setattachedobjectrotz(playerid, params);
  1533.  
  1534. CMD:setattachedobjectscalex(playerid, params[])
  1535. {
  1536.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  1537.     else if(!GetPlayerAttachedObjectsCount(playerid))
  1538.     {
  1539.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  1540.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  1541.     }
  1542.     else
  1543.     {
  1544.         new slot, Float:newscalex;
  1545.         if(sscanf(params, "df", slot, newscalex))
  1546.         {
  1547.             SendClientMessage(playerid, COLOR_MAGENTA, "* Usage: /setattachedobjectscalex <AttachedObjectSlot> <Float:ScaleX>");
  1548.             SendClientMessage(playerid, COLOR_WHITE, "** Allows you to set your attached object size (ScaleX) with specified parameters");
  1549.         }
  1550.         else
  1551.         {
  1552.             if(IsValidAttachedObjectSlot(slot))
  1553.             {
  1554.                 if(IsPlayerAttachedObjectSlotUsed(playerid, slot))
  1555.                 {
  1556.                     if(MIN_ATTACHED_OBJECT_SIZE <= newscalex <= MAX_ATTACHED_OBJECT_SIZE)
  1557.                     {
  1558.                         UpdatePlayerAttachedObjectEx(playerid, slot, PAO[playerid][slot][AO_MODEL_ID], PAO[playerid][slot][AO_BONE_ID], PAO[playerid][slot][AO_X], PAO[playerid][slot][AO_Y], PAO[playerid][slot][AO_Z],
  1559.                         PAO[playerid][slot][AO_RX], PAO[playerid][slot][AO_RY], PAO[playerid][slot][AO_RZ], newscalex, PAO[playerid][slot][AO_SY], PAO[playerid][slot][AO_SZ], PAO[playerid][slot][AO_MC1], PAO[playerid][slot][AO_MC2]);
  1560.                         format(AOE_STR, sizeof(AOE_STR), "* Updated your attached object size (ScaleX) to %.2f at slot/index number %d!", newscalex, slot);
  1561.                         SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  1562.                         GameTextForPlayer(playerid, "~g~Attached object size updated!", 3000, 3);
  1563.                     }
  1564.                     else
  1565.                     {
  1566.                         format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object scale(X) value [%f]!", newscalex);
  1567.                         SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1568.                         SendClientMessage(playerid, COLOR_YELLOW, "** Allowed float (ScaleX) value is larger than "#MIN_ATTACHED_OBJECT_SIZE" and less than "#MAX_ATTACHED_OBJECT_SIZE);
  1569.                         GameTextForPlayer(playerid, "~r~~h~Invalid attached object size value!", 3000, 3);
  1570.                     }
  1571.                 }
  1572.                 else
  1573.                 {
  1574.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you don't have attached object at slot/index number %d!", slot);
  1575.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1576.                     format(AOE_STR, sizeof(AOE_STR), "~r~~h~You have no attached object~n~~w~index/number: %d", slot);
  1577.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1578.                 }
  1579.             }
  1580.             else
  1581.             {
  1582.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  1583.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1584.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  1585.             }
  1586.         }
  1587.     }
  1588.     return 1;
  1589. }
  1590.  
  1591. CMD:saosx(playerid, params[]) return cmd_setattachedobjectscalex(playerid, params);
  1592.  
  1593. CMD:setattachedobjectscaley(playerid, params[])
  1594. {
  1595.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  1596.     else if(!GetPlayerAttachedObjectsCount(playerid))
  1597.     {
  1598.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  1599.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  1600.     }
  1601.     else
  1602.     {
  1603.         new slot, Float:newscaley;
  1604.         if(sscanf(params, "df", slot, newscaley))
  1605.         {
  1606.             SendClientMessage(playerid, COLOR_MAGENTA, "* Usage: /setattachedobjectscaley <AttachedObjectSlot> <Float:ScaleY>");
  1607.             SendClientMessage(playerid, COLOR_WHITE, "** Allows you to set your attached object size (ScaleY) with specified parameters");
  1608.         }
  1609.         else
  1610.         {
  1611.             if(IsValidAttachedObjectSlot(slot))
  1612.             {
  1613.                 if(IsPlayerAttachedObjectSlotUsed(playerid, slot))
  1614.                 {
  1615.                     if(MIN_ATTACHED_OBJECT_SIZE <= newscaley <= MAX_ATTACHED_OBJECT_SIZE)
  1616.                     {
  1617.                         UpdatePlayerAttachedObjectEx(playerid, slot, PAO[playerid][slot][AO_MODEL_ID], PAO[playerid][slot][AO_BONE_ID], PAO[playerid][slot][AO_X], PAO[playerid][slot][AO_Y], PAO[playerid][slot][AO_Z],
  1618.                         PAO[playerid][slot][AO_RX], PAO[playerid][slot][AO_RY], PAO[playerid][slot][AO_RZ], PAO[playerid][slot][AO_SX], newscaley, PAO[playerid][slot][AO_SZ], PAO[playerid][slot][AO_MC1], PAO[playerid][slot][AO_MC2]);
  1619.                         format(AOE_STR, sizeof(AOE_STR), "* Updated your attached object size (ScaleY) to %.2f at slot/index number %d!", newscaley, slot);
  1620.                         SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  1621.                         GameTextForPlayer(playerid, "~g~Attached object size updated!", 3000, 3);
  1622.                     }
  1623.                     else
  1624.                     {
  1625.                         format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object scale(Y) value [%f]!", newscaley);
  1626.                         SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1627.                         SendClientMessage(playerid, COLOR_YELLOW, "** Allowed float (ScaleY) value is larger than "#MIN_ATTACHED_OBJECT_SIZE" and less than "#MAX_ATTACHED_OBJECT_SIZE);
  1628.                         GameTextForPlayer(playerid, "~r~~h~Invalid attached object size value!", 3000, 3);
  1629.                     }
  1630.                 }
  1631.                 else
  1632.                 {
  1633.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you don't have attached object at slot/index number %d!", slot);
  1634.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1635.                     format(AOE_STR, sizeof(AOE_STR), "~r~~h~You have no attached object~n~~w~index/number: %d", slot);
  1636.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1637.                 }
  1638.             }
  1639.             else
  1640.             {
  1641.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  1642.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1643.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  1644.             }
  1645.         }
  1646.     }
  1647.     return 1;
  1648. }
  1649.  
  1650. CMD:saosy(playerid, params[]) return cmd_setattachedobjectscaley(playerid, params);
  1651.  
  1652. CMD:setattachedobjectscalez(playerid, params[])
  1653. {
  1654.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  1655.     else if(!GetPlayerAttachedObjectsCount(playerid))
  1656.     {
  1657.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  1658.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  1659.     }
  1660.     else
  1661.     {
  1662.         new slot, Float:newscalez;
  1663.         if(sscanf(params, "df", slot, newscalez))
  1664.         {
  1665.             SendClientMessage(playerid, COLOR_MAGENTA, "* Usage: /setattachedobjectscalez <AttachedObjectSlot> <Float:ScaleZ>");
  1666.             SendClientMessage(playerid, COLOR_WHITE, "** Allows you to set your attached object size (ScaleZ) with specified parameters");
  1667.         }
  1668.         else
  1669.         {
  1670.             if(IsValidAttachedObjectSlot(slot))
  1671.             {
  1672.                 if(IsPlayerAttachedObjectSlotUsed(playerid, slot))
  1673.                 {
  1674.                     if(MIN_ATTACHED_OBJECT_SIZE <= newscalez <= MAX_ATTACHED_OBJECT_SIZE)
  1675.                     {
  1676.                         UpdatePlayerAttachedObjectEx(playerid, slot, PAO[playerid][slot][AO_MODEL_ID], PAO[playerid][slot][AO_BONE_ID], PAO[playerid][slot][AO_X], PAO[playerid][slot][AO_Y], PAO[playerid][slot][AO_Z],
  1677.                         PAO[playerid][slot][AO_RX], PAO[playerid][slot][AO_RY], PAO[playerid][slot][AO_RZ], PAO[playerid][slot][AO_SX], PAO[playerid][slot][AO_SY], newscalez, PAO[playerid][slot][AO_MC1], PAO[playerid][slot][AO_MC2]);
  1678.                         format(AOE_STR, sizeof(AOE_STR), "* Updated your attached object size (ScaleZ) to %.2f at slot/index number %d!", newscalez, slot);
  1679.                         SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  1680.                         GameTextForPlayer(playerid, "~g~Attached object size updated!", 3000, 3);
  1681.                     }
  1682.                     else
  1683.                     {
  1684.                         format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object scale(Z) value [%f]!", newscalez);
  1685.                         SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1686.                         SendClientMessage(playerid, COLOR_YELLOW, "** Allowed float (ScaleZ) value is larger than "#MIN_ATTACHED_OBJECT_SIZE" and less than "#MAX_ATTACHED_OBJECT_SIZE);
  1687.                         GameTextForPlayer(playerid, "~r~~h~Invalid attached object size value!", 3000, 3);
  1688.                     }
  1689.                 }
  1690.                 else
  1691.                 {
  1692.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you don't have attached object at slot/index number %d!", slot);
  1693.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1694.                     format(AOE_STR, sizeof(AOE_STR), "~r~~h~You have no attached object~n~~w~index/number: %d", slot);
  1695.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1696.                 }
  1697.             }
  1698.             else
  1699.             {
  1700.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  1701.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1702.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  1703.             }
  1704.         }
  1705.     }
  1706.     return 1;
  1707. }
  1708.  
  1709. CMD:saosz(playerid, params[]) return cmd_setattachedobjectscalez(playerid, params);
  1710.  
  1711. CMD:setattachedobjectmc1(playerid, params[])
  1712. {
  1713.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  1714.     else if(!GetPlayerAttachedObjectsCount(playerid))
  1715.     {
  1716.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  1717.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  1718.     }
  1719.     else
  1720.     {
  1721.         new slot, hex:newmc1;
  1722.         if(sscanf(params, "dx", slot, newmc1))
  1723.         {
  1724.             SendClientMessage(playerid, COLOR_MAGENTA, "* Usage: /setattachedobjectmc1 <AttachedObjectSlot> <MaterialColor>");
  1725.             SendClientMessage(playerid, COLOR_WHITE, "** Allows you to set your attached object color (Material:1) with specified parameters");
  1726.         }
  1727.         else
  1728.         {
  1729.             if(IsValidAttachedObjectSlot(slot))
  1730.             {
  1731.                 if(IsPlayerAttachedObjectSlotUsed(playerid, slot))
  1732.                 {
  1733.                     UpdatePlayerAttachedObjectEx(playerid, slot, PAO[playerid][slot][AO_MODEL_ID], PAO[playerid][slot][AO_BONE_ID], PAO[playerid][slot][AO_X], PAO[playerid][slot][AO_Y], PAO[playerid][slot][AO_Z],
  1734.                     PAO[playerid][slot][AO_RX], PAO[playerid][slot][AO_RY], PAO[playerid][slot][AO_RZ], PAO[playerid][slot][AO_SX], PAO[playerid][slot][AO_SY], PAO[playerid][slot][AO_SZ], newmc1, PAO[playerid][slot][AO_MC2]);
  1735.                     format(AOE_STR, sizeof(AOE_STR), "* Updated your attached object color (MC1) to 0x{%06x}%x{%06x} (%i) at slot/index number %d!", newmc1 & 0xFFFFFF, newmc1, COLOR_GREEN >>> 8, newmc1, slot);
  1736.                     SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  1737.                     GameTextForPlayer(playerid, "~g~Attached object color updated!", 3000, 3);
  1738.                 }
  1739.                 else
  1740.                 {
  1741.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you don't have attached object at slot/index number %d!", slot);
  1742.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1743.                     format(AOE_STR, sizeof(AOE_STR), "~r~~h~You have no attached object~n~~w~index/number: %d", slot);
  1744.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1745.                 }
  1746.             }
  1747.             else
  1748.             {
  1749.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  1750.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1751.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  1752.             }
  1753.         }
  1754.     }
  1755.     return 1;
  1756. }
  1757.  
  1758. CMD:saomc1(playerid, params[]) return cmd_setattachedobjectmc1(playerid, params);
  1759.  
  1760. CMD:setattachedobjectmc2(playerid, params[])
  1761. {
  1762.     if(AOE_CantEdit(playerid)) SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you can't use this command right now!");
  1763.     else if(!GetPlayerAttachedObjectsCount(playerid))
  1764.     {
  1765.         SendClientMessage(playerid, COLOR_YELLOW, "* Sorry, you don't have any attached object!");
  1766.         GameTextForPlayer(playerid, "~r~~h~You have no attached object!", 3000, 3);
  1767.     }
  1768.     else
  1769.     {
  1770.         new slot, newmc2;
  1771.         if(sscanf(params, "dx", slot, newmc2))
  1772.         {
  1773.             SendClientMessage(playerid, COLOR_MAGENTA, "* Usage: /setattachedobjectmc2 <AttachedObjectSlot> <MaterialColor>");
  1774.             SendClientMessage(playerid, COLOR_WHITE, "** Allows you to set your attached object color (Material:2) with specified parameters");
  1775.         }
  1776.         else
  1777.         {
  1778.             if(IsValidAttachedObjectSlot(slot))
  1779.             {
  1780.                 if(IsPlayerAttachedObjectSlotUsed(playerid, slot))
  1781.                 {
  1782.                     UpdatePlayerAttachedObjectEx(playerid, slot, PAO[playerid][slot][AO_MODEL_ID], PAO[playerid][slot][AO_BONE_ID], PAO[playerid][slot][AO_X], PAO[playerid][slot][AO_Y], PAO[playerid][slot][AO_Z],
  1783.                     PAO[playerid][slot][AO_RX], PAO[playerid][slot][AO_RY], PAO[playerid][slot][AO_RZ], PAO[playerid][slot][AO_SX], PAO[playerid][slot][AO_SY], PAO[playerid][slot][AO_SZ], PAO[playerid][slot][AO_MC1], newmc2);
  1784.                     format(AOE_STR, sizeof(AOE_STR), "* Updated your attached object color (MC2) to 0x{%06x}%x{%06x} (%i) at slot/index number %d!", newmc2 & 0xFFFFFF, newmc2, COLOR_GREEN >>> 8, newmc2, slot);
  1785.                     SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  1786.                     GameTextForPlayer(playerid, "~g~Attached object color updated!", 3000, 3);
  1787.                 }
  1788.                 else
  1789.                 {
  1790.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you don't have attached object at slot/index number %d!", slot);
  1791.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1792.                     format(AOE_STR, sizeof(AOE_STR), "~r~~h~You have no attached object~n~~w~index/number: %d", slot);
  1793.                     GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1794.                 }
  1795.             }
  1796.             else
  1797.             {
  1798.                 format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid attached object slot/index number [%d]!", slot);
  1799.                 SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1800.                 GameTextForPlayer(playerid, "~r~~h~Invalid attached object slot!", 3000, 3);
  1801.             }
  1802.         }
  1803.     }
  1804.     return 1;
  1805. }
  1806.  
  1807. CMD:saomc2(playerid, params[]) return cmd_setattachedobjectmc2(playerid, params);
  1808. //------------------------------------------------------------------------------
  1809. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  1810. {
  1811.     switch(dialogid)
  1812.     {
  1813.         case E_AOED:
  1814.         {
  1815.             if(response)
  1816.             {
  1817.                 switch(listitem)
  1818.                 {
  1819.                     case 0: cmd_createattachedobject(playerid, "");
  1820.                     case 1: cmd_duplicateattachedobject(playerid, "");
  1821.                     case 2: cmd_editattachedobject(playerid, "");
  1822.                     case 3: cmd_setattachedobjectindex(playerid, "");
  1823.                     case 4: cmd_setattachedobjectmodel(playerid, "");
  1824.                     case 5: cmd_setattachedobjectbone(playerid, "");
  1825.                     case 6: cmd_saveattachedobject(playerid, "");
  1826.                     case 7: cmd_saveattachedobjects(playerid, "");
  1827.                     case 8: cmd_loadattachedobject(playerid, "");
  1828.                     case 9: cmd_loadattachedobjects(playerid, "");
  1829.                     case 10: cmd_removeattachedobject(playerid, "");
  1830.                     case 11: cmd_removeattachedobjects(playerid, "");
  1831.                     case 12: cmd_undeleteattachedobject(playerid, "");
  1832.                     case 13: cmd_attachedobjectstats(playerid, "");
  1833.                     case 14: cmd_totalattachedobjects(playerid, "");
  1834.                     case 15: AOE_ShowPlayerDialog(playerid, 1, E_AOED_HELP, "Attached Object Editor Help", "Close");
  1835.                     case 16: AOE_ShowPlayerDialog(playerid, 2, E_AOED_ABOUT, "About Attached Object Editor", "Close");
  1836.                 }
  1837.             }
  1838.             else SendClientMessage(playerid, COLOR_WHITE, "* You've closed attached object editor dialog");
  1839.         }
  1840.         case E_AOED_CREATE_SLOT:
  1841.         {
  1842.             if(response)
  1843.             {
  1844.                 valstr(AOE_STR, listitem);
  1845.                 cmd_createattachedobject(playerid, AOE_STR);
  1846.             }
  1847.         }
  1848.         case E_AOED_CREATE_MODEL:
  1849.         {
  1850.             if(response)
  1851.             {
  1852.                 new model;
  1853.                 model = strval(inputtext), SetPVarInt(playerid, "PAO_CAOM", model);
  1854.                 if(!IsValidObjectModel(model) || !IsNumeric(inputtext))
  1855.                 {
  1856.                     format(AOE_STR, sizeof(AOE_STR), "* Sorry, you've entered an invalid object model number/id [%s]!", inputtext);
  1857.                     SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  1858.                     GameTextForPlayer(playerid, "~r~~h~Invalid object model!", 3000, 3);
  1859.                 }
  1860.                 else AOE_ShowPlayerDialog(playerid, 4, E_AOED_CREATE_BONE, "Create Attached Object", "Select", "Sel Model");
  1861.             }
  1862.             else AOE_ShowPlayerDialog(playerid, 5, E_AOED_CREATE_SLOT, "Create Attached Object", "Select", "Cancel");
  1863.         }
  1864.         case E_AOED_CREATE_BONE:
  1865.         {
  1866.             if(response)
  1867.             {
  1868.                 new slot = GetPVarInt(playerid, "PAO_CAOI"), model = GetPVarInt(playerid, "PAO_CAOM"), bone = listitem+1;
  1869.                 SetPVarInt(playerid, "PAO_CAOB", bone);
  1870.                 CreatePlayerAttachedObject(playerid, slot, model, bone);
  1871.                 format(AOE_STR, sizeof(AOE_STR), "* Created attached object model %d at slot/index number %d [Bone: %s (%d)]!", model, slot, GetAttachedObjectBoneName(bone), bone);
  1872.                 SendClientMessage(playerid, COLOR_BLUE, AOE_STR);
  1873.                 format(AOE_STR, sizeof(AOE_STR), "~b~Created attached object~n~~w~index/number: %d~n~Model: %d - Bone: %d", slot, model, bone);
  1874.                 GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1875.                 AOE_ShowPlayerDialog(playerid, 9, E_AOED_CREATE_EDIT, "Create Attached Object (Edit)", "Edit", "Skip");
  1876.             }
  1877.             else AOE_ShowPlayerDialog(playerid, 3, E_AOED_CREATE_MODEL, "Create Attached Object", "Enter", "Sel Index");
  1878.         }
  1879.         case E_AOED_CREATE_REPLACE:
  1880.         {
  1881.             if(response) AOE_ShowPlayerDialog(playerid, 3, E_AOED_CREATE_MODEL, "Create Attached Object", "Enter", "Sel Index");
  1882.             else AOE_ShowPlayerDialog(playerid, 5, E_AOED_CREATE_SLOT, "Create Attached Object", "Select", "Cancel");
  1883.         }
  1884.         case E_AOED_CREATE_EDIT:
  1885.         {
  1886.             if(response)
  1887.             {
  1888.                 valstr(AOE_STR, GetPVarInt(playerid, "PAO_CAOI"));
  1889.                 cmd_editattachedobject(playerid, AOE_STR);
  1890.             }
  1891.             else
  1892.             {
  1893.                 SendClientMessage(playerid, COLOR_WHITE, "* You've skipped to edit your attached object");
  1894.                 SendClientMessage(playerid, COLOR_WHITE, "** Note: use /editattachedobject command to edit your attached object");
  1895.             }
  1896.         }
  1897.         case E_AOED_EDIT_SLOT:
  1898.         {
  1899.             if(response)
  1900.             {
  1901.                 if(IsPlayerAttachedObjectSlotUsed(playerid, listitem))
  1902.                 {
  1903.                     valstr(AOE_STR, listitem);
  1904.                     cmd_editattachedobject(playerid, AOE_STR);
  1905.                 }
  1906.                 else
  1907.                 {
  1908.                     valstr(AOE_STR, listitem);
  1909.                     cmd_createattachedobject(playerid, AOE_STR);
  1910.                 }
  1911.             }
  1912.             SetPVarInt(playerid, "PAO_EAO", 0);
  1913.         }
  1914.         case E_AOED_REMOVE_SLOT:
  1915.         {
  1916.             if(response)
  1917.             {
  1918.                 valstr(AOE_STR, listitem);
  1919.                 cmd_removeattachedobject(playerid, AOE_STR);
  1920.             }
  1921.         }
  1922.         case E_AOED_REMOVEALL:
  1923.         {
  1924.             if(response)
  1925.             {
  1926.                 new slots = RemovePlayerAttachedObjectEx(playerid, MAX_PLAYER_ATTACHED_OBJECTS);
  1927.                 format(AOE_STR, sizeof(AOE_STR), "* You've removed all of your %d attached object(s)!", slots);
  1928.                 SendClientMessage(playerid, COLOR_RED, AOE_STR);
  1929.                 format(AOE_STR, sizeof(AOE_STR), "~r~Removed all your attached object(s)~n~~w~Total: %d", slots);
  1930.                 GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1931.             }
  1932.             else SendClientMessage(playerid, COLOR_WHITE, "* You've canceled removing all your attached object(s)");
  1933.         }
  1934.         case E_AOED_STATS_SLOT:
  1935.         {
  1936.             if(response)
  1937.             {
  1938.                 valstr(AOE_STR, listitem);
  1939.                 cmd_attachedobjectstats(playerid, AOE_STR);
  1940.             }
  1941.         }
  1942.         case E_AOED_STATS:
  1943.         {
  1944.             if(response && IsPlayerAdmin(playerid))
  1945.             {
  1946.                 new slot = GetPVarInt(playerid, "PAO_AOSI"), targetid = GetPVarInt(playerid, "PAO_AOSU");
  1947.                 GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
  1948.                 printf("  >> Admin %s (ID:%d) has requested to print attached object stats", PlayerName, playerid);
  1949.                 GetPlayerName(targetid, PlayerName, sizeof(PlayerName));
  1950.                 printf("  Player: %s (ID:%d)\nAttached object slot/index number: %d\n  - Model ID/Number/Type: %d\n  - Bone: %s (BID:%d)\n  - Offsets:\n  -- X: %.2f ~ Y: %.2f ~ Z: %.2f\n  - Rotations:\n  -- RX: %.2f ~ RY: %.2f ~ RZ: %.2f\
  1951.                 \n  - Scales:\n  -- SX: %.2f ~ SY: %.2f ~ SZ: %.2f\n  - Material Colors:\n  -- Color 1: 0x%04x%04x (%i) ~ Color 2: 0x%04x%04x (%i)", PlayerName, targetid, slot, PAO[targetid][slot][AO_MODEL_ID], GetAttachedObjectBoneName(PAO[targetid][slot][AO_BONE_ID]),
  1952.                 PAO[targetid][slot][AO_BONE_ID], PAO[targetid][slot][AO_X], PAO[targetid][slot][AO_Y], PAO[targetid][slot][AO_Z], PAO[targetid][slot][AO_RX], PAO[targetid][slot][AO_RY], PAO[targetid][slot][AO_RZ],
  1953.                 PAO[targetid][slot][AO_SX], PAO[targetid][slot][AO_SY], PAO[targetid][slot][AO_SZ], AOE_HexFormat(PAO[targetid][slot][AO_MC1]), PAO[targetid][slot][AO_MC1], AOE_HexFormat(PAO[targetid][slot][AO_MC2], PAO[targetid][slot][AO_MC2]));
  1954.                 printf("  Skin: %d ~ Code usage (playerid = %d):\n  SetPlayerAttachedObject(playerid, %d, %d, %d, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %d, %d);", GetPlayerSkin(targetid), targetid,
  1955.                 slot, PAO[targetid][slot][AO_MODEL_ID], PAO[targetid][slot][AO_BONE_ID], PAO[targetid][slot][AO_X], PAO[targetid][slot][AO_Y], PAO[targetid][slot][AO_Z], PAO[targetid][slot][AO_RX], PAO[targetid][slot][AO_RY], PAO[targetid][slot][AO_RZ],
  1956.                 PAO[targetid][slot][AO_SX], PAO[targetid][slot][AO_SY], PAO[targetid][slot][AO_SZ], PAO[targetid][slot][AO_MC1], PAO[targetid][slot][AO_MC2]);
  1957.                 SendClientMessage(playerid, COLOR_WHITE, "SERVER: Attached object stats has been printed to server console!");
  1958.             }
  1959.             else SendClientMessage(playerid, COLOR_WHITE, "* You've closed your attached object stats dialog");
  1960.         }
  1961.         case E_AOED_DUPLICATE_SLOT1:
  1962.         {
  1963.             if(response)
  1964.             {
  1965.                 valstr(AOE_STR, listitem);
  1966.                 cmd_duplicateattachedobject(playerid, AOE_STR);
  1967.             }
  1968.         }
  1969.         case E_AOED_DUPLICATE_SLOT2:
  1970.         {
  1971.             if(response)
  1972.             {
  1973.                 format(AOE_STR, sizeof(AOE_STR), "%d %d", GetPVarInt(playerid, "PAO_DAOI1"), listitem);
  1974.                 cmd_duplicateattachedobject(playerid, AOE_STR);
  1975.             }
  1976.             else AOE_ShowPlayerDialog(playerid, 6, E_AOED_DUPLICATE_SLOT1, "Duplicate Attached Object Index (1)", "Select", "Cancel");
  1977.         }
  1978.         case E_AOED_DUPLICATE_REPLACE:
  1979.         {
  1980.             if(response)
  1981.             {
  1982.                 new slot1 = GetPVarInt(playerid, "PAO_DAOI1"), slot2 = GetPVarInt(playerid, "PAO_DAOI2");
  1983.                 DuplicatePlayerAttachedObject(playerid, slot1, slot2);
  1984.                 format(AOE_STR, sizeof(AOE_STR), "* Duplicated your attached object from slot/index number %d to %d!", slot1, slot2);
  1985.                 SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  1986.                 format(AOE_STR, sizeof(AOE_STR), "~g~Attached object duplicated~n~~w~index/number:~n~%d to %d", slot1, slot2);
  1987.                 GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  1988.             }
  1989.             else AOE_ShowPlayerDialog(playerid, 5, E_AOED_DUPLICATE_SLOT2, "Duplicate Attached Object Index (2)", "Select", "Sel Idx1");
  1990.         }
  1991.         case E_AOED_SET_SLOT1:
  1992.         {
  1993.             if(response)
  1994.             {
  1995.                 valstr(AOE_STR, listitem);
  1996.                 cmd_setattachedobjectindex(playerid, AOE_STR);
  1997.             }
  1998.         }
  1999.         case E_AOED_SET_SLOT2:
  2000.         {
  2001.             if(response)
  2002.             {
  2003.                 format(AOE_STR, sizeof(AOE_STR), "%d %d", GetPVarInt(playerid, "PAO_SAOI1"), listitem);
  2004.                 cmd_setattachedobjectindex(playerid, AOE_STR);
  2005.             }
  2006.             else AOE_ShowPlayerDialog(playerid, 6, E_AOED_SET_SLOT1, "Set Attached Object Index (1)", "Select", "Cancel");
  2007.         }
  2008.         case E_AOED_SET_SLOT_REPLACE:
  2009.         {
  2010.             if(response)
  2011.             {
  2012.                 new slot = GetPVarInt(playerid, "PAO_SAOI1"), newslot = GetPVarInt(playerid, "PAO_SAOI2");
  2013.                 MovePlayerAttachedObjectIndex(playerid, slot, newslot);
  2014.                 format(AOE_STR, sizeof(AOE_STR), "* Moved & replaced your attached object from slot/index number %d to %d!", slot, newslot);
  2015.                 SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  2016.                 format(AOE_STR, sizeof(AOE_STR), "~g~Attached object moved~n~~w~index/number:~n~%d to %d", slot, newslot);
  2017.                 GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  2018.             }
  2019.             else AOE_ShowPlayerDialog(playerid, 5, E_AOED_SET_SLOT2, "Set Attached Object Index (2)", "Select", "Sel Idx1");
  2020.         }
  2021.         case E_AOED_SET_MODEL_SLOT:
  2022.         {
  2023.             if(response)
  2024.             {
  2025.                 valstr(AOE_STR, listitem);
  2026.                 cmd_setattachedobjectmodel(playerid, AOE_STR);
  2027.             }
  2028.         }
  2029.         case E_AOED_SET_MODEL:
  2030.         {
  2031.             if(response)
  2032.             {
  2033.                 format(AOE_STR, sizeof(AOE_STR), "%d %d", GetPVarInt(playerid, "PAO_SAOMI"), strval(inputtext));
  2034.                 cmd_setattachedobjectmodel(playerid, AOE_STR);
  2035.             }
  2036.             else AOE_ShowPlayerDialog(playerid, 6, E_AOED_SET_MODEL_SLOT, "Set Attached Object Model", "Select", "Cancel");
  2037.         }
  2038.         case E_AOED_SET_BONE_SLOT:
  2039.         {
  2040.             if(response)
  2041.             {
  2042.                 valstr(AOE_STR, listitem);
  2043.                 cmd_setattachedobjectbone(playerid, AOE_STR);
  2044.             }
  2045.         }
  2046.         case E_AOED_SET_BONE:
  2047.         {
  2048.             if(response)
  2049.             {
  2050.                 format(AOE_STR, sizeof(AOE_STR), "%d %d", GetPVarInt(playerid, "PAO_SAOBI"), listitem+1);
  2051.                 cmd_setattachedobjectbone(playerid, AOE_STR);
  2052.             }
  2053.             else AOE_ShowPlayerDialog(playerid, 6, E_AOED_SET_BONE_SLOT, "Set Attached Object Bone", "Select", "Cancel");
  2054.         }
  2055.         case E_AOED_SAVE_SLOT:
  2056.         {
  2057.             if(response)
  2058.             {
  2059.                 valstr(AOE_STR, listitem);
  2060.                 cmd_saveattachedobject(playerid, AOE_STR);
  2061.             }
  2062.         }
  2063.         case E_AOED_SAVE:
  2064.         {
  2065.             if(response)
  2066.             {
  2067.                 format(AOE_STR, sizeof(AOE_STR), "%d %s", GetPVarInt(playerid, "PAO_SAOI"), inputtext);
  2068.                 cmd_saveattachedobject(playerid, AOE_STR);
  2069.             }
  2070.             else AOE_ShowPlayerDialog(playerid, 6, E_AOED_SAVE_SLOT, "Save Attached Object", "Select", "Cancel");
  2071.         }
  2072.         case E_AOED_SAVE_REPLACE:
  2073.         {
  2074.             if(response)
  2075.             {
  2076.                 new filename[32+1], slot = GetPVarInt(playerid, "PAO_SAOI"), filelen;
  2077.                 GetPVarString(playerid, "PAO_SAON", filename, sizeof(filename));
  2078.                 SendClientMessage(playerid, COLOR_WHITE, "* Saving attached object file, please wait...");
  2079.                 if(AOE_SavePlayerAttachedObject(playerid, filename, slot, "", filelen))
  2080.                 {
  2081.                     format(AOE_STR, sizeof(AOE_STR), "** Your attached object from index %d has been saved as \"%s\" (Model: %d - Bone: %d - %d bytes)!", slot, filename, PAO[playerid][slot][AO_MODEL_ID], PAO[playerid][slot][AO_BONE_ID], filelen);
  2082.                     SendClientMessage(playerid, COLOR_BLUE, AOE_STR);
  2083.                     SendClientMessage(playerid, COLOR_BLUE, "** The attached object data on file has been overwritten (Re-Created)");
  2084.                 }
  2085.                 else
  2086.                 {
  2087.                     SendClientMessage(playerid, COLOR_RED, "* Error: Invalid attached object data, save canceled");
  2088.                     GameTextForPlayer(playerid, "~r~~h~Invalid attached object data!", 3000, 3);
  2089.                 }
  2090.             }
  2091.         }
  2092.         case E_AOED_SAVE2: if(response) cmd_saveattachedobjects(playerid, inputtext);
  2093.         case E_AOED_SAVE2_REPLACE:
  2094.         {
  2095.             if(response)
  2096.             {
  2097.                 new filename[32+1], filelen;
  2098.                 GetPVarString(playerid, "PAO_SAON", filename, sizeof(filename));
  2099.                 SendClientMessage(playerid, COLOR_WHITE, "* Saving attached object(s) set file, please wait...");
  2100.                 new slots = AOE_SavePlayerAttachedObject(playerid, filename, MAX_PLAYER_ATTACHED_OBJECTS, "", filelen);
  2101.                 if(slots)
  2102.                 {
  2103.                     format(AOE_STR, sizeof(AOE_STR), "** Your attached object set has been saved as \"%s\" (Total: %d - %d bytes)!", filename, slots, filelen);
  2104.                     SendClientMessage(playerid, COLOR_BLUE, AOE_STR);
  2105.                     SendClientMessage(playerid, COLOR_BLUE, "** The attached object(s) data on file has been overwritten (Re-Created)");
  2106.                 }
  2107.                 else SendClientMessage(playerid, COLOR_RED, "** Error: file saving was canceled because there were no valid attached object!");
  2108.             }
  2109.         }
  2110.         case E_AOED_LOAD: if(response) cmd_loadattachedobject(playerid, inputtext);
  2111.         case E_AOED_LOAD_SLOT:
  2112.         {
  2113.             if(response)
  2114.             {
  2115.                 GetPVarString(playerid, "PAO_LAON", AOE_STR, sizeof(AOE_STR));
  2116.                 format(AOE_STR, sizeof(AOE_STR), "%s %d", AOE_STR, strval(inputtext));
  2117.                 cmd_loadattachedobject(playerid, AOE_STR);
  2118.             }
  2119.             else AOE_ShowPlayerDialog(playerid, 14, E_AOED_LOAD, "Load Attached Object", "Enter", "Cancel");
  2120.         }
  2121.         case E_AOED_LOAD_REPLACE:
  2122.         {
  2123.             if(response)
  2124.             {
  2125.                 SendClientMessage(playerid, COLOR_WHITE, "* Loading attached object file, please wait...");
  2126.                 new slot = GetPVarInt(playerid, "PAO_LAOI"), filename[32+1], comment[64+1];
  2127.                 GetPVarString(playerid, "PAO_LAON", filename, sizeof(filename));
  2128.                 if(AOE_LoadPlayerAttachedObject(playerid, filename, slot, comment, sizeof(comment)))
  2129.                 {
  2130.                     format(AOE_STR, sizeof(AOE_STR), "** You've loaded & replaced your attached object from file \"%s\" by s from skin d (Index: %d - Model: %d - Bone: %d)!", AOE_STR,
  2131.                     slot, PAO[playerid][slot][AO_MODEL_ID], PAO[playerid][slot][AO_BONE_ID]);
  2132.                     SendClientMessage(playerid, COLOR_GREEN, AOE_STR);
  2133.                 }
  2134.             }
  2135.         }
  2136.         case E_AOED_LOAD2: if(response) cmd_loadattachedobjects(playerid, inputtext);
  2137.     }
  2138.     return 0;
  2139. }
  2140.  
  2141. public OnPlayerEditAttachedObject(playerid, response, index, modelid, boneid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:fRotZ, Float:fScaleX, Float:fScaleY, Float:fScaleZ)
  2142. {
  2143.     if(response == EDIT_RESPONSE_FINAL)
  2144.     {
  2145.         if(IsPlayerAttachedObjectSlotUsed(playerid, index)) RemovePlayerAttachedObject(playerid, index);
  2146.         UpdatePlayerAttachedObjectEx(playerid, index, modelid, boneid, fOffsetX, fOffsetY, fOffsetZ, fRotX, fRotY, fRotZ, fScaleX, fScaleY, fScaleZ, PAO[playerid][index][AO_MC1], PAO[playerid][index][AO_MC2]);
  2147.         format(AOE_STR, sizeof(AOE_STR), "* You've edited your attached object from slot/index number %d", index);
  2148.         SendClientMessage(playerid, COLOR_CYAN, AOE_STR);
  2149.         format(AOE_STR, sizeof(AOE_STR), "~b~~h~Edited your attached object~n~~w~index/number: %d", index);
  2150.         GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  2151.     }
  2152.     if(response == EDIT_RESPONSE_CANCEL)
  2153.     {
  2154.         if(IsPlayerAttachedObjectSlotUsed(playerid, index)) RemovePlayerAttachedObject(playerid, index);
  2155.         SetPlayerAttachedObject(playerid, index, PAO[playerid][index][AO_MODEL_ID], PAO[playerid][index][AO_BONE_ID], PAO[playerid][index][AO_X], PAO[playerid][index][AO_Y], PAO[playerid][index][AO_Z],
  2156.         PAO[playerid][index][AO_RX], PAO[playerid][index][AO_RY], PAO[playerid][index][AO_RZ], PAO[playerid][index][AO_SX], PAO[playerid][index][AO_SY], PAO[playerid][index][AO_SZ], PAO[playerid][index][AO_MC1], PAO[playerid][index][AO_MC2]);
  2157.         PAO[playerid][index][AO_STATUS] = 1;
  2158.         format(AOE_STR, sizeof(AOE_STR), "* You've canceled editing your attached object from slot/index number %d", index);
  2159.         SendClientMessage(playerid, COLOR_YELLOW, AOE_STR);
  2160.         format(AOE_STR, sizeof(AOE_STR), "~r~~h~Canceled editing your attached object~n~~w~index/number: %d", index);
  2161.         GameTextForPlayer(playerid, AOE_STR, 5000, 3);
  2162.     }
  2163.     SetPVarInt(playerid, "PAO_EAO", 0);
  2164.     return 1;
  2165. }
  2166. // =============================================================================
  2167. AOE_UnsetValues(playerid, index)
  2168. {
  2169.     PAO[playerid][index][AO_STATUS] = 0;
  2170.     PAO[playerid][index][AO_MODEL_ID] = 0, PAO[playerid][index][AO_BONE_ID] = 0;
  2171.     PAO[playerid][index][AO_X] = 0.0, PAO[playerid][index][AO_Y] = 0.0, PAO[playerid][index][AO_Z] = 0.0;
  2172.     PAO[playerid][index][AO_RX] = 0.0, PAO[playerid][index][AO_RY] = 0.0, PAO[playerid][index][AO_RZ] = 0.0;
  2173.     PAO[playerid][index][AO_SX] = 0.0, PAO[playerid][index][AO_SY] = 0.0, PAO[playerid][index][AO_SZ] = 0.0;
  2174.     PAO[playerid][index][AO_MC1] = 0, PAO[playerid][index][AO_MC2] = 0;
  2175. }
  2176.  
  2177. AOE_UnsetVars(playerid)
  2178. {
  2179.     if(GetPVarInt(playerid, "PAO_EAO") == 1) CancelEdit(playerid);
  2180.     DeletePVar(playerid, "PAO_CAOI");
  2181.     DeletePVar(playerid, "PAO_CAOM");
  2182.     DeletePVar(playerid, "PAO_CAOB");
  2183.     DeletePVar(playerid, "PAO_EAO");
  2184.     DeletePVar(playerid, "PAO_AOSI");
  2185.     DeletePVar(playerid, "PAO_AOSU");
  2186.     DeletePVar(playerid, "PAO_DAOI1");
  2187.     DeletePVar(playerid, "PAO_DAOI2");
  2188.     DeletePVar(playerid, "PAO_SAOI1");
  2189.     DeletePVar(playerid, "PAO_SAOI2");
  2190.     DeletePVar(playerid, "PAO_SAOMI");
  2191.     DeletePVar(playerid, "PAO_SAOBI");
  2192.     DeletePVar(playerid, "PAO_SAOI");
  2193.     DeletePVar(playerid, "PAO_SAON");
  2194.     DeletePVar(playerid, "PAO_LAON");
  2195.     DeletePVar(playerid, "PAO_LAOI");
  2196.     DeletePVar(playerid, "PAO_LAOR");
  2197. }
  2198.  
  2199. AOE_ShowPlayerDialog(playerid, type, dialogid, caption[], button1[], button2[] = "")
  2200. {
  2201.     new AOE_STR2[1560], slot, slot2;
  2202.     switch(type)
  2203.     {
  2204.         case 0: // AOE menu
  2205.         {
  2206.             new slots = GetPlayerAttachedObjectsCount(playerid);
  2207.             slot = GetPVarInt(playerid, "PAO_LAOR");
  2208.             if(!GetPVarType(playerid, "PAO_LAOR")) AOE_STR = "{FF3333}Restore your last deleted attached object";
  2209.             else if(IsPlayerAttachedObjectSlotUsed(playerid, slot)) format(AOE_STR, sizeof(AOE_STR), "{CCCCCC}Restore your last deleted attached object [Index:%d]", slot);
  2210.             else format(AOE_STR, sizeof(AOE_STR), "Restore your last deleted attached object [Index:%d]", slot);
  2211.             if(!slots)
  2212.             {
  2213.                 format(AOE_STR2, sizeof(AOE_STR2), "Create your attached object\n{FF3333}Duplicate your attached object\n{FF3333}Edit your attached object\n\
  2214.                 {FF3333}Edit your attached object index\n{FF3333}Edit your attached object model\n{FF3333}Edit your attached object bone\n\
  2215.                 {FF3333}Save your attached object\n{FF3333}Save all of your attached object(s) [Total:%d]\nLoad attached object file\nLoad attached object(s) set", slots);
  2216.                 format(AOE_STR2, sizeof(AOE_STR2), "%s\n{FF3333}Remove your attached object\n{FF3333}Remove all of your attached object(s) [Total:%d]\n%s\n\
  2217.                 {FF3333}View your attached object stats\n{FFFFFF}Total attached object(s) [%d]", AOE_STR2, slots, AOE_STR, slots);
  2218.             }
  2219.             else if(slots == MAX_PLAYER_ATTACHED_OBJECTS)
  2220.             {
  2221.                 format(AOE_STR2, sizeof(AOE_STR2), "{FF3333}Create your attached object\n{CCCCCC}Duplicate your attached object\nEdit your attached object\n\
  2222.                 Edit your attached object index\nEdit your attached object model\nEdit your attached object bone\n\
  2223.                 Save your attached object\nSave all of your attached object(s) [Total:%d]\n{FF3333}Load attached object file\n{FF3333}Load attached object(s) set", slots);
  2224.                 format(AOE_STR2, sizeof(AOE_STR2), "%s\nRemove your attached object\nRemove all of your attached object(s) [Total:%d]\n%s\n\
  2225.                 View your attached object stats\nTotal attached object(s) [%d]", AOE_STR2, slots, AOE_STR, slots);
  2226.             }
  2227.             else
  2228.             {
  2229.                 format(AOE_STR2, sizeof(AOE_STR2), "Create your attached object\nDuplicate your attached object\nEdit your attached object\n\
  2230.                 Edit your attached object index\nEdit your attached object model\nEdit your attached object bone\n\
  2231.                 Save your attached object\nSave all of your attached object(s) [Total:%d]\nLoad attached object file\nLoad attached object(s) set", slots);
  2232.                 format(AOE_STR2, sizeof(AOE_STR2), "%s\nRemove your attached object\nRemove all of your attached object(s) [Total:%d]\n%s\n\
  2233.                 View your attached object stats\nTotal attached object(s) [%d]", AOE_STR2, slots, AOE_STR, slots);
  2234.             }
  2235.             strcat(AOE_STR2, "\nHelp/commands\nAbout this editor");
  2236.             ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, caption, AOE_STR2, button1, button2);
  2237.         }
  2238.         case 1: // AOE help
  2239.         {
  2240.             strcat(AOE_STR2, "/attachedobjecteditor (/aoe): Shows attached object editor menu dialog\n\
  2241.                 /createattachedobject (/cao): Create your attached object\n\
  2242.                 /editattachedobject (/eao): Edit your attached object\n\
  2243.                 /duplicateattachedobject (/dao): Duplicate your attached object\n");
  2244.             strcat(AOE_STR2, "/removeattachedobject (/rao): Remove your attached object\n\
  2245.                 /removeattachedobjects (/raos): Remove all of your attached object(s)\n\
  2246.                 /undeleteattachedobject (/udao): Restore your last deleted attached object\n\
  2247.                 /saveattachedobject (/sao): Save your attached object to a file\n");
  2248.             strcat(AOE_STR2, "/saveattachedobjects (/saos): Save all of your attached object(s) to a set file\n\
  2249.                 /loadattachedobject (/lao): Load existing attached object file\n\
  2250.                 /loadattachedobjects (/laos): Load existing attached object(s) set file\n\
  2251.                 /attachedobjectstats (/aos): Shows a player's or your attached object stats\n");
  2252.             strcat(AOE_STR2, "/totalattachedobjects (/taos): Shows the number of attached object(s)\n\
  2253.                 /refreshattachedobject (/rpao): Refresh another player's attached object\n\
  2254.                 /setattachedobjectindex (/saoi): Set your attached object index\n\
  2255.                 /setattachedobjectmodel (/saom): Set your attached object model\n");
  2256.             strcat(AOE_STR2, "/setattachedobjectbone (/saob): Set your attached object bone\n\
  2257.                 /setattachedobjectoffset[x/y/z] (/saoo[x/y/z]): Set your attached object offset [X/Y/Z]\n\
  2258.                 /setattachedobjectrot[x/y/z] (/saor[x/y/z]): Set your attached object rotation [RX/RY/RZ]\n");
  2259.             strcat(AOE_STR2, "/setattachedobjectscale[x/y/z] (/saos[x/y/z]): Set your attached object size [SX/SY/SZ]\n\
  2260.                 /setattachedobjectmc[1/2] (/saomc[1/2]): Set your attached object material color [#1/#2]");
  2261.             ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, caption, AOE_STR2, button1, button2);
  2262.         }
  2263.         case 2: // AOE about
  2264.         {
  2265.             GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
  2266.             format(AOE_STR2, sizeof(AOE_STR2), "[FilterScript] Attached Object Editor for SA:MP 0.3e or upper\nAn editor for player attachment\n\nVersion: %s\nCreated by: Robo_N1X\nhttp://forum.sa-mp.com/showthread.php?t=416138\n\nCredits & Thanks to:\n\
  2267.             > SA:MP Team (www.sa-mp.com)\n> h02/Scott: attachments editor idea\n> Y-Less (y-less.com)\n> Zeex: ZCMD\n> SA:MP Wiki Contributors (wiki.sa-mp.com)\nAnd whoever that made useful function for this script\nAlso you, %s for using this editor!",
  2268.             AOE_VERSION, PlayerName);
  2269.             ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, caption, AOE_STR2, button1, button2);
  2270.         }
  2271.         case 3: // AOE object model input
  2272.         {
  2273.             format(AOE_STR, sizeof(AOE_STR), "* %s: Please enter object model id/number...", caption);
  2274.             ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, caption, "Please enter a valid GTA:SA/SA:MP object model id/number below:", button1, button2);
  2275.             SendClientMessage(playerid, COLOR_WHITE, AOE_STR);
  2276.         }
  2277.         case 4: // AOE bone list
  2278.         {
  2279.             for(new i = 1; i <= MAX_ATTACHED_OBJECT_BONES; i++)
  2280.             {
  2281.                 format(AOE_STR2, sizeof(AOE_STR2), "%s%d. %s\n", AOE_STR2, i, GetAttachedObjectBoneName(i));
  2282.             }
  2283.             format(AOE_STR, sizeof(AOE_STR), "* %s: Please select attached object bone...", caption);
  2284.             ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, caption, AOE_STR2, button1, button2);
  2285.             SendClientMessage(playerid, COLOR_WHITE, AOE_STR);
  2286.         }
  2287.         case 5: // AOE slot/index list (free slot)
  2288.         {
  2289.             for(new i = 0; i < MAX_PLAYER_ATTACHED_OBJECTS; i++)
  2290.             {
  2291.                 if(IsValidPlayerAttachedObject(playerid, i) == -1) format(AOE_STR2, sizeof(AOE_STR2), "%s{FFFFFF}%d. None - (Not Used)\n", AOE_STR2, i);
  2292.                 else if(!IsValidPlayerAttachedObject(playerid, i)) format(AOE_STR2, sizeof(AOE_STR2), "%s{CCCCCC}%d. Unknown - Invalid attached object info\n", AOE_STR2, i);
  2293.                 else format(AOE_STR2, sizeof(AOE_STR2), "%s{FF3333}%d. %d - %s (BID:%d) - (Used)\n", AOE_STR2, i, PAO[playerid][i][AO_MODEL_ID], GetAttachedObjectBoneName(PAO[playerid][i][AO_BONE_ID]), PAO[playerid][i][AO_BONE_ID]);
  2294.             }
  2295.             if(!strcmp(button1, "Select", true)) format(AOE_STR, sizeof(AOE_STR), "* %s: Please select attached object slot/index number...", caption);
  2296.             else format(AOE_STR, sizeof(AOE_STR), "* %s: Please select attached object slot/index number to %s...", caption, button1);
  2297.             ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, caption, AOE_STR2, button1, button2);
  2298.             SendClientMessage(playerid, COLOR_WHITE, AOE_STR);
  2299.         }
  2300.         case 6: // AOE slot/index list (used slot)
  2301.         {
  2302.             for(new i = 0; i < MAX_PLAYER_ATTACHED_OBJECTS; i++)
  2303.             {
  2304.                 if(IsValidPlayerAttachedObject(playerid, i) == -1) format(AOE_STR2, sizeof(AOE_STR2), "%s{FF3333}%d. None - (Not Used)\n", AOE_STR2, i);
  2305.                 else if(!IsValidPlayerAttachedObject(playerid, i)) format(AOE_STR2, sizeof(AOE_STR2), "%s{CCCCCC}%d. Unknown - Invalid attached object info\n", AOE_STR2, i);
  2306.                 else format(AOE_STR2, sizeof(AOE_STR2), "%s{FFFFFF}%d. %d - %s (BID:%d) - (Used)\n", AOE_STR2, i, PAO[playerid][i][AO_MODEL_ID], GetAttachedObjectBoneName(PAO[playerid][i][AO_BONE_ID]), PAO[playerid][i][AO_BONE_ID]);
  2307.             }
  2308.             if(!strcmp(button1, "Select", true)) format(AOE_STR, sizeof(AOE_STR), "* %s: Please select attached object slot/index number...", caption);
  2309.             else format(AOE_STR, sizeof(AOE_STR), "* %s: Please select attached object slot/index number to %s...", caption, button1);
  2310.             ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, caption, AOE_STR2, button1, button2);
  2311.             SendClientMessage(playerid, COLOR_WHITE, AOE_STR);
  2312.         }
  2313.         case 7: // AOE stats
  2314.         {
  2315.             slot = GetPVarInt(playerid, "PAO_AOSI");
  2316.             new targetid = GetPVarInt(playerid, "PAO_AOSU");
  2317.             GetPlayerName(targetid, PlayerName, sizeof(PlayerName));
  2318.             format(AOE_STR2, sizeof(AOE_STR2), "Attached object slot/index number %d stats...\n\nStatus: %s\nModel ID/Number/Type: %d\nBone: %s (%d)\n\nOffsets\nX Offset: %f\nY Offset: %f\nZ Offset: %f\n\nRotations\nX Rotation: %f\nY Rotation: %f\
  2319.             \nZ Rotation: %f\n\nScales\nX Scale: %f\nY Scale: %f\nZ Scale: %f\n\nMaterials\nColor 1: 0x%x (%i) {%06x}¤{A9C4E4}\nColor 2: 0x%x (%i) {%06x}¤{A9C4E4}\n\nSkin ID: %d\nTotal of %s's attached object(s): %d", slot,
  2320.             ((PAO[targetid][slot][AO_STATUS] == 0) ? ("Invalid data") : ((PAO[targetid][slot][AO_STATUS] == 1) ? ("Valid Data") : ("Editing"))), PAO[targetid][slot][AO_MODEL_ID], GetAttachedObjectBoneName(PAO[targetid][slot][AO_BONE_ID]), PAO[targetid][slot][AO_BONE_ID],
  2321.             PAO[targetid][slot][AO_X], PAO[targetid][slot][AO_Y], PAO[targetid][slot][AO_Z], PAO[targetid][slot][AO_RX], PAO[targetid][slot][AO_RY], PAO[targetid][slot][AO_RZ], PAO[targetid][slot][AO_SX], PAO[targetid][slot][AO_SY], PAO[targetid][slot][AO_SZ],
  2322.             PAO[targetid][slot][AO_MC1], PAO[targetid][slot][AO_MC1], PAO[targetid][slot][AO_MC1] & 0xFFFFFF, PAO[targetid][slot][AO_MC2], PAO[targetid][slot][AO_MC2], PAO[targetid][slot][AO_MC2] & 0xFFFFFF, GetPlayerSkin(targetid), PlayerName, GetPlayerAttachedObjectsCount(targetid));
  2323.             ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, caption, AOE_STR2, (IsPlayerAdmin(playerid) ? button1 : button2), (IsPlayerAdmin(playerid) ? button2 : "")); // Only show "Close" button for non-admin
  2324.             if(targetid == playerid) format(AOE_STR, sizeof(AOE_STR), "* You're viewing your attached object stats from slot/index number %d", slot);
  2325.             else format(AOE_STR, sizeof(AOE_STR), "* You're viewing %s's attached object stats from slot/index number %d", PlayerName, slot);
  2326.             SendClientMessage(playerid, COLOR_CYAN, AOE_STR);
  2327.             if(IsPlayerAdmin(playerid)) SendClientMessage(playerid, COLOR_WHITE, "* As you're an admin, you can print this attached object stats & usage to the console");
  2328.         }
  2329.         case 8: // AOE create replace
  2330.         {
  2331.             format(AOE_STR2, sizeof(AOE_STR2), "Sorry, attached object slot/index number %d\nis already used, do you want to replace it?\n(This action can't be undone)", GetPVarInt(playerid, "PAO_CAOI"));
  2332.             ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, caption, AOE_STR2, button1, button2);
  2333.         }
  2334.         case 9: // AOE create final
  2335.         {
  2336.             format(AOE_STR2, sizeof(AOE_STR2), "You've created your attached object\nat slot/index number: %d\nModel: %d\nBone: %s (BID:%d)\n\nDo you want to edit your attached object?", GetPVarInt(playerid, "PAO_CAOI"),
  2337.             GetPVarInt(playerid, "PAO_CAOM"), GetAttachedObjectBoneName(GetPVarInt(playerid, "PAO_CAOB")), GetPVarInt(playerid, "PAO_CAOB"));
  2338.             ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, caption, AOE_STR2, button1, button2);
  2339.         }
  2340.         case 10: // AOE remove all
  2341.         {
  2342.             format(AOE_STR2, sizeof(AOE_STR2), "You're about to remove all of your attached object(s)\nTotal: %d\nAre you sure you want to remove them?\n(This action can't be undone)", GetPlayerAttachedObjectsCount(playerid));
  2343.             ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, caption, AOE_STR2, button1, button2);
  2344.         }
  2345.         case 11: // AOE duplicate replace
  2346.         {
  2347.             slot = GetPVarInt(playerid, "PAO_DAOI1"), slot2 = GetPVarInt(playerid, "PAO_DAOI2");
  2348.             format(AOE_STR2, sizeof(AOE_STR2), "You already have attached object at slot/index number %d!\nDo you want to replace it with attached object from slot %d?", slot, slot2);
  2349.             ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, caption, AOE_STR2, button1, button2);
  2350.         }
  2351.         case 12: // AOE set index replace
  2352.         {
  2353.             slot = GetPVarInt(playerid, "PAO_SAOI1"), slot2 = GetPVarInt(playerid, "PAO_SAOI2");
  2354.             format(AOE_STR2, sizeof(AOE_STR2), "You already have attached object at slot/index number %d!\nDo you want to replace it with attached object from slot %d?", slot2, slot);
  2355.             ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, caption, AOE_STR2, button1, button2);
  2356.         }
  2357.         case 13: // AOE save
  2358.         {
  2359.             format(AOE_STR, sizeof(AOE_STR), "* %s: Please enter attached object file name to save...", caption);
  2360.             ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, caption, "Please enter a valid file name to save this attached object below,\n\nPlease note that valid characters are:\n\
  2361.             A to Z or a to z, 0 to 9 and @, $, (, ), [, ], _, =, .\nand the length must be 1-24 characters long", button1, button2);
  2362.             SendClientMessage(playerid, COLOR_WHITE, AOE_STR);
  2363.         }
  2364.         case 14: // AOE load
  2365.         {
  2366.             format(AOE_STR, sizeof(AOE_STR), "* %s: Please enter attached object file name to load...", caption);
  2367.             ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, caption, "Please enter an valid and existing attached object file name below,\n\nPlease note that valid characters are:\n\
  2368.             A to Z or a to z, 0 to 9 and @, $, (, ), [, ], _, =, .\nand the length must be 1-24 characters long", button1, button2);
  2369.             SendClientMessage(playerid, COLOR_WHITE, AOE_STR);
  2370.         }
  2371.         case 15: // AOE load replace
  2372.         {
  2373.             format(AOE_STR2, sizeof(AOE_STR2), "You already have attached object at slot/index number %d!\nDo you want to continue loading and replace it?", GetPVarInt(playerid, "PAO_LAOI"));
  2374.             ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, caption, AOE_STR2, button1, button2);
  2375.         }
  2376.         case 16: // AOE save replace
  2377.         {
  2378.             new name[32];
  2379.             GetPVarString(playerid, "PAO_SAON", name, sizeof(name));
  2380.             format(AOE_STR2, sizeof(AOE_STR2), "The file \"%s\" is already exist!\nDo you want to replace and overwrite it?\n(This action can't be undone)", name);
  2381.             ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, caption, AOE_STR2, button1, button2);
  2382.             SendClientMessage(playerid, COLOR_WHITE, "* As you're an admin, you can replace an existed attached object file");
  2383.         }
  2384.     }
  2385. }
  2386.  
  2387. AOE_SavePlayerAttachedObject(playerid, filename[], index, comment[] = "", &filelen) // use MAX_PLAYER_ATTACHED_OBJECTS to save all
  2388. {
  2389.     if(!IsPlayerConnected(playerid)) return INVALID_PLAYER_ID;
  2390.     new File:SAO = fopen(filename, io_write), slots = 0;
  2391.     if(SAO)
  2392.     {
  2393.         new AOE_STR2[256], Year, Month, Day, Hour, Minute, Second;
  2394.         GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
  2395.         getdate(Year, Month, Day);
  2396.         gettime(Hour, Minute, Second);
  2397.         if(!strlen(comment))
  2398.         {
  2399.             format(AOE_STR, sizeof(AOE_STR), "// Created by %s for skin ID %d on %02d/%02d/%d - %02d:%02d:%02d", PlayerName, GetPlayerSkin(playerid), Day, Month, Year, Hour, Minute, Second);
  2400.             fwrite(SAO, AOE_STR);
  2401.         }
  2402.         if(index == MAX_PLAYER_ATTACHED_OBJECTS)
  2403.         {
  2404.             for(new i = 0; i < MAX_PLAYER_ATTACHED_OBJECTS; i++)
  2405.             {
  2406.                 if(IsValidPlayerAttachedObject(playerid, i) == 1)
  2407.                 {
  2408.                     format(AOE_STR2, sizeof(AOE_STR2), "\r\nSetPlayerAttachedObject(playerid, %d, %d, %d, %f, %f, %f, %f, %f, %f, %f, %f, %f, %x, %x);", i, PAO[playerid][i][AO_MODEL_ID], PAO[playerid][i][AO_BONE_ID],
  2409.                         PAO[playerid][i][AO_X], PAO[playerid][i][AO_Y], PAO[playerid][i][AO_Z], PAO[playerid][i][AO_RX], PAO[playerid][i][AO_RY], PAO[playerid][i][AO_RZ],
  2410.                         PAO[playerid][i][AO_SX], PAO[playerid][i][AO_SY], PAO[playerid][i][AO_SZ], PAO[playerid][i][AO_MC1], PAO[playerid][i][AO_MC2]);
  2411.                     fwrite(SAO, AOE_STR2);
  2412.                     slots++;
  2413.                 }
  2414.             }
  2415.         }
  2416.         else
  2417.         {
  2418.             if(IsValidPlayerAttachedObject(playerid, index) == 1)
  2419.             {
  2420.                 format(AOE_STR2, sizeof(AOE_STR2), "\r\nSetPlayerAttachedObject(playerid, %d, %d, %d, %f, %f, %f, %f, %f, %f, %f, %f, %f, %x, %x);", index, PAO[playerid][index][AO_MODEL_ID], PAO[playerid][index][AO_BONE_ID],
  2421.                     PAO[playerid][index][AO_X], PAO[playerid][index][AO_Y], PAO[playerid][index][AO_Z], PAO[playerid][index][AO_RX], PAO[playerid][index][AO_RY], PAO[playerid][index][AO_RZ],
  2422.                     PAO[playerid][index][AO_SX], PAO[playerid][index][AO_SY], PAO[playerid][index][AO_SZ], PAO[playerid][index][AO_MC1], PAO[playerid][index][AO_MC2]);
  2423.                 fwrite(SAO, AOE_STR2);
  2424.                 slots++;
  2425.             }
  2426.         }
  2427.         fclose(SAO);
  2428.         if(fexist(filename))
  2429.         {
  2430.             if(!slots) fremove(filename);
  2431.             else
  2432.             {
  2433.                 SAO = fopen(filename, io_read);
  2434.                 if(SAO)
  2435.                 {
  2436.                     filelen = flength(SAO);
  2437.                     fclose(SAO);
  2438.                 }
  2439.             }
  2440.         }
  2441.     }
  2442.     return slots;
  2443. }
  2444.  
  2445. AOE_LoadPlayerAttachedObject(playerid, filename[], index, const comment[], commentlen) // use MAX_PLAYER_ATTACHED_OBJECTS to load all
  2446. {
  2447.     #pragma unused comment
  2448.     if(!IsPlayerConnected(playerid)) return INVALID_PLAYER_ID;
  2449.     if(!fexist(filename)) return 0;
  2450.     new File:LAO = fopen(filename, io_read), slots = 0;
  2451.     if(LAO)
  2452.     {
  2453.         enum E_ATTACHED_OBJECT_L
  2454.         {
  2455.             LAO_MODEL_ID, LAO_BONE_ID,
  2456.             Float:LAO_X, Float:LAO_Y, Float:LAO_Z,
  2457.             Float:LAO_RX, Float:LAO_RY, Float:LAO_RZ,
  2458.             Float:LAO_SX, Float:LAO_SY, Float:LAO_SZ,
  2459.             hex:LAO_MC1, hex:LAO_MC2
  2460.         }
  2461.         new AOE_STR2[256], idx, LAOD[E_ATTACHED_OBJECT_L];
  2462.         while(fread(LAO, AOE_STR2))
  2463.         {
  2464.             if(!unformat(AOE_STR2, "'// 's[160]", AOE_STR2))
  2465.             {
  2466.                 for(new i = 0; i < commentlen; i++) setarg(3, i, AOE_STR2[i]);
  2467.             }
  2468.             else
  2469.             {
  2470.                 if(!unformat(AOE_STR2, "'SetPlayerAttachedObject'P<();,>{s[3]s[32]}dddF(0.0)F(0.0)F(0.0)F(0.0)F(0.0)F(0.0)F(1.0)F(1.0)F(1.0)X(0)X(0)", idx, LAOD[LAO_MODEL_ID], LAOD[LAO_BONE_ID],
  2471.                     LAOD[LAO_X], LAOD[LAO_Y], LAOD[LAO_Z], LAOD[LAO_RX], LAOD[LAO_RY], LAOD[LAO_RZ], LAOD[LAO_SX], LAOD[LAO_SY], LAOD[LAO_SZ], LAOD[LAO_MC1], LAOD[LAO_MC2]))
  2472.                 {
  2473.                     if(IsValidAttachedObjectSlot(idx) && IsValidObjectModel(LAOD[LAO_MODEL_ID]) && IsValidAttachedObjectBone(LAOD[LAO_BONE_ID]))
  2474.                     {
  2475.                         if(index == MAX_PLAYER_ATTACHED_OBJECTS)
  2476.                         {
  2477.                             if(slots == MAX_PLAYER_ATTACHED_OBJECTS) break;
  2478.                             slots += UpdatePlayerAttachedObjectEx(playerid, idx, LAOD[LAO_MODEL_ID], LAOD[LAO_BONE_ID], LAOD[LAO_X], LAOD[LAO_Y], LAOD[LAO_Z],
  2479.                                         LAOD[LAO_RX], LAOD[LAO_RY], LAOD[LAO_RZ], LAOD[LAO_SX], LAOD[LAO_SY], LAOD[LAO_SZ], LAOD[LAO_MC1], LAOD[LAO_MC2]);
  2480.                         }
  2481.                         else
  2482.                         {
  2483.                             if(index == idx)
  2484.                             {
  2485.                                 slots += UpdatePlayerAttachedObjectEx(playerid, idx, LAOD[LAO_MODEL_ID], LAOD[LAO_BONE_ID], LAOD[LAO_X], LAOD[LAO_Y], LAOD[LAO_Z],
  2486.                                             LAOD[LAO_RX], LAOD[LAO_RY], LAOD[LAO_RZ], LAOD[LAO_SX], LAOD[LAO_SY], LAOD[LAO_SZ], LAOD[LAO_MC1], LAOD[LAO_MC2]);
  2487.                                 break;
  2488.                             }
  2489.                         }
  2490.                     }
  2491.                 }
  2492.             }
  2493.         }
  2494.         fclose(LAO);
  2495.     }
  2496.     return slots;
  2497. }
  2498. //------------------------------------------------------------------------------
  2499. CreatePlayerAttachedObject(playerid, index, modelid, bone)
  2500. {
  2501.     if(!IsPlayerConnected(playerid)) return INVALID_PLAYER_ID;
  2502.     if(!IsValidAttachedObjectSlot(index) || !IsValidObjectModel(modelid) || !IsValidAttachedObjectBone(bone)) return 0;
  2503.     if(IsPlayerAttachedObjectSlotUsed(playerid, index)) RemovePlayerAttachedObject(playerid, index);
  2504.     SetPVarInt(playerid, "PAO_CAOI", index);
  2505.     SetPVarInt(playerid, "PAO_CAOM", modelid);
  2506.     SetPVarInt(playerid, "PAO_CAOB", bone);
  2507.     PAO[playerid][index][AO_STATUS] = 1;
  2508.     PAO[playerid][index][AO_MODEL_ID] = modelid;
  2509.     PAO[playerid][index][AO_BONE_ID] = bone;
  2510.     PAO[playerid][index][AO_X] = 0.0, PAO[playerid][index][AO_Y] = 0.0, PAO[playerid][index][AO_Z] = 0.0;
  2511.     PAO[playerid][index][AO_RX] = 0.0, PAO[playerid][index][AO_RY] = 0.0, PAO[playerid][index][AO_RZ] = 0.0;
  2512.     PAO[playerid][index][AO_SX] = 1.0, PAO[playerid][index][AO_SY] = 1.0, PAO[playerid][index][AO_SZ] = 1.0;
  2513.     PAO[playerid][index][AO_MC1] = 0, PAO[playerid][index][AO_MC2] = 0;
  2514.     return SetPlayerAttachedObject(playerid, index, modelid, bone);
  2515. }
  2516.  
  2517. UpdatePlayerAttachedObject(playerid, index, modelid, bone)
  2518.     return UpdatePlayerAttachedObjectEx(playerid, index, modelid, bone, PAO[playerid][index][AO_X], PAO[playerid][index][AO_Y], PAO[playerid][index][AO_Z], PAO[playerid][index][AO_RX], PAO[playerid][index][AO_RY], PAO[playerid][index][AO_RZ],
  2519.     PAO[playerid][index][AO_SX], PAO[playerid][index][AO_SY], PAO[playerid][index][AO_SZ], PAO[playerid][index][AO_MC1], PAO[playerid][index][AO_MC2]);
  2520.  
  2521. UpdatePlayerAttachedObjectEx(playerid, index, modelid, bone, Float:fOffsetX = 0.0, Float:fOffsetY = 0.0, Float:fOffsetZ = 0.0, Float:fRotX = 0.0, Float:fRotY = 0.0, Float:fRotZ = 0.0, Float:fScaleX = 1.0, Float:fScaleY = 1.0, Float:fScaleZ = 1.0, materialcolor1 = 0, materialcolor2 = 0)
  2522. {
  2523.     if(!IsPlayerConnected(playerid)) return INVALID_PLAYER_ID;
  2524.     if(!IsValidAttachedObjectSlot(index) || !IsValidObjectModel(modelid) || !IsValidAttachedObjectBone(bone)) return 0;
  2525.     PAO[playerid][index][AO_STATUS] = 1;
  2526.     PAO[playerid][index][AO_MODEL_ID] = modelid;
  2527.     PAO[playerid][index][AO_BONE_ID] = bone;
  2528.     PAO[playerid][index][AO_X] = fOffsetX, PAO[playerid][index][AO_Y] = fOffsetY, PAO[playerid][index][AO_Z] = fOffsetZ;
  2529.     PAO[playerid][index][AO_RX] = fRotX, PAO[playerid][index][AO_RY] = fRotY, PAO[playerid][index][AO_RZ] = fRotZ;
  2530.     PAO[playerid][index][AO_SX] = fScaleX, PAO[playerid][index][AO_SY] = fScaleY, PAO[playerid][index][AO_SZ] = fScaleZ;
  2531.     PAO[playerid][index][AO_MC1] = materialcolor1, PAO[playerid][index][AO_MC2] = materialcolor2;
  2532.     return SetPlayerAttachedObject(playerid, index, modelid, bone, fOffsetX, fOffsetY, fOffsetZ, fRotX, fRotY, fRotZ, fScaleX, fScaleY, fScaleZ, materialcolor1, materialcolor2);
  2533. }
  2534.  
  2535. DuplicatePlayerAttachedObject(playerid, fromindex, asindex)
  2536. {
  2537.     if(IsValidPlayerAttachedObject(playerid, fromindex) && IsValidAttachedObjectSlot(fromindex) && IsValidAttachedObjectSlot(asindex))
  2538.     {
  2539.         if(IsPlayerAttachedObjectSlotUsed(playerid, asindex)) RemovePlayerAttachedObject(playerid, asindex);
  2540.         return UpdatePlayerAttachedObjectEx(playerid, asindex, PAO[playerid][fromindex][AO_MODEL_ID], PAO[playerid][fromindex][AO_BONE_ID], PAO[playerid][fromindex][AO_X], PAO[playerid][fromindex][AO_Y], PAO[playerid][fromindex][AO_Z],
  2541.         PAO[playerid][fromindex][AO_RX], PAO[playerid][fromindex][AO_RY], PAO[playerid][fromindex][AO_RZ], PAO[playerid][fromindex][AO_SX], PAO[playerid][fromindex][AO_SY], PAO[playerid][fromindex][AO_SZ], PAO[playerid][fromindex][AO_MC1], PAO[playerid][fromindex][AO_MC2]);
  2542.     }
  2543.     return 0;
  2544. }
  2545.  
  2546. MovePlayerAttachedObjectIndex(playerid, fromindex, toindex)
  2547. {
  2548.     if(IsValidPlayerAttachedObject(playerid, fromindex) && IsValidAttachedObjectSlot(toindex))
  2549.     {
  2550.         if(IsPlayerAttachedObjectSlotUsed(playerid, fromindex)) RemovePlayerAttachedObject(playerid, fromindex), PAO[playerid][fromindex][AO_STATUS] = 0;
  2551.         return UpdatePlayerAttachedObjectEx(playerid, toindex, PAO[playerid][fromindex][AO_MODEL_ID], PAO[playerid][fromindex][AO_BONE_ID], PAO[playerid][fromindex][AO_X], PAO[playerid][fromindex][AO_Y], PAO[playerid][fromindex][AO_Z],
  2552.         PAO[playerid][fromindex][AO_RX], PAO[playerid][fromindex][AO_RY], PAO[playerid][fromindex][AO_RZ], PAO[playerid][fromindex][AO_SX], PAO[playerid][fromindex][AO_SY], PAO[playerid][fromindex][AO_SZ], PAO[playerid][fromindex][AO_MC1], PAO[playerid][fromindex][AO_MC2]);
  2553.     }
  2554.     return 0;
  2555. }
  2556.  
  2557. RefreshPlayerAttachedObject(playerid, forplayerid, index)
  2558. {
  2559.     if(!IsPlayerConnected(playerid) || !IsPlayerConnected(forplayerid)) return INVALID_PLAYER_ID;
  2560.     if(IsPlayerAttachedObjectSlotUsed(playerid, index) || IsValidPlayerAttachedObject(playerid, index))
  2561.     {
  2562.         return UpdatePlayerAttachedObjectEx(forplayerid, index, PAO[playerid][index][AO_MODEL_ID], PAO[playerid][index][AO_BONE_ID], PAO[playerid][index][AO_X], PAO[playerid][index][AO_Y], PAO[playerid][index][AO_Z],
  2563.         PAO[playerid][index][AO_RX], PAO[playerid][index][AO_RY], PAO[playerid][index][AO_RZ], PAO[playerid][index][AO_SX], PAO[playerid][index][AO_SY], PAO[playerid][index][AO_SZ], PAO[playerid][index][AO_MC1], PAO[playerid][index][AO_MC2]);
  2564.     }
  2565.     return 0;
  2566. }
  2567.  
  2568. RestorePlayerAttachedObject(playerid, index)
  2569. {
  2570.     if(!IsPlayerConnected(playerid)) return INVALID_PLAYER_ID;
  2571.     if(IsValidAttachedObjectSlot(index) || IsValidObjectModel(PAO[playerid][index][AO_MODEL_ID]) || IsValidAttachedObjectBone(PAO[playerid][index][AO_BONE_ID]))
  2572.     {
  2573.         PAO[playerid][index][AO_STATUS] = 1;
  2574.         return SetPlayerAttachedObject(playerid, index, PAO[playerid][index][AO_MODEL_ID], PAO[playerid][index][AO_BONE_ID], PAO[playerid][index][AO_X], PAO[playerid][index][AO_Y], PAO[playerid][index][AO_Z],
  2575.         PAO[playerid][index][AO_RX], PAO[playerid][index][AO_RY], PAO[playerid][index][AO_RZ], PAO[playerid][index][AO_SX], PAO[playerid][index][AO_SY], PAO[playerid][index][AO_SZ], PAO[playerid][index][AO_MC1], PAO[playerid][index][AO_MC2]);
  2576.     }
  2577.     return 0;
  2578. }
  2579.  
  2580. RemovePlayerAttachedObjectEx(playerid, index = -1) // use MAX_PLAYER_ATTACHED_OBJECTS as index to remove all
  2581. {
  2582.     if(!IsPlayerConnected(playerid)) return INVALID_PLAYER_ID;
  2583.     new _AttachedObjectsRemoved = 0;
  2584.     if(index == MAX_PLAYER_ATTACHED_OBJECTS)
  2585.     {
  2586.         for(new i = 0; i < MAX_PLAYER_ATTACHED_OBJECTS; i++)
  2587.         {
  2588.             if(IsPlayerAttachedObjectSlotUsed(playerid, i))
  2589.             {
  2590.                 _AttachedObjectsRemoved += RemovePlayerAttachedObject(playerid, i);
  2591.                 PAO[playerid][i][AO_STATUS] = 0;
  2592.                 SetPVarInt(playerid, "PAO_LAOR", i);
  2593.             }
  2594.         }
  2595.     }
  2596.     else
  2597.     {
  2598.         if(index == -1) index = GetPVarInt(playerid, "PAO_LAOR");
  2599.         if(!IsValidAttachedObjectSlot(index)) return 0;
  2600.         if(IsPlayerAttachedObjectSlotUsed(playerid, index))
  2601.         {
  2602.             _AttachedObjectsRemoved += RemovePlayerAttachedObject(playerid, index);
  2603.             PAO[playerid][index][AO_STATUS] = 0;
  2604.             SetPVarInt(playerid, "PAO_LAOR", index);
  2605.         }
  2606.     }
  2607.     return _AttachedObjectsRemoved;
  2608. }
  2609.  
  2610. GetAttachedObjectBoneName(BoneID)
  2611. {
  2612.     new _AttachedObjectBoneName[15+1];
  2613.     if(!IsValidAttachedObjectBone(BoneID)) _AttachedObjectBoneName = "INVALID_BONE_ID";
  2614.     else _AttachedObjectBoneName = AttachedObjectBones[BoneID - 1];
  2615.     return _AttachedObjectBoneName;
  2616. }
  2617.  
  2618. GetAttachedObjectBone(const BoneName[])
  2619. {
  2620.     if(!IsValidAttachedObjectBoneName(BoneName)) return 0;
  2621.     if(IsNumeric(BoneName) && IsValidAttachedObjectBoneName(BoneName)) return strval(BoneName);
  2622.     for(new i = 0; i < sizeof(AttachedObjectBones); i++)
  2623.     {
  2624.         if(strfind(AttachedObjectBones[i], BoneName, true) != -1) return i + 1;
  2625.     }
  2626.     return 0;
  2627. }
  2628.  
  2629. GetAttachedObjectsCount()
  2630. {
  2631.     new _AttachedObjectsCount;
  2632.     new j = GetMaxPlayers();
  2633.     if(j > MAX_PLAYERS) j = MAX_PLAYERS;
  2634.     for(new i = 0; i < j; i++)
  2635.     {
  2636.         if(IsPlayerConnected(i))
  2637.         {
  2638.             for(new x = 0; x < MAX_PLAYER_ATTACHED_OBJECTS; x++)
  2639.             {
  2640.                 if(IsPlayerAttachedObjectSlotUsed(i, x)) _AttachedObjectsCount++;
  2641.             }
  2642.         }
  2643.      }
  2644.     return _AttachedObjectsCount;
  2645. }
  2646.  
  2647. GetPlayerAttachedObjectsCount(playerid)
  2648. {
  2649.     if(!IsPlayerConnected(playerid)) return INVALID_PLAYER_ID;
  2650.     new _PlayerAttachedObjectsCount;
  2651.     for(new i = 0; i < MAX_PLAYER_ATTACHED_OBJECTS; i++)
  2652.     {
  2653.         if(IsPlayerAttachedObjectSlotUsed(playerid, i)) _PlayerAttachedObjectsCount++;
  2654.     }
  2655.     return _PlayerAttachedObjectsCount;
  2656. }
  2657.  
  2658. IsValidPlayerAttachedObject(playerid, index)
  2659. {
  2660.     if(!IsPlayerConnected(playerid)) return INVALID_PLAYER_ID; // Player is offline
  2661.     if(!IsPlayerAttachedObjectSlotUsed(playerid, index)) return -1; // Not used
  2662.     if(!IsValidAttachedObjectSlot(index) || !IsValidObjectModel(PAO[playerid][index][AO_MODEL_ID]) || !IsValidAttachedObjectBone(PAO[playerid][index][AO_BONE_ID]) || !PAO[playerid][index][AO_STATUS]) return 0; // Invalid data
  2663.     return 1;
  2664. }
  2665.  
  2666. IsValidAttachedObjectSlot(SlotID)
  2667.     return (0 <= SlotID < MAX_PLAYER_ATTACHED_OBJECTS);
  2668.  
  2669. IsValidAttachedObjectBone(BoneID)
  2670.     return (1 <= BoneID <= MAX_ATTACHED_OBJECT_BONES);
  2671.  
  2672. IsValidAttachedObjectBoneName(const BoneName[])
  2673. {
  2674.     new length = strlen(BoneName);
  2675.     if(!length || length > 16) return false;
  2676.     for(new i = 0; i < sizeof(AttachedObjectBones); i++)
  2677.     {
  2678.         if(!strcmp(BoneName, AttachedObjectBones[i], true)) return true;
  2679.     }
  2680.     if(IsNumeric(BoneName) && IsValidAttachedObjectBone(strval(BoneName))) return true;
  2681.     return false;
  2682. }
  2683.  
  2684. IsValidObjectModel(ModelID)
  2685. {
  2686.     return((ModelID >= 321 && ModelID <= 328)
  2687.     || (ModelID >= 330 && ModelID <= 331)
  2688.     || (ModelID >= 333 && ModelID <= 339)
  2689.     || (ModelID >= 341 && ModelID <= 373)
  2690.     || (ModelID >= 615 && ModelID <= 698)
  2691.     || (ModelID >= 700 && ModelID <= 1193)
  2692.     || (ModelID >= 1207 && ModelID <= 1698)
  2693.     || (ModelID >= 1700 && ModelID <= 4762)
  2694.     || (ModelID >= 4806 && ModelID <= 6525)
  2695.     || (ModelID >= 6863 && ModelID <= 11681)
  2696.     || (ModelID >= 12800 && ModelID <= 13890)
  2697.     || (ModelID >= 14383 && ModelID <= 14898)
  2698.     || (ModelID >= 14900 && ModelID <= 14903)
  2699.     || (ModelID >= 15025 && ModelID <= 15064)
  2700.     || (ModelID >= 16000 && ModelID <= 16790)
  2701.     || (ModelID >= 17000 && ModelID <= 18630)
  2702.     // SA:MP Objects 18631 - 19521 (0.3x RC2-4)
  2703.     || (ModelID >= 18631 && ModelID <= 19521)
  2704.     // Custom Objects 19522 - 19999 (can be changed)
  2705.     || (ModelID >= 19522 && ModelID <= 19999));
  2706. }
  2707.  
  2708. IsValidFileName(const filename[])
  2709. {
  2710.     new length = strlen(filename);
  2711.     if(1 < length > 24) return false;
  2712.     for(new j = 0; j < length; j++)
  2713.     {
  2714.         if((filename[j] < 'A' || filename[j] > 'Z') && (filename[j] < 'a' || filename[j] > 'z') && (filename[j] < '0' || filename[j] > '9')
  2715.             && (filename[j] != '@' || filename[j] != '$' || filename[j] != '(' || filename[j] != ')' || filename[j] != '['
  2716.             || filename[j] != ']' || filename[j] != '_' || filename[j] != '=' || filename[j] != '.')) return false;
  2717.     }
  2718.     return true;
  2719. }
  2720. //------------------------------------------------------------------------------
  2721. stock IsNumeric(const string[])
  2722. {
  2723.     new length = strlen(string);
  2724.     if(!length) return false;
  2725.     for(new i = 0; i < length; i++)
  2726.     {
  2727.         if(string[i] > '9' || string[i] <'0') return false;
  2728.     }
  2729.     return true;
  2730. }
Add Comment
Please, Sign In to add comment