Advertisement
Guest User

Untitled

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