Advertisement
Guest User

Dennis12's Attachments Object Editor

a guest
Aug 4th, 2018
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.56 KB | None | 0 0
  1. /*
  2.     Script Version: v1
  3.     This FilterScript was created by Dennis12
  4.     LEAKS.RO  -> leaks.ro/profile/411-dennis12/
  5.     SA-MP.RO  -> www.sa-mp.ro/profile/20571-dennis12/
  6.     SA-MP.COM -> forum.sa-mp.com/member.php?u=305443
  7. */
  8.  
  9. #define FILTERSCRIPT
  10.  
  11. #include <a_samp>
  12. #include <zcmd>
  13.  
  14. #if defined FILTERSCRIPT
  15.  
  16. #define D12_MESSAGE SendClientMessage
  17. #define COLOR_YELLOW 0xFFFF00AA
  18.  
  19. public OnFilterScriptInit()
  20. {
  21.     for(new i = 0, x = 50; i < x; i++) SendClientMessageToAll(-1,"");
  22.     print("This FilterScript was created by Dennis12( D12 ).");
  23.     print("For help, type the [/help] command in the game.");
  24.     print("Or read this topic: https ...");
  25.     return 1;
  26. }
  27. public OnFilterScriptExit()
  28. {
  29.     print("Thanks for using 'D12 ATTACHMENTS OBJECT EDITOR'!");
  30.     return 1;
  31. }
  32. public OnPlayerSpawn(playerid) {
  33.     SetPlayerPos(playerid, 112.6015,-162.6049,1.5781);
  34.     D12_MESSAGE(playerid,0xFF0000FF,"[D12 ATTACHMENTS OBJECT EDITOR]");
  35.     D12_MESSAGE(playerid,0xFF0000FF,"This FilterScript was created by Dennis12.");
  36.     D12_MESSAGE(playerid,0xFF0000FF,"For help, type the [/help] command.");
  37.     return 1;
  38. }
  39.  
  40.  
  41. // Enums
  42. enum D12_ATTACHED_OBJECT {
  43.     objectID,
  44.     objectSlot,
  45.     objectBone,
  46.     Float: objectPos[3],
  47.     Float: objectRot[3],
  48.     Float: objectScale[3]
  49. };
  50. new D12_AO[MAX_PLAYERS][MAX_PLAYER_ATTACHED_OBJECTS][D12_ATTACHED_OBJECT];
  51.  
  52. enum { D_EDITOBJECT, D_CLEARSLOT, D_EDITSLOT };
  53.  
  54. // Commmands
  55. COMMAND:attach(playerid) {
  56.     new szStr[256];
  57.     format(szStr, 256, "Slot 0[objectid: %d]\nSlot 1[objectid: %d]\nSlot 2[objectid: %d]\nSlot 3[objectid: %d]\nSlot 4[objectid: %d]\nSlot 5[objectid: %d]\nSlot 6[objectid: %d]\nSlot 7[objectid: %d]\nSlot 8[objectid: %d]\nSlot 9[objectid: %d]",
  58.     D12_AO[playerid][0][objectID], D12_AO[playerid][1][objectID],D12_AO[playerid][2][objectID],D12_AO[playerid][3][objectID],D12_AO[playerid][4][objectID],D12_AO[playerid][5][objectID],D12_AO[playerid][6][objectID],D12_AO[playerid][7][objectID],D12_AO[playerid][8][objectID],D12_AO[playerid][9][objectID]);
  59.     ShowPlayerDialog(playerid, D_EDITSLOT, DIALOG_STYLE_LIST, "[D12] Attach Object:",szStr,"Edit","Cancel");
  60.     return true;
  61. }
  62. COMMAND:saveattach(playerid, params[]) {
  63.     new
  64.         File: attach,
  65.         writeAttach[ 512 ],
  66.         writeObjects;  
  67.        
  68.     if(!fexist("attach.pwn")) {
  69.         attach = fopen("attach.pwn", io_write);
  70.         fclose(attach);
  71.     } attach = fopen("attach.pwn", io_append);
  72.    
  73.     if(isnull(params)) return D12_MESSAGE(playerid,0xFF0000FF,"You need to write a project name to save your project."), D12_MESSAGE(playerid,COLOR_YELLOW,"/saveattach <project name>");  
  74.    
  75.     for(new i = 0; i < MAX_PLAYER_ATTACHED_OBJECTS; i++) {
  76.         if(D12_AO[playerid][i][objectID] != 0) {
  77.             format(writeAttach, 512, "\nDENNIS12 ATTACHED OBJECT CREATOR\n\n//Slot %d | Project Name: %s\nSetPlayerAttachedObject(playerid, %d, %d, %d, %f, %f, %f, %f, %f, %f, %f, %f, %f);\r\n",
  78.                   D12_AO[playerid][i][objectSlot], params, D12_AO[playerid][i][objectSlot], D12_AO[playerid][i][objectID],D12_AO[playerid][i][objectBone],D12_AO[playerid][i][objectPos][0],D12_AO[playerid][i][objectPos][1],D12_AO[playerid][i][objectPos][2],D12_AO[playerid][i][objectRot][0],D12_AO[playerid][i][objectRot][1],D12_AO[playerid][i][objectRot][2],
  79.                   D12_AO[playerid][i][objectScale][0],D12_AO[playerid][i][objectScale][1],D12_AO[playerid][i][objectScale][2]);
  80.            
  81.             fwrite(attach, writeAttach);
  82.             writeObjects ++;
  83.         }
  84.     }
  85.     if(!writeObjects) return D12_MESSAGE(playerid,0xFF0000FF,"There is nothing you can export.");
  86.    
  87.     fclose(attach);
  88.     D12_MESSAGE(playerid, -1, writeAttach),D12_MESSAGE(playerid, COLOR_YELLOW, "[D12 Attached Object Editor]"),D12_MESSAGE(playerid, COLOR_YELLOW, "Attached objects were saved in the file attach.pwn."),D12_MESSAGE(playerid, COLOR_YELLOW, "The file 'attach' can be found in scriptfiles -> attach.pwn.");
  89.     return true;
  90. }
  91. COMMAND:clearattach(playerid) {
  92.     new szStr[ 256 ];
  93.     format(szStr,256,"Clear Slots\nSlot 0[objectid: %d]\nSlot 1[objectid: %d]\nSlot 2[objectid: %d]\nSlot 3[objectid: %d]\nSlot 4[objectid: %d]\nSlot 5[objectid: %d]\nSlot 6[objectid: %d]\nSlot 7[objectid: %d]\nSlot 8[objectid: %d]\nSlot 9[objectid: %d]",
  94.     D12_AO[playerid][0][objectID], D12_AO[playerid][1][objectID],D12_AO[playerid][2][objectID],D12_AO[playerid][3][objectID],D12_AO[playerid][4][objectID],D12_AO[playerid][5][objectID],D12_AO[playerid][6][objectID],D12_AO[playerid][7][objectID],D12_AO[playerid][8][objectID],D12_AO[playerid][9][objectID]);
  95.     ShowPlayerDialog(playerid, D_CLEARSLOT, DIALOG_STYLE_LIST, "[D12] Clear Slots:",szStr,"Clear","Cancel");
  96.     return true;
  97. }
  98. COMMAND:editattach(playerid) {
  99.     new szStr[ 256 ];
  100.     format(szStr,256,"Slot 0[objectid: %d]\nSlot 1[objectid: %d]\nSlot 2[objectid: %d]\nSlot 3[objectid: %d]\nSlot 4[objectid: %d]\nSlot 5[objectid: %d]\nSlot 6[objectid: %d]\nSlot 7[objectid: %d]\nSlot 8[objectid: %d]\nSlot 9[objectid: %d]",
  101.     D12_AO[playerid][0][objectID], D12_AO[playerid][1][objectID],D12_AO[playerid][2][objectID],D12_AO[playerid][3][objectID],D12_AO[playerid][4][objectID],D12_AO[playerid][5][objectID],D12_AO[playerid][6][objectID],D12_AO[playerid][7][objectID],D12_AO[playerid][8][objectID],D12_AO[playerid][9][objectID]);
  102.     ShowPlayerDialog(playerid, D_EDITOBJECT, DIALOG_STYLE_LIST, "[D12] Edit Slots:",szStr,"Edit","Cancel");
  103.     return true;
  104. }
  105. COMMAND:clearfile(playerid) {
  106.     new File: attach;  
  107.    
  108.     if(fexist("attach.pwn")) {
  109.         attach = fopen("attach.pwn", io_write);
  110.         fwrite(attach,"");
  111.         fclose(attach);
  112.         D12_MESSAGE(playerid,COLOR_YELLOW,"The attach.pwn has been cleared.");
  113.     } else D12_MESSAGE(playerid, 0xFF0000FF, "The attach.pwn file could not be found in the scriptfiles folder.");
  114.     return true;
  115. }
  116. COMMAND:help(playerid) {
  117.     new dialog[1024];
  118.     dialog[0] = EOS;
  119.     strcat(dialog,"{FFFFFF}D12 Attachments Object Editor\n\n");
  120.     strcat(dialog,"{FFFFFF}/attach      -> To attach an object to one of the 9 slots.\n");
  121.     strcat(dialog,"{FFFFFF}/editattach  -> To edit an attached object.\n");
  122.     strcat(dialog,"{FFFFFF}/clearattach -> To delete the object on one of the 9 slots.\n");
  123.     strcat(dialog,"{FFFFFF}/saveattach  -> To save your progress into [scriptfiles/attach.pwn].\n");
  124.     strcat(dialog,"{FFFFFF}/clearfile   -> To delete the contents of the attach.pwn file.");
  125.     ShowPlayerDialog(playerid, 69, DIALOG_STYLE_MSGBOX,"D12 Attachments Editor Help",dialog,"Thanks","");
  126.     return true;
  127. }
  128.  
  129. public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[]) {
  130.     switch(dialogid) {
  131.         case D_EDITOBJECT: {
  132.             if(!response) return true;
  133.             switch(listitem) {
  134.                 case 0 .. 9: {
  135.                     if(D12_AO[playerid][listitem][objectID] == 0) return D12_MESSAGE(playerid,0xFF0000FF,"You have no object attached to this slot.");
  136.                     EditAttachedObject(playerid, listitem);
  137.                     new string[ 64 ];
  138.                     format(string, 64, "You are now editing attached object in the slot %d.", listitem);
  139.                     D12_MESSAGE(playerid,COLOR_YELLOW,string);
  140.                 }
  141.             }
  142.         }
  143.         case D_CLEARSLOT: {
  144.             if(!response) return true;
  145.             switch(listitem) {
  146.                 case 0: {
  147.                     for(new i = 0; i < MAX_PLAYER_ATTACHED_OBJECTS; i++) {
  148.                         if(D12_AO[playerid][i][objectID] != 0) RemovePlayerAttachedObject(playerid, i);
  149.                         D12_AO[playerid][i][objectID] = 0;
  150.                     }
  151.                     D12_MESSAGE(playerid,COLOR_YELLOW,"All attachments have been deleted.");
  152.                 }
  153.                 case 1 .. 10: {
  154.                     if(D12_AO[playerid][listitem-1][objectID] == 0) return D12_MESSAGE(playerid,0xFF0000FF,"You have no object attached to this slot.");
  155.                     D12_AO[playerid][listitem-1][objectID] = 0;
  156.                    
  157.                     if(IsPlayerAttachedObjectSlotUsed(playerid, listitem-1))
  158.                         RemovePlayerAttachedObject(playerid, listitem-1);
  159.                        
  160.                     new string[64];
  161.                     format(string, 64, "You deleted the attached object in the slot %d.",listitem-1);
  162.                     D12_MESSAGE(playerid,0xFF0000FF,string);
  163.                 }
  164.             }
  165.         }
  166.         case D_EDITSLOT: {
  167.             if(!response) return true;
  168.             switch(listitem) {
  169.                 case 0 .. 9: {
  170.                     if(D12_AO[playerid][listitem][objectID] != 0) return D12_MESSAGE(playerid,-1,"You already have an object attached to this slot. Use [/clearattach].");
  171.                     new szTitle[20], szString[64];
  172.                     SetPVarInt(playerid,"selectedSlot", listitem);
  173.                     format(szTitle, 20,"Editing Slot: %d", GetPVarInt(playerid,"selectedSlot"));
  174.                     format(szString,64,"Type the object ID you want to attach for slot %d", GetPVarInt(playerid,"selectedSlot"));
  175.                     ShowPlayerDialog(playerid,D_EDITSLOT+1,DIALOG_STYLE_INPUT,szTitle,szString,"Done","Cancel");
  176.                     SetPVarInt(playerid,"editSlotStep",0);
  177.                 }
  178.             }
  179.         }
  180.         case D_EDITSLOT+1: {
  181.             if(!response) return DeletePVar(playerid,"objectID"), DeletePVar(playerid,"objectBone");
  182.             switch(GetPVarInt(playerid,"editSlotStep")) {
  183.                 case 0: {
  184.                     if(isnull(inputtext) || strval(inputtext) < 0) return D12_MESSAGE(playerid,0xFF0000FF,"Invalid objectid");
  185.                     SetPVarInt(playerid,"objectID", strval(inputtext));
  186.                     SetPVarInt(playerid,"editSlotStep", 1);
  187.                     ShowPlayerDialog(playerid,D_EDITSLOT+1,DIALOG_STYLE_LIST,"[D12 OC] Select Bone","Spine\nHead\nLeft Upper Arm\nRight Upper Arm\nLeft Hand\nRight Hand\nLeft Tigh\nRight Tigh\nLeft Foot\nRight Foot\nRight Calf\nLeft Calf\nLeft forearm\nRight forearm\nLeft clavicle (shoulder)\nRight clavicle (shoulder)\nNeck\nJaw","Select","Close");
  188.                 }
  189.                 case 1: {
  190.                     switch(listitem) {
  191.                         case 0 .. 17: {
  192.                             SetPVarInt(playerid, "objectBone", listitem+1);
  193.                             SetPVarInt(playerid, "editSlotStep", 2);
  194.                             ShowPlayerDialog(playerid,D_EDITSLOT+1,DIALOG_STYLE_MSGBOX,"[D12 OC] Save Settings","You want to create your object by your settings?","Yes","No");
  195.                         }
  196.                     }
  197.                 }
  198.                 case 2: {
  199.                     new slot = GetPVarInt(playerid,"selectedSlot");
  200.                     D12_AO[playerid][slot][objectID]     = GetPVarInt(playerid,"objectID");
  201.                     D12_AO[playerid][slot][objectSlot]   = GetPVarInt(playerid,"selectedSlot");
  202.                     D12_AO[playerid][slot][objectBone]   = GetPVarInt(playerid,"objectBone");
  203.                     D12_AO[playerid][slot][objectPos][0] = 0.0;
  204.                     D12_AO[playerid][slot][objectPos][1] = 0.0;
  205.                     D12_AO[playerid][slot][objectPos][2] = 0.0;
  206.                     D12_AO[playerid][slot][objectRot][0] = 0.0;
  207.                     D12_AO[playerid][slot][objectRot][1] = 0.0;
  208.                     D12_AO[playerid][slot][objectRot][2] = 0.0;
  209.                     D12_AO[playerid][slot][objectScale][0] = 1.0;
  210.                     D12_AO[playerid][slot][objectScale][1] = 1.0;
  211.                     D12_AO[playerid][slot][objectScale][2] = 1.0;
  212.                    
  213.                     SetPlayerAttachedObject(playerid,D12_AO[playerid][slot][objectSlot],D12_AO[playerid][slot][objectID],D12_AO[playerid][slot][objectBone],D12_AO[playerid][slot][objectPos][0],D12_AO[playerid][slot][objectPos][1],D12_AO[playerid][slot][objectPos][2],D12_AO[playerid][slot][objectRot][0],D12_AO[playerid][slot][objectRot][1],D12_AO[playerid][slot][objectRot][2],D12_AO[playerid][slot][objectScale][0],D12_AO[playerid][slot][objectScale][1],D12_AO[playerid][slot][objectScale][2]);
  214.                     EditAttachedObject(playerid, D12_AO[playerid][slot][objectSlot]);
  215.                 }
  216.             }
  217.         }
  218.     }
  219.     return true;
  220. }
  221.  
  222. 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)
  223. {
  224.     switch(response) {
  225.         case 0: {
  226.             D12_AO[playerid][index][objectID]   = 0;
  227.             D12_AO[playerid][index][objectBone] = 0;
  228.             D12_AO[playerid][index][objectSlot] = 0;
  229.            
  230.             if(IsPlayerAttachedObjectSlotUsed(playerid, index)) RemovePlayerAttachedObject(playerid, index);
  231.  
  232.             D12_MESSAGE(playerid,COLOR_YELLOW,"Object not saved.");
  233.         }
  234.         case 1: {
  235.             D12_AO[playerid][index][objectPos][0]   = fOffsetX;
  236.             D12_AO[playerid][index][objectPos][1]   = fOffsetY;
  237.             D12_AO[playerid][index][objectPos][2]   = fOffsetZ;
  238.             D12_AO[playerid][index][objectRot][0]   = fRotX;
  239.             D12_AO[playerid][index][objectRot][1]   = fRotY;
  240.             D12_AO[playerid][index][objectRot][2]   = fRotZ;
  241.             D12_AO[playerid][index][objectScale][0] = fScaleX;
  242.             D12_AO[playerid][index][objectScale][1] = fScaleY;
  243.             D12_AO[playerid][index][objectScale][2] = fScaleZ;
  244.  
  245.             if(IsPlayerAttachedObjectSlotUsed(playerid, index)) RemovePlayerAttachedObject(playerid, index);
  246.                
  247.             SetPlayerAttachedObject(playerid,D12_AO[playerid][index][objectSlot],D12_AO[playerid][index][objectID],D12_AO[playerid][index][objectBone],D12_AO[playerid][index][objectPos][0],D12_AO[playerid][index][objectPos][1],D12_AO[playerid][index][objectPos][2],D12_AO[playerid][index][objectRot][0],D12_AO[playerid][index][objectRot][1],D12_AO[playerid][index][objectRot][2],D12_AO[playerid][index][objectScale][0],D12_AO[playerid][index][objectScale][1],D12_AO[playerid][index][objectScale][2]);
  248.        
  249.             D12_MESSAGE(playerid,COLOR_YELLOW,"Object saved.");
  250.         }
  251.     }
  252.     return true;
  253. }
  254. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement