Advertisement
LeomarMM

Object Attacher ( EDITOR ) by TreePuncher

Nov 4th, 2012
1,671
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.80 KB | None | 0 0
  1. //Made by TreePuncher or Jay_McReary
  2. #include <a_samp>
  3. #include <DOF2>
  4. new bool:UsingEDIT[MAX_PLAYERS];
  5. stock IsNumeric(string[])
  6. {
  7.     for (new i = 0, j = strlen(string);
  8.     i < j; i++)
  9.     {
  10.     if (string[i] > '9' || string[i] < '0')
  11.     return 0;
  12.     }
  13.     return 1;
  14. }
  15. public OnFilterScriptInit()
  16. {
  17.     print("----------TreePuncher Object Editor Loaded---------");
  18. }
  19. public OnPlayerCommandText(playerid, cmdtext[])
  20. {
  21.     new treecmd[256], treeidx;
  22.     treecmd = strtok(cmdtext, treeidx);
  23.     if(!strcmp(treecmd, "/started", true))
  24.     {
  25.         if(!IsPlayerAdmin(playerid)) return 0;
  26.         new tmp[256];
  27.         tmp = strtok(cmdtext, treeidx);
  28.         if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "Please, input an OBJECT id");
  29.         if(!IsNumeric(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "You cannot use letters, just integer numbers");
  30.         if(IsPlayerAttachedObjectSlotUsed(playerid, 9)) RemovePlayerAttachedObject(playerid, 9);
  31.         new objectid;
  32.         objectid = strval(tmp);
  33.         SetPlayerAttachedObject(playerid, 9, objectid, 1);
  34.         EditAttachedObject(playerid, 9);
  35.         SendClientMessage(playerid, 0xFF0000FF, "Edition Started, please use the diskette when you are done");
  36.         UsingEDIT[playerid] = true;
  37.         TogglePlayerControllable(playerid, false);
  38.         return 1;
  39.     }
  40.     return 0;
  41. }
  42. public OnFilterScriptExit()
  43. {
  44.     print("----------TreePuncher Object Editor Unloaded-------");
  45.     DOF2_Exit();
  46.     return 1;
  47. }
  48. 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)
  49. {
  50.     if(response && UsingEDIT[playerid] == true)
  51.     {
  52.         new file[30];
  53.         format(file, sizeof(file), "%i.txt", modelid);
  54.         DOF2_CreateFile(file);
  55.         DOF2_SetInt(file, "Object ID", modelid);
  56.         DOF2_SetFloat(file, "OffSet Float X", fOffsetX);
  57.         DOF2_SetFloat(file, "OffSet Float Y", fOffsetY);
  58.         DOF2_SetFloat(file, "OffSet Float Z", fOffsetZ);
  59.         DOF2_SetFloat(file, "OffSet Rotation X", fRotX);
  60.         DOF2_SetFloat(file, "OffSet Rotation Y", fRotY);
  61.         DOF2_SetFloat(file, "OffSet Rotation Z", fRotZ);
  62.         DOF2_SetFloat(file, "OffSet Scale X", fScaleX);
  63.         DOF2_SetFloat(file, "OffSet Scale Y", fScaleY);
  64.         DOF2_SetFloat(file, "OffSet Scale Z", fScaleZ);
  65.         DOF2_WriteFile();
  66.         DOF2_SaveFile();
  67.         UsingEDIT[playerid] = false;
  68.         TogglePlayerControllable(playerid, true);
  69.         return SendClientMessage(playerid, 0xFF0000FF, "Project saved on a file, look for the object ID you used");
  70.     }
  71.     if(!response && UsingEDIT[playerid] == true)
  72.     {
  73.         SendClientMessage(playerid, 0xFF0000FF, "You have cancelled your attachment edition");
  74.         UsingEDIT[playerid] = false;
  75.         TogglePlayerControllable(playerid, true);
  76.         return RemovePlayerAttachedObject(playerid, 9);
  77.     }
  78.     return 1;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement