Advertisement
Guest User

Attached Object Editor [0.3e]

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