Guest User

Ilcev1

a guest
Jun 17th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.63 KB | None | 0 0
  1. //-------------------------------------------------
  2. //
  3. // This is an example of using the EditAttachedObject functions
  4. // to allow the player to customize their character.
  5. //
  6. // h02 2012
  7. //
  8. // SA-MP 0.3e and above
  9. //
  10. //-------------------------------------------------
  11.  
  12. #include <a_samp>
  13.  
  14. #define DIALOG_ATTACH_INDEX 13500
  15. #define DIALOG_ATTACH_INDEX_SELECTION DIALOG_ATTACH_INDEX+1
  16. #define DIALOG_ATTACH_EDITREPLACE DIALOG_ATTACH_INDEX+2
  17. #define DIALOG_ATTACH_MODEL_SELECTION DIALOG_ATTACH_INDEX+3
  18. #define DIALOG_ATTACH_BONE_SELECTION DIALOG_ATTACH_INDEX+4
  19.  
  20. enum AttachmentEnum
  21. {
  22. attachmodel,
  23. attachname[24]
  24. }
  25.  
  26. new AttachmentObjects[][AttachmentEnum] = {
  27. {ID objekta, "Text"},
  28. {ID objekta, "Text"},
  29. {ID objekta, "Text"}
  30. };
  31.  
  32. new AttachmentBones[][24] = {
  33. {"Kicma"},
  34. {"Glava"},
  35. {"Leva Nadlaktica"},
  36. {"Desna Nadlaktica"},
  37. {"Leva Ruka"},
  38. {"Desna Ruka"},
  39. {"Leva Butina"},
  40. {"Desna Butina"},
  41. {"Leva Noga"},
  42. {"Desna Noga"},
  43. {"Desna Noga List"},
  44. {"Leva Noga List"},
  45. {"Leva Podlaktica"},
  46. {"Desna Podlaktica"},
  47. {"Levo Rame"},
  48. {"Desno Rame"},
  49. {"Vrat"},
  50. {"Vilica"}
  51. };
  52.  
  53. public OnPlayerCommandText(playerid, cmdtext[])
  54. {
  55. if(!strcmp(cmdtext, "/create", true))
  56. {
  57. new string[128];
  58. for(new x;x<MAX_PLAYER_ATTACHED_OBJECTS;x++)
  59. {
  60. if(IsPlayerAttachedObjectSlotUsed(playerid, x)) format(string, sizeof(string), "%s%d (Used)\n", string, x);
  61. else format(string, sizeof(string), "%s%d\n", string, x);
  62. }
  63. ShowPlayerDialog(playerid, DIALOG_ATTACH_INDEX_SELECTION, DIALOG_STYLE_LIST, \
  64. "{FF0000}Attachment Modification - Index Selection", string, "Select", "Cancel");
  65. return 1;
  66. }
  67. return 0;
  68. }
  69.  
  70. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  71. {
  72. switch(dialogid)
  73. {
  74. case DIALOG_ATTACH_INDEX_SELECTION:
  75. {
  76. if(response)
  77. {
  78. if(IsPlayerAttachedObjectSlotUsed(playerid, listitem))
  79. {
  80. ShowPlayerDialog(playerid, DIALOG_ATTACH_EDITREPLACE, DIALOG_STYLE_MSGBOX, \
  81. "{FF0000}Attachment Modification", "Do you wish to edit the attachment in that slot, or delete it?", "Edit", "Delete");
  82. }
  83. else
  84. {
  85. new string[4000+1];
  86. for(new x;x<sizeof(AttachmentObjects);x++)
  87. {
  88. format(string, sizeof(string), "%s%s\n", string, AttachmentObjects[x][attachname]);
  89. }
  90. ShowPlayerDialog(playerid, DIALOG_ATTACH_MODEL_SELECTION, DIALOG_STYLE_LIST, \
  91. "{FF0000}Attachment Modification - Model Selection", string, "Select", "Cancel");
  92. }
  93. SetPVarInt(playerid, "AttachmentIndexSel", listitem);
  94. }
  95. return 1;
  96. }
  97. case DIALOG_ATTACH_EDITREPLACE:
  98. {
  99. if(response) EditAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
  100. else RemovePlayerAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
  101. DeletePVar(playerid, "AttachmentIndexSel");
  102. return 1;
  103. }
  104. case DIALOG_ATTACH_MODEL_SELECTION:
  105. {
  106. if(response)
  107. {
  108. if(GetPVarInt(playerid, "AttachmentUsed") == 1) EditAttachedObject(playerid, listitem);
  109. else
  110. {
  111. SetPVarInt(playerid, "AttachmentModelSel", AttachmentObjects[listitem][attachmodel]);
  112. new string[256+1];
  113. for(new x;x<sizeof(AttachmentBones);x++)
  114. {
  115. format(string, sizeof(string), "%s%s\n", string, AttachmentBones[x]);
  116. }
  117. ShowPlayerDialog(playerid, DIALOG_ATTACH_BONE_SELECTION, DIALOG_STYLE_LIST, \
  118. "{FF0000}Attachment Modification - Bone Selection", string, "Select", "Cancel");
  119. }
  120. }
  121. else DeletePVar(playerid, "AttachmentIndexSel");
  122. return 1;
  123. }
  124. case DIALOG_ATTACH_BONE_SELECTION:
  125. {
  126. if(response)
  127. {
  128. SetPlayerAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"), GetPVarInt(playerid, "AttachmentModelSel"), listitem+1);
  129. EditAttachedObject(playerid, GetPVarInt(playerid, "AttachmentIndexSel"));
  130. SendClientMessage(playerid, 0xFFFFFFFF, "Hint: Use {FFFF00}~k~~PED_SPRINT~{FFFFFF} to look around.");
  131. }
  132. DeletePVar(playerid, "AttachmentIndexSel");
  133. DeletePVar(playerid, "AttachmentModelSel");
  134. return 1;
  135. }
  136. }
  137. return 0;
  138. }
  139.  
  140. public OnPlayerEditAttachedObject( playerid, response, index, modelid, boneid,
  141. Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ,
  142. Float:fRotX, Float:fRotY, Float:fRotZ,
  143. Float:fScaleX, Float:fScaleY, Float:fScaleZ )
  144. {
  145. new debug_string[256+1];
  146. format(debug_string,256,"SetPlayerAttachedObject(playerid,%d,%d,%d,%f,%f,%f,%f,%f,%f,%f,%f,%f)",
  147. index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);
  148.  
  149. print(debug_string);
  150. //SendClientMessage(playerid, 0xFFFFFFFF, debug_string);
  151.  
  152. SetPlayerAttachedObject(playerid,index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);
  153. SendClientMessage(playerid, 0xFFFFFFFF, "You finished editing an attached object");
  154.  
  155. return 1;
  156. }
Advertisement
Add Comment
Please, Sign In to add comment