MX_Master

MTASA: Walking style of PEDs - source

Feb 4th, 2012
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.39 KB | None | 0 0
  1. -- Author:          Kernell
  2. -- Version:         1.0.0
  3.  
  4. local ped_states =
  5. {
  6.     stand        = 3; -- The ped is standing still
  7.     walk        = 0; -- The ped is walking
  8.     powerwalk    = 0; -- The ped is walking quickly
  9.     jog            = 1; -- The ped is jogging
  10.     sprint        = 2; -- The ped is sprinting
  11. --     crouch        = NULL; -- The ped is crouching still
  12. };
  13.  
  14. local ped_state = 3; -- 0: walk; 1: run; 2: sprint; 3: idle; 4: roadcross;
  15. local old_move_state = 'NULL';
  16.  
  17. function OnMoveStateChanged( move_state, old_move_state )
  18.     triggerServerEvent( "setAnimation", localPlayer, "PED", "facanger", 0, false, false, false, false );
  19.    
  20.     local ped_state        = ped_states[ move_state ] or -1;
  21.     local anim_group    = GetPedAnimGroup( localPlayer );
  22.    
  23.     if anim_group then
  24.         local animation = GetAnimation( anim_group, ped_state );
  25.        
  26.         if animation then
  27.             triggerServerEvent( "setAnimation", localPlayer, "PED", animation, 1, true, ped_state ~= 3 );
  28.         end
  29.     end
  30. end
  31.  
  32. local function OnRender()
  33.     if isDebugViewActive() then
  34.         local x, y = 100, 500;
  35.        
  36.         for k = 1, 4 do
  37.             local a, b, c, d = getPedTask( localPlayer, "primary", k );
  38.            
  39.             dxDrawText( "Primary task #" .. k .. " is " .. tostring( a ) .. " -> " .. tostring( b ) .. " -> " .. tostring( c ) .. " -> " .. tostring( d ) .. " -> ", x, y );
  40.            
  41.             y = y + 15;
  42.         end
  43.        
  44.         y = y + 15;
  45.        
  46.         for k = 1, 5 do
  47.             local a, b, c, d = getPedTask( localPlayer, "secondary", k );
  48.            
  49.             dxDrawText( "Secondary task #" .. k .. " is " .. tostring( a ) .. " -> " .. tostring( b ) .. " -> " .. tostring( c ) .. " -> " .. tostring( d ) .. " -> ", x, y );
  50.            
  51.             y = y + 15;
  52.         end
  53.        
  54.         y = y + 30;
  55.        
  56.         dxDrawText( "Simplest task: " .. tostring( getPedSimplestTask( localPlayer ) ), x, y );
  57.        
  58.         y = y + 30;
  59.        
  60.         dxDrawText( "Move state: " .. tostring( getPedMoveState( localPlayer ) ), x, y );
  61.     end
  62.    
  63.     local move_state = getPedMoveState( localPlayer );
  64.    
  65.     if move_state ~= old_move_state then
  66.         OnMoveStateChanged( move_state, old_move_state );
  67.     end
  68.    
  69.     old_move_state = move_state;
  70. end
  71.  
  72. addEventHandler( "onClientRender", root, OnRender );
Advertisement
Add Comment
Please, Sign In to add comment