func.pwn 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. ShowAttachedDialog(playerid, dialogid) {
  2. switch( dialogid ) {
  3. case DIALOGID_ATTACH_INDEXLIST: {
  4. g_DialogInfo = "Index\tModel ID\tModel Name\tBone\n";
  5. for(new index; index < MAX_PLAYERATTACH_INDEX; index ++) {
  6. if( g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_TOGGLE] ) {
  7. new
  8. modelid = g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_MODEL],
  9. boneid = g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_BONE]
  10. ;
  11. GetBoneName(boneid, g_BoneString, sizeof g_BoneString);
  12. GetModelName(modelid, g_ModelString, sizeof g_ModelString);
  13. format(g_DialogInfoRow, sizeof g_DialogInfoRow, "%i\t%i\t%s\t%s\n", index, modelid, g_ModelString, g_BoneString);
  14. } else {
  15. format(g_DialogInfoRow, sizeof g_DialogInfoRow, "%i\t \t \t \n", index);
  16. }
  17. strcat(g_DialogInfo, g_DialogInfoRow);
  18. }
  19. ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_TABLIST_HEADERS, "Attached Objects", g_DialogInfo, "Select", "Cancel");
  20. }
  21. case DIALOGID_ATTACH_MAIN: {
  22. new index = GetPlayerEditAttached(playerid);
  23. if( index == INVALID_PLAYERATTACH_INDEX || !g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_TOGGLE] ) {
  24. return 1;
  25. }
  26. format(g_DialogCaption, sizeof g_DialogCaption, "Attachment Index %i", index);
  27. g_DialogInfo = "";
  28. for(new listitem; listitem < MAX_LISTITEMS_ATTACH; listitem ++) {
  29. switch(listitem) {
  30. case LISTITEM_ATTACH_MODEL: {
  31. if( g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_TOGGLE] ) {
  32. new modelid = g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_MODEL];
  33. if( GetModelName(modelid, g_ModelString, sizeof g_ModelString) ) {
  34. format(g_DialogInfoRow, sizeof g_DialogInfoRow, "Model\t%i %s\n", modelid, g_ModelString);
  35. } else {
  36. format(g_DialogInfoRow, sizeof g_DialogInfoRow, "Model\tNOT FOUND\n", modelid);
  37. }
  38. strcat(g_DialogInfo, g_DialogInfoRow);
  39. } else {
  40. strcat(g_DialogInfo, "Model\t \n");
  41. }
  42. }
  43. case LISTITEM_ATTACH_BONE: {
  44. if( g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_TOGGLE] ) {
  45. new boneid = g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_BONE];
  46. GetBoneName(boneid, g_BoneString, sizeof g_BoneString);
  47. format(g_DialogInfoRow, sizeof g_DialogInfoRow, "Bone\t%i %s\n", boneid, g_BoneString);
  48. strcat(g_DialogInfo, g_DialogInfoRow);
  49. } else {
  50. strcat(g_DialogInfo, "Bone\t \n");
  51. }
  52. }
  53. case LISTITEM_ATTACH_COORD: {
  54. strcat(g_DialogInfo, "Offset, Rotation, Scale\t \n");
  55. }
  56. case LISTITEM_ATTACH_MOVE: {
  57. strcat(g_DialogInfo, "Click & Drag Move\t \n");
  58. }
  59. case LISTITEM_ATTACH_COLOR1: {
  60. if( g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_TOGGLE] ) {
  61. format(g_DialogInfoRow, sizeof g_DialogInfoRow, "Color 1\t{%06x}Color\n", ARGBtoRGB( g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_COLOR1] ) );
  62. strcat(g_DialogInfo, g_DialogInfoRow);
  63. } else {
  64. strcat(g_DialogInfo, "Color 1\t \n");
  65. }
  66. }
  67. case LISTITEM_ATTACH_ALPHA1: {
  68. if( g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_TOGGLE] ) {
  69. format(g_DialogInfoRow, sizeof g_DialogInfoRow, "Color Alpha 1\t%i/%i\n", ARGBtoA( g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_COLOR1] ), 0xFF );
  70. strcat(g_DialogInfo, g_DialogInfoRow);
  71. } else {
  72. strcat(g_DialogInfo, "Color Alpha 1\t \n");
  73. }
  74. }
  75. case LISTITEM_ATTACH_COLOR2: {
  76. if( g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_TOGGLE] ) {
  77. format(g_DialogInfoRow, sizeof g_DialogInfoRow, "Color 2\t{%06x}Color\n", ARGBtoRGB( g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_COLOR2] ) );
  78. strcat(g_DialogInfo, g_DialogInfoRow);
  79. } else {
  80. strcat(g_DialogInfo, "Color 2\t \n");
  81. }
  82. }
  83. case LISTITEM_ATTACH_ALPHA2: {
  84. if( g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_TOGGLE] ) {
  85. format(g_DialogInfoRow, sizeof g_DialogInfoRow, "Color Alpha 2\t%i/%i\n", ARGBtoA( g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_COLOR2] ), 0xFF );
  86. strcat(g_DialogInfo, g_DialogInfoRow);
  87. } else {
  88. strcat(g_DialogInfo, "Color Alpha 2\t \n");
  89. }
  90. }
  91. case LISTITEM_ATTACH_REMOVE: {
  92. strcat(g_DialogInfo, "Remove\t \n");
  93. }
  94. default: {
  95. strcat(g_DialogInfo, " \t \n");
  96. }
  97. }
  98. }
  99. ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_TABLIST, g_DialogCaption, g_DialogInfo, "Select", "Cancel");
  100. }
  101. case DIALOGID_ATTACH_BONE: {
  102. g_DialogInfo = "";
  103. for(new boneid = 1; boneid <= MAX_BONE_ID; boneid ++) {
  104. GetBoneName(boneid, g_BoneString, sizeof g_BoneString);
  105. format(g_DialogInfoRow, sizeof g_DialogInfoRow, "%i\t%s\n", boneid, g_BoneString);
  106. strcat(g_DialogInfo, g_DialogInfoRow);
  107. }
  108. ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_TABLIST, "Attached Bones", g_DialogInfo, "Select", "Cancel");
  109. }
  110. case DIALOGID_ATTACH_COORD: {
  111. new index = GetPlayerEditAttached(playerid);
  112. if( index == INVALID_PLAYERATTACH_INDEX || !g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_TOGGLE] ) {
  113. return 1;
  114. }
  115. g_DialogInfo = "";
  116. format(g_DialogInfoRow, sizeof g_DialogInfoRow, "x \t%f\n", g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_X ]);
  117. strcat(g_DialogInfo, g_DialogInfoRow);
  118. format(g_DialogInfoRow, sizeof g_DialogInfoRow, "y \t%f\n", g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_Y ]);
  119. strcat(g_DialogInfo, g_DialogInfoRow);
  120. format(g_DialogInfoRow, sizeof g_DialogInfoRow, "z \t%f\n", g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_Z ]);
  121. strcat(g_DialogInfo, g_DialogInfoRow);
  122. format(g_DialogInfoRow, sizeof g_DialogInfoRow, "rx\t%f\n", g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_RX]);
  123. strcat(g_DialogInfo, g_DialogInfoRow);
  124. format(g_DialogInfoRow, sizeof g_DialogInfoRow, "ry\t%f\n", g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_RY]);
  125. strcat(g_DialogInfo, g_DialogInfoRow);
  126. format(g_DialogInfoRow, sizeof g_DialogInfoRow, "rz\t%f\n", g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_RZ]);
  127. strcat(g_DialogInfo, g_DialogInfoRow);
  128. format(g_DialogInfoRow, sizeof g_DialogInfoRow, "sx\t%f\n", g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_SX]);
  129. strcat(g_DialogInfo, g_DialogInfoRow);
  130. format(g_DialogInfoRow, sizeof g_DialogInfoRow, "sy\t%f\n", g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_SY]);
  131. strcat(g_DialogInfo, g_DialogInfoRow);
  132. format(g_DialogInfoRow, sizeof g_DialogInfoRow, "sz\t%f\n", g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_SZ]);
  133. strcat(g_DialogInfo, g_DialogInfoRow);
  134. ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, "Attached Offsets", g_DialogInfo, "Enter", "Cancel");
  135. }
  136. case DIALOGID_COLORALPHA_ATTACH_1, DIALOGID_COLORALPHA_ATTACH_2: {
  137. new attach_idx = GetPlayerEditAttached(playerid);
  138. if( attach_idx == INVALID_PLAYERATTACH_INDEX || !g_PlayerAttachData[playerid][attach_idx][PLAYERATTACH_DATA_TOGGLE] ) {
  139. return 1;
  140. }
  141. new attach_color_argb;
  142. switch( dialogid ) {
  143. case DIALOGID_COLORALPHA_ATTACH_1: {
  144. g_DialogCaption = "Attach Color 1 Alpha";
  145. attach_color_argb = g_PlayerAttachData[playerid][attach_idx][PLAYERATTACH_DATA_COLOR1];
  146. }
  147. case DIALOGID_COLORALPHA_ATTACH_2: {
  148. g_DialogCaption = "Attach Color 2 Alpha";
  149. attach_color_argb = g_PlayerAttachData[playerid][attach_idx][PLAYERATTACH_DATA_COLOR2];
  150. }
  151. default: {
  152. return 1;
  153. }
  154. }
  155. format(g_DialogInfo, sizeof g_DialogInfo, "Current Value: %i/%i", ARGBtoA(attach_color_argb), 0xFF);
  156. ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, g_DialogCaption, g_DialogInfo, "Enter", "Cancel");
  157. }
  158. default: {
  159. return 0;
  160. }
  161. }
  162. return 1;
  163. }
  164. DefaultPlayerAttachData(playerid, index) {
  165. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_TOGGLE] = false;
  166. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_MODEL] = 0;
  167. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_BONE] = 1;
  168. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_X ] = 0.0;
  169. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_Y ] = 0.0;
  170. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_Z ] = 0.0;
  171. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_RX] = 0.0;
  172. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_RY] = 0.0;
  173. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_RZ] = 0.0;
  174. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_SX] = 1.0;
  175. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_SY] = 1.0;
  176. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_SZ] = 1.0;
  177. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_COLOR1] = 0xFFFFFFFF;
  178. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_COLOR2] = 0xFFFFFFFF;
  179. }
  180. ApplyPlayerAttachData(playerid, index) {
  181. if( !IsValidPlayerAttachIndex(index) ) {
  182. return 0;
  183. }
  184. if( !g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_TOGGLE] ) {
  185. return RemovePlayerAttachedObject(playerid, index), 1;
  186. }
  187. SetPlayerAttachedObject(playerid, index,
  188. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_MODEL],
  189. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_BONE],
  190. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_X ],
  191. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_Y ],
  192. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_Z ],
  193. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_RX],
  194. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_RY],
  195. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_RZ],
  196. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_SX],
  197. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_SY],
  198. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_SZ],
  199. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_COLOR1],
  200. g_PlayerAttachData[playerid][index][PLAYERATTACH_DATA_COLOR2]
  201. );
  202. return 1;
  203. }