local pressed = 0 local anim = 0 function ai_stock_custom_init(e) end function ai_stock_custom_main(e) --check for user pressing "e" to change the state if GetInKey() == "e" and pressed == 0 then anim = anim + 1 pressed = 1 end --check character is not running into the player if GetPlayerDistance(e) > 300 then AIEntityGoToPosition(g_Entity[e]['obj'],g_PlayerPosX,g_PlayerPosZ) else --otherwise make him stop moving AIEntityGoToPosition(g_Entity[e]['obj'],g_Entity[e]['x'],g_Entity[e]['z']) end --control the actual animations if anim == 0 then --make character put away his gun (only need to call this once - if he was previously armed) CharacterControlUnarmed(e) --make character walk SetCharacterToWalk(e) elseif anim == 1 then --make character run SetCharacterToRun(e) elseif anim == 2 then --make character bring out his gun (only need to call this once - if was previously unarmed) CharacterControlArmed(e) SetCharacterToWalk(e) elseif anim == 3 then SetCharacterToRun(e) elseif anim == 4 then anim = 0 end --reset the "e" press so it wont loop too fast if pressed == 1 and GetInKey() == "" then pressed = 0 end end function ai_stock_custom_exit(e) end