Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Authors: Kernell, qwerty
- -- Version: 1.0.0
- local ped_states =
- {
- stand = 3; -- The ped is standing still
- walk = 0; -- The ped is walking
- powerwalk = 0; -- The ped is walking quickly
- jog = 1; -- The ped is jogging
- sprint = 2; -- The ped is sprinting
- -- crouch = NULL; -- The ped is crouching still
- };
- function OnMoveStateChanged( uPed, move_state )
- setPedAnimation( uPed, "PED", "facanger", 0, false, false, false, false );
- local ped_state = ped_states[ move_state ] or -1;
- local anim_group = GetPedAnimGroup(uPed);
- if anim_group then
- local animation = GetAnimation( anim_group, ped_state );
- if animation then
- setPedAnimation( uPed, "PED", animation, 1, true, ped_state ~= 3 );
- end
- end
- end
- function OnRender()
- if isDebugViewActive() then
- local x, y = 100, 500;
- for k = 1, 4 do
- local a, b, c, d = getPedTask( localPlayer, "primary", k );
- dxDrawText( "Primary task #" .. k .. " is " .. tostring( a ) .. " -> " .. tostring( b ) .. " -> " .. tostring( c ) .. " -> " .. tostring( d ) .. " -> ", x, y );
- y = y + 15;
- end
- y = y + 15;
- for k = 1, 5 do
- local a, b, c, d = getPedTask( localPlayer, "secondary", k );
- dxDrawText( "Secondary task #" .. k .. " is " .. tostring( a ) .. " -> " .. tostring( b ) .. " -> " .. tostring( c ) .. " -> " .. tostring( d ) .. " -> ", x, y );
- y = y + 15;
- end
- y = y + 30;
- dxDrawText( "Simplest task: " .. tostring( getPedSimplestTask( localPlayer ) ), x, y );
- y = y + 30;
- dxDrawText( "Move state: " .. tostring( getPedMoveState( localPlayer ) ), x, y );
- end
- local tStreamedPlayers = getElementsByType( 'player', root, true )
- local sMove_state = ''
- for _, uPlayer in ipairs(tStreamedPlayers) do
- sMove_state = getPedMoveState(uPlayer);
- if sMove_state ~= getElementData( uPlayer, 'old_move_state' ) then
- OnMoveStateChanged( uPlayer, sMove_state );
- end
- setElementData( uPlayer, 'old_move_state', sMove_state, false )
- end
- end
- addEventHandler( "onClientRender", root, OnRender );
- -- юзаем вместо переменной old_move_state,
- -- чисто клиентский ElementData 'old_move_state' для каждого игрока
- addEventHandler( 'onClientResourceStart', resourceRoot,
- function()
- local tPlayers = getElementsByType('player')
- for _, uPlayer in ipairs(tPlayers) do
- setElementData( uPlayer, 'old_move_state', 'NULL', false )
- end
- end
- )
- addEventHandler( 'onClientPlayerJoin', root,
- function()
- setElementData( source, 'old_move_state', 'NULL', false )
- end
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement