Guest User

Untitled

a guest
Jan 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. public OnPlayerKeyStateChange( playerid, newkeys, oldkeys )
  2. {
  3. #if ADMIN_ONLY
  4. if ( !IsPlayerAdmin( playerid ) )
  5. return;
  6. #endif
  7.  
  8. if ( !g_HoldingObject[ playerid ][ e_iModel ] || !IsPlayerAttachedObjectSlotUsed( playerid, HOLDING_OBJECT_SLOT ) )
  9. return;
  10.  
  11. new
  12. iPressedKeys = ( newkeys ^ oldkeys ) & newkeys
  13. ;
  14.  
  15. if ( ( oldkeys & KEY_SPRINT ) )
  16. {
  17. new
  18. iSearchDirection = 0
  19. ;
  20.  
  21. if ( ( iPressedKeys & iKeyLeft[ playerid ] ) )
  22. iSearchDirection = -1;
  23. else if ( ( iPressedKeys & iKeyRight[ playerid ] ) )
  24. iSearchDirection = 1;
  25. else
  26. return;
  27.  
  28. repeat_1:
  29. if ( g_cPlayerAction{ playerid } == 1 && iSearchDirection == -1 )
  30. g_cPlayerAction{ playerid } = MAX_ACTIONS - 1;
  31. else
  32. {
  33. g_cPlayerAction{ playerid } += iSearchDirection;
  34.  
  35. g_cPlayerAction{ playerid } %= MAX_ACTIONS;
  36. }
  37.  
  38. if ( !g_cPlayerAction{ playerid } )
  39. goto repeat_1;
  40.  
  41. g_cActionSettings{ playerid } |= ACTION_SETTING_DISABLED;
  42.  
  43. switch ( g_cPlayerAction{ playerid } )
  44. {
  45. case ACTION_BROWSE_MODEL: GameTextForPlayer( playerid, "~w~browse ~y~model", 1250, 4 );
  46. case ACTION_BROWSE_BONE: GameTextForPlayer( playerid, "~w~browse ~y~bone", 1250, 4 );
  47. case ACTION_MOVE_X: GameTextForPlayer( playerid, "~w~move ~y~x", 1250, 4 );
  48. case ACTION_MOVE_Y: GameTextForPlayer( playerid, "~w~move ~y~y", 1250, 4 );
  49. case ACTION_MOVE_Z: GameTextForPlayer( playerid, "~w~move ~y~z", 1250, 4 );
  50. case ACTION_ROTATE_X: GameTextForPlayer( playerid, "~w~rotate ~y~rx", 1250, 4 );
  51. case ACTION_ROTATE_Y: GameTextForPlayer( playerid, "~w~rotate ~y~ry", 1250, 4 );
  52. case ACTION_ROTATE_Z: GameTextForPlayer( playerid, "~w~rotate ~y~rz", 1250, 4 );
  53. case ACTION_SCALE_X: GameTextForPlayer( playerid, "~w~scale ~y~x", 1250, 4 );
  54. case ACTION_SCALE_Y: GameTextForPlayer( playerid, "~w~scale ~y~y", 1250, 4 );
  55. case ACTION_SCALE_Z: GameTextForPlayer( playerid, "~w~scale ~y~z", 1250, 4 );
  56. case ACTION_ROTATE_CAM: GameTextForPlayer( playerid, "~w~rotate by camera", 1250, 4 );
  57. default:
  58. {
  59. g_cPlayerAction{ playerid } = ACTION_BROWSE_MODEL;
  60.  
  61. GameTextForPlayer( playerid, "~w~browse ~y~model", 1250, 4 );
  62. }
  63. }
  64.  
  65. return;
  66. }
  67.  
  68. if ( ( g_cActionSettings{ playerid } & ACTION_SETTING_DISABLED ) )
  69. return;
  70.  
  71. switch ( g_cPlayerAction{ playerid } )
  72. {
  73. case ACTION_BROWSE_BONE:
  74. {
  75. new
  76. iSearchDirection = 0
  77. ;
  78.  
  79. if ( ( iPressedKeys & iKeyLeft[ playerid ] ) )
  80. iSearchDirection = -1;
  81. else if ( ( iPressedKeys & iKeyRight[ playerid ] ) )
  82. iSearchDirection = 1;
  83. else
  84. goto skip_browse_bone;
  85.  
  86. new
  87. szBoneName[ MAX_BONE_NAME ],
  88. szGameText[ 16 + MAX_BONE_NAME ]
  89. ;
  90.  
  91. repeat_2:
  92. g_HoldingObject[ playerid ][ e_iBone ] += iSearchDirection;
  93. g_HoldingObject[ playerid ][ e_iBone ] = g_HoldingObject[ playerid ][ e_iBone ] % 19;
  94.  
  95. if ( g_HoldingObject[ playerid ][ e_iBone ] == 0 )
  96. goto repeat_2;
  97.  
  98. GetBoneName( g_HoldingObject[ playerid ][ e_iBone ], szBoneName );
  99.  
  100. format( szGameText, sizeof( szGameText ), "~y~%s ~w~-~r~ %d", szBoneName, g_HoldingObject[ playerid ][ e_iBone ] );
  101.  
  102. GameTextForPlayer( playerid, szGameText, 1250, 4 );
  103.  
  104. UpdateHoldingObject( playerid );
  105.  
  106. skip_browse_bone:
  107. }
  108.  
  109. case ACTION_BROWSE_MODEL:
  110. {
  111. new
  112. iSearchDirection = 0
  113. ;
  114.  
  115. if ( ( iPressedKeys & iKeyLeft[ playerid ] ) )
  116. iSearchDirection = -1;
  117. else if ( ( iPressedKeys & iKeyRight[ playerid ] ) )
  118. iSearchDirection = 1;
  119. else
  120. goto skip_browse;
  121.  
  122. new
  123. bool:bFound = false,
  124. iSearchModel = g_HoldingObject[ playerid ][ e_iModel ]
  125. ;
  126.  
  127. while ( !bFound )
  128. {
  129. iSearchModel += iSearchDirection;
  130.  
  131. if ( !( 0 < iSearchModel < 20001 ) )
  132. iSearchModel = iSearchModel % 20001;
  133.  
  134. if ( IsValidHoldModel( iSearchModel ) )
  135. bFound = true;
  136. }
  137.  
  138. new
  139. szModelName[ MAX_MODEL_NAME ],
  140. szGameText[ 16 + MAX_MODEL_NAME ]
  141. ;
  142.  
  143. g_HoldingObject[ playerid ][ e_iModel ] = iSearchModel;
  144.  
  145. GetModelName( iSearchModel, szModelName );
  146.  
  147. format( szGameText, sizeof( szGameText ), "~y~%s ~w~-~r~ %d", szModelName, iSearchModel );
  148.  
  149. GameTextForPlayer( playerid, szGameText, 1250, 4 );
  150.  
  151. UpdateHoldingObject( playerid );
  152.  
  153. skip_browse:
  154. }
  155.  
  156. case ACTION_MOVE_X .. ACTION_SCALE_Z:
  157. {
  158. if ( ( iPressedKeys & iKeyLeft[ playerid ] ) )
  159. {
  160. g_fActionSpeed[ playerid ] = 0.0;
  161.  
  162. UpdateHoldingObject( playerid );
  163. }
  164. else if ( ( iPressedKeys & iKeyRight[ playerid ] ) )
  165. {
  166. g_fActionSpeed[ playerid ] = 0.0;
  167.  
  168. UpdateHoldingObject( playerid );
  169. }
  170. }
  171. }
  172. }
Add Comment
Please, Sign In to add comment